~asac/live-build/virtual-hdd-mtab-hack

« back to all changes in this revision

Viewing changes to helpers/lh_binary_debian-installer

  • Committer: Daniel Baumann
  • Date: 2009-11-22 13:38:00 UTC
  • Revision ID: git-v1:a62f12110b19a52a58d7eae871012202cfa16055
Renaming categories to archive areas (Closes: #519690).

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
#!/bin/sh
 
2
 
 
3
# lh_binary_debian-installer(1) - install debian-installer into binary
 
4
# Copyright (C) 2006-2009 Daniel Baumann <daniel@debian.org>
 
5
#
 
6
# live-helper comes with ABSOLUTELY NO WARRANTY; for details see COPYING.
 
7
# This is free software, and you are welcome to redistribute it
 
8
# under certain conditions; see COPYING for details.
 
9
 
 
10
set -e
 
11
 
 
12
# Including common functions
 
13
. "${LH_BASE:-/usr/share/live-helper}"/functions.sh
 
14
 
 
15
# Setting static variables
 
16
DESCRIPTION="$(Echo 'install debian-installer into binary')"
 
17
HELP=""
 
18
USAGE="${PROGRAM} [--force]"
 
19
 
 
20
Arguments "${@}"
 
21
 
 
22
# Reading configuration files
 
23
Read_conffiles config/all config/common config/bootstrap config/chroot config/binary config/source
 
24
Set_defaults
 
25
 
 
26
if [ "${LH_BINARY_IMAGES}" = "virtual-hdd" ]
 
27
then
 
28
        exit 0
 
29
fi
 
30
 
 
31
if [ "${_DEBUG}" = "enabled" ]
 
32
then
 
33
        WGET_OPTIONS="${WGET_OPTIONS} --verbose"
 
34
elif [ "${_QUIET}" = "enabled" ]
 
35
then
 
36
        WGET_OPTIONS="${WGET_OPTIONS} --quiet"
 
37
else
 
38
        WGET_OPTIONS="${WGET_OPTIONS} --no-verbose"
 
39
fi
 
40
 
 
41
# Check d-i configuration
 
42
case "${LH_DEBIAN_INSTALLER}" in
 
43
        enabled|cdrom|netinst|netboot|businesscard|live)
 
44
                ;;
 
45
 
 
46
        disabled)
 
47
                exit 0
 
48
                ;;
 
49
 
 
50
        *)
 
51
                Echo_error "debian-installer flavour %s not supported." "${LH_DEBIAN_INSTALLER}"
 
52
                exit 1
 
53
                ;;
 
54
esac
 
55
 
 
56
Echo_message "Begin installing debian-installer..."
 
57
 
 
58
# Requiring stage file
 
59
Require_stagefile .stage/config .stage/bootstrap
 
60
 
 
61
# Checking stage file
 
62
Check_stagefile .stage/binary_debian-installer
 
63
 
 
64
# Checking lock file
 
65
Check_lockfile .lock
 
66
 
 
67
# Creating lock file
 
68
Create_lockfile .lock
 
69
 
 
70
# Checking depends
 
71
Check_package chroot/usr/bin/wget wget
 
72
Check_package chroot/usr/bin/apt-ftparchive apt-utils
 
73
 
 
74
# Restoring cache
 
75
Restore_cache cache/packages_binary
 
76
 
 
77
# Installing depends
 
78
Install_package
 
79
 
 
80
# Setting destination directory
 
81
case "${LH_BINARY_IMAGES}" in
 
82
        net)
 
83
                DESTDIR="tftpboot/debian-install/${LH_ARCHITECTURE}"
 
84
                ;;
 
85
 
 
86
        tar|usb-hdd)
 
87
                DESTDIR="binary/install"
 
88
 
 
89
                # Workaround for syslinux (<< 3.36) which doesn't support long file/path names
 
90
                if [ "${LH_DEBIAN_INSTALLER_DISTRIBUTION}" = "etch" ] && [ "${LH_BOOTLOADER}" = "syslinux" ]
 
91
                then
 
92
                        DESTDIR="binary"
 
93
                fi
 
94
                ;;
 
95
 
 
96
        *)
 
97
                DESTDIR="binary/install"
 
98
                ;;
 
99
esac
 
100
 
 
101
# Set d-i image type
 
102
case "${LH_DEBIAN_INSTALLER}" in
 
103
        businesscard|netboot|netinst)
 
104
                DI_IMAGE_TYPE="netboot"
 
