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 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192
|
#! /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
#
LOGDIR=Logs
clean=false
verbose=false
MAKE=${MAKE:-make}
for opt in $*
do
case "$opt" in
-clean)
clean=true
shift
;;
-verbose)
verbose=true
shift
;;
*)
break
;;
esac
done
test ! -d $LOGDIR && mkdir $LOGDIR
rm -rf $LOGDIR/*
tmp=`mktemp -d /tmp/pcp.XXXXXXXXX` || exit 1
trap "rm -rf $tmp" 0 1 2 3 15
ARCH=`uname -m | sed -e 's/i.86/ia32/'`
VERS=`uname -s | cut -c-5`
# Sanity checks ... this is sick, but I'm really tired of QA failing
# because of bad binaries being built from the Ubuntu toolchain for
# i?86 platforms
# - Ken McDonell Apr 2010
#
if [ -f /etc/lsb-release -a "$ARCH" = "ia32" ]
then
if grep -q 'DISTRIB_ID=Ubuntu' /etc/lsb-release
then
if [ -f /usr/bin/dpkg-buildpackage ]
then
ok=true
if grep -q '^my $default_flags .*O2' /usr/bin/dpkg-buildpackage
then
echo '/usr/bin/dpkg-buildpackage: need to remove O2 from $default_flags'
ok=false
fi
if grep -q '^[ ]*LDFLAGS.*-Bsymbolic-functions' /usr/bin/dpkg-buildpackage
then
echo '/usr/bin/dpkg-buildpackage: need to remove -Bsymbolic-function from LDFLAGS'
ok=false
fi
if $ok
then
:
else
echo "Refer to Ubuntu notes in PCP's ./INSTALL"
exit 1
fi
fi
fi
fi
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 "== autoconf, log is in $LOGDIR/autoconf"
autoconf 2>&1 >$LOGDIR/autoconf
fi
LOGF=$LOGDIR/pcp
echo
echo "== Building pcp, log is in $LOGF"
. ./VERSION.pcp
special=false
[ "$VERS" = MINGW ] && special=windows
[ -f /etc/debian_version ] && special=debian
if [ $special != false ]
then
LOGF=`pwd`/$LOGF
if $verbose ; then
$MAKE -j 1 configure_pcp 2>&1 | tee -a $LOGF
else
$MAKE -j 1 configure_pcp 2>&1 >> $LOGF
fi
echo
echo "== src-link, log is in $LOGF" | tee -a $LOGF
VERSION=${PACKAGE_MAJOR}.${PACKAGE_MINOR}.${PACKAGE_REVISION}
SRCLINK_ROOT=`pwd`/pcp-$VERSION
if [ $special = debian ] ; then
SRCLINK_ROOT=`pwd`/build/deb/pcp-$VERSION
fi
export SRCLINK_ROOT
rm -fr $SRCLINK_ROOT
mkdir -p $SRCLINK_ROOT || exit 1
$MAKE -j 1 src-link-pcp || exit 1
cd $SRCLINK_ROOT
if [ $special = debian ]
then
SUDO=${SUDO:-fakeroot}
if $verbose ; then
dpkg-buildpackage -r$SUDO | tee -a $LOGF
else
dpkg-buildpackage -r$SUDO >> $LOGF || exit 1
fi
exit 0
fi
fi
# Fall through for MinGW (Win32) builds
if $verbose ; then
st=`(($MAKE -j 1 default_pcp 2>&1; echo $? >&3) | tee $LOGF 1>&2) 3>&1`
else
$MAKE -j 1 default_pcp > $LOGF 2>&1; st=$?
fi
if [ $st -ne 0 ] ; then
if ! $verbose ; then
echo \"$MAKE default_pcp\" failed, see log in $LOGF
tail $LOGF
fi
exit 1
fi
rm -f files.rpm
echo
echo "== Packaging pcp, log is in $LOGF" | tee -a $LOGF
if $verbose ; then
($MAKE -j 1 -C build pack_pcp 2>&1 || touch $tmp/failed) | tee -a $LOGF
else
($MAKE -j 1 -C build pack_pcp 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/\.\.\/\.\.\///'
fi
fi
rm -f $tmp/failed
exit 0
|