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
10 # GPL v2 - see COPYING
13 # CD name of the jigit
14 # location of the mirror
15 # output location; where the jigdo, template file and
16 # snapshot will be written
17 # the locations of the input jigdo and template files
18 # the keyword to look for (e.g. Debian)
19 # the snapshot dirname (e.g. today's date)
21 # ./mkjigsnap -o /tmp/mjs-test -n mjs-test -m /tmp/mirror \
22 # -j ~/jigdo/update/debian-update-3.0r2.01-i386.jigdo \
23 # -t ~/jigdo/update/debian-update-3.0r2.01-i386.template \
62 KEYWORDS="$KEYWORDS $1"
72 if [ "$CDNAME"x = ""x ] ; then
73 echo "You must specify the output name for the jigit conf!"
77 if [ "$MIRROR"x = ""x ] ; then
78 echo "You must specify the location of the mirror!"
82 if [ "$OUT"x = ""x ] ; then
83 echo "You must specify where to set up the snapshot!"
87 if [ "$JIGDO"x = ""x ] ; then
88 echo "You must specify the jigdo file!"
92 if [ "$TEMPLATE"x = ""x ] ; then
93 echo "You must specify the template file!"
97 if [ "$DIRNAME"x = ""x ] ; then
98 echo "You must specify the snapshot directory name!"
102 if [ "$KEYWORDS"x = ""x ] ; then
103 echo "You must specify the keywords to match!"
107 # If we got here, we have all the info we need
108 echo "Creating snapshot tree:"
109 for KEYWORD in $KEYWORDS
111 NUM=$(( $NUM + `zcat -f $JIGDO | grep "$KEYWORD:" | wc -l`))
114 for KEYWORD in $KEYWORDS
116 for jentry in `zcat -f $JIGDO | grep =$KEYWORD:`
118 file=`echo $jentry | sed "s/^.*$KEYWORD://g"`
119 dir=$OUT/snapshot/$DIRNAME/`dirname $file`
120 if [ ! -d $dir ] ; then
123 ln -f $MIRROR/$file $OUT/snapshot/$DIRNAME/$file
125 if [ $error -ne 0 ] ; then
126 echo "Unable to link $MIRROR/$file; error $error"
129 LINKS_DONE=$(($LINKS_DONE + 1))
130 printf "\r%d/%d links created" $LINKS_DONE $NUM
136 zcat -f $JIGDO | sed "s:^Template=.*$:Template=$CDNAME.template:" | gzip -9 > $OUT/$CDNAME.jigdo
137 cp $TEMPLATE $OUT/$CDNAME.template
138 echo "JIGDO=$CDNAME.jigdo" > $OUT/$CDNAME.conf
139 echo "TEMPLATE=$CDNAME.template" >> $OUT/$CDNAME.conf
140 echo "SNAPSHOT=snapshot/$DIRNAME" >> $OUT/$CDNAME.conf