~gilir/debian-cd/ubuntu

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
#!/bin/sh

# Script to build everything possible : sources and binaries for all archs

. ./CONF.sh

rm -rf "$TDIR"
rm -rf "$OUT"
TMP_OUT=$OUT

if [ -z "$ARCHES" ]; then
	export ARCHES='amd64 i386 powerpc'
fi

for FULLARCH in $ARCHES
do
	export ARCH="${FULLARCH%%+*}"
	if [ "$ARCH" = "$FULLARCH" ]; then
		export SUBARCH=
	else
		export SUBARCH="${FULLARCH#*+}"
	fi
	echo "Now we're going to build CD for $FULLARCH !"
	if type find-mirror >/dev/null 2>&1; then
		# TODO: nasty upcall to cdimage wrapper scripts
		export MIRROR="$(find-mirror "$ARCH")"
		if [ "$SECURITY" ]; then
			export SECURITY="$MIRROR"
		fi
	fi
	echo " ... cleaning"
	make distclean
	make ${CODENAME}_status
	echo " ... checking your mirror"
	if [ "$SKIPMIRRORCHECK" != "yes" ] ; then 
		make mirrorcheck-binary
      	if [ "$FULLARCH" = "i386" ]; then
            make mirrorcheck-source
        fi
	else
		echo "WARNING: skipping mirrorcheck"
	fi

	if [ $? -gt 0 ]; then
		echo "ERROR: Your mirror has a problem, please correct it." >&2
		exit 1
	fi
	echo " ... selecting packages to include"
	if [ -e ${MIRROR}/dists/${CODENAME}/main/disks-${ARCH}/current/. ] ; then
		disks=`du -sm ${MIRROR}/dists/${CODENAME}/main/disks-${ARCH}/current/. | \
				awk '{print $1}'`
	else
		disks=0
	fi
	if [ -f $BASEDIR/tools/boot/$CODENAME/boot-$FULLARCH.calc ]; then
	    . $BASEDIR/tools/boot/$CODENAME/boot-$FULLARCH.calc
	fi
	SIZE_ARGS=''
	for CD in 1; do
		size=`eval echo '$'"BOOT_SIZE_${CD}"`
		[ "$size" = "" ] && size=0
		[ $CD = "1" ] && size=$(($size + $disks))
        mult=`eval echo '$'"SIZE_MULT_${CD}"`
        [ "$mult" = "" ] && mult=100
        FULL_SIZE=`echo "($DEFBINSIZE - $size) * 1024 * 1024" | bc`
        echo "INFO: Reserving $size MB on CD $CD for boot files.  SIZELIMIT=$FULL_SIZE."
        if [ $mult != 100 ]; then
            echo "  INFO: Reserving "$((100-$mult))"% of the CD for extra metadata"
            FULL_SIZE=`echo "$FULL_SIZE * $mult" / 100 | bc`
            echo "  INFO: SIZELIMIT now $FULL_SIZE."
        fi
        SIZE_ARGS="$SIZE_ARGS SIZELIMIT${CD}=$FULL_SIZE"
	done
    FULL_SIZE=`echo "($DEFSRCSIZE - $size) * 1024 * 1024" | bc`
	echo " ... building the images"
	if [ "$FULLARCH" = "i386" ] && \
	   ([ "$CDIMAGE_INSTALL" = 1 ] || [ "$CDIMAGE_ONLYSOURCE" = 1 ]) && \
	   [ "$CDIMAGE_DVD" != 1 ] && [ "$DIST" != warty ] && \
	   [ "$SPECIAL" != 1 ] && [ "$CDIMAGE_NOSOURCE" != 1 ]; then
		if [ "$CDIMAGE_ONLYSOURCE" != 1 ]; then
			make list $SIZE_ARGS SRCSIZELIMIT=$FULL_SIZE

			export OUT="$TMP_OUT/$FULLARCH"; mkdir -p $OUT
			make bin-official_images $SIZE_ARGS SRCSIZELIMIT=$FULL_SIZE
			echo Generating MD5Sums of the images
			make imagesums
			echo Generating list files for images
			make pi-makelist
		else
			make src-list SRCSIZELIMIT=$FULL_SIZE
		fi

		export OUT="$TMP_OUT/src"; mkdir -p $OUT
		make src-official_images $SIZE_ARGS SRCSIZELIMIT=$FULL_SIZE
		echo Generating MD5Sums of the images
		make imagesums
		echo Generating list files for images
		make pi-makelist
	elif [ "$CDIMAGE_PREINSTALLED" = 1 ]; then
		export OUT="$TMP_OUT/$FULLARCH"; mkdir -p $OUT
		make bin-preinstalled_images

		echo Generating MD5Sums of the images
		make imagesums
	else
		make bin-list $SIZE_ARGS SRCSIZELIMIT=$FULL_SIZE
		export OUT=$TMP_OUT/$FULLARCH; mkdir -p $OUT
		make bin-official_images $SIZE_ARGS SRCSIZELIMIT=$FULL_SIZE
		if [ $? -gt 0 ]; then
			echo "ERROR WHILE BUILDING OFFICIAL IMAGES !!" >&2
			if [ "$ATTEMPT_FALLBACK" = "yes" ]; then
				echo "I'll try to build a simple (non-bootable) CD" >&2
				make clean
				make installtools
				make bin-images $SIZE_ARGS SRCSIZELIMIT=$FULL_SIZE
			else
				# exit 1
				continue
			fi
		fi
		echo Generating MD5Sums of the images
		make imagesums
		echo Generating list files for images
		make pi-makelist
	fi
	if [ "$CDIMAGE_COMPRESS" = 1 ]; then
		echo Compressing CD images
		make bin-compress_images
	fi
	echo "--------------- `date` ---------------"
done