File: make_image

package info (click to toggle)
debian-cd 3.1.17
  • links: PTS, VCS
  • area: main
  • in suites: jessie, jessie-kfreebsd
  • size: 4,056 kB
  • ctags: 180
  • sloc: sh: 5,391; perl: 3,927; makefile: 388
file content (147 lines) | stat: -rwxr-xr-x 4,183 bytes parent folder | download | duplicates (4)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
#!/bin/sh
#
# Debian-cd helper script for making ISO / jigdo images
#

set -e

DIR=$1
ARCHES="$2"
OUT=$3
DEBVERSION=$4
MIRROR=$5
MKISOFS=$6
MKISOFS_OPTS=$7
JIGDO_OPTS=$8
JIGDO_CLEANUP=$9

NUM_ARCHES=`echo $ARCHES | wc -w`

if [ "$CD"x = ""x ] ; then
    echo "Generating the $ARCHES iso/jigdo images ..."
    FILES=$DIR/*.volid
else
    echo "Generating $ARCHES iso/jigdo image number $CD ..."
    FILES=$DIR/$CD.volid
fi

NUM_CDS=`ls -1 $FILES | wc -l`

last_minute_update () {
    echo "  Last-minute updates:"
    # Aaargh. Only now that we know how many CDs we're making can we
    # fill in the TOTALNUM number in README.{html,txt} (and therefore also
    # update the md5sum.txt entries for those files)
    for file in README.html README.txt
    do
        echo "    $file"
        OLD_MD5=`md5sum ./$file`
        sed -i "s?TOTALNUM?$NUM_CDS?" $file
        NEW_MD5=`md5sum ./$file`
        sed -i "s?$OLD_MD5?$NEW_MD5?" md5sum.txt
    done
}

for file in $FILES
do
    dir=${file%%.volid}
    n=${dir##$DIR/}
    dir=$DIR/CD$n

    cd $dir
    # Anything last-minute that can only be done now?
    last_minute_update

    cd $dir/..

    opts=`cat $DIR/$n.mkisofs_opts` || true
    dirs=`cat $DIR/$n.mkisofs_dirs` || true
    volid=`cat $DIR/$n.volid`
    relname=`echo $DEBVERSION | sed -e 's/ //g'`
    DISKINFO=`cat $DIR/$n.diskinfo`

    ARCHLIST=`echo "$ARCHES" | tr ' ' '-'`
    OUTFILE="${CDNAME:-debian}-$relname-$ARCHLIST-$DISKTYPE-$n"

    # Clean up any old files
    rm -f $OUT/$OUTFILE.iso $OUT/$OUTFILE.jigdo $OUT/$OUTFILE.template

    date

    # Work out whether we want ISO, jigdo or both
    if [ "$MAXISOS"x = ""x ] || [ "$MAXISOS" = "all" ] || \
        [ "$MAXISOS" = "ALL" ] || [ "$n" -le "$MAXISOS" ] ; then
        ISO_WANTED=1
    else
        ISO_WANTED=0
    fi
    if [ "$MAXJIGDOS"x = ""x ] || [ "$MAXJIGDOS" = "all" ] || \
        [ "$MAXJIGDOS" = "ALL" ] || [ "$n" -le "$MAXJIGDOS" ] ; then
        JIGDO_WANTED=1
    else
        JIGDO_WANTED=0
    fi

    # Actually make the ISO/jigdo images. Long command lines
    # here... :-(
    CMD=
    if [ $JIGDO_WANTED = 0 ] && [ $ISO_WANTED = 1 ] ; then

        CMD="$MKISOFS $MKISOFS_OPTS -V '$volid' \
            -o $OUT/$OUTFILE.iso $opts $dirs CD$n"

    elif [ $JIGDO_WANTED = 1 ] && [ $ISO_WANTED = 1 ] ; then

        CMD="$MKISOFS $MKISOFS_OPTS -V '$volid' \
            -o $OUT/$OUTFILE.iso \
            -jigdo-jigdo $OUT/$OUTFILE.jigdo \
            -jigdo-template $OUT/$OUTFILE.template \
            -jigdo-map Debian=$MIRROR/ \
            -jigdo-exclude boot$n \
            -md5-list $DIR/md5-check \
            $JIGDO_OPTS $opts $dirs CD$n"

    elif [ $JIGDO_WANTED = 1 ] && [ $ISO_WANTED = 0 ] ; then

        CMD="$MKISOFS $MKISOFS_OPTS -V '$volid' \
            -o /dev/null \
            -jigdo-jigdo $OUT/$OUTFILE.jigdo \
            -jigdo-template $OUT/$OUTFILE.template \
            -jigdo-map Debian=$MIRROR/ \
            -jigdo-exclude boot$n \
            -md5-list $DIR/md5-check \
            $JIGDO_OPTS $opts $dirs CD$n"

    else
        echo "Neither jigdo nor iso wanted for CD$n"
    fi
    if [ "$CMD" ]; then
        echo $CMD
        echo $CMD > CD$n/.disk/mkisofs
        eval "$CMD"
	    if [ $ISO_WANTED = 1 ] ; then
	        chmod +r $OUT/$OUTFILE.iso
	    fi

        # Generate our listfile while we have the information to hand easily
        find CD$n/pool -type f | sed 's?^.*/??g' | gzip -9 > $OUT/$OUTFILE.list.gz
    fi

    # If we've made jigdo files, tweak them with extra info now
    if [ "$JIGDO_WANTED" = 1 ] ; then
        SNAPSHOT_DATE=`cat $DIR/DATE-zulu`
        if [ "$SNAPURL"x != ""x ] ; then
            SNAPSHOTURL=`echo "$SNAPURL" | sed "s/SNAPDATETIME/$SNAPSHOT_DATE/g"`
        fi
        $JIGDO_CLEANUP $OUT/$OUTFILE.jigdo \
            $OUTFILE.iso $DIR/CD$n \
            "`echo "$JIGDOTEMPLATEURL" | sed -e 's|%ARCH%|$ARCH|g'`$OUTFILE.template" \
            "$DISKINFO" \
            "$SNAPSHOTURL" \
            $JIGDOFALLBACKURLS
        if [ "$ISO_WANTED" = 1 ] ; then
            # Make sure that the ISO is as new/newer than the jigdo file; #587774
            touch $OUT/$OUTFILE.iso
        fi
    fi
done