debian-cd-clone/update-cd

316 lines
8.8 KiB
Plaintext
Raw Permalink Normal View History

2009-02-14 11:27:21 -01:00
#!/bin/bash
#
# $Id$
#
# (c) Steve McIntyre <stevem@chiark.greenend.org.uk> Released under
# GNU GPL v2 1st January 2001
#
# Quick and dirty script to create update CDs for people to upgrade
2009-04-13 23:55:36 +00:00
# from potato (2.2r0) to the latest release level
2009-02-14 11:27:21 -01:00
#
set -e
# Configuration goes here.
# Where is your mirror?
MIRROR_NORM=/mnt/cd-raid0/ftp/debian/
2009-02-14 11:27:21 -01:00
MIRROR_AMD64=/org/cdbuilder.debian.org/src/ftp/debian-amd64/debian
# If you have a non-US mirror, where is it? Leave blank if you don't have one.
# NONUS=${NONUS:-/mirror/debian-non-US}
# Do you want non-free? 1 for yes, 0 for no
NONFREE=0
# What release version is this?
VER=5.0.5
2009-02-14 11:27:21 -01:00
# Is this an official CD?
OFFICIAL=Official
# OFFICIAL="Unofficial snapshot"
# Path to use with mkisofs/mkhybrid
#MKISOFS=${MKISOFS:-"mkhybrid"}
MKISOFS="$PWD/../genisoimage -jigdo-template-compress bzip2 -r -checksum_algorithm_iso md5,sha1,sha256,sha512"
2009-02-14 11:27:21 -01:00
# Use JTE extensions to mkisofs to make jigdo files?
JTE=1
# The working directory to use. MUST be on the same partition as the mirror.
TDIR=/mnt/cd-raid0/deb-cd/tmp/lenny-update/cd-work
2009-02-14 11:27:21 -01:00
2009-04-13 23:55:36 +00:00
# Building lenny cd set ...
CODENAME=lenny
2009-02-14 11:27:21 -01:00
# Path where the images will be written
OUT=/mnt/cd-raid0/deb-cd/tmp/lenny-update/cd-out
2009-02-14 11:27:21 -01:00
# Location(s) for the snapshot(s)
SNAPSHOT='Debian=http://us.cdimage.debian.org/cdimage/snapshot/Debian/ --try-last'
# Type of disc image, cd or dvd (lower case)
if [ "$1"x = ""x ] ; then
TYPE=cd
else
TYPE=$1
fi
case $TYPE in
cd|CD)
TYPE=cd
TYPEUP=CD;;
dvd|DVD)
TYPE=dvd
TYPEUP=DVD;;
*)
echo "Specify a disk type..."
exit 1;;
esac
# Location of the diff file to use to determine the changes. If you leave
# this blank, we'll try to determine the changes from the ChangeLog files,
# which is probably less accurate.
DIFF=/home/debian-cd/lists/lenny/r0-r5.diff
2009-02-14 11:27:21 -01:00
if [ "$TYPE" = "cd" ] ; then
CDSIZE=610 # megabytes, leaving space for metadata
else
CDSIZE=4300 # megabytes, leaving space for metadata
fi
REL=Debian"$VER"
CLOG=dists/$CODENAME/ChangeLog
NUCLOG=dists/$CODENAME/non-US/ChangeLog
UPD=$TDIR/$CODENAME-update
DATE=`date +%Y%m%d`
BASEDIR=`pwd`
SECTS="main non-free contrib"
VERBOSE=2
GRAB_MD5=$BASEDIR/tools/grab_md5
export VERBOSE BASEDIR SECTS
2009-04-13 23:55:36 +00:00
FIRSTVER=`echo $VER | cut -c 1-4`0
2009-02-14 11:27:21 -01:00
CAPCODE=`perl -e "print ucfirst("$CODENAME")"`
2009-04-13 23:55:36 +00:00
export FIRSTVER CAPCODE
2009-02-14 11:27:21 -01:00
if [ "$ARCHLIST"x = ""x ] ; then
2009-04-13 23:55:36 +00:00
ARCHLIST="alpha amd64 arm armel hppa i386 ia64 mips mipsel powerpc s390 sparc source" # amd64 # all dealt with specially
2009-02-14 11:27:21 -01:00
fi
export TDIR NONFREE NONUS VER MIRROR CODENAME OUT BASEDIR
CDSIZE=$(($CDSIZE * 1024))
scanpackages=$BASEDIR/tools/scanpackages.old
scansources=$BASEDIR/tools/scansources.old
set_mkisofs_opts=$BASEDIR/tools/set_mkisofs_opts
addfiles=$BASEDIR/tools/add_files
create_control_files () {
CDDIR=$1
shift
ARCHES=$*
echo " Creating control files for \"$ARCHES\" on $CDDIR"
for ARCH in $ARCHES
do
case "$ARCH" in
source)
echo " source"
for SECT in $SECTS
do
mkdir -p $CDDIR/dists/$CODENAME/$SECT/source
mkdir -p $CDDIR/dists/$CODENAME/non-US/$SECT/source
done
cd $UPD
$scansources $CDDIR >/dev/null 2>&1
;;
all)
;;
*)
echo " $ARCH"
for SECT in $SECTS
do
mkdir -p $CDDIR/dists/$CODENAME/$SECT/binary-$ARCH
mkdir -p $CDDIR/dists/$CODENAME/non-US/$SECT/binary-$ARCH
done
ARCH=$ARCH $scanpackages scan $CDDIR >/dev/null 2>&1
ARCH=$ARCH $scanpackages -noPackages.cd install $CDDIR >/dev/null 2>&1
rm -f $CDDIR/*.Packages* >/dev/null 2>&1
;;
esac
done
}
copy_file () {
ROOTDIR=$1
shift
FILE=$1
DIR=`dirname $FILE`
if [ ! -d $ROOTDIR/$DIR ] ; then
mkdir -p $ROOTDIR/$DIR
fi
if [ -e $MIRROR/$FILE ] ; then
cp -l $MIRROR/$FILE $ROOTDIR/$FILE
elif [ -e $NONUS/$FILE ] ; then
cp -l $NONUS/$FILE $ROOTDIR/$FILE
else
echo
echo "File $FILE not found!"
exit 1
fi
}
make_cd () {
CDNUM=$1
shift
THISNUM=$1
shift
THISARCH=$1
shift
SRCFILES=$1
shift
ARCHFILES=$1
shift
ALLFILES=$1
echo
echo " Creating Packages and Sources files for CD$CDNUM"
cd $UPD
create_control_files CD$CDNUM $THISARCH
echo " Creating image for CD$CDNUM ($SRCFILES source files, $ARCHFILES $ARCH debs, $ALLFILES all debs)"
echo -n " "
if [ ! -d $OUT/$THISARCH/iso-$TYPE ] ; then
mkdir -p $OUT/$THISARCH/iso-$TYPE
fi
if [ $JTE = 1 ] ; then
if [ ! -d $OUT/$THISARCH/jigdo-$TYPE ] ; then
mkdir -p $OUT/$THISARCH/jigdo-$TYPE
fi
${MKISOFS} -J -r -V "Debian $VER update $TYPEUP" -o \
$OUT/$THISARCH/iso-$TYPE/debian-update-$VER-$THISARCH-$TYPEUP-$THISNUM.iso \
-jigdo-jigdo $OUT/$THISARCH/jigdo-$TYPE/debian-update-$VER-$THISARCH-$TYPEUP-$THISNUM.jigdo \
-jigdo-template $OUT/$THISARCH/jigdo-$TYPE/debian-update-$VER-$THISARCH-$TYPEUP-$THISNUM.template \
-jigdo-map Debian=$MIRROR/ \
-jigdo-map Non-US=$NONUS/ \
-jigdo-force-md5 /pool/ \
-md5-list $UPD/md5-check \
$UPD/CD$CDNUM 2>&1 | grep "extents written"
2009-02-14 11:27:21 -01:00
$BASEDIR/tools/jigdo_cleanup \
$OUT/$THISARCH/jigdo-$TYPE/debian-update-$VER-$THISARCH-$TYPEUP-$THISNUM.jigdo \
debian-update-$VER-$THISARCH-$TYPEUP-$THISNUM.iso \
$OUT debian-update-$VER-$THISARCH-$TYPEUP-$THISNUM.template \
2009-04-13 23:55:36 +00:00
"Debian GNU/Linux $VER - $OFFICIAL $THISARCH $FIRSTVER->$VER update $TYPEUP #$THISNUM"
2009-02-14 11:27:21 -01:00
echo $SNAPSHOT >> $OUT/$THISARCH/jigdo-$TYPE/debian-update-$VER-$THISARCH-$TYPEUP-$THISNUM.jigdo
2009-04-13 23:55:36 +00:00
MD5=`cat $OUT/$THISARCH/jigdo-$TYPE/debian-update-$VER-$THISARCH-$TYPEUP-$THISNUM.jigdo | \
awk '/Image Hex MD5Sum/ {print $5}'`
echo "$MD5 debian-update-$VER-$THISARCH-$TYPEUP-$THISNUM.iso" >> $OUT/$THISARCH/jigdo-$TYPE/MD5SUMS.update
echo "$MD5 debian-update-$VER-$THISARCH-$TYPEUP-$THISNUM.iso" >> $OUT/$THISARCH/iso-$TYPE/MD5SUMS.update
SHA1=`cat $OUT/$THISARCH/jigdo-$TYPE/debian-update-$VER-$THISARCH-$TYPEUP-$THISNUM.jigdo | \
awk '/Image Hex SHA1Sum/ {print $5}'`
echo "$SHA1 debian-update-$VER-$THISARCH-$TYPEUP-$THISNUM.iso" >> $OUT/$THISARCH/jigdo-$TYPE/SHA1SUMS.update
echo "$SHA1 debian-update-$VER-$THISARCH-$TYPEUP-$THISNUM.iso" >> $OUT/$THISARCH/iso-$TYPE/SHA1SUMS.update
gzip -9 $OUT/$THISARCH/jigdo-$TYPE/debian-update-$VER-$THISARCH-$TYPEUP-$THISNUM.jigdo
mv -v $OUT/$THISARCH/jigdo-$TYPE/debian-update-$VER-$THISARCH-$TYPEUP-$THISNUM.jigdo.gz \
$OUT/$THISARCH/jigdo-$TYPE/debian-update-$VER-$THISARCH-$TYPEUP-$THISNUM.jigdo
2009-02-14 11:27:21 -01:00
else
${MKISOFS} -J -r -V "Debian $VER update $TYPEUP" -o \
$OUT/iso-$TYPE/$CODENAME-update-$THISARCH-$TYPEUP-$THISNUM.raw \
$UPD/CD$CDNUM 2>&1 | grep "extents written"
fi
}
echo Cleaning up
rm -rf $UPD
mkdir -p $UPD
CDNUM=1
echo Creating file list
if [ ! -e $DIFF ] ; then
echo "NO DIFF FOUND. ABORT!"
exit 1
fi
cp $DIFF $UPD/list
if [ "$NONUS"x == ""x ] ; then
echo "Removing non-US files from the list"
grep -v non-US $UPD/list > $UPD/list1
mv -f $UPD/list1 $UPD/list
fi
if [ "$NONFREE"x != "1"x ] ; then
echo "Removing non-free files from the list"
grep -v non-free $UPD/list > $UPD/list1
mv -f $UPD/list1 $UPD/list
fi
for THISARCH in $ARCHLIST
do
THISNUM=0
MIRROR=$MIRROR_NORM
rm -f $UPD/md5-check
$GRAB_MD5 $MIRROR "$ARCHLIST" $CODENAME $CODENAME $UPD/md5-check
2009-02-14 11:27:21 -01:00
if [ "$NONUS"x != ""x ] ; then
$GRAB_MD5 $NONUS "$ARCHLIST" $CODENAME $CODENAME $UPD/md5-check
2009-02-14 11:27:21 -01:00
fi
for file in `cat $UPD/list`
do
if [ ! -d $UPD/CD$CDNUM ] ; then
echo
cd $MIRROR
THISNUM=$((THISNUM + 1))
if [ $THISARCH = "source" ] ; then
echo "Creating $TYPEUP$CDNUM for source (part $THISNUM)"
else
echo "Creating $TYPEUP$CDNUM for binary-$THISARCH (part $THISNUM)"
fi
mkdir $UPD/CD$CDNUM $UPD/CD$CDNUM/.disk
INFO="Debian GNU/Linux $VER Update $TYPEUP $DATE: $THISARCH $TYPEUP $THISNUM"
echo $INFO > $UPD/CD$CDNUM/.disk/info
SIZE_USED=0
SRCFILES=0
ARCHFILES=0
ALLFILES=0
fi
SIZE_USED=`du -sk $UPD/CD$CDNUM | awk '{print $1}'`
if [ $SIZE_USED -gt $CDSIZE ] ; then
make_cd $CDNUM $THISNUM $THISARCH $SRCFILES $ARCHFILES $ALLFILES
CDNUM=$(($CDNUM + 1))
continue
fi
case "$THISARCH" in
source)
case "$file" in
*.gz|*.dsc)
copy_file $UPD/CD$CDNUM $file
SRCFILES=$(($SRCFILES + 1))
;;
esac
echo -en "\r$SRCFILES copied"
;;
*)
case "$file" in
*_$THISARCH.deb)
copy_file $UPD/CD$CDNUM $file
ARCHFILES=$(($ARCHFILES + 1))
;;
*_all.deb)
copy_file $UPD/CD$CDNUM $file
ALLFILES=$(($ALLFILES + 1))
;;
esac
echo -en "\r$THISARCH:$ARCHFILES all:$ALLFILES copied"
;;
esac
done
make_cd $CDNUM $THISNUM $THISARCH $SRCFILES $ARCHFILES $ALLFILES
CDNUM=$(($CDNUM + 1))
done