~asac/live-build/live-helper.install-kernel-with-no-initramfs

« back to all changes in this revision

Viewing changes to helpers/lh_binary_usb

  • Committer: Daniel Baumann
  • Date: 2007-09-23 08:04:47 UTC
  • Revision ID: git-v1:f4383da69d4642521cb07f8f970d9c9c759b44ee
Tags: 1.0_a2-1
Adding live-helper 1.0~a2-1.

Show diffs side-by-side

added added

removed removed

Lines of Context:
17
17
Set_defaults
18
18
 
19
19
# Requiring stage file
20
 
Require_stagefile "${LIVE_ROOT}"/.stage/bootstrap
 
20
Require_stagefile .stage/bootstrap
 
21
Require_stagefile .stage/chroot_proc
21
22
 
22
23
# Checking lock file
23
 
Check_lockfile "${LIVE_ROOT}"/.lock
 
24
Check_lockfile .lock
24
25
 
25
26
# Creating lock file
26
 
Create_lockfile "${LIVE_ROOT}"/.lock
 
27
Create_lockfile .lock
27
28
 
28
29
# Checking stage file
29
 
Check_stagefile "${LIVE_ROOT}"/.stage/binary_usb
 
30
Check_stagefile .stage/binary_usb
30
31
 
31
32
for IMAGE in ${LIVE_BINARY_IMAGE}
32
33
do
33
34
        if [ "${IMAGE}" = "usb" ]
34
35
        then
35
 
                if [ ! -f "${LIVE_CHROOT}"/sbin/mkdosfs ]
 
36
                if [ ! -f chroot/sbin/mkdosfs ]
36
37
                then
37
38
                        PACKAGES="${PACKAGES} dosfstools"
38
39
                fi
39
40
 
40
 
                if [ ! -f "${LIVE_CHROOT}"/usr/bin/mtools ]
 
41
                if [ ! -f chroot/usr/bin/mtools ]
41
42
                then
42
43
                        PACKAGES="${PACKAGES} mtools"
43
44
                fi
44
45
 
45
 
                if [ ! -f "${LIVE_CHROOT}"/sbin/parted ]
 
46
                if [ ! -f chroot/sbin/parted ]
46
47
                then
47
48
                        PACKAGES="${PACKAGES} parted"
48
49
                fi
49
50
 
50
 
                if [ ! -f "${LIVE_CHROOT}"/usr/bin/syslinux ]
 
51
                if [ ! -f chroot/usr/bin/syslinux ]
51
52
                then
52
53
                        PACKAGES="${PACKAGES} syslinux"
53
54
                fi
56
57
                then
57
58
                        # Installing packages
58
59
                        case "${LH_APT}" in
59
 
                                apt)
 
60
                                apt|apt-get)
60
61
                                        Chroot "apt-get install --yes ${PACKAGES}"
61
62
                                        ;;
62
63
 
67
68
                fi
68
69
 
69
70
                # Remove old binary
70
 
                if [ -f "${LIVE_ROOT}"/binary.img ]
 
71
                if [ -f binary.img ]
71
72
                then
72
 
                        rm -f "${LIVE_ROOT}"/binary.img
 
73
                        rm -f binary.img
73
74
                fi
74
75
 
75
76
                # Everything which comes here needs to be cleaned up,
76
 
                DU_DIM="`du -ms ${LIVE_ROOT}/binary | cut -f1`"
 
77
                DU_DIM="`du -ms binary | cut -f1`"
77
78
                REAL_DIM="`expr ${DU_DIM} + ${DU_DIM} / 20`" # Just 5% more to be sure, need something more sophistcated here...
78
 
                dd if=/dev/zero of="${LIVE_ROOT}"/binary.img bs=1024k count=${REAL_DIM}
79
 
                FREELO="`losetup -f`"
80
 
                if [ ! -b "${LIVE_CHROOT}"/${FREELO} ]
 
79
                dd if=/dev/zero of=binary.img bs=1024k count=${REAL_DIM}
 
80
                FREELO="`${LH_LOSETUP} -f`"
 
81
                if [ ! -b chroot/${FREELO} ]
81
82
                then
82
83
                        MAKEDEV="true"
83
 
                        Chroot "cd /dev && ./MAKEDEV ${FREELO}"
 
84
 
 
85
                        mv chroot/dev chroot/dev.tmp
 
86
                        find /dev | cpio -dmpu chroot
84
87
                fi
85
88
 
86
89
                echo "!!! The following error/warning messages can be ignored !!!"
87
 
                lh_losetup $FREELO "${LIVE_ROOT}"/binary.img 0
 
90
                lh_losetup $FREELO binary.img 0
88
91
                Chroot "parted -s ${FREELO} mklabel msdos" || true
89
92
                Chroot "parted -s ${FREELO} mkpartfs primary fat16 0.0 100%" || true
90
93
                Chroot "parted -s ${FREELO} set 1 boot on" || true
91
94
                Chroot "parted -s ${FREELO} set 1 lba off" || true
92
 
                cat "${LIVE_CHROOT}"/usr/lib/syslinux/mbr.bin > ${FREELO}
93
 
                losetup -d ${FREELO}
 
95
                cat chroot/usr/lib/syslinux/mbr.bin > ${FREELO}
 
96
                ${LH_LOSETUP} -d ${FREELO}
94
97
 
95
 
                lh_losetup $FREELO "${LIVE_ROOT}"/binary.img 1
 
98
                lh_losetup $FREELO binary.img 1
96
99
                Chroot "mkfs.msdos -n DEBIAN_LIVE ${FREELO}"
97
 
                mkdir -p "${LIVE_ROOT}"/binary.tmp
98
 
                mount ${FREELO} "${LIVE_ROOT}"/binary.tmp
99
 
                cp -r "${LIVE_ROOT}"/binary/* "${LIVE_ROOT}"/binary.tmp
100
 
                umount "${LIVE_ROOT}"/binary.tmp
101
 
                rmdir "${LIVE_ROOT}"/binary.tmp
 
100
                mkdir -p binary.tmp
 
101
                mount ${FREELO} binary.tmp
 
102
                cp -r binary/* binary.tmp
 
103
                umount binary.tmp
 
104
                rmdir binary.tmp
102
105
                Chroot "syslinux ${FREELO}"
103
 
                losetup -d ${FREELO}
 
106
                ${LH_LOSETUP} -d ${FREELO}
104
107
                echo "!!! The above error/warning messages can be ignored !!!"
105
108
 
106
109
                if [ -n "${MAKEDEV}" ]
107
110
                then
108
 
                        rm -f "${LIVE_CHROOT}"/${FREELO}
 
111
                        rm -f chroot/dev
 
112
                        mv chroot/dev.tmp chroot/dev
109
113
                fi
110
114
 
111
115
                if [ -n "${PACKAGES}" ]
112
116
                then
113
117
                        # Removing packages
114
118
                        case "${LH_APT}" in
115
 
                                apt)
 
119
                                apt|apt-get)
116
120
                                        Chroot "apt-get remove --purge --yes ${PACKAGES}"
117
121
                                        ;;
118
122
 
121
125
                                        ;;
122
126
                        esac
123
127
                fi
 
128
 
 
129
                # Creating stage file
 
130
                Create_stagefile .stage/binary_usb
124
131
        fi
125
 
 
126
 
        # Creating stage file
127
 
        Create_stagefile "${LIVE_ROOT}"/.stage/binary_usb
128
132
done