forked from Lainports/freebsd-ports
if requested (".keep" file in the port directory), no matter where
we fail.
* Add package dependencies before the corresponding build stage
(e.g. FETCH_DEPENDS before 'make fetch'), and remove them again
afterwards. This allows us to catch ports that list their
dependencies too early/late.
* No need to check for set[ug]id files here, the security-check target
in bsd.port.mk does it for us.
* Exclude some more directories and files from showing up in the mtree
before/after comparison, to trim down the false-positive in the
pkg-plist check.
* Other minor changes
202 lines
4.7 KiB
Bash
Executable file
202 lines
4.7 KiB
Bash
Executable file
#!/bin/sh
|
|
|
|
# usage: $0 DIRNAME PHASE
|
|
# PHASE is 1 (checksum) or 2 (package)
|
|
|
|
cleanup() {
|
|
status=$1
|
|
|
|
if [ -e ${dir}/.keep ]; then
|
|
cd ${dir}
|
|
objdir=$(make -V WRKDIR)
|
|
tar cfjC /tmp/work.tbz ${objdir}/.. work
|
|
fi
|
|
|
|
cat /tmp/make.log${status}
|
|
echo 1 > /tmp/status
|
|
echo "================================================================"
|
|
echo -n "build ended at "
|
|
date
|
|
|
|
exit 0
|
|
}
|
|
|
|
add_pkg() {
|
|
pkgs=$*
|
|
|
|
echo add_pkg $pkgs
|
|
cd /tmp/depends
|
|
export PKG_PATH=/tmp/depends
|
|
if [ ! -z "${pkgs}" ]; then
|
|
echo "adding dependencies"
|
|
for i in $pkgs; do
|
|
echo "pkg_add $i"
|
|
base=$(basename $i .tgz)
|
|
base=$(basename $base .tbz)
|
|
if pkg_info -q -e $base; then
|
|
echo "skipping $base, already added"
|
|
else
|
|
if ! pkg_add $i; then
|
|
echo "error in dependency $i, exiting"
|
|
echo "1" > /tmp/status
|
|
exit 1
|
|
fi
|
|
fi
|
|
done
|
|
fi
|
|
}
|
|
|
|
del_pkg() {
|
|
pkgs=$*
|
|
|
|
cd /tmp/depends
|
|
export PKG_PATH=/tmp/depends
|
|
if [ ! -z "${pkgs}" ]; then
|
|
unset delpkg
|
|
for i in $pkgs; do
|
|
base=$(basename $i .tgz)
|
|
base=$(basename $base .tbz)
|
|
if ! pkg_info -q -e $base; then
|
|
echo "skipping $base, already deleted"
|
|
else
|
|
delpkg="${base} ${delpkg}"
|
|
fi
|
|
done
|
|
echo "Deleting $delpkg"
|
|
if ! (echo ${delpkg} | xargs pkg_delete -f); then
|
|
echo "error in pkg_delete, exiting"
|
|
echo "1" > /tmp/status
|
|
exit 1
|
|
fi
|
|
fi
|
|
}
|
|
|
|
dir=$1
|
|
phase=$2
|
|
|
|
ED=$3
|
|
PD=$4
|
|
FD=$5
|
|
BD=$6
|
|
RD=$7
|
|
|
|
if [ $phase = 1 ]; then
|
|
|
|
cd $dir || exit 1
|
|
echo "maintained by: $(make maintainer)"
|
|
echo "port directory: ${dir}"
|
|
echo "build started at $(date)"
|
|
|
|
echo "FETCH_DEPENDS=${FD}"
|
|
echo "PATCH_DEPENDS=${PD}"
|
|
echo "EXTRACT_DEPENDS=${ED}"
|
|
echo "BUILD_DEPENDS=${BD}"
|
|
echo "RUN_DEPENDS=${RD}"
|
|
|
|
add_pkg $FD
|
|
|
|
#Allow ports to notice they're being run on bento
|
|
export PACKAGE_BUILDING=1
|
|
|
|
cd $dir || exit 1
|
|
pkgname=$(make package-name)
|
|
echo "================================================================"
|
|
echo "====================<phase 1: make checksum>===================="
|
|
|
|
if /pnohang $TIMEOUT /tmp/make.log1 ${pkgname} make checksum; then
|
|
cat /tmp/make.log1
|
|
echo "0" > /tmp/status
|
|
else
|
|
cleanup 1
|
|
fi
|
|
|
|
else
|
|
|
|
xvfb=0
|
|
if which -s Xvfb; then
|
|
xvfb=1
|
|
pid=$(echo $$ % 32768 | bc)
|
|
X11BASE=$(which Xvfb | sed -e 's./bin/Xvfb..')
|
|
Xvfb :${pid} -fp ${X11BASE}/lib/X11/fonts/misc &
|
|
DISPLAY=:${pid}
|
|
export DISPLAY
|
|
fi
|
|
|
|
cd $dir || exit 1
|
|
pkgname=$(make package-name)
|
|
|
|
echo "================================================================"
|
|
echo "====================<phase 2: make extract>===================="
|
|
add_pkg ${ED}
|
|
cd $dir
|
|
/pnohang $TIMEOUT /tmp/make.log2 ${pkgname} make extract || cleanup 2
|
|
cat /tmp/make.log2
|
|
del_pkg ${ED}
|
|
|
|
echo "================================================================"
|
|
echo "====================<phase 3: make patch>===================="
|
|
add_pkg ${PD}
|
|
cd $dir
|
|
/pnohang $TIMEOUT /tmp/make.log3 ${pkgname} make patch || cleanup 3
|
|
cat /tmp/make.log3
|
|
del_pkg ${PD}
|
|
|
|
echo "================================================================"
|
|
echo "====================<phase 4: make build>===================="
|
|
add_pkg ${BD}
|
|
cd $dir
|
|
/pnohang $TIMEOUT /tmp/make.log4 ${pkgname} make build || cleanup 4
|
|
cat /tmp/make.log4
|
|
|
|
echo "================================================================"
|
|
echo "====================<phase 5: make package>===================="
|
|
add_pkg ${RD}
|
|
cat > /tmp/mtree.exclude <<EOF
|
|
./var/*
|
|
./tmp/*
|
|
EOF
|
|
mtree -X /tmp/mtree.exclude -xcn -k uid,gid,mode -p / > /tmp/mtree
|
|
cd $dir
|
|
if /pnohang $TIMEOUT /tmp/make.log5 ${pkgname} make package; then
|
|
cat /tmp/make.log5
|
|
echo "0" > /tmp/status
|
|
prefix=$(make -V PREFIX)
|
|
del_pkg ${pkgname}
|
|
|
|
mtree -X /tmp/mtree.exclude -x -f /tmp/mtree -p / | egrep -v '^(usr/local/share/nls/POSIX|usr/local/share/nls/en_US.US-ASCII|etc/shells.bak|etc/services|compat |usr/X11R6 |etc/manpath.config|usr/local/info/dir)' > /tmp/list3
|
|
|
|
# BUILD_DEPENDS need to be present at install-time, e.g. gmake
|
|
# Concatenate and remove duplicates
|
|
BRD=$(echo $BD $RD | tr ' ' '\n' | sort -u | tr '\n' ' ')
|
|
del_pkg ${BRD}
|
|
cd /var/db/pkg
|
|
if [ $(echo $(echo * | wc -c)) != 2 ]; then
|
|
echo "leftover packages:" *
|
|
del_pkg *
|
|
fi
|
|
|
|
if [ -s /tmp/list3 ]; then
|
|
echo "================================================================"
|
|
echo "list of extra files and directories in /"
|
|
cat /tmp/list3
|
|
if [ "x${PLISTCHECK}" != "x" ]; then
|
|
echo "1" > /tmp/status
|
|
fi
|
|
fi
|
|
else
|
|
cleanup 5
|
|
fi
|
|
|
|
if [ ${xvfb} = 1 ]; then
|
|
kill $(jobid %1)
|
|
fi
|
|
|
|
if [ -e ${dir}/.keep ]; then
|
|
cd ${dir}
|
|
objdir=$(make -V WRKDIR)
|
|
tar cfjC /tmp/work.tbz ${objdir}/.. work
|
|
fi
|
|
|
|
fi
|
|
|
|
exit 0
|