105
                ;;
 
106
        *)
 
107
                case "${LH_BINARY_IMAGES}" in
 
108
                        net)
 
109
                                DI_IMAGE_TYPE="netboot"
 
110
                                ;;
 
111
 
 
112
                        *)
 
113
                                DI_IMAGE_TYPE="cdrom"
 
114
                                ;;
 
115
                esac
 
116
                ;;
 
117
esac
 
118
 
 
119
# Set architecture-specific variables
 
120
case "${LH_ARCHITECTURE}" in
 
121
        powerpc)
 
122
                case "${DI_IMAGE_TYPE}" in
 
123
                        cdrom)
 
124
                                DI_REMOTE_BASE="${LH_ARCHITECTURE}/cdrom"
 
125
                        ;;
 
126
 
 
127
                        netboot)
 
128
                                DI_REMOTE_BASE="${LH_ARCHITECTURE}/netboot"
 
129
                                ;;
 
130
                esac
 
131
 
 
132
                DI_REMOTE_KERNEL="vmlinux"
 
133
                DI_REMOTE_BASE_GTK="${DI_REMOTE_BASE}/gtk"
 
134
                ;;
 
135
 
 
136
        sparc)
 
137
                DEFAULT_FLAVOUR="$(echo ${LH_LINUX_FLAVOURS} | awk '{ print $1 }')"
 
138
                DI_REMOTE_KERNEL="$(basename chroot/boot/vmlinuz-*${DEFAULT_FLAVOUR})"
 
139
                DI_REMOTE_BASE_GTK="none"
 
140
 
 
141
                if [ "${LH_DEBIAN_INSTALLER_DISTRIBUTION}" = "etch" ]
 
142
                then
 
143
                        DI_REMOTE_BASE="cdrom/2.6"
 
144
                else
 
145
                        DI_REMOTE_BASE="cdrom"
 
146
                fi
 
147
                ;;
 
148
        *)
 
149
                case "${DI_IMAGE_TYPE}" in
 
150
                        netboot)
 
151
                                DI_REMOTE_BASE="netboot/debian-installer/${LH_ARCHITECTURE}"
 
152
                                DI_REMOTE_BASE_GTK="netboot/gtk/debian-installer/${LH_ARCHITECTURE}"
 
153
                                DI_REMOTE_KERNEL="linux"
 
154
                                ;;
 
155
 
 
156
                        cdrom)
 
157
                                DI_REMOTE_BASE="cdrom"
 
158
                                DI_REMOTE_BASE_GTK="cdrom/gtk"
 
159
                                DI_REMOTE_KERNEL="vmlinuz"
 
160
                                ;;
 
161
                esac
 
162
                ;;
 
163
esac
 
164
 
 
165
Check_multiarchitecture
 
166
 
 
167
Install_file() {
 
168
        local FILE
 
169
        FILE="${1}"
 
170
 
 
171
        local TARGET
 
172
        TARGET="${2}"
 
173
 
 
174
        SOURCE="$(dpkg -f ${FILE} Source | awk '{ print $1 }')"
 
175
 
 
176
        if [ -z "${SOURCE}" ]
 
177
        then
 
178
                SOURCE="$(basename ${FILE} | awk -F_ '{ print $1 }')"
 
179
        fi
 
180
 
 
181
        case "${SOURCE}" in
 
182
                lib?*)
 
183
                        LETTER="$(echo ${SOURCE} | sed 's|\(....\).*|\1|')"
 
184
                        ;;
 
185
 
 
186
                *)
 
187
                        LETTER="$(echo ${SOURCE} | sed 's|\(.\).*|\1|')"
 
188
                        ;;
 
189
        esac
 
190
 
 
191
        # Install directory
 
192
        mkdir -p "${TARGET}"/"${LETTER}"/"${SOURCE}"
 
193
 
 
194
        # Move files
 
195
        cp "${FILE}" "${TARGET}"/"${LETTER}"/"${SOURCE}"
 
196
}
 
197
 
 
198
# Set absolute directory for caching; we require it when we call Download_file
 
199
# from a non-standard cwd.
 
200
_LH_CACHE_DIR="$(pwd)/cache/binary_debian-installer"
 
