File: get-images.sh

package info (click to toggle)
debian-installer-netboot-images 20150422+deb8u5
  • links: PTS, VCS
  • area: main
  • in suites: jessie
  • size: 56 kB
  • sloc: sh: 111; makefile: 32
file content (162 lines) | stat: -rwxr-xr-x 5,228 bytes parent folder | download
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
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
#!/bin/sh

set -e

# Make sure binNMUs are properly versioned:
if echo "$VERSION" | grep -qs '\+b[0-9][0-9]*$'; then
	echo "E: wrong version detected, please check debian/README to see how binNMUs are versioned"
	exit 1
fi

VERSION=$(echo "$VERSION" | sed 's,\.\(b[0-9][0-9]*\)$,+\1,g')
MAJORVERSION=$(echo "$MAJOR_VERSION")

RELEASE_FILE=$PWD/Release

destdir() {
	ARCHITECTURE=$1
	echo debian/debian-installer-$MAJORVERSION-netboot-$ARCHITECTURE/usr/lib/debian-installer/images/$MAJOR_VERSION
}

get_installer () {
	ARCHITECTURE=$1

	BASEDIR=$MIRROR/dists/$DISTRIBUTION/main/installer-$ARCHITECTURE/$VERSION/images

	DESTDIR=$PWD/$(destdir $ARCHITECTURE)

	SHA256SUM_FILE=$PWD/SHA256SUMS
	MD5SUM_FILE=$PWD/MD5SUMS

	wget -c $BASEDIR/SHA256SUMS -O $SHA256SUM_FILE
	check_file_against_release main/installer-$ARCHITECTURE/$VERSION/images/SHA256SUMS $SHA256SUM_FILE

	wget -c $BASEDIR/MD5SUMS -O $MD5SUM_FILE
	check_file_against_release main/installer-$ARCHITECTURE/$VERSION/images/MD5SUMS $MD5SUM_FILE

	mkdir -p $DESTDIR/$ARCHITECTURE
	BUILD_PWD=$(pwd)
	cd $DESTDIR/$ARCHITECTURE

        NETBOOTDIR_POSTFIX=
	if [ ${ARCHITECTURE:-} = "kfreebsd-amd64" -o ${ARCHITECTURE:-} = "kfreebsd-i386" ]; then
		NETBOOTDIR_POSTFIX=-$KFREEBSD_KERNEL_MAJOR
	fi

	if wget -c $BASEDIR/netboot${NETBOOTDIR_POSTFIX}/netboot.tar.gz -O netboot-text.tar.gz; then
		# Only check the stronger hash
		# check_md5sum_file "./netboot${NETBOOTDIR_POSTFIX}/netboot.tar.gz" netboot-text.tar.gz $MD5SUM_FILE
		check_sha256sum_file "./netboot${NETBOOTDIR_POSTFIX}/netboot.tar.gz" netboot-text.tar.gz $SHA256SUM_FILE
		unpack_installer $ARCHITECTURE/text netboot-text.tar.gz

		if wget -c $BASEDIR/netboot${NETBOOTDIR_POSTFIX}/gtk/netboot.tar.gz -O netboot-gtk.tar.gz; then
			# Only check the stronger hash
			# check_md5sum_file "./netboot${NETBOOTDIR_POSTFIX}/gtk/netboot.tar.gz" netboot-gtk.tar.gz $MD5SUM_FILE
			check_sha256sum_file "./netboot${NETBOOTDIR_POSTFIX}/gtk/netboot.tar.gz" netboot-gtk.tar.gz $SHA256SUM_FILE
			unpack_installer $ARCHITECTURE/gtk netboot-gtk.tar.gz
		else
			rm -f netboot-gtk.tar.gz
		fi
	else
		rm -f netboot-text.tar.gz

		FILES=$(wget $BASEDIR/MANIFEST -O - | awk '/netboot/ { print $1 }' | grep -v mini.iso)

		for FILE in $FILES; do
			mkdir -p $(dirname $FILE | sed -e 's|netboot/||')
			FILENAME=$(echo $FILE | sed -e 's|netboot/||' -e 's|//|/|')
			FILE_CLEAN=$(echo $FILE | sed -e 's|//|/|')
			wget -c $BASEDIR/$FILE_CLEAN -O $FILENAME
			# Only check the stronger hash
			# check_md5sum_file $FILE_CLEAN $FILENAME $MD5SUM_FILE
			check_sha256sum_file ./$FILE_CLEAN $FILENAME $SHA256SUM_FILE
		done

		if [ ${ARCHITECTURE:-} = "armel" ]; then
			rm -Rf $DESTDIR/$ARCHITECTURE/kirkwood/marvell/guruplug
			ln -sf sheevaplug $DESTDIR/$ARCHITECTURE/kirkwood/marvell/guruplug
		fi
	fi
	rm $SHA256SUM_FILE
	rm $MD5SUM_FILE
	cd $BUILD_PWD
}

