use less fifo but direct file writing instead

main
josch 10 years ago
parent f4cf179b6d
commit bc22cc62dd

@ -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' # 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 if [ "$#" -eq 1 ]; then
rm -rf /home/myfifo /home/myfifo2 /tmp/pkglists tmpdir="$1"
# fifo to receive data # once something is written to the fifo, it indicates that fatrace should start
mkfifo /home/myfifo SCHROOT_SESSION_ID=`cat "${tmpdir}/myfifo"`;
# fifo to acknowledge reception # change to the schroot mount
mkfifo /home/myfifo2 cd /var/lib/schroot/mount/$SCHROOT_SESSION_ID
# 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
# start fatrace in the mounted directory # start fatrace in the mounted directory
( fatrace --current-mount > "${tmpdir}/fatrace.log" &
cd /var/lib/schroot/mount/$SCHROOT_SESSION_ID; FATRACE_PID=$!
fatrace --current-mount > /home/fatrace.log & # give fatrace some time to set up (value is arbitrary)
FATRACE_PID=$!; sleep 5
cat /home/myfifo > /dev/null; # signal that fatrace was started
echo > /home/myfifo2 echo > "${tmpdir}/myfifo"
kill $FATRACE_PID; # wait for build to finish
) cat "${tmpdir}/myfifo" > /dev/null
kill $FATRACE_PID
# clean up the fatrace log to only include unique paths # 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; }' \ | awk '{ print $3; }' \
| grep -v ^/build \ | grep -v ^/build \
| sort \ | sort \
| uniq \ | uniq \
> accessed.log > "${tmpdir}/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 namever; do while read namever; do
name=`echo $namever | cut -d '=' -f 1 | cut -d ':' -f 1` 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
if [ -z "`comm -12 accessed.log /tmp/pkglists/$namever`" ] \ if [ -z `comm -12 "${tmpdir}/accessed.log" "${tmpdir}/$namever"` ] \
&& grep --line-regexp "$name" /tmp/sbuild-dummy-depends > /dev/null; then && grep --line-regexp "$name" "${tmpdir}/sbuild-dummy-depends" > /dev/null; then
echo $namever echo $namever
fi fi
done > unneededdepends.list < bdselection.list done > "${tmpdir}/unneededdepends.list" < "${tmpdir}/bdselection.list"
else elif [ "$#" -eq 2 ]; then
case "$1" in case "$1" in
chroot-setup) chroot-setup)
env tmpdir="$2"
dpkg --list | awk '$1 == "ii" { print $2"="$3 }' > /home/myfifo dpkg --list | awk '$1 == "ii" { print $2"="$3 }' | sort > "${tmpdir}/initialselection.list"
cat /home/myfifo2 > /dev/null
;; ;;
pre-realbuild) pre-realbuild)
tmpdir="$2"
# 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 --list | awk '$1 == "ii" { print $2"="$3 }' > /home/myfifo dpkg --list | awk '$1 == "ii" { print $2"="$3 }' | sort > "${tmpdir}/fullselection.list"
cat /home/myfifo2 > /dev/null # 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 # output the files belonging to all packages
dpkg --list | awk '$1 == "ii" { print $2, $3 }' | while read namever; do dpkg --list | awk '$1 == "ii" { print $2, $3 }' | while read namever; do
set -- $namever set -- $namever
name=$1 name=$1
ver=$2 ver=$2
echo "${name}=${ver}" > /home/myfifo if grep --line-regexp $pkgnamever "${tmpdir}/bdselection.list"; then
cat /home/myfifo2 > /dev/null dpkg -L $name > "${tmpdir}/${name}=${ver}"
dpkg -L $name > /home/myfifo fi
cat /home/myfifo2 > /dev/null
done 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 # output the dependencies of the sbuild dummy package
dpkg --get-selections | awk '{ print $1; }' \ dpkg --get-selections | awk '{ print $1; }' \
| grep sbuild-build-depends \ | grep sbuild-build-depends \
@ -97,15 +63,18 @@ else
| grep -v sbuild-build-depends-essential-dummy \ | grep -v sbuild-build-depends-essential-dummy \
| grep -v sbuild-build-depends-lintian-dummy \ | grep -v sbuild-build-depends-lintian-dummy \
| xargs -I {} dpkg-query --showformat='${Depends}\n' --show {} \ | xargs -I {} dpkg-query --showformat='${Depends}\n' --show {} \
> /home/myfifo | sed 's/, \+/\n/'g \
cat /home/myfifo2 > /dev/null | sed 's/\([a-zA-Z0-9][a-zA-Z0-9+.-]*\).*/\1/' \
> "${tmpdir}/sbuild-dummy-depends"
# output the schroot id to start tracing # output the schroot id to start tracing
echo $SCHROOT_SESSION_ID > /home/myfifo echo $SCHROOT_SESSION_ID > "${tmpdir}/myfifo"
cat /home/myfifo2 > /dev/null # wait for fatrace to be forked
cat "${tmpdir}/myfifo" > /dev/null
;; ;;
post-realbuild) post-realbuild)
echo "done" > /home/myfifo tmpdir="$2"
cat /home/myfifo2 > /dev/null # signal that the build is done
echo > "${tmpdir}/myfifo"
;; ;;
equivs) equivs)
namever="$2" namever="$2"
@ -130,4 +99,10 @@ else
echo "invalid argument: $1" >&2 echo "invalid argument: $1" >&2
;; ;;
esac esac
else
echo "usage: " >&2
echo " $0 tmpdir"
echo " $0 [chroot-setup|pre-realbuild|post-realbuild] tmpdir"
echo " $0 equivs pkgname"
exit 1
fi fi

