File: Makepkgs

package info (click to toggle)
pcp 2.7.4-20080507
  • links: PTS
  • area: main
  • in suites: lenny
  • size: 9,112 kB
  • ctags: 9,774
  • sloc: ansic: 98,235; sh: 15,651; makefile: 3,052; yacc: 2,018; cpp: 1,062; lex: 1,003; perl: 747; fortran: 60; java: 22; awk: 20
file content (167 lines) | stat: -rwxr-xr-x 3,841 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
#! /bin/sh
#
# Make whichever packages the system supports
#
# Copyright (c) 2004 Silicon Graphics, Inc.  All Rights Reserved.
# 
# This program is free software; you can redistribute it and/or modify it
# under the terms of the GNU General Public License as published by the
# Free Software Foundation; either version 2 of the License, or (at your
# option) any later version.
# 
# This program is distributed in the hope that it will be useful, but
# WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
# or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
# for more details.
# 
# You should have received a copy of the GNU General Public License along
# with this program; if not, write to the Free Software Foundation, Inc.,
# 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA
# 
# Contact information: Silicon Graphics, Inc., 1500 Crittenden Lane,
# Mountain View, CA 94043, USA, or: http://www.sgi.com
#
LOGDIR=Logs

clean=false
verbose=false

MAKE=${MAKE:-make}

for opt in $*
do
    case "$opt" in
    -clean)
	clean=true
	shift
	;;
    -verbose)
	verbose=true
	shift
	;;
    -*)
	echo "Unknown option $opt"
	echo "Usage: Makepkgs [-clean] [-verbose] products..."
	echo "products may be one or more of \"pcp pro\""
	exit 1
	;;
    *)
	break
	;;
    esac
done

if [ -f /etc/debian_version ]
then
    SUDO=${SUDO:-sudo}
    LOGDEB=`pwd`
    LOGDEB=../`basename $LOGDEB`.log
    echo "== Debian build, log is $LOGDEB"; echo
    if $verbose ; then
	dpkg-buildpackage -r$SUDO | tee $LOGDEB
    else
	dpkg-buildpackage -r$SUDO > $LOGDEB || exit 1
    fi
    exit 0
fi

if [ $# = 0 ] ; then
    set -- pcp
fi

test ! -d $LOGDIR && mkdir $LOGDIR
rm -rf $LOGDIR/* 

tmp=/tmp/$$
trap "rm -f $tmp.*;" 0 1 2 3 15

if $clean; then
    echo "== cleaning, log is in $LOGDIR/clean"
    if $verbose ; then
	($MAKE -j 1 clean 2>&1 || touch $tmp.failed )| tee $LOGDIR/clean
    else
	$MAKE -j 1 clean > $LOGDIR/clean 2>&1  || touch $tmp.failed
    fi
    if [ -f $tmp.failed ] ; then
	if ! $verbose ; then
	    echo \"$MAKE clean\" failed, see log in $LOGDIR/clean
	    tail $LOGDIR/clean
	fi
        exit 1
    fi
fi

echo
if [ ! -f ./configure ]
then
    echo "== autconf, log is in $LOGDIR/autoconf"
    autoconf 2>&1 >$LOGDIR/autoconf
fi

ARCH=`uname -m | sed -e 's/i.86/ia32/'`

for prod ; do
    LOGF=$LOGDIR/$prod
    echo
    echo "== Building $prod, log is in $LOGF"

    . VERSION.$prod

    if [ "$prod" = "pro" ]
    then
    	if [ ! -f src/libpcp/src/libpcp.so.2 -o ! -f src/pmns/stdpmid ]
	then
	    echo "Error: \"pcp\" must be built before (or with) \"pro\""
	    exit 1
	fi

	#
	# unpack the root for the pcp-pro build
	[ -z "$ROOT" ] && export ROOT=`pwd`/root-$ARCH
	if [ ! -d $ROOT/include -o ! -d $ROOT/lib ]; then make -C $ROOT; fi
    else
	if [ -n "$SGI_PROPACK_BUILD" ] ; then
	    PACKAGE_NAME=${prod}-open
	else
	    PACKAGE_NAME=${prod}
	fi
	export PACKAGE_NAME
    fi

    if $verbose ; then
	st=`(($MAKE -j 1 default_$prod 2>&1; echo $? >&3) | tee $LOGF 1>&2) 3>&1`
    else
	$MAKE -j 1 default_$prod > $LOGF 2>&1; st=$? 
    fi
    if [ $st -ne 0 ] ; then
	if ! $verbose ; then
	    echo \"$MAKE default_$prod\" failed, see log in $LOGF
	    tail $LOGF
	fi
        exit 1
    fi

    rm -f files.rpm
    echo
    echo "== Packaging $prod, log is in $LOGF" | tee -a $LOGF
    [ ! -f .census ] && touch .census
    if $verbose ; then
	($MAKE -j 1 -C build pack_$prod 2>&1 || touch $tmp.failed) | tee -a $LOGF
    else
	($MAKE -j 1 -C build pack_$prod 2>&1 || touch $tmp.failed) >> $LOGF
    fi
    if [ -f $tmp.failed ] ; then
	if ! $verbose ; then
	    echo Packaging failed, see log in $LOGF
	    tail $LOGF
	fi
        exit 1
    else
	if ! $verbose ; then
	    grep '^Wrote:' $LOGF | sed -e 's/\.\.\/\.\.\///' | fgrep -v tar.gz
	fi
    fi
done

rm -f $tmp.failed
exit 0