201
 
 
202
Download_file () {
 
203
        local _LH_TARGET
 
204
        _LH_TARGET="${1}"
 
205
 
 
206
        local _LH_URL
 
207
        _LH_URL="${2}"
 
208
 
 
209
        _LH_CACHE_FILE="${_LH_CACHE_DIR}/$(echo "${_LH_URL}" | sed 's|/|_|g')"
 
210
 
 
211
        if [ ! -f "${_LH_CACHE_FILE}" ]
 
212
        then
 
213
                mkdir -p ${_LH_CACHE_DIR}
 
214
                if ! wget ${WGET_OPTIONS} -O "${_LH_CACHE_FILE}" "${_LH_URL}"
 
215
                then
 
216
                        rm -f "${_LH_CACHE_FILE}"
 
217
 
 
218
                        Echo_error "Could not download file: %s" "${_LH_URL}"
 
219
                        exit 1
 
220
                fi
 
221
        fi
 
222
 
 
223
        if [ "$(stat --printf %d "${_LH_CACHE_DIR}")" = "$(stat --printf %d ./)" ]
 
224
        then
 
225
                CP_OPTIONS="-l"
 
226
        fi
 
227
 
 
228
        cp -f ${CP_OPTIONS} -- "${_LH_CACHE_FILE}" "${_LH_TARGET}"
 
229
}
 
230
 
 
231
VMLINUZ_DI="vmlinuz"
 
232
INITRD_DI="initrd.gz"
 
233
DESTDIR_DI="${DESTDIR}"
 
234
 
 
235
VMLINUZ_GI="gtk/vmlinuz"
 
236
INITRD_GI="gtk/initrd.gz"
 
237
DESTDIR_GI="${DESTDIR}/gtk"
 
238
 
 
239
# Workaround for syslinux (<< 3.36) which doesn't support long file/path names
 
240
if [ "${LH_DEBIAN_INSTALLER_DISTRIBUTION}" = "etch" ]
 
241
then
 
242
        case "${LH_BINARY_IMAGES}" in
 
243
                usb-hdd|tar)
 
244
                        VMLINUZ_DI="vmlinuz.di"
 
245
                        INITRD_DI="initrddi.gz"
 
246
                        DESTDIR_DI="${DESTDIR}"
 
247
 
 
248
                        VMLINUZ_GI="vmlinuz.gi"
 
249
                        INITRD_GI="initrdgi.gz"
 
250
                        DESTDIR_GI="${DESTDIR}"
 
251
                        ;;
 
252
        esac
 
253
fi
 
254
 
 
255
if [ "${LH_DEBIAN_INSTALLER_DISTRIBUTION}" = "daily" ]
 
256
then
 
257
        LH_DEBIAN_INSTALLER_DISTRIBUTION="sid"
 
258
 
 
259
        # Debian Installer daily builds
 
260
        case "${LH_ARCHITECTURE}" in
 
261
                alpha|amd64|hppa|ia64|mips|mipsel|powerpc)
 
262
                        URL="http://d-i.debian.org/daily-images/${LH_ARCHITECTURE}/daily/"
 
263
                        ;;
 
264
 
 
265
                arm|armel)
 
266
                        URL="http://people.debian.org/~kmuto/d-i/images/daily/"
 
267
                        ;;
 
268
 
 
269
                i386)
 
270
                        URL="http://people.debian.org/~joeyh/d-i/images/daily/"
 
271
                        ;;
 
272
 
 
273
                m68k)
 
274
                        URL="http://people.debian.org/~smarenka/d-i/images-m68k/daily/"
 
275
                        ;;
 
276
 
 
277
                s390)
 
278
                        URL="http://lophos.multibuild.org/d-i/images/daily/"
 
279
                        ;;
 
280
 
 
281
                sparc)
 
282
                        URL="http://people.debian.org/~stappers/d-i/images/daily/"
 
283
                        ;;
 
284
 
 
285
                *)
 
286
                        Echo_error "No daily-builds found for your architecture."
 
287
                        exit 1
 
288
                        ;;
 
289
        esac
 
290
else
 
291
        URL="${LH_MIRROR_CHROOT}/dists/${LH_DEBIAN_INSTALLER_DISTRIBUTION}/main/installer-${LH_ARCHITECTURE}/current/images/"
 
292
fi
 
293
 
 
294
mkdir -p "${DESTDIR_DI}"
 
295
 
 
296
if [ "${LH_ARCHITECTURE}" = "sparc" ] && [ "${DI_IMAGE_TYPE}" = "netboot" ]
 
297
then
 
298
        # There are no prepared kernel/initrd pairs for sparc netboot so we
 
299
        # must unpack them from a mini.iso
 
300
 
 
301
        if [ "${LH_DEBIAN_INSTALLER_DISTRIBUTION}" = "etch" ]
 