@ -5,26 +5,31 @@ if [ $# -eq 0 ]; then
exit 1 exit 1
fi fi
echo > buildsuccess.list build () {
for dsc in $1; do dsc="$1"
echo $dsc archall="$2"
/home/findunusedbd.sh & tmpdir=`mktemp -d --tmpdir=/home`
sbuild --no-arch-all \ mkfifo "${tmpdir}/myfifo"
--chroot-setup-commands='/home/findunusedbd.sh chroot-setup' \ chmod a+w "${tmpdir}/myfifo"
--pre-realbuild-commands='/home/findunusedbd.sh pre-realbuild' \ /home/findunusedbd.sh "$tmpdir" &
--post-realbuild-commands='/home/findunusedbd.sh post-realbuild' \ 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" "$dsc"
ret=$? ret=$?
rm -f *.deb *.udeb *.changes rm -f *.deb *.udeb *.changes
if [ $ret -eq 0 ] && [ -s unneededdepends.list ]; then if [ $ret -eq 0 ] && [ -s unneededdepends.list ]; then
mv unneededdepends.list `basename $dsc .dsc`.unusedbd mv "${tmpdir}/unneededdepends.list" `basename $dsc .dsc`.${archall}.unusedbd
echo $dsc >> buildsuccess.list echo $dsc >> buildsuccess.${archall}.list
fi fi
done rm -rf "$tmpdir"
}
while read dscname; do check () {
echo $dscname dscname="$1"
unusedbdname=`basename $dscname .dsc`.unusedbd archall="$2"
unusedbdname=`basename $dscname .dsc`.${archall}.unusedbd
while read bd; do while read bd; do
# now run sbuild with "findunusedbd.sh equivs" creating a fake equivs package # now run sbuild with "findunusedbd.sh equivs" creating a fake equivs package
sbuild --no-arch-all \ sbuild --no-arch-all \
@ -35,4 +40,17 @@ while read dscname; do
fi fi
rm -f *.deb *.udeb *.changes rm -f *.deb *.udeb *.changes
done < $unusedbdname 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…
Cancel
Save