source: lliurex-maker/trunk/fuentes/new/usr/share/lliurex-maker/auto/build @ 1365

Last change on this file since 1365 was 1365, checked in by kbut, 5 years ago

fix bug

  • Property svn:executable set to *
File size: 5.1 KB
Line 
1#! /bin/sh
2set -e
3
4export LC_ALL=C
5
6( . "${LIVE_BUILD}/scripts/build.sh" > /dev/null 2>&1 || true ) || . /usr/lib/live/build.sh
7
8Arguments "${@}"
9
10Read_conffiles config/all config/common config/bootstrap config/chroot config/binary config/source
11Set_defaults
12
13# Setup cleanup function
14Setup_cleanup
15
16rm -f binary.success
17(
18
19        lb bootstrap "$@"
20
21        Chroot chroot "dpkg-divert --quiet --add \
22                --divert /usr/sbin/update-initramfs.REAL --rename \
23                /usr/sbin/update-initramfs"
24        cat > chroot/usr/sbin/update-initramfs <<'EOF'
25#! /bin/sh
26if [ $# != 1 ] || [ "$1" != -u ]; then
27        exec update-initramfs.REAL "$@"
28fi
29echo "update-initramfs: diverted by livecd-rootfs (will be called later)" >&2
30exit 0
31EOF
32        chmod +x chroot/usr/sbin/update-initramfs
33
34        cat > config/hooks/999-undivert-update-initramfs.chroot <<'EOF'
35#! /bin/sh
36rm -f /usr/sbin/update-initramfs
37dpkg-divert --quiet --remove --rename /usr/sbin/update-initramfs
38EOF
39
40        cat > config/hooks/fixvmlinuz.binary <<'EOF'
41#! /bin/sh
42kernel=$(ls binary/casper/vmlinuz-* | grep -v efi | sort -r | head -1)
43kernel_efi=$(ls binary/casper/vmlinuz-* | grep efi | sort -r | head -1)
44cp $kernel binary/casper/vmlinuz
45cp $kernel_efi binary/casper/vmlinuz.efi
46cp binary/casper/initrd.img* binary/casper/initrd.lz
47EOF
48
49
50        lb chroot "$@"
51
52        echo "===== Checking size of /usr/share/doc ====="
53        echo BEGIN docdirs
54        (cd chroot && find usr/share/doc -maxdepth 1 -type d | xargs du -s | sort -nr)
55        echo END docdirs
56        rm chroot/etc/apt/sources.list.d/* || true
57        cp -r config/final_apt/* chroot/etc/apt/ || true
58
59        if [ "${LB_ARCHITECTURES}" = 'amd64']; then
60                cp /usr/lib/live/build/lb_binary custom_binary
61                sed -i -e 's%^lb binary_iso ${\*}%auto/lliurexbuildiso ${*}%g' custom_binary
62                chmod +x custom_binary
63                ./custom_binary "$@"
64        else
65                lb binary "$@"
66        fi
67        touch binary.success
68) 2>&1 | tee binary.log
69
70# bash has trouble with the build.sh sourcing arrangement at the top of this
71# file, so we use this cheap-and-cheerful approach rather than the more
72# correct 'set -o pipefail'.
73if [ -e binary.success ]; then
74        rm -f binary.success
75else
76        exit 1
77fi
78
79# Link output files somewhere BuildLiveCD will be able to find them.
80PREFIX="livecd.$PROJECT${SUBARCH:+-$SUBARCH}"
81
82case $LB_INITRAMFS in
83        casper)
84                INITFS="casper"
85                ;;
86
87        live-boot)
88                INITFS="live"
89                ;;
90
91        *)
92                INITFS="boot"
93                ;;
94esac
95
96for OUTPUT in ext2 ext3 ext4 manifest manifest-remove size squashfs; do
97        [ -e "binary/$INITFS/filesystem.$OUTPUT" ] || continue
98        ln "binary/$INITFS/filesystem.$OUTPUT" "$PREFIX.$OUTPUT"
99        chmod 644 "$PREFIX.$OUTPUT"
100done
101
102for ISO in binary.iso binary.hybrid.iso; do
103        [ -e "$ISO" ] || continue
104        ln "$ISO" "$PREFIX.iso"
105        chmod 644 "$PREFIX.iso"
106        break
107done
108
109if [ -e "binary/$INITFS/filesystem.dir" ]; then
110        (cd "binary/$INITFS/filesystem.dir/" && tar -c *) | \
111                gzip -9 --rsyncable > "$PREFIX.rootfs.tar.gz"
112        chmod 644 "$PREFIX.rootfs.tar.gz"
113elif [ -e binary-tar.tar.gz ]; then
114        cp -a binary-tar.tar.gz "$PREFIX.rootfs.tar.gz"
115fi
116
117# '--initramfs none' produces different manifest names.
118if [ -e "binary/$INITFS/filesystem.packages" ]; then
119        ln "binary/$INITFS/filesystem.packages" "$PREFIX.manifest"
120        chmod 644 "$PREFIX.manifest"
121fi
122if [ -e "binary/$INITFS/filesystem.packages-remove" ]; then
123        # Not a typo, empty manifest-remove has a single LF in it. :/
124        if [ $(cat binary/$INITFS/filesystem.packages-remove | wc -c) -gt 1 ]; then
125                ln "binary/$INITFS/filesystem.packages-remove" "$PREFIX.manifest-remove"
126                chmod 644 "$PREFIX.manifest-remove"
127        fi
128fi
129
130
131for FLAVOUR in $LB_LINUX_FLAVOURS; do
132        if [ -z "$LB_LINUX_FLAVOURS" ] || [ "$LB_LINUX_FLAVOURS" = "none" ]; then
133                continue
134        fi
135        if [ "$FLAVOUR" = "virtual" ]; then
136                # The virtual kernel is named generic in /boot
137                FLAVOUR="generic"
138        fi
139        KVERS="$( (cd "binary/$INITFS"; ls vmlinu?-* 2>/dev/null || true) | (fgrep -v .efi || true) | sed -n "s/^vmlinu.-\\([^-]*-[^-]*-$FLAVOUR\\)$/\\1/p" )"
140        if [ -z "$KVERS" ]; then
141                if [ -e "binary/$INITFS/vmlinuz" ]; then
142                        # already renamed by ubuntu-defaults-image
143                        break
144                fi
145                echo "No kernel output for $FLAVOUR!" >&2
146                exit 1
147        fi
148        NUMKVERS="$(set -- $KVERS; echo $#)"
149        if [ "$NUMKVERS" -gt 1 ]; then
150                echo "Cannot handle more than one kernel for $FLAVOUR ($KVERS)!" >&2
151                exit 1
152        fi
153        ln "binary/$INITFS/"vmlinu?-"$KVERS" "$PREFIX.kernel-$FLAVOUR"
154        if [ -e "binary/$INITFS/"vmlinu?-"$KVERS.efi.signed" ]; then
155                ln "binary/$INITFS/"vmlinu?-"$KVERS.efi.signed" "$PREFIX.kernel-$FLAVOUR.efi.signed"
156                chmod 644 "$PREFIX.kernel-$FLAVOUR.efi.signed"
157        fi
158        chmod 644 "$PREFIX.kernel-$FLAVOUR"
159        if [ -e "binary/$INITFS/initrd.img-$KVERS" ]; then
160                ln "binary/$INITFS/initrd.img-$KVERS" "$PREFIX.initrd-$FLAVOUR"
161                chmod 644 "$PREFIX.initrd-$FLAVOUR"
162        fi
163done
164
165NUMFLAVOURS="$(set -- $LB_LINUX_FLAVOURS; echo $#)"
166if [ "$NUMFLAVOURS" = 1 ] && [ "$LB_LINUX_FLAVOURS" != "none" ]; then
167        # only one kernel flavour
168        if [ -e "binary/$INITFS/vmlinuz" ]; then
169                ln "binary/$INITFS/vmlinuz" "$PREFIX.kernel"
170                chmod 644 "$PREFIX.kernel"
171        else
172                ln -sf "$PREFIX.kernel-$LB_LINUX_FLAVOURS" "$PREFIX.kernel"
173        fi
174        if [ -e "binary/$INITFS/initrd.lz" ]; then
175                ln "binary/$INITFS/initrd.lz" "$PREFIX.initrd"
176                chmod 644 "$PREFIX.initrd"
177        else
178                ln -sf "$PREFIX.initrd-$LB_LINUX_FLAVOURS" "$PREFIX.initrd"
179        fi
180fi
Note: See TracBrowser for help on using the repository browser.