Git init
[framework/base/acl.git] / Makepkgs
1 #! /bin/sh
2
3 # Copyright (C) 2001, 2002, 2003  Silicon Graphics, Inc.  All rights reserved.
4 #
5 # This program is free software: you can redistribute it and/or modify it
6 # under the terms of the GNU General Public License as published by
7 # the Free Software Foundation, either version 2 of the License, or
8 # (at your option) any later version.
9 #
10 # This program is distributed in the hope that it will be useful,
11 # but WITHOUT ANY WARRANTY; without even the implied warranty of
12 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
13 # GNU General Public License for more details.
14 #
15 # You should have received a copy of the GNU General Public License
16 # along with this program.  If not, see <http://www.gnu.org/licenses/>.
17 #
18 #       Make whichever packages have been requested.
19 #       Defaults to RPMs.
20 #
21 LOGDIR=Logs
22
23 type=rpm
24 verbose=false
25
26 MAKE=${MAKE:-make}
27 test ! -z "$MAKE" && make=$MAKE
28
29 for opt in $*
30 do
31         case "$opt" in
32         clean)
33                 ;; # ignored, kept for backward compatibility
34         rpm)
35                 type=rpm ;;
36         debian)
37                 type=debian ;;
38         verbose)
39                 verbose=true ;;
40         *)
41                 echo "Usage: Makepkgs [verbose] [debian|rpm]"; exit 1 ;;
42         esac
43 done
44
45 # start with a clean manifest
46 test -f files.rpm && rm -f files.rpm
47 test -f filesdevel.rpm && rm -f filesdevel.rpm
48 test -f fileslib.rpm && rm -f fileslib.rpm
49
50 test ! -d $LOGDIR && mkdir $LOGDIR
51 rm -rf $LOGDIR/* > /dev/null 2>&1
52
53 # build Debian packages, cleans itself before starting
54 SUDO=${SUDO:-sudo}
55 test ! -z "$SUDO" && sudo=$SUDO
56 if [ $type = debian ] ; then
57         LOGDEB=`pwd`
58         LOGDEB=../`basename $LOGDEB`.log
59         echo "== Debian build, log is $LOGDEB"; echo
60         if $verbose ; then
61                 dpkg-buildpackage -r$SUDO | tee $LOGDEB
62         else
63                 dpkg-buildpackage -r$SUDO > $LOGDEB || exit 1
64         fi
65         exit 0
66 fi
67
68 # build RPM packages - manual clean before starting
69 echo "== clean, log is $LOGDIR/clean"
70 if $verbose ; then
71         $MAKE clean 2>&1 | tee $LOGDIR/clean
72 else
73         $MAKE clean > $LOGDIR/clean 2>&1  || exit 1
74 fi
75
76 echo
77 echo "== configure, log is $LOGDIR/configure"
78 rm -f .census   # force configure to run here
79 if $verbose ; then
80         $MAKE configure 2>&1 | tee $LOGDIR/configure
81 else
82         $MAKE configure > $LOGDIR/configure 2>&1 || exit 1
83 fi
84
85 echo
86 echo "== default, log is $LOGDIR/default"
87 if $verbose ; then
88         $MAKE default 2>&1 | tee $LOGDIR/default
89 else
90         $MAKE default > $LOGDIR/default 2>&1 || exit 1
91 fi
92
93 echo
94 echo "== dist, log is $LOGDIR/dist"
95 [ ! -f .census ] && touch .census
96 if $verbose ; then
97         $MAKE -C build dist 2>&1 | tee $LOGDIR/dist
98 else
99         $MAKE -C build dist > $LOGDIR/dist 2>&1 || exit 1
100         grep '^Wrote:' $LOGDIR/dist | sed -e 's/\.\.\/\.\.\///'
101 fi
102
103 exit 0