use less fifo but direct file writing instead
This commit is contained in:
parent
f4cf179b6d
commit
bc22cc62dd
2 changed files with 78 additions and 85 deletions
115
findunusedbd.sh
115
findunusedbd.sh
|
@ -3,93 +3,59 @@
|
|||
#
|
||||
# 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 [ "$#" -eq 0 ]; then
|
||||
rm -rf /home/myfifo /home/myfifo2 /tmp/pkglists
|
||||
# fifo to receive data
|
||||
mkfifo /home/myfifo
|
||||
# fifo to acknowledge reception
|
||||
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
|
||||
# strip the architecture qualifier
|
||||
cat /home/myfifo | sort > initialselection.list
|
||||
echo > /home/myfifo2
|
||||
cat /home/myfifo | 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
|
||||
pkgnamever=`cat /home/myfifo`
|
||||
echo > /home/myfifo2
|
||||
# end loop when packagename is empty
|
||||
[ -z "$pkgnamever" ] && break
|
||||
# check if the package was installed as its build dependencies
|
||||
if grep --line-regexp $pkgnamever bdselection.list; then
|
||||
cat /home/myfifo | sort > "/tmp/pkglists/$pkgnamever"
|
||||
else
|
||||
cat /home/myfifo > /dev/null
|
||||
fi
|
||||
echo > /home/myfifo2
|
||||
done
|
||||
cat /home/myfifo | sed 's/, \+/\n/'g \
|
||||
| sed 's/\([a-zA-Z0-9][a-zA-Z0-9+.-]*\).*/\1/' \
|
||||
> /tmp/sbuild-dummy-depends
|
||||
echo > /home/myfifo2
|
||||
SCHROOT_SESSION_ID=`cat /home/myfifo`;
|
||||
echo > /home/myfifo2
|
||||
|
||||
if [ "$#" -eq 1 ]; then
|
||||
tmpdir="$1"
|
||||
# once something is written to the fifo, it indicates that fatrace should start
|
||||
SCHROOT_SESSION_ID=`cat "${tmpdir}/myfifo"`;
|
||||
# change to the schroot mount
|
||||
cd /var/lib/schroot/mount/$SCHROOT_SESSION_ID
|
||||
# start fatrace in the mounted directory
|
||||
(
|
||||
cd /var/lib/schroot/mount/$SCHROOT_SESSION_ID;
|
||||
fatrace --current-mount > /home/fatrace.log &
|
||||
FATRACE_PID=$!;
|
||||
cat /home/myfifo > /dev/null;
|
||||
echo > /home/myfifo2
|
||||
kill $FATRACE_PID;
|
||||
)
|
||||
|
||||
fatrace --current-mount > "${tmpdir}/fatrace.log" &
|
||||
FATRACE_PID=$!
|
||||
# give fatrace some time to set up (value is arbitrary)
|
||||
sleep 5
|
||||
# signal that fatrace was started
|
||||
echo > "${tmpdir}/myfifo"
|
||||
# wait for build to finish
|
||||
cat "${tmpdir}/myfifo" > /dev/null
|
||||
kill $FATRACE_PID
|
||||
# clean up the fatrace log to only include unique paths
|
||||
sed 's/\/var\/lib\/schroot\/mount\/[^\/]\+//' /home/fatrace.log \
|
||||
sed 's/\/var\/lib\/schroot\/mount\/[^\/]\+//' "${tmpdir}/fatrace.log" \
|
||||
| awk '{ print $3; }' \
|
||||
| grep -v ^/build \
|
||||
| sort \
|
||||
| uniq \
|
||||
> accessed.log
|
||||
> "${tmpdir}/accessed.log"
|
||||
# now get all packages in /tmp/pkglists that have files that never appear in the collected trace
|
||||
while read namever; do
|
||||
name=`echo $namever | cut -d '=' -f 1 | cut -d ':' -f 1`
|
||||
# FIXME: the following cannot handle dependencies on virtual packages
|
||||
if [ -z "`comm -12 accessed.log /tmp/pkglists/$namever`" ] \
|
||||
&& grep --line-regexp "$name" /tmp/sbuild-dummy-depends > /dev/null; then
|
||||
if [ -z `comm -12 "${tmpdir}/accessed.log" "${tmpdir}/$namever"` ] \
|
||||
&& grep --line-regexp "$name" "${tmpdir}/sbuild-dummy-depends" > /dev/null; then
|
||||
echo $namever
|
||||
fi
|
||||
done > unneededdepends.list < bdselection.list
|
||||
else
|
||||
done > "${tmpdir}/unneededdepends.list" < "${tmpdir}/bdselection.list"
|
||||
elif [ "$#" -eq 2 ]; then
|
||||
case "$1" in
|
||||
chroot-setup)
|
||||
env
|
||||
dpkg --list | awk '$1 == "ii" { print $2"="$3 }' > /home/myfifo
|
||||
cat /home/myfifo2 > /dev/null
|
||||
tmpdir="$2"
|
||||
dpkg --list | awk '$1 == "ii" { print $2"="$3 }' | sort > "${tmpdir}/initialselection.list"
|
||||
;;
|
||||
pre-realbuild)
|
||||
tmpdir="$2"
|
||||
# get the current selection so that the parent script can find the additional packages that were installed
|
||||
dpkg --list | awk '$1 == "ii" { print $2"="$3 }' > /home/myfifo
|
||||
cat /home/myfifo2 > /dev/null
|
||||
dpkg --list | awk '$1 == "ii" { print $2"="$3 }' | sort > "${tmpdir}/fullselection.list"
|
||||
# get all packages that were installed on top of the base packages
|
||||
comm -13 "${tmpdir}/initialselection.list" "${tmpdir}/fullselection.list" > "${tmpdir}/bdselection.list"
|
||||
# output the files belonging to all packages
|
||||
dpkg --list | awk '$1 == "ii" { print $2, $3 }' | while read namever; do
|
||||
set -- $namever
|
||||
name=$1
|
||||
ver=$2
|
||||
echo "${name}=${ver}" > /home/myfifo
|
||||
cat /home/myfifo2 > /dev/null
|
||||
dpkg -L $name > /home/myfifo
|
||||
cat /home/myfifo2 > /dev/null
|
||||
if grep --line-regexp $pkgnamever "${tmpdir}/bdselection.list"; then
|
||||
dpkg -L $name > "${tmpdir}/${name}=${ver}"
|
||||
fi
|
||||
done
|
||||
# output an empty line to indicate the end
|
||||
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 \
|
||||
|
@ -97,15 +63,18 @@ else
|
|||
| grep -v sbuild-build-depends-essential-dummy \
|
||||
| grep -v sbuild-build-depends-lintian-dummy \
|
||||
| xargs -I {} dpkg-query --showformat='${Depends}\n' --show {} \
|
||||
> /home/myfifo
|
||||
cat /home/myfifo2 > /dev/null
|
||||
| sed 's/, \+/\n/'g \
|
||||
| sed 's/\([a-zA-Z0-9][a-zA-Z0-9+.-]*\).*/\1/' \
|
||||
> "${tmpdir}/sbuild-dummy-depends"
|
||||
# output the schroot id to start tracing
|
||||
echo $SCHROOT_SESSION_ID > /home/myfifo
|
||||
cat /home/myfifo2 > /dev/null
|
||||
echo $SCHROOT_SESSION_ID > "${tmpdir}/myfifo"
|
||||
# wait for fatrace to be forked
|
||||
cat "${tmpdir}/myfifo" > /dev/null
|
||||
;;
|
||||
post-realbuild)
|
||||
echo "done" > /home/myfifo
|
||||
cat /home/myfifo2 > /dev/null
|
||||
tmpdir="$2"
|
||||
# signal that the build is done
|
||||
echo > "${tmpdir}/myfifo"
|
||||
;;
|
||||
equivs)
|
||||
namever="$2"
|
||||
|
@ -130,4 +99,10 @@ else
|
|||
echo "invalid argument: $1" >&2
|
||||
;;
|
||||
esac
|
||||
else
|
||||
echo "usage: " >&2
|
||||
echo " $0 tmpdir"
|
||||
echo " $0 [chroot-setup|pre-realbuild|post-realbuild] tmpdir"
|
||||
echo " $0 equivs pkgname"
|
||||
exit 1
|
||||
fi
|
||||
|
|
48
run.sh
48
run.sh
|
@ -5,26 +5,31 @@ if [ $# -eq 0 ]; then
|
|||
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' \
|
||||
build () {
|
||||
dsc="$1"
|
||||
archall="$2"
|
||||
tmpdir=`mktemp -d --tmpdir=/home`
|
||||
mkfifo "${tmpdir}/myfifo"
|
||||
chmod a+w "${tmpdir}/myfifo"
|
||||
/home/findunusedbd.sh "$tmpdir" &
|
||||
sbuild --$archall \
|
||||
--chroot-setup-commands="/home/findunusedbd.sh $tmpdir chroot-setup" \
|
||||
--pre-realbuild-commands="/home/findunusedbd.sh $tmpdir pre-realbuild" \
|
||||
--post-realbuild-commands="/home/findunusedbd.sh $tmpdir 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
|
||||
mv "${tmpdir}/unneededdepends.list" `basename $dsc .dsc`.${archall}.unusedbd
|
||||
echo $dsc >> buildsuccess.${archall}.list
|
||||
fi
|
||||
done
|
||||
rm -rf "$tmpdir"
|
||||
}
|
||||
|
||||
while read dscname; do
|
||||
echo $dscname
|
||||
unusedbdname=`basename $dscname .dsc`.unusedbd
|
||||
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 --no-arch-all \
|
||||
|
@ -35,4 +40,17 @@ while read dscname; do
|
|||
fi
|
||||
rm -f *.deb *.udeb *.changes
|
||||
done < $unusedbdname
|
||||
done < buildsuccess.list
|
||||
}
|
||||
|
||||
for a in "arch-all" "no-arch-all"; do
|
||||
echo > buildsuccess.${a}.list
|
||||
for dsc in $@; do
|
||||
echo $dsc
|
||||
build "$dsc" "$a"
|
||||
done
|
||||
|
||||
while read dscname; do
|
||||
echo $dscname
|
||||
check $dscname "$a"
|
||||
done < buildsuccess.${a}.list
|
||||
done
|
||||
|
|
Loading…
Reference in a new issue