check_file_against_release() {
	# Only check the stronger hash
	# grep '^ [a-f0-9]\{32\} ' $RELEASE_FILE | sed 's|^ \([a-f0-9]\{32\}\) .* \(.*\)$|\1  ./\2|' > $RELEASE_FILE.md5sums
	# check_md5sum_file ./$1 $(basename $2) $RELEASE_FILE.md5sums

	# Only check the stronger hash
	# grep '^ [a-f0-9]\{40\} ' $RELEASE_FILE | sed 's|^ \([a-f0-9]\{40\}\) .* \(.*\)$|\1  ./\2|' > $RELEASE_FILE.sha1sums
	# check_sha1sum_file ./$1 $(basename $2) $RELEASE_FILE.sha1sums

	# SHA256 _is_ the stronger hash
	grep '^ [a-f0-9]\{64\} ' $RELEASE_FILE | sed 's|^ \([a-f0-9]\{64\}\) .* \(.*\)$|\1  ./\2|' > $RELEASE_FILE.sha256sums
	check_sha256sum_file ./$1 $(basename $2) $RELEASE_FILE.sha256sums
}

check_sha256sum_file () {
	grep " $1$" $3 | sed -e "s| $1| $2|" > $2.sha256sum
	sha256sum -c $2.sha256sum
	rm $2.sha256sum
}

check_sha1sum_file () {
	grep " $1$" $3 | sed -e "s| $1| $2|" > $2.sha1sum
	sha1sum -c $2.sha1sum
	rm $2.sha1sum
}

check_md5sum_file () {
	grep " $1$" $3 | sed -e "s| $1| $2|" > $2.md5sum
	md5sum -c $2.md5sum
	rm $2.md5sum
}

get_di_built_using() {
	ARCHITECTURE=$1
	PACKAGES_FULL_PATH=main/binary-$ARCHITECTURE/Packages.gz
	DI_DEB=debian-installer_${VERSION}_${ARCHITECTURE}.deb

	wget -c $MIRROR/dists/$DISTRIBUTION/$PACKAGES_FULL_PATH -O $ARCHITECTURE.Packages.gz
	check_file_against_release $PACKAGES_FULL_PATH $ARCHITECTURE.Packages.gz

	gunzip -f $ARCHITECTURE.Packages.gz

	wget -c $MIRROR/pool/main/d/debian-installer/${DI_DEB}

	grep-dctrl -P debian-installer -X -s Sha256 $ARCHITECTURE.Packages \
		| sed -e "s/^S.*256: \([a-f0-9]\{64\}\)$/\1  .\/${DI_DEB}/" \
		> ${DI_DEB}.sha256sum

	sha256sum -c ${DI_DEB}.sha256sum
	rm ${DI_DEB}.sha256sum

	dpkg -I ${DI_DEB} | grep '^ Built-Using' \
		| sed -e 's/^ Built-Using: /d-i:built-using=/' \
		>> debian/debian-installer-$MAJORVERSION-netboot-$ARCHITECTURE.substvars
	rm ${DI_DEB}
}

unpack_installer () {
	DIRECTORY=$1
	FILE=$2

	cd ../$(dirname $DIRECTORY)
	mkdir -p $(basename $DIRECTORY)
	tar xfz $FILE -C $(basename $DIRECTORY)
	rm -f $FILE
}

wget -c $MIRROR/dists/$DISTRIBUTION/Release.gpg -O $RELEASE_FILE.gpg
wget -c $MIRROR/dists/$DISTRIBUTION/Release     -O $RELEASE_FILE

if gpgv --keyring /usr/share/keyrings/debian-archive-keyring.gpg $RELEASE_FILE.gpg $RELEASE_FILE ; then
	get_di_built_using $1
	get_installer $1
fi

rm -f *.Packages*
rm $RELEASE_FILE $RELEASE_FILE.gpg
rm -f $RELEASE_FILE.*