2014-06-18 05:03:42 +00:00
|
|
|
#!/bin/sh -x
|
|
|
|
|
|
|
|
if [ $# -eq 0 ]; then
|
|
|
|
echo "usage: $0 foo.dsc [bar.dsc ...]"
|
|
|
|
exit 1
|
|
|
|
fi
|
|
|
|
|
2014-06-23 11:27:08 +00:00
|
|
|
# 1. create temporary directory
|
|
|
|
# 2. create fifo
|
|
|
|
# 3. run findunusedbd to start fatrace from outside
|
|
|
|
# 4. run sbuild with the correct hooks
|
|
|
|
# 5. if sbuild was successful, collect unused dependencies
|
|
|
|
# 6. remove temporary directory
|
2014-06-23 10:05:08 +00:00
|
|
|
build () {
|
|
|
|
dsc="$1"
|
|
|
|
archall="$2"
|
|
|
|
tmpdir=`mktemp -d --tmpdir=/home`
|
|
|
|
mkfifo "${tmpdir}/myfifo"
|
|
|
|
chmod a+w "${tmpdir}/myfifo"
|
|
|
|
/home/findunusedbd.sh "$tmpdir" &
|
2014-06-23 11:21:00 +00:00
|
|
|
sbuild --$archall --quiet \
|
2014-06-23 10:09:50 +00:00
|
|
|
--chroot-setup-commands="/home/findunusedbd.sh chroot-setup $tmpdir" \
|
|
|
|
--pre-realbuild-commands="/home/findunusedbd.sh pre-realbuild $tmpdir" \
|
|
|
|
--post-realbuild-commands="/home/findunusedbd.sh post-realbuild $tmpdir" \
|
2014-06-18 05:03:42 +00:00
|
|
|
"$dsc"
|
|
|
|
ret=$?
|
|
|
|
rm -f *.deb *.udeb *.changes
|
2014-06-23 10:21:56 +00:00
|
|
|
if [ $ret -eq 0 ] && [ -s "${tmpdir}/unneededdepends.list" ]; then
|
2014-06-23 10:05:08 +00:00
|
|
|
mv "${tmpdir}/unneededdepends.list" `basename $dsc .dsc`.${archall}.unusedbd
|
|
|
|
echo $dsc >> buildsuccess.${archall}.list
|
2014-06-18 05:03:42 +00:00
|
|
|
fi
|
2014-06-23 10:05:08 +00:00
|
|
|
rm -rf "$tmpdir"
|
|
|
|
}
|
2014-06-18 05:03:42 +00:00
|
|
|
|
2014-06-23 10:05:08 +00:00
|
|
|
for a in "arch-all" "no-arch-all"; do
|
2014-06-23 11:29:59 +00:00
|
|
|
>buildsuccess.${a}.list
|
2014-06-23 10:05:08 +00:00
|
|
|
for dsc in $@; do
|
|
|
|
echo $dsc
|
|
|
|
build "$dsc" "$a"
|
|
|
|
done
|
2014-06-23 10:53:24 +00:00
|
|
|
done
|
|
|
|
|
|
|
|
# now process the possibly droppable build dependencies found by no-arch-all
|
|
|
|
# and remove from them all that were also found by arch-all
|
|
|
|
for noarchall in *.no-arch-all.unusedbd; do
|
|
|
|
archall=`basename $noarchall .no-arch-all.unusedbd`.arch-all.unusedbd
|
|
|
|
if [ -s $archall ]; then
|
|
|
|
# only keep the values unique to no-arch-all
|
|
|
|
comm -23 $noarchall $archall > tmp
|
|
|
|
if [ -s tmp ]; then
|
|
|
|
mv tmp $noarchall
|
|
|
|
else
|
|
|
|
# no unique values in noarchall
|
|
|
|
rm $noarchall
|
|
|
|
fi
|
|
|
|
fi
|
|
|
|
done
|
2014-06-23 10:05:08 +00:00
|
|
|
|
2014-06-23 11:27:08 +00:00
|
|
|
# 1. for all possibly unused dependencise, run sbuild with a hook creating a
|
|
|
|
# fake equivs package
|
|
|
|
# 2. if sbuild was successful, collect result
|
|
|
|
check () {
|
|
|
|
dscname="$1"
|
|
|
|
archall="$2"
|
|
|
|
unusedbdname=`basename $dscname .dsc`.${archall}.unusedbd
|
|
|
|
while read bd; do
|
|
|
|
# now run sbuild with "findunusedbd.sh equivs" creating a fake equivs package
|
|
|
|
sbuild --$archall --quiet \
|
|
|
|
--chroot-setup-commands="/home/findunusedbd.sh equivs $bd" \
|
|
|
|
"$dscname"
|
|
|
|
if [ $? -eq 0 ]; then
|
|
|
|
echo $bd >> "${unusedbdname}".real
|
|
|
|
fi
|
|
|
|
rm -f *.deb *.udeb *.changes
|
|
|
|
done < $unusedbdname
|
|
|
|
}
|
|
|
|
|
2014-06-23 10:53:24 +00:00
|
|
|
for a in "arch-all" "no-arch-all"; do
|
2014-06-23 10:05:08 +00:00
|
|
|
while read dscname; do
|
|
|
|
echo $dscname
|
|
|
|
check $dscname "$a"
|
|
|
|
done < buildsuccess.${a}.list
|
|
|
|
done
|