add changes from actual run

main
josch 10 years ago
parent 637aa89de1
commit d07f55519b

@ -20,5 +20,28 @@ which can be added to sbuild by applying
Any unused dependencies can then be found by investigating the file
`unneededdepends.list`.
Bugs: when investigating which build dependencies are unused, virtual packages
are not taken into account.
The process can be automated for multiple packages by passing `dsc` files to
`run.sh`:
$ ./run.sh ../mysources/*.dsc
This script will put the successful builds in `buildsuccess.list` and the found
unused build dependencies as `*.unusedbd` for each `dsc` file in the current
directory. A second pass on the successfully built `dsc` files will then check
each of the found unused build dependencies for their validity by replacing
them by an empty equivs package one after another. The results of that run are
stored in `*.unusedbd.real` files for each `dsc` file in the current directory.
The `run.sh` script expects to find `findunusedbd.sh` directly under `/home`.
Best try this out in a chroot to not mess with the host system.
Customize the schroot:
$ sbuild-shell source:sid-amd64-sbuild
$ echo 'Acquire::Check-Valid-Until "false";' > /etc/apt/apt.conf.d/80-nocheckvaliduntil
$ apt-get install equivs --no-install-recommends
Bugs:
- when investigating which build dependencies are unused, virtual packages are not taken into account
- maybe the fake equivs package can be built outside the schroot to avoid the additional dependencies for installing equivs
- maybe equivs can be avoided altogether by finding a way to edit debian/control on the fly

@ -1,52 +1,52 @@
#!/bin/sh -ex
# start this script without arguments and then start sbuild as:
#
# sbuild --chroot-setup-commands='/home/josch/prebuildcmd.sh chroot-setup' --pre-realbuild-commands='/home/josch/prebuildcmd.sh pre-realbuild' --post-realbuild-commands='/home/josch/prebuildcmd.sh post-realbuild'
# sbuild --chroot-setup-commands='/home/prebuildcmd.sh chroot-setup' --pre-realbuild-commands='/home/prebuildcmd.sh pre-realbuild' --post-realbuild-commands='/home/prebuildcmd.sh post-realbuild'
if [ "$#" -ne 1 ]; then
rm -rf /home/josch/myfifo /home/josch/myfifo2 /tmp/pkglists
mkfifo /home/josch/myfifo
mkfifo /home/josch/myfifo2
if [ "$#" -eq 0 ]; then
rm -rf /home/myfifo /home/myfifo2 /tmp/pkglists
mkfifo /home/myfifo
mkfifo /home/myfifo2
mkdir -p /tmp/pkglists
# strip the architecture qualifier
cat /home/josch/myfifo | cut -d ':' -f 1 | sort > initialselection.list
echo > /home/josch/myfifo2
cat /home/josch/myfifo | cut -d ':' -f 1 | sort > fullselection.list
echo > /home/josch/myfifo2
cat /home/myfifo | cut -d ':' -f 1 | sort > initialselection.list
echo > /home/myfifo2
cat /home/myfifo | cut -d ':' -f 1 | sort > fullselection.list
echo > /home/myfifo2
# get all packages that were installed on top of the base packages
comm -13 initialselection.list fullselection.list > bdselection.list
while true; do
pkgname=`cat /home/josch/myfifo | cut -d ':' -f 1`
echo > /home/josch/myfifo2
pkgname=`cat /home/myfifo | cut -d ':' -f 1`
echo > /home/myfifo2
# end loop when packagename is empty
[ -z "$pkgname" ] && break
# check if the package was installed as its build dependencies
if grep --line-regexp $pkgname bdselection.list; then
cat /home/josch/myfifo | sort > "/tmp/pkglists/$pkgname"
cat /home/myfifo | sort > "/tmp/pkglists/$pkgname"
else
cat /home/josch/myfifo > /dev/null
cat /home/myfifo > /dev/null
fi
echo > /home/josch/myfifo2
echo > /home/myfifo2
done
cat /home/josch/myfifo | sed 's/, \+/\n/'g \
cat /home/myfifo | sed 's/, \+/\n/'g \
| sed 's/\([a-zA-Z0-9][a-zA-Z0-9+.-]*\).*/\1/' \
> /tmp/sbuild-dummy-depends
echo > /home/josch/myfifo2
SCHROOT_SESSION_ID=`cat /home/josch/myfifo`;
echo > /home/josch/myfifo2
echo > /home/myfifo2
SCHROOT_SESSION_ID=`cat /home/myfifo`;
echo > /home/myfifo2
# start fatrace in the mounted directory
(
cd /var/lib/schroot/mount/$SCHROOT_SESSION_ID;
sudo fatrace --current-mount > /home/josch/fatrace.log &
fatrace --current-mount > /home/fatrace.log &
FATRACE_PID=$!;
cat /home/josch/myfifo > /dev/null;
echo > /home/josch/myfifo2
sudo kill $FATRACE_PID;
cat /home/myfifo > /dev/null;
echo > /home/myfifo2
kill $FATRACE_PID;
)
# clean up the fatrace log to only include unique paths
sed 's/\/var\/lib\/schroot\/mount\/[^\/]\+//' /home/josch/fatrace.log \
sed 's/\/var\/lib\/schroot\/mount\/[^\/]\+//' /home/fatrace.log \
| awk '{ print $3; }' \
| grep -v ^/build \
| sort \
@ -62,23 +62,23 @@ else
case "$1" in
chroot-setup)
env
dpkg --get-selections | awk '{ print $1; }' > /home/josch/myfifo
cat /home/josch/myfifo2 > /dev/null
dpkg --get-selections | awk '{ print $1; }' > /home/myfifo
cat /home/myfifo2 > /dev/null
;;
pre-realbuild)
# get the current selection so that the parent script can find the additional packages that were installed
dpkg --get-selections | awk '{ print $1; }' > /home/josch/myfifo
cat /home/josch/myfifo2 > /dev/null
dpkg --get-selections | awk '{ print $1; }' > /home/myfifo
cat /home/myfifo2 > /dev/null
# output the files belonging to all packages
for pkg in `dpkg --get-selections | awk '{ print $1; }'`; do
echo $pkg > /home/josch/myfifo
cat /home/josch/myfifo2 > /dev/null
dpkg -L $pkg > /home/josch/myfifo
cat /home/josch/myfifo2 > /dev/null
echo $pkg > /home/myfifo
cat /home/myfifo2 > /dev/null
dpkg -L $pkg > /home/myfifo
cat /home/myfifo2 > /dev/null
done
# output an empty line to indicate the end
echo > /home/josch/myfifo
cat /home/josch/myfifo2 > /dev/null
echo > /home/myfifo
cat /home/myfifo2 > /dev/null
# output the dependencies of the sbuild dummy package
dpkg --get-selections | awk '{ print $1; }' \
| grep sbuild-build-depends \
@ -86,15 +86,21 @@ else
| grep -v sbuild-build-depends-essential-dummy \
| grep -v sbuild-build-depends-lintian-dummy \
| xargs -I {} dpkg-query --showformat='${Depends}\n' --show {} \
> /home/josch/myfifo
cat /home/josch/myfifo2 > /dev/null
> /home/myfifo
cat /home/myfifo2 > /dev/null
# output the schroot id to start tracing
echo $SCHROOT_SESSION_ID > /home/josch/myfifo
cat /home/josch/myfifo2 > /dev/null
echo $SCHROOT_SESSION_ID > /home/myfifo
cat /home/myfifo2 > /dev/null
;;
post-realbuild)
echo "done" > /home/josch/myfifo
cat /home/josch/myfifo2 > /dev/null
echo "done" > /home/myfifo
cat /home/myfifo2 > /dev/null
;;
equivs)
pkgname="$2"
# create and install a package with same name and version but without dependencies
apt-cache show --no-all-versions $pkgname | grep -v "^Depends:" | grep -v "^Pre-Depends:" | equivs-build -
dpkg -i ${pkgname}_*.deb
;;
*)
echo "invalid argument: $1" >&2

@ -0,0 +1,38 @@
#!/bin/sh -x
if [ $# -eq 0 ]; then
echo "usage: $0 foo.dsc [bar.dsc ...]"
exit 1
fi
echo > buildsuccess.list
for dsc in $1; do
echo $dsc
/home/findunusedbd.sh &
sbuild --no-arch-all \
--chroot-setup-commands='/home/findunusedbd.sh chroot-setup' \
--pre-realbuild-commands='/home/findunusedbd.sh pre-realbuild' \
--post-realbuild-commands='/home/findunusedbd.sh post-realbuild' \
"$dsc"
ret=$?
rm -f *.deb *.udeb *.changes
if [ $ret -eq 0 ] && [ -s unneededdepends.list ]; then
mv unneededdepends.list `basename $dsc .dsc`.unusedbd
echo $dsc >> buildsuccess.list
fi
done
while read dscname; do
echo $dscname
unusedbdname=`basename $dscname .dsc`.unusedbd
while read bd; do
# now run sbuild with "findunusedbd.sh equivs" creating a fake equivs package
sbuild --no-arch-all \
--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
done < buildsuccess.list
Loading…
Cancel
Save