FAQ | This is a LIVE service | Changelog

Commit ad91da90 authored by Dr Adam Thorn's avatar Dr Adam Thorn
Browse files

Fix generation of list of package files to exclude in the standard prepare script

c714a331 introduced an annoying bug here. If the filenames piped to xargs include
an apostrophe, xargs will complain and stop. We have thus, in practice, been
including all files that appear in the list after

/usr/share/sounds/ubuntu/ringtones/Sam's Song.ogg

!! Also, we've not been properly handling filenames with spaces in, and perhaps
other filenames too. We thus null-terminate the filenames for ourself.

Because I want to get to the point where we can have a sensible return code
from the prepare script, this commit also adds some set -e commands to try
to ensure errors bubble up. This is a little tedious to achieve due to all
the subshells in this script.

For the same reason, we split off the "diff" command into a "set +e" block
because diff returns non-zero if differences are found. We do not consider
that to be an error!
parent 40f64d5c
......@@ -8,28 +8,37 @@
SSH="ssh -p ${SSHPORT:-22} -o ConnectTimeout=10"
SCP="scp -P ${SSHPORT:-22}"
#echo $SSH
set -xv
if [ -z $SERVER ] ; then
echo $0 Server
exit 1
set -e
# Has the package status changed since last time we generated the list of files?
if $SSH root@$SERVER [ /var/lib/dpkg/status -nt /var/adm/backup/package-files ] ; then
# Need to rebuild package-files
$SSH root@$SERVER "
set -e
set -o pipefail
umask 077
mkdir -p /var/adm/backup
# Which packages are installed?
dpkg --get-selections | awk ' { print \$1 ; } ' >/var/adm/backup/packages
cat /var/lib/dpkg/info/*.list | while read F ; do [ -f \"\$F\" ] && echo \"\$F\" ; done | sort > \$FILELIST
awk '/Description:/ { flag = 0 } ; flag == 1 { print \$1 ; } ; /Conffiles:/ { flag = 1 } ; ' </var/lib/dpkg/status | sort >\$CONFLIST
diff -u \$FILELIST \$CONFLIST | grep ^-/ | sed s/^-// | xargs -n1 realpath >/var/adm/backup/package-files
# ignore the fact that diff exits non-zero when differences are found
set +e
set -e
cat \$DIFFLIST | grep ^-/ | sed s/^-// | tr '\\n' '\\0' | xargs -n1 -0 realpath >/var/adm/backup/package-files
$SCP -q root@$SERVER:/var/adm/backup/package-files $CONFDIR/$SERVER/exclude
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment