summaryrefslogtreecommitdiff
path: root/helpers/lh_binary_debian-installer
blob: 99227c06fe25e9041c5be7aab4c6de33acd4109a (plain)
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
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
#!/bin/sh

# lh_binary_debian-installer(1) - install debian-installer into binary
# Copyright (C) 2006-2007 Daniel Baumann <daniel@debian.org>
#
# live-helper comes with ABSOLUTELY NO WARRANTY; for details see COPYING.
# This is free software, and you are welcome to redistribute it
# under certain conditions; see COPYING for details.

set -e

# Including common functions
LH_BASE="${LH_BASE:-/usr/share/live-helper}"

for FUNCTION in "${LH_BASE}"/functions/*.sh
do
	. "${FUNCTION}"
done

# Setting static variables
DESCRIPTION="install debian-installer into binary"
HELP=""
USAGE="${PROGRAM} [--force]"

Arguments "${@}"

# Reading configuration files
Read_conffile config/common
Read_conffile config/bootstrap
Read_conffile config/chroot
Read_conffile config/binary
Read_conffile config/source
Set_defaults

if [ "${LIVE_DEBIAN_INSTALLER}" != "enabled" ]
then
	exit 0
fi

Echo_message "Begin installing debian-installer..."

# Requiring stage file
Require_stagefile .stage/bootstrap

# Checking stage file
Check_stagefile .stage/binary_debian-installer

# Checking lock file
Check_lockfile .lock

# Creating lock file
Create_lockfile .lock

# Setting destination directory
case "${LIVE_BINARY_IMAGES}" in
	iso)
		DESTDIR="binary/install"
		DESTDIR_INSTALLER="cdrom"
		;;

	net)
		DESTDIR="tftpboot"
		DESTDIR_INSTALLER="netboot"

		Echo_error "Not supported yet (FIXME)"
		exit 1
		;;

	usb-hdd|hdd)
		# Workaround for syslinux (<< 3.36) which doesn't support long file/path names
		if [ "${LIVE_DISTRIBUTION}" = "etch" ] || [ "${LIVE_DISTRIBUTION}" = "lenny" ]
		then
			if [ "${LIVE_BOOTLOADER}" = "syslinux" ]
			then
				DESTDIR="binary"
			else
				DESTDIR="binary/install"
			fi
		else
			DESTDIR="binary/install"
		fi

		DESTDIR_INSTALLER="hd-media"
		;;
esac

# Temporary check for broken syslinux
if [ "${LIVE_BINARY_IMAGES}" = "iso" ]
then
	# Assemble multi-arch
	if [ -n "${MULTIARCH}" ]
	then
		case "${LIVE_ARCHITECTURE}" in
			amd64)
				DESTDIR="${DESTDIR}.amd"
				;;

			i386)
				DESTDIR="${DESTDIR}.386"
				;;

			powerpc)
				DESTDIR="${DESTDIR}.ppc"
				;;
		esac
	fi
fi

# Downloading debian-installer
mkdir -p "${DESTDIR}"

# Workaround for syslinux (<< 3.36) which doesn't support long file/path names
if [ "${LIVE_DISTRIBUTION}" = "etch" ] || [ "${LIVE_DISTRIBUTION}" = "lenny" ]
then
	if [ "${LIVE_BINARY_IMAGES}" = "usb-hdd" ] || [ "${LIVE_BINARY_IMAGES}" = "hdd" ]
	then
		if [ "${LIVE_BOOTLOADER}" = "syslinux" ]
		then
			wget --no-clobber -O "${DESTDIR}"/vmlinuz.di "${LIVE_MIRROR_BOOTSTRAP}"/dists/"${LIVE_DISTRIBUTION}"/main/installer-"${LIVE_ARCHITECTURE}"/current/images/"${DESTDIR_INSTALLER}"/vmlinuz
			wget --no-clobber -O "${DESTDIR}"/initrddi.gz "${LIVE_MIRROR_BOOTSTRAP}"/dists/"${LIVE_DISTRIBUTION}"/main/installer-"${LIVE_ARCHITECTURE}"/current/images/"${DESTDIR_INSTALLER}"/initrd.gz
		else
			wget --no-clobber -O "${DESTDIR}"/vmlinuz "${LIVE_MIRROR_BOOTSTRAP}"/dists/"${LIVE_DISTRIBUTION}"/main/installer-"${LIVE_ARCHITECTURE}"/current/images/"${DESTDIR_INSTALLER}"/vmlinuz
			wget --no-clobber -O "${DESTDIR}"/initrd.gz "${LIVE_MIRROR_BOOTSTRAP}"/dists/"${LIVE_DISTRIBUTION}"/main/installer-"${LIVE_ARCHITECTURE}"/current/images/"${DESTDIR_INSTALLER}"/initrd.gz
		fi
	else
		wget --no-clobber -O "${DESTDIR}"/vmlinuz "${LIVE_MIRROR_BOOTSTRAP}"/dists/"${LIVE_DISTRIBUTION}"/main/installer-"${LIVE_ARCHITECTURE}"/current/images/"${DESTDIR_INSTALLER}"/vmlinuz
		wget --no-clobber -O "${DESTDIR}"/initrd.gz "${LIVE_MIRROR_BOOTSTRAP}"/dists/"${LIVE_DISTRIBUTION}"/main/installer-"${LIVE_ARCHITECTURE}"/current/images/"${DESTDIR_INSTALLER}"/initrd.gz
	fi
else
	wget --no-clobber -O "${DESTDIR}"/vmlinuz "${LIVE_MIRROR_BOOTSTRAP}"/dists/"${LIVE_DISTRIBUTION}"/main/installer-"${LIVE_ARCHITECTURE}"/current/images/"${DESTDIR_INSTALLER}"/vmlinuz
	wget --no-clobber -O "${DESTDIR}"/initrd.gz "${LIVE_MIRROR_BOOTSTRAP}"/dists/"${LIVE_DISTRIBUTION}"/main/installer-"${LIVE_ARCHITECTURE}"/current/images/"${DESTDIR_INSTALLER}"/initrd.gz
fi

# Downloading graphical-installer
if [ "${LIVE_ARCHITECTURE}" = "amd64" ] || [ "${LIVE_ARCHITECTURE}" = "i386" ] || [ "${LIVE_ARCHITECTURE}" = "powerpc" ]
then
	# Workaround for syslinux (<< 3.36) which doesn't support long file/path names
	if [ "${LIVE_DISTRIBUTION}" = "etch" ] || [ "${LIVE_DISTRIBUTION}" = "lenny" ]
	then
		if [ "${LIVE_BINARY_IMAGES}" = "usb-hdd" ] || [ "${LIVE_BINARY_IMAGES}" = "hdd" ]
		then
			if [ "${LIVE_BOOTLOADER}" = "syslinux" ]
			then
				wget --no-clobber -O "${DESTDIR}"/vmlinuz.gi "${LIVE_MIRROR_BOOTSTRAP}"/dists/"${LIVE_DISTRIBUTION}"/main/installer-"${LIVE_ARCHITECTURE}"/current/images/"${DESTDIR_INSTALLER}"/gtk/vmlinuz
				wget --no-clobber -O "${DESTDIR}"/initrdgi.gz "${LIVE_MIRROR_BOOTSTRAP}"/dists/"${LIVE_DISTRIBUTION}"/main/installer-"${LIVE_ARCHITECTURE}"/current/images/"${DESTDIR_INSTALLER}"/gtk/initrd.gz
			else
				mkdir -p "${DESTDIR}"/gtk

				wget --no-clobber -O "${DESTDIR}"/gtk/vmlinuz "${LIVE_MIRROR_BOOTSTRAP}"/dists/"${LIVE_DISTRIBUTION}"/main/installer-"${LIVE_ARCHITECTURE}"/current/images/"${DESTDIR_INSTALLER}"/gtk/vmlinuz
				wget --no-clobber -O "${DESTDIR}"/gtk/initrd.gz "${LIVE_MIRROR_BOOTSTRAP}"/dists/"${LIVE_DISTRIBUTION}"/main/installer-"${LIVE_ARCHITECTURE}"/current/images/"${DESTDIR_INSTALLER}"/gtk/initrd.gz
			fi
		else
			mkdir -p "${DESTDIR}"/gtk

			wget --no-clobber -O "${DESTDIR}"/gtk/vmlinuz "${LIVE_MIRROR_BOOTSTRAP}"/dists/"${LIVE_DISTRIBUTION}"/main/installer-"${LIVE_ARCHITECTURE}"/current/images/"${DESTDIR_INSTALLER}"/gtk/vmlinuz
			wget --no-clobber -O "${DESTDIR}"/gtk/initrd.gz "${LIVE_MIRROR_BOOTSTRAP}"/dists/"${LIVE_DISTRIBUTION}"/main/installer-"${LIVE_ARCHITECTURE}"/current/images/"${DESTDIR_INSTALLER}"/gtk/initrd.gz
		fi
	else
		mkdir -p "${DESTDIR}"/gtk

		wget --no-clobber -O "${DESTDIR}"/gtk/vmlinuz "${LIVE_MIRROR_BOOTSTRAP}"/dists/"${LIVE_DISTRIBUTION}"/main/installer-"${LIVE_ARCHITECTURE}"/current/images/"${DESTDIR_INSTALLER}"/gtk/vmlinuz
		wget --no-clobber -O "${DESTDIR}"/gtk/initrd.gz "${LIVE_MIRROR_BOOTSTRAP}"/dists/"${LIVE_DISTRIBUTION}"/main/installer-"${LIVE_ARCHITECTURE}"/current/images/"${DESTDIR_INSTALLER}"/gtk/initrd.gz
	fi
fi

FIXME ()
{
# Downloading udebs
mkdir -p binary/dists/"${LIVE_DISTRIBUTION}"/main/debian-installer/binary-"${LIVE_ARCHITECTURE}"
cd binary/dists/"${LIVE_DISTRIBUTION}"/main/debian-installer/binary-"${LIVE_ARCHITECTURE}"
wget "${LIVE_MIRROR_BOOTSTRAP}"/dists/"${LIVE_DISTRIBUTION}"/main/debian-installer/binary-"${LIVE_ARCHITECTURE}"/Packages.gz
gunzip -c Packages.gz > Packages
cd "${OLDPWD}"

for DISTRIBUTION in frozen stable testing unstable
do
	ln -s ${LIVE_DISTRIBUTION} binary/dists/${DISTRIBUTION}
done

DEBS="`awk '/Filename: / { print $2 }' binary/dists/${LIVE_DISTRIBUTION}/main/debian-installer/binary-${LIVE_ARCHITECTURE}/Packages`"
UDEBS="`echo ${DEBS} | grep '.*.udeb'`"

rm -f packages.di

for UDEB in ${UDEBS}
do
	mkdir -p binary/`dirname ${UDEB}`
	cd binary/`dirname ${UDEB}`
	wget "${LIVE_MIRROR_BOOTSTRAP}"/${UDEB}
	cd "${OLDPWD}"
done

# Downloading debs
if [ -d cache/packages_bootstrap ]
then
	for FILE in cache/packages_bootstrap/*.deb
	do
		SOURCE="`dpkg -f ${FILE} Source`"

		if [ -z "${SOURCE}" ]
		then
			SOURCE="`basename ${FILE} | awk -F_ '{ print $1 }'`"
		fi

		case "${SOURCE}" in
			lib?*)
				LETTER="`echo ${SOURCE} | sed 's/\(....\).*/\1/'`"
				;;

			*)
				LETTER="`echo ${SOURCE} | sed 's/\(.\).*/\1/'`"
				;;
		esac

		# Install directory
		mkdir -p binary/pool/main/"${LETTER}"/"${SOURCE}"

		# Move files
		cp "${FILE}" binary/pool/main/"${LETTER}"/"${SOURCE}"
	done
fi

mkdir -p binary/dists/${LIVE_DISTRIBUTION}/main/binary-${LIVE_ARCHITECTURE}

cat > binary/dists/${LIVE_DISTRIBUTION}/main/binary-${LIVE_ARCHITECTURE}/Release << EOF
Archive: ${LIVE_DISTRIBUTION}
Component: main
Origin: Debian
Label: Debian
Architecture: ${LIVE_ARCHITECTURE}
EOF

mkdir -p cache/indices_debian-installer

cat > cache/indices_debian-installer/archive << EOF
Dir
{
	ArchiveDir	"binary";
	// OverrideDir	"";
	// CacheDir	"";
	FileListDir	"cache/indices_debian-installer";
};

Default
{
	Packages::Compress	". gzip";
	// Packages::Extension	".deb";
	// Sources::Extensions	".dsc";
	// Contents::Compress	"gzip";
	// DeLinkLimit		"0";
	// FileMode		"0644";
};

TreeDefault
{
	// MaxContentsChange
	// ContentsAge
	Directory		"dists/\$(DIST)/\$(SECTION)/binary-\$(ARCH)/";
	Packages		"dists/\$(DIST)/\$(SECTION)/binary-\$(ARCH)/Packages";
	InternalPrefix		"dists/\$(DIST)/\$(SECTION)/";
	Contents		"dists/\$(DIST)/Contents-\$(ARCH)";
	// Contents::Header
	// BinCacheDB		"cache.\$(DIST).\$(SECTION).\$(ARCH)";
	// FileList		"filelist.\$(DIST).\$(SECTION).\$(ARCH)";
	FileList		"filelist";
	// BinOverride		"override.\$(DIST).\$(SECTION)";
};

tree "${LIVE_DISTRIBUTION}"
{
	Sections	"main";
	Architectures	"${LIVE_ARCHITECTURE}";
};
EOF

cd binary
find pool -name "*.deb" | sort > ../cache/indices_debian-installer/filelist
cd "${OLDPWD}"

cat > cache/indices_debian-installer/release << EOF
APT::FTPArchive::Release::Origin	"Debian";
APT::FTPArchive::Release::Label		"Debian";
APT::FTPArchive::Release::Suite		"${LIVE_DISTRIBUTION}";
APT::FTPArchive::Release::Version	"4.0";
APT::FTPArchive::Release::Codename	"${LIVE_DISTRIBUTION}";
APT::FTPArchive::Release::Date		"`date -R`";
APT::FTPArchive::Release::Architectures	"${LIVE_ARCHITECTURE}";
APT::FTPArchive::Release::Components	"main";
EOF

apt-ftparchive generate cache/indices_debian-installer/archive
apt-ftparchive -c cache/indices_debian-installer/release -o APT::FTPArchive::Release::Description="Last updated: `date -R`" release binary/dists/${LIVE_DISTRIBUTION} > binary/dists/${LIVE_DISTRIBUTION}/Release
}

mkdir binary/.disk
echo "main" > binary/.disk/base_components
touch binary/.disk/base_installable
echo "not_complete" > binary/.disk/cd_type
#echo "Debian GNU/Linux 4.0 r0 \"Etch\" - Official i386 NETINST Binary-1 20070407-11:29" > binary/.disk/info
echo "Debian GNU/Linux ${LIVE_DISTRIBUTION} - Unofficial ${LIVE_ARCHITECTURE} NETINST Binary-1 `date +%Y%m%d-%H:%M`" > binary/.disk/info
touch binary/.disk/mkisofs

# Creating stage file
Create_stagefile .stage/binary_debian-installer