5 # (c) 2004 Steve McIntyre
7 # Server-side wrapper; run this on a machine with a mirror to set up
8 # the snapshots for jigit
11 # CD name of the jigit
12 # location of the mirror
13 # output location; where the jigdo, template file and
14 # snapshot will be written
15 # the locations of the input jigdo and template files
16 # the keyword to look for (e.g. Debian)
17 # the snapshot dirname (e.g. today's date)
19 # ./mkjigsnap -o /tmp/mjs-test -n mjs-test -m /tmp/mirror \
20 # -j ~/jigdo/update/debian-update-3.0r2.01-i386.jigdo \
21 # -t ~/jigdo/update/debian-update-3.0r2.01-i386.template \
60 KEYWORDS="$KEYWORDS $1"
70 if [ "$CDNAME"x = ""x ] ; then
71 echo "You must specify the output name for the jigit conf!"
75 if [ "$MIRROR"x = ""x ] ; then
76 echo "You must specify the location of the mirror!"
80 if [ "$OUT"x = ""x ] ; then
81 echo "You must specify where to set up the snapshot!"
85 if [ "$JIGDO"x = ""x ] ; then
86 echo "You must specify the jigdo file!"
90 if [ "$TEMPLATE"x = ""x ] ; then
91 echo "You must specify the template file!"
95 if [ "$DIRNAME"x = ""x ] ; then
96 echo "You must specify the snapshot directory name!"
100 if [ "$KEYWORDS"x = ""x ] ; then
101 echo "You must specify the keywords to match!"
105 # If we got here, we have all the info we need
106 echo "Creating snapshot tree:"
107 for KEYWORD in $KEYWORDS
109 NUM=$(( $NUM + `zcat -f $JIGDO | grep "$KEYWORD:" | wc -l`))
112 for KEYWORD in $KEYWORDS
114 for jentry in `zcat -f $JIGDO | grep =$KEYWORD:`
116 file=`echo $jentry | sed "s/^.*$KEYWORD://g"`
117 dir=$OUT/snapshot/$DIRNAME/`dirname $file`
118 if [ ! -d $dir ] ; then
121 ln -f $MIRROR/$file $OUT/snapshot/$DIRNAME/$file
123 if [ $error -ne 0 ] ; then
124 echo "Unable to link $MIRROR/$file; error $error"
127 LINKS_DONE=$(($LINKS_DONE + 1))
128 printf "\r%d/%d links created" $LINKS_DONE $NUM
134 zcat -f $JIGDO | sed "s:^Template=.*$:Template=$CDNAME.template:" | gzip -9 > $OUT/$CDNAME.jigdo
135 cp $TEMPLATE $OUT/$CDNAME.template
136 echo "JIGDO=$CDNAME.jigdo" > $OUT/$CDNAME.conf
137 echo "TEMPLATE=$CDNAME.template" >> $OUT/$CDNAME.conf
138 echo "SNAPSHOT=snapshot/$DIRNAME" >> $OUT/$CDNAME.conf