debian-cd-clone/tools/make_image

154 lines
4.2 KiB
Plaintext
Raw Permalink Normal View History

#!/bin/sh
#
# Debian-cd helper script for making ISO / jigdo images
#
set -e
DIR=$1
Merge of changes from Steve's development branch to take us to debian-cd version 3.0.0. Highlights: * Support now added for multi-arch CDs/DVDs, including mixed binary/source discs. Multi-arch discs should be bootable on those multiple arches, modulo boot-sector clashes. Extra support added in boot-i386 and boot-amd64 to make the 2 main arches happily co-exist. * Disc sizing is now much more intelligent - sizes are defined depending on the disk type chosen at the start, and discs are now filled exactly to those sizes while files are added rather than the old up-front guessing method. Equally, the metadata on the disc (Packages, Packages.gz, Sources, Sources.gz, md5sums.txt) is generated as much as possible while this is happening to make the sizing code incredibly accurate. Using this method of disc sizing means that customising discs should be much easier/safer - either add custom contents at the start and debian-cd will fill the remainder of the disc, or afterwards roll back the packages on the disc and add extras later. * Source is now treated as (almost) just another arch, with most of the special casing for source hidden internally. If asking for source-only discs, they will simply be built using all the available sources. If combined with other arches, the sources will automatically be chosen to match the binary packages. Meeting GPL requirements was never so easy! * Removed lots of old cruft to clean up the codebase: + non-US support + woody support + lots of old support scripts that have been made redundant + significantly simpler Makefile, much easier to follow + old boot-$ARCH.calc files for estimating boot-file sizes are now (obviously) obsolete and therefore gone
2006-12-07 22:09:01 -01:00
ARCHES="$2"
OUT=$3
DEBVERSION=$4
MIRROR=$5
MKISOFS=$6
MKISOFS_OPTS=$7
JIGDO_OPTS=$8
JIGDO_CLEANUP=$9
Merge of changes from Steve's development branch to take us to debian-cd version 3.0.0. Highlights: * Support now added for multi-arch CDs/DVDs, including mixed binary/source discs. Multi-arch discs should be bootable on those multiple arches, modulo boot-sector clashes. Extra support added in boot-i386 and boot-amd64 to make the 2 main arches happily co-exist. * Disc sizing is now much more intelligent - sizes are defined depending on the disk type chosen at the start, and discs are now filled exactly to those sizes while files are added rather than the old up-front guessing method. Equally, the metadata on the disc (Packages, Packages.gz, Sources, Sources.gz, md5sums.txt) is generated as much as possible while this is happening to make the sizing code incredibly accurate. Using this method of disc sizing means that customising discs should be much easier/safer - either add custom contents at the start and debian-cd will fill the remainder of the disc, or afterwards roll back the packages on the disc and add extras later. * Source is now treated as (almost) just another arch, with most of the special casing for source hidden internally. If asking for source-only discs, they will simply be built using all the available sources. If combined with other arches, the sources will automatically be chosen to match the binary packages. Meeting GPL requirements was never so easy! * Removed lots of old cruft to clean up the codebase: + non-US support + woody support + lots of old support scripts that have been made redundant + significantly simpler Makefile, much easier to follow + old boot-$ARCH.calc files for estimating boot-file sizes are now (obviously) obsolete and therefore gone
2006-12-07 22:09:01 -01:00
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
# Grab the xorriso version and turn it into a number we can use
xorriso_version() {
$MKISOFS --version 2>&1 | awk '
/^xorriso version/ {
split($4, ver, ".")
print ver[1]*10000+ver[2]*100+ver[3]
}'
}
for file in $FILES
do
dir=${file%%.volid}
n=${dir##$DIR/}
dir=$DIR/CD$n
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" ] || \
2010-07-02 22:15:21 +00:00
[ "$MAXISOS" = "ALL" ] || [ "$n" -le "$MAXISOS" ] ; then
ISO_WANTED=1
else
ISO_WANTED=0
fi
if [ "$MAXJIGDOS"x = ""x ] || [ "$MAXJIGDOS" = "all" ] || \
2010-07-02 22:15:21 +00:00
[ "$MAXJIGDOS" = "ALL" ] || [ "$n" -le "$MAXJIGDOS" ] ; then
JIGDO_WANTED=1
else
JIGDO_WANTED=0
fi
# Work out common jigdo options if needed
if [ $JIGDO_WANTED = 1 ]; then
XOR_VER=$(xorriso_version)
if [ $XOR_VER -lt 10502 ]; then
# Only supports jigdo format v1
case "$JIGDO_CHECKSUM"x in
"md5"x|x)
JIGDO_CHECKSUM_OPTS="-md5-list $DIR/checksum-check \
-jigdo-force-md5 /pool/"
;;
*)
echo "Older xorriso version $XOR_VER does not support jigdo checksum algorithm $JIGDO_CHECKSUM"
exit 1
;;
esac
else
JIGDO_CHECKSUM_OPTS="-checksum-list $DIR/checksum-check \
-jigdo-checksum-algorithm $JIGDO_CHECKSUM \
-jigdo-force-checksum /pool/"
fi
JIGDO_OPTS="$JIGDO_CHECKSUM_OPTS $JIGDO_OPTS \
-jigdo-jigdo $OUT/$OUTFILE.jigdo \
-jigdo-template $OUT/$OUTFILE.template \
-jigdo-map Debian=$MIRROR/ \
-jigdo-exclude boot$n"
fi
# Actually make the ISO/jigdo images. Long command lines
# here, with lots of stuff included :-(
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_OPTS $opts $dirs CD$n"
elif [ $JIGDO_WANTED = 1 ] && [ $ISO_WANTED = 0 ] ; then
CMD="$MKISOFS $MKISOFS_OPTS -V '$volid' \
-o /dev/null \
$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' | pigz -9nm > $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
2010-07-02 22:15:21 +00:00
$JIGDO_CLEANUP $OUT/$OUTFILE.jigdo \
$OUTFILE.iso $DIR/CD$n \
"`echo "$JIGDOTEMPLATEURL" | sed -e 's|%ARCH%|$ARCH|g'`$OUTFILE.template" \
"$DISKINFO" \
"$SNAPSHOTURL" \
2010-07-02 22:15:21 +00:00
$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