302
        then
 
303
                Download_file mini.iso ${URL}/combined/2.6/mini.iso
 
304
        else
 
305
                Download_file mini.iso ${URL}/mini.iso
 
306
        fi
 
307
 
 
308
        mkdir mini.tmp
 
309
        ${LH_ROOT_COMMAND} mount -o loop -t iso9660 mini.iso mini.tmp
 
310
 
 
311
        cp mini.tmp/boot/vmlinuz-${DEFAULT_FLAVOUR} "${DESTDIR}"/"${VMLINUZ_DI}"
 
312
        cp mini.tmp/boot/initrd.gz "${DESTDIR}"/"${INITRD_DI}"
 
313
 
 
314
        ${LH_ROOT_COMMAND} umount mini.tmp
 
315
        rm -rf mini.tmp mini.iso
 
316
else
 
317
        # Downloading debian-installer
 
318
        Download_file "${DESTDIR}"/"${VMLINUZ_DI}" ${URL}/${DI_REMOTE_BASE}/${DI_REMOTE_KERNEL}
 
319
        Download_file "${DESTDIR}"/"${INITRD_DI}" ${URL}/${DI_REMOTE_BASE}/initrd.gz
 
320
 
 
321
        # Downloading graphical-installer
 
322
        DOWNLOAD_GTK_INSTALLER=0
 
323
        if [ "${LH_DEBIAN_INSTALLER_GUI}" = "enabled" ]
 
324
        then
 
325
                case "${LH_ARCHITECTURE}" in
 
326
                        amd64|i386|lpia)
 
327
                                DOWNLOAD_GTK_INSTALLER=1
 
328
                                ;;
 
329
 
 
330
                        powerpc)
 
331
                                if [ "${LH_DEBIAN_INSTALLER}" = "netboot" ]
 
332
                                then
 
333
                                        DOWNLOAD_GTK_INSTALLER=1
 
334
                                fi
 
335
                                ;;
 
336
                esac
 
337
        fi
 
338
 
 
339
        if [ ${DOWNLOAD_GTK_INSTALLER} -eq 1 ]
 
340
        then
 
341
                mkdir -p "${DESTDIR_GI}"
 
342
                Download_file "${DESTDIR}"/"${VMLINUZ_GI}" ${URL}/${DI_REMOTE_BASE_GTK}/${DI_REMOTE_KERNEL}
 
343
                Download_file "${DESTDIR}"/"${INITRD_GI}" ${URL}/${DI_REMOTE_BASE_GTK}/initrd.gz
 
344
        fi
 
345
fi
 
346
 
 
347
# Only download additional packages if appropriate
 
348
if [ "${DI_IMAGE_TYPE}" != "netboot" ]
 
349
then
 
350
        # Downloading additional packages
 
351
        mkdir -p chroot/binary.deb/archives/partial
 
352
        mkdir -p binary/pool/main
 
353
        mv chroot/var/lib/dpkg/status chroot/var/lib/dpkg/status.tmp
 
354
        touch chroot/var/lib/dpkg/status
 
355
 
 
356
        case "${LH_ARCHITECTURE}" in
 
357
                amd64)
 
358
                        DI_REQ_PACKAGES="lilo grub"
 
359
                        DI_PACKAGES="${DI_REQ_PACKAGES} linux-image-2.6-amd64"
 
360
                        ;;
 
361
 
 
362
                i386|lpia)
 
363
                        DI_REQ_PACKAGES="elilo lilo grub"
 
364
                        DI_PACKAGES="${DI_REQ_PACKAGES} linux-image-2.6-486 linux-image-2.6-686"
 
365
                        ;;
 
366
 
 
367
                sparc)
 
368
                        DI_REQ_PACKAGES="silo"
 
369
                        DI_PACKAGES="${DI_REQ_PACKAGES} linux-image-2.6-sparc64 linux-image-2.6-sparc64-smp"
 
370
 
 
371
                        if [ "${LH_DEBIAN_INSTALLER_DISTRIBUTION}" = "etch" ]
 
372
                        then
 
373
                                DI_PACKAGES="${DI_PACKAGES} linux-image-2.6-sparc32"
 
374
                        fi
 
375
                        ;;
 
376
 
 
377
                powerpc)
 
378
                        DI_REQ_PACKAGES="yaboot"
 
379
                        DI_PACKAGES="${DI_REQ_PACKAGES} linux-image-2.6-powerpc linux-image-2.6-powerpc64 linux-image-2.6-powerpc-smp"
 
380
 
 
381
                        if [ "${LH_DEBIAN_INSTALLER_DISTRIBUTION}" = "etch" ]
 
382
                        then
 
383
                                DI_PACKAGES="${DI_PACKAGES} linux-image-2.6-prep"
 
384
                        fi
 
385
                        ;;
 
386
        esac
 
387
 
 
388
        DI_PACKAGES="${DI_PACKAGES} busybox cryptsetup lvm2"
 
389
 
 
390
        # Set apt command prefix
 
391
        _LH_APT_COMMAND="apt-get ${APT_OPTIONS} -o Dir::Cache=/binary.deb -o APT::Install-Recommends=false --download-only"
 
392
 
 
393
        if [ "${LH_DEBIAN_INSTALLER}" = "live" ]
 
394
        then
 
395
                # We don't want to duplicate .debs of packages in binary/pool that are already
 
396
                # installed to target/ via live-installer.
 
397
                #
 
398
                # However, we need to force various packages' inclusion in binary/pool/main as
 
399
                # d-i does not support (for example) re-installing grub from target/ - the grub
 
400
                # .debs must actually exist.
 
401
 
 
402
                # Modify dpkg status to show the required packages are not installed.
 
403
                cp chroot/var/lib/dpkg/status.tmp chroot/var/lib/dpkg/status
 
404
                for PACKAGE in ${DI_REQ_PACKAGES}
 
405
                do
 
406
                        awk -v f=0 '
 
407
                                f == 1 { print "Status: purge ok not-installed"; f=0; next }
 
408
                                /Package: '"${PACKAGE}"'/ { f=1; }
 
409
                                { print }
 
410
                                ' chroot/var/lib/dpkg/status > chroot/var/lib/dpkg/status.awk
 
411
                        mv chroot/var/lib/dpkg/status.awk chroot/var/lib/dpkg/status
 
412
                done
 
413
 
 
414
                # Download .deb's that we just marked as "purged" which caused broken dependencies
 
415
                Chroot chroot ${_LH_APT_COMMAND} -f dist-upgrade
 
416
 
 
417
                # Revert dpkg status file
 
418
                mv chroot/var/lib/dpkg/status.tmp chroot/var/lib/dpkg/status
 
419
 
 
420
                # Download .debs of the required packages
 
421
                Chroot chroot ${_LH_APT_COMMAND} install ${DI_REQ_PACKAGES}
 
422
        else
 
423
                # Download .debs of the required packages
 
424
                Chroot chroot ${_LH_APT_COMMAND} install ${DI_PACKAGES}
 
425
 
 
426
                # Revert dpkg status file
 
427
                mv chroot/var/lib/dpkg/status.tmp chroot/var/lib/dpkg/status
 
428
        fi
 
429
 
 
430
        mv chroot/binary.deb ./
 
431
 
 
432
        if Find_files binary.deb/archives/*.deb
 
433
        then
 
434
                for FILE in binary.deb/archives/*.deb
 
435
                do
 
436
                        Install_file "${FILE}" "binary/pool/main"
 
437
                done
 
438
        fi
 
439
 
 
440
        if [ "${LH_DEBIAN_INSTALLER}" != "live" ]
 
441
        then
 
442
                # Including base debian packages
 
443
                if [ -d cache/packages_bootstrap ]
 
444
                then
 
445
                        for FILE in cache/packages_bootstrap/*.deb
 
446
                        do
 
447
                                Install_file "${FILE}" "binary/pool/main"
 
448
                        done
 
449
                else
 
450
                        Echo_error "Could not find cache/packages_bootstrap."
 
451
                        Echo_error "You selected values of LH_CACHE, LH_CACHE_PACKAGES, LH_CACHE_STAGES and LH_DEBIAN_INSTALLER which will result in 'bootstrap' packages not being cached - these are required when integrating the Debian Installer."
 
452
                        exit 1
 
453
                fi
 
454
        fi
 
455
 
 
456
        # Including local debs
 
457
        if Find_files config/binary_local-debs/*_"${LH_ARCHITECTURE}".deb
 
458
        then
 
459
                for FILE in config/binary_local-debs/*_"${LH_ARCHITECTURE}".deb
 
460
                do
 
461
                        Install_file "${FILE}" "binary/pool/main"
 
462
                done
 
463
        fi
 
464
 
 
465
        if Find_files config/binary_local-debs/*_all.deb
 
466
        then
 
467
                for FILE in config/binary_local-debs/*_all.deb
 
468
                do
 
469
                        Install_file "${FILE}" "binary/pool/main"
 
470
                done
 
471
        fi
 
472
 
 
473
        # Generating deb indices
 
474
        mkdir -p binary/dists/${LH_DEBIAN_INSTALLER_DISTRIBUTION}/main/binary-${LH_ARCHITECTURE}
 
475
 
 
476
        mv binary chroot/root
 
477
        echo "cd /root/binary && apt-ftparchive packages pool/main > dists/${LH_DEBIAN_INSTALLER_DISTRIBUTION}/main/binary-${LH_ARCHITECTURE}/Packages" > chroot/binary.sh
 
478
        Chroot chroot "sh binary.sh"
 
479
        rm -f chroot/binary.sh
 
480
        mv chroot/root/binary ./
 
481
 
 
482
        gzip -9 -c binary/dists/${LH_DEBIAN_INSTALLER_DISTRIBUTION}/main/binary-${LH_ARCHITECTURE}/Packages > binary/dists/${LH_DEBIAN_INSTALLER_DISTRIBUTION}/main/binary-${LH_ARCHITECTURE}/Packages.gz
 
483
 
 
484
        # Fetching release
 
485
        Download_file binary/dists/${LH_DEBIAN_INSTALLER_DISTRIBUTION}/main/binary-${LH_ARCHITECTURE}/Release "${LH_MIRROR_CHROOT}"/dists/"${LH_DEBIAN_INSTALLER_DISTRIBUTION}"/main/binary-"${LH_ARCHITECTURE}"/Release
 
486
 
 
487
        mkdir binary.udeb
 
488
        cd binary.udeb
 
489
 
 
490
        # Downloading udeb indices
 
491
        Download_file Packages.gz "${LH_MIRROR_CHROOT}"/dists/"${LH_DEBIAN_INSTALLER_DISTRIBUTION}"/main/debian-installer/binary-"${LH_ARCHITECTURE}"/Packages.gz
 
492
        gunzip -c Packages.gz > Packages
 
493
 
 
494
        # Sorting udebs
 
495
        UDEBS="$(awk '/Filename: / { print $2 }' Packages)"
 
496
 
 
497
        # Downloading udebs
 
498
        for UDEB in ${UDEBS}
 
499
        do
 
500
                if [ -f ../cache/packages_debian-installer.udeb/"$(basename ${UDEB})" ]
 
501
                then
 
502
                        # Copying cached udebs
 
503
                        cp ../cache/packages_debian-installer.udeb/"$(basename ${UDEB})" ./
 
504
                else
 
505
                        # Downloading udebs
 
506
                        wget ${WGET_OPTIONS} "${LH_MIRROR_CHROOT}"/${UDEB}
 
507
                fi
 
508
        done
 
509
 
 
510
        # Caching udebs
 
511
        rm -rf ../cache/packages_debian-installer.udeb
 
512
        mkdir -p ../cache/packages_debian-installer.udeb
 
513
        cp *.udeb ../cache/packages_debian-installer.udeb
 
514
 
 
515
        # Including local udebs
 
516
        if Find_files ../config/binary_local-udebs/*_"${LH_ARCHITECTURE}".udeb
 
517
        then
 
518
                for FILE in ../config/binary_local-udebs/*_"${LH_ARCHITECTURE}".udeb
 
519
                do
 
520
                        Install_file "${FILE}" "pool/main"
 
521
 
 
522
                        # Prefer local udebs over downloaded udebs
 
523
                        rm -f "$(basename ${FILE} | awk -F_ '{ print $1 }')"_*.udeb
 
524
                done
 
525
        fi
 
526
 
 
527
        if Find_files ../config/binary_local-udebs/*_all.udeb
 
528
        then
 
529
                for FILE in ../config/binary_local-udebs/*_all.udeb
 
530
                do
 
531
                        Install_file "${FILE}" "pool/main"
 
532
 
 
533
                        # Prefer local udebs over downloaded udebs
 
534
                        rm -f "$(basename ${FILE} | awk -F_ '{ print $1 }')"_*.udeb
 
535
                done
 
536
        fi
 
537
 
 
538
        # Excluding udebs
 
539
        grep -v "^#" "${LH_BASE}"/data/debian-cd/"${LH_DEBIAN_INSTALLER_DISTRIBUTION}"/udeb_exclude > exclude || true
 
540
        grep -v "^#" "${LH_BASE}"/data/debian-cd/"${LH_DEBIAN_INSTALLER_DISTRIBUTION}"/exclude-udebs >> exclude || true
 
541
        grep -v "^#" "${LH_BASE}"/data/debian-cd/"${LH_DEBIAN_INSTALLER_DISTRIBUTION}"/exclude-udebs-${LH_ARCHITECTURE} >> exclude || true
 
542
 
 
543
        # Local exclude file
 
544
        if [ -e ../config/binary_debian-installer/udeb_exclude ]
 
545
        then
 
546
                cat ../config/binary_debian-installer/udeb_exclude >> exclude
 
547
        fi
 
548
 
 
549
        # Excluding udebs from excludes because we want them to be in the image on purpose
 
550
        sed -i -e 's|di-utils-exit-installer||' exclude # used for live-installer-launcher
 
551
 
 
552
        while read EXCLUDE
 
553
        do
 
554
                if [ "${LH_DEBIAN_INSTALLER}" = "live" ] && [ "${EXCLUDE}" = "live-installer" ]
 
555
                then
 
556
                        continue
 
557
                fi
 
558
 
 
559
                rm -f ${EXCLUDE}_*.udeb
 
560
        done < exclude
 
561
 
 
562
        # Enable live-installer
 
563
        if [ "${LH_DEBIAN_INSTALLER}" = "live" ] && [ "${LH_DEBIAN_INSTALLER_DISTRIBUTION}" != "etch" ]
 
564
        then
 
565
                # Remove local udebs
 
566
                rm -f pool/main/b/base-installer/bootstrap-base_*.udeb
 
567
 
 
568
                # Remove d-i udebs
 
569
                rm -f bootstrap-base_*.udeb
 
570
        fi
 
571
 
 
572
        # Moving udebs
 
573
        for UDEB in ${UDEBS}
 
574
        do
 
575
                if [ -f "$(basename ${UDEB})" ]
 
576
                then
 
577
                        mkdir -p $(dirname ${UDEB})
 
578
                        mv "$(basename ${UDEB})" "$(dirname ${UDEB})"
 
579
                fi
 
580
        done
 
581
 
 
582
        # Creating udeb indices
 
583
        mkdir -p dists/"${LH_DEBIAN_INSTALLER_DISTRIBUTION}"/main/debian-installer/binary-"${LH_ARCHITECTURE}"
 
584
        cd "${OLDPWD}"
 
585
 
 
586
        mv binary.udeb chroot/root
 
587
        echo "cd /root/binary.udeb && apt-ftparchive packages pool/main > dists/${LH_DEBIAN_INSTALLER_DISTRIBUTION}/main/debian-installer/binary-${LH_ARCHITECTURE}/Packages" > chroot/binary.sh
 
588
        Chroot chroot "sh binary.sh"
 
589
        rm -f chroot/binary.sh
 
590
        mv chroot/root/binary.udeb ./
 
591
 
 
592
        cd binary.udeb
 
593
        gzip -9 -c dists/${LH_DEBIAN_INSTALLER_DISTRIBUTION}/main/debian-installer/binary-${LH_ARCHITECTURE}/Packages > dists/${LH_DEBIAN_INSTALLER_DISTRIBUTION}/main/debian-installer/binary-${LH_ARCHITECTURE}/Packages.gz
 
594
 
 
595
        rm -f Packages* exclude
 
596
        find . | cpio -dmpu "${OLDPWD}"/binary
 
597
        cd "${OLDPWD}"
 
598
 
 
599
        rm -rf binary.udeb
 
600
        rm -rf binary.deb
 
601
 
 
602
        # Generating release file
 
603
        mv binary chroot/root
 
604
 
 
605
cat > chroot/binary.sh << EOF
 
606
cd /root/binary && apt-ftparchive \
 
607
        -o APT::FTPArchive::Release::Origin="Debian" \
 
608
        -o APT::FTPArchive::Release::Label="Debian" \
 
609
        -o APT::FTPArchive::Release::Suite="${LH_DEBIAN_INSTALLER_DISTRIBUTION}" \
 
610
        -o APT::FTPArchive::Release::Version="4.0" \
 
611
        -o APT::FTPArchive::Release::Codename="${LH_DEBIAN_INSTALLER_DISTRIBUTION}" \
 
612
        -o APT::FTPArchive::Release::Date="$(date -R)" \
 
613
        -o APT::FTPArchive::Release::Architectures="${LH_ARCHITECTURE}" \
 
614
        -o APT::FTPArchive::Release::Components="main" \
 
615
        -o APT::FTPArchive::Release::Description="Last updated: $(date -R)" \
 
616
        release dists/${LH_DEBIAN_INSTALLER_DISTRIBUTION} > dists/${LH_DEBIAN_INSTALLER_DISTRIBUTION}/Release
 
617
EOF
 
618
 
 
619
        Chroot chroot "sh binary.sh"
 
620
        rm -f chroot/binary.sh
 
621
        mv chroot/root/binary ./
 
622
 
 
623
        # Creating dist symlinks
 
624
        for DISTRIBUTION in frozen stable testing unstable
 
625
        do
 
626
                ln -s ${LH_DEBIAN_INSTALLER_DISTRIBUTION} binary/dists/${DISTRIBUTION}
 
627
        done
 
628
 
 
629
        if [ "${LH_BINARY_IMAGES}" != "usb-hdd" ]
 
630
        then
 
631
                ln -s . binary/debian
 
632
        fi
 
633
 
 
634
        # Including preseeding files
 
635
        if Find_files config/binary_debian-installer/*.cfg
 
636
        then
 
637
                cp config/binary_debian-installer/*.cfg binary/install
 
638
        fi
 
639
fi
 
640
 
 
641
Repack_initrd()
 
642
{
 
643
        local TARGET_INITRD
 
644
        local INCLUDE_PATH
 
645
        TARGET_INITRD="${1}"
 
646
        INCLUDE_PATH="${2}"
 
647
        REPACK_TMPDIR="unpacked-initrd"
 
648
 
 
649
        if [ -d "${INCLUDE_PATH}" ]
 
650
        then
 
651
                INCLUDE_PATH=$(readlink -f ${INCLUDE_PATH})
 
652
        fi
 
653
 
 
654
        # cpio does not have a "extract to directory", so we must change directory
 
655
        mkdir -p ${REPACK_TMPDIR}
 
656
        cd ${REPACK_TMPDIR}
 
657
 
 
658
        gzip -d < ../${TARGET_INITRD} | cpio -i --make-directories --no-absolute-filenames
 
659
        if [ ! -d "${INCLUDE_PATH}" ]
 
660
        then
 
661
                # Invoked the old way, just copy the preseeds
 
662
                cp ../config/binary_debian-installer/*.cfg .
 
663
        else
 
664
                # New way, include target directory content in the initrd
 
665
                REPACK_TMPDIR_ABS="${PWD}"
 
666
                cd "${INCLUDE_PATH}"
 
667
                find -print0 | cpio -pumd0 --no-preserve-owner "${REPACK_TMPDIR_ABS}/"
 
668
                cd "${OLDPWD}"
 
669
        fi
 
670
        find -print0 | cpio -H newc -o0 | gzip -9 > ../${TARGET_INITRD}
 
671
 
 
672
        cd ..
 
673
        rm -rf ${REPACK_TMPDIR}
 
674
}
 
675
 
 
676
# Preseed d-i by repacking the initrd in certain situations
 
677
if [ "${DI_IMAGE_TYPE}" = "netboot" ] && [ -e config/binary_debian-installer/preseed.cfg ]
 
678
then
 
679
        Repack_initrd "${DESTDIR}"/"${INITRD_DI}"
 
680
 
 
681
        if [ -e "${DESTDIR}"/"${INITRD_GI}" ]
 
682
        then
 
683
                Repack_initrd "${DESTDIR}"/"${INITRD_GI}"
 
684
        fi
 
685
fi
 
686
 
 
687
# Include content of config/binary_debian-installer-includes if exists and not empty
 
688
if [ -d config/binary_debian-installer-includes ] && [ -n "$(ls -A config/binary_debian-installer-includes)" ]
 
689
then
 
690
        Repack_initrd "${DESTDIR}"/"${INITRD_DI}" config/binary_debian-installer-includes
 
691
 
 
692
        if [ -e "${DESTDIR}"/"${INITRD_GI}" ]
 
693
        then
 
694
                Repack_initrd "${DESTDIR}"/"${INITRD_GI}" config/binary_debian-installer-includes
 
695
        fi
 
696
fi
 
697
 
 
698
# Saving cache
 
699
Save_cache cache/packages_binary
 
700
 
 
701
# Removing depends
 
702
Remove_package
 
703
 
 
704
# Creating stage file
 
705
Create_stagefile .stage/binary_debian-installer