Debian Codegraph @

contrib/debmirror-delta-security

raw
1 #!/bin/bash
2
3 set -e
4
5 # A simple script that will create a repository of deltas, that may be
6 # used by debdelta-upgrade for upgrading package in stable and
7 # stable-security
8
9 # Copyright (C) 2006-11 Andrea Mennucci.
10 # License: GNU Library General Public License, version 2 or later
11
12 # With a change by Torsten Spindler for use with Ubuntu
13
14 ############################ WARNING ##############
15 #this script is not completely satisfactory
16
17 # situation,
18 # baz_2_all.deb is in stable, but then
19 # baz_2+1_all.deb enters as a "point release" in stable and replaces baz_2_all.deb
20 # (this needs a delta for stable updates, but it will be managed in a different repo)
21
22 # then there is a security update, baz_2+2_all.deb
23
24 # now two deltas should be generated for security ,
25 # 2 -> 2+2
26 # 2+1 -> 2+2
27
28 # the first one is not generated by this simple script.
29 ##########################################
30
31 #who I am
32 b=`basename $0`
33
34 DEBUG=''
35 VERBOSE=''
36 [ "$1" = '-v' ] && { VERBOSE='-v' ; shift ; }
37 [ "$1" = '-d' ] && { DEBUG='--debug' ; shift; }
38 [ "$1" = '-v' ] && { VERBOSE='-v' ; shift ; }
39 if [ "$1" = '' ] || test ! -r "$1" ; then
40 echo please provide the configuration file as argument
41 exit 1
42 fi
43 . "$1"
44
45 if [ -n "$TMPDIR" ]; then
46 export TMPDIR
47 fi
48
49 # set gpg-agent variables, test it
50 gpgagentcmd="gpg-agent --homedir \"${GNUPGHOME}\" --daemon --write-env-file \"$GNUPGAGENTINFO\" "
51 if test "$GNUPGAGENTINFO" ; then
52 if test ! -r "$GNUPGAGENTINFO" ; then
53 echo ERROR no agent info, please start the agent with
54 echo $gpgagentcmd
55 exit 1
56 else
57 . "$GNUPGAGENTINFO"
58 export GPG_AGENT_INFO
59 if test ! "${GPG_AGENT_INFO}" -o ! -e "${GPG_AGENT_INFO/:*/}" -o ! -O "${GPG_AGENT_INFO/:*/}" ; then
60 echo ERROR agent info is not OK, please run the command
61 echo $gpgagentcmd
62 exit 1
63 elif ! echo | gpg-connect-agent --homedir ${GNUPGHOME} ; then
64 echo ERROR agent is not responding, please run the command
65 echo $gpgagentcmd
66 exit 1
67 fi
68 fi
69 fi
70
71
72 #test that we can sign, possibly loading the password in the agent
73 if test "$GNUPGSEC" ; then
74 t=`tempfile`
75 echo pippo > $t
76 if ! gpg2 --quiet --batch --homedir "${GNUPGHOME}" -o /dev/null --default-key $GNUPGSEC --sign $t ;
77 then
78 echo signature test FAILED
79 rm $t
80 exit 1
81 fi
82 rm $t
83 fi
84
85
86 #make copy of current stable-security lists of packages
87 olddists=${TMPDIR:-/tmp}/oldsecdists-`date +'%F_%H-%M-%S'`
88 mkdir $olddists
89 cp -a $secdebmir/dists $olddists
90
91
92 #do mirror security
93 trap "rm $VERBOSE -f $secdebmirlock ; echo FAILED , please delete $olddists" 0
94 #this version of 'debmirror' is patched to support the '--trash' option,
95 # see in /usr/share/debdelta
96 $DEBMIRROR $DEBUG $VERBOSE $secdebmir $DEBMIRROR_TRASH \
97 --method=$DEBMIRROR_METHOD --nosource -h $sechost \
98 -r $release -d ${secstable} --arch=$ARCHc \
99 $DEBMIRROR_OPTIONS
100
101 #do create deltas
102 lockfile -r 1 /tmp/$b.lock || exit 1
103 trap "rm $VERBOSE -f /tmp/$b.lock; echo FAILED , please delete $olddists " 0
104 cd $secdebmir
105 for arch in $ARCHs ; do
106 for sec in $SECTIONS; do
107 $debdeltas $VERBOSE -v --test $debdelta_opt \
108 --old $fulldebmir/dists/${origstable}/$sec/binary-$arch/Packages.gz \
109 --old $olddists/dists/${secstable}/$sec/binary-$arch/Packages.gz \
110 --alt $deltamir/old_debs \
111 --dir $deltamir// dists/${secstable}/$sec/binary-$arch/Packages.gz
112 done
113 done
114
115 #do clean up a bit
116 trap "" 0
117 rm $VERBOSE -f /tmp/$b.lock
118 rm -r $olddists
119 find $deltamir/old_debs -type f -mtime +80 | xargs -r rm || true
120
121 find $deltamir/pool \
122 \( -name '*debdelta-fails' -or -name '*debdelta-too-big' \
123 -or -name '*debdelta' \) -mtime +80 -type f |\
124 xargs -r rm || true