make dependencies versioned, improve equivs package, add write permissions to fifo

This commit is contained in:
josch 2014-06-19 16:56:37 +02:00
parent 1d1562f20e
commit 25fd8a6f4f
2 changed files with 46 additions and 22 deletions

View file

@ -35,10 +35,11 @@ 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 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 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 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 them by an empty equivs package with no dependencies one after another. The
stored in `*.unusedbd.real` files for each `dsc` file in the current directory. results of that run are stored in `*.unusedbd.real` files for each `dsc` file
The `run.sh` script expects to find `findunusedbd.sh` directly under `/home`. in the current directory. The `run.sh` script expects to find
Best try this out in a chroot to not mess with the host system. `findunusedbd.sh` directly under `/home`. Best try this out in a chroot to not
mess with the host system.
Schroot setup Schroot setup
------------- -------------
@ -64,7 +65,6 @@ Bugs
- when investigating which build dependencies are unused, virtual packages are not taken into account - 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 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
License License
------- -------

58
findunusedbd.sh Normal file → Executable file
View file

@ -5,24 +5,29 @@
if [ "$#" -eq 0 ]; then if [ "$#" -eq 0 ]; then
rm -rf /home/myfifo /home/myfifo2 /tmp/pkglists rm -rf /home/myfifo /home/myfifo2 /tmp/pkglists
# fifo to receive data
mkfifo /home/myfifo mkfifo /home/myfifo
# fifo to acknowledge reception
mkfifo /home/myfifo2 mkfifo /home/myfifo2
# make sure the sbuild user can write to the fifos
chmod a+w /home/myfifo
chmod a+w /home/myfifo2
mkdir -p /tmp/pkglists mkdir -p /tmp/pkglists
# strip the architecture qualifier # strip the architecture qualifier
cat /home/myfifo | cut -d ':' -f 1 | sort > initialselection.list cat /home/myfifo | sort > initialselection.list
echo > /home/myfifo2 echo > /home/myfifo2
cat /home/myfifo | cut -d ':' -f 1 | sort > fullselection.list cat /home/myfifo | sort > fullselection.list
echo > /home/myfifo2 echo > /home/myfifo2
# get all packages that were installed on top of the base packages # get all packages that were installed on top of the base packages
comm -13 initialselection.list fullselection.list > bdselection.list comm -13 initialselection.list fullselection.list > bdselection.list
while true; do while true; do
pkgname=`cat /home/myfifo | cut -d ':' -f 1` pkgnamever=`cat /home/myfifo`
echo > /home/myfifo2 echo > /home/myfifo2
# end loop when packagename is empty # end loop when packagename is empty
[ -z "$pkgname" ] && break [ -z "$pkgnamever" ] && break
# check if the package was installed as its build dependencies # check if the package was installed as its build dependencies
if grep --line-regexp $pkgname bdselection.list; then if grep --line-regexp $pkgnamever bdselection.list; then
cat /home/myfifo | sort > "/tmp/pkglists/$pkgname" cat /home/myfifo | sort > "/tmp/pkglists/$pkgnamever"
else else
cat /home/myfifo > /dev/null cat /home/myfifo > /dev/null
fi fi
@ -53,27 +58,33 @@ if [ "$#" -eq 0 ]; then
| uniq \ | uniq \
> accessed.log > accessed.log
# now get all packages in /tmp/pkglists that have files that never appear in the collected trace # now get all packages in /tmp/pkglists that have files that never appear in the collected trace
while read pkg; do while read namever; do
name=`echo $namever | cut -d '=' -f 1 | cut -d ':' -f 1`
# FIXME: the following cannot handle dependencies on virtual packages # FIXME: the following cannot handle dependencies on virtual packages
[ -z "`comm -12 accessed.log /tmp/pkglists/$pkg`" ] \ if [ -z "`comm -12 accessed.log /tmp/pkglists/$namever`" ] \
&& grep --line-regexp "$pkg" /tmp/sbuild-dummy-depends || true && grep --line-regexp "$name" /tmp/sbuild-dummy-depends > /dev/null; then
echo $namever
fi
done > unneededdepends.list < bdselection.list done > unneededdepends.list < bdselection.list
else else
case "$1" in case "$1" in
chroot-setup) chroot-setup)
env env
dpkg --get-selections | awk '{ print $1; }' > /home/myfifo dpkg --list | awk '$1 == "ii" { print $2"="$3 }' > /home/myfifo
cat /home/myfifo2 > /dev/null cat /home/myfifo2 > /dev/null
;; ;;
pre-realbuild) pre-realbuild)
# get the current selection so that the parent script can find the additional packages that were installed # get the current selection so that the parent script can find the additional packages that were installed
dpkg --get-selections | awk '{ print $1; }' > /home/myfifo dpkg --list | awk '$1 == "ii" { print $2"="$3 }' > /home/myfifo
cat /home/myfifo2 > /dev/null cat /home/myfifo2 > /dev/null
# output the files belonging to all packages # output the files belonging to all packages
for pkg in `dpkg --get-selections | awk '{ print $1; }'`; do dpkg --list | awk '$1 == "ii" { print $2, $3 }' | while read namever; do
echo $pkg > /home/myfifo set -- $namever
name=$1
ver=$2
echo "${name}=${ver}" > /home/myfifo
cat /home/myfifo2 > /dev/null cat /home/myfifo2 > /dev/null
dpkg -L $pkg > /home/myfifo dpkg -L $name > /home/myfifo
cat /home/myfifo2 > /dev/null cat /home/myfifo2 > /dev/null
done done
# output an empty line to indicate the end # output an empty line to indicate the end
@ -97,10 +108,23 @@ else
cat /home/myfifo2 > /dev/null cat /home/myfifo2 > /dev/null
;; ;;
equivs) equivs)
pkgname="$2" namever="$2"
# create and install a package with same name and version but without dependencies # 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 - # removing Source: field because of bug#751942
dpkg -i ${pkgname}_*.deb apt-cache show --no-all-versions $namever
| grep -v "^Pre-Depends:" \
| grep -v "^Depends:" \
| grep -v "^Recommends:" \
| grep -v "^Suggests:" \
| grep -v "^Conflicts:" \
| grep -v "^Breaks:" \
| grep -v "^Provides:" \
| grep -v "^Replaces:" \
| grep -v "^Source:" \
| equivs-build -
name=`echo $namever | cut -d '=' -f 1 | cut -d ':' -f 1`
# we use a wildcard because there should only be a single file anyways
dpkg -i ${name}_*.deb
;; ;;
*) *)
echo "invalid argument: $1" >&2 echo "invalid argument: $1" >&2