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

Last change on this file since 1377 was 1377, checked in by mabarracus, 3 years ago

avoid warning

  • Property svn:executable set to *
File size: 5.2 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/ 2>/dev/null || true
58
59        if [ "${LB_ARCHITECTURES}" = 'amd64' ]; then
60                echo "===== Detected AMD64 hooking to custom_binary build ====="
61                cp /usr/lib/live/build/lb_binary custom_binary
62                sed -i -e 's%^lb binary_iso ${\*}%auto/lliurexbuildiso ${*}%g' custom_binary
63                chmod +x custom_binary
64                ./custom_binary "$@"
65        else
66                lb binary "$@"
67        fi
68        touch binary.success
69) 2>&1 | tee binary.log
70
71# bash has trouble with the build.sh sourcing arrangement at the top of this
72# file, so we use this cheap-and-cheerful approach rather than the more
73# correct 'set -o pipefail'.
74if [ -e binary.success ]; then
75        rm -f binary.success
76else
77        exit 1
78fi
79
80# Link output files somewhere BuildLiveCD will be able to find them.
81PREFIX="livecd.$PROJECT${SUBARCH:+-$SUBARCH}"
82
83case $LB_INITRAMFS in
84        casper)
85                INITFS="casper"
86                ;;
87
88        live-boot)
89                INITFS="live"
90                ;;
91
92        *)
93                INITFS="boot"
94                ;;
95esac
96
97for OUTPUT in ext2 ext3 ext4 manifest manifest-remove size squashfs; do
98        [ -e "binary/$INITFS/filesystem.$OUTPUT" ] || continue
99        ln "binary/$INITFS/filesystem.$OUTPUT" "$PREFIX.$OUTPUT"
100        chmod 644 "$PREFIX.$OUTPUT"
101done
102
103for ISO in binary.iso binary.hybrid.iso; do
104        [ -e "$ISO" ] || continue
105        ln "$ISO" "$PREFIX.iso"
106        chmod 644 "$PREFIX.iso"
107        break
108done
109
110if [ -e "binary/$INITFS/filesystem.dir" ]; then
111        (cd "binary/$INITFS/filesystem.dir/" && tar -c *) | \
112                gzip -9 --rsyncable > "$PREFIX.rootfs.tar.gz"
113        chmod 644 "$PREFIX.rootfs.tar.gz"
114elif [ -e binary-tar.tar.gz ]; then
115        cp -a binary-tar.tar.gz "$PREFIX.rootfs.tar.gz"
116fi
117
118# '--initramfs none' produces different manifest names.
119if [ -e "binary/$INITFS/filesystem.packages" ]; then
120        ln "binary/$INITFS/filesystem.packages" "$PREFIX.manifest"
121        chmod 644 "$PREFIX.manifest"
122fi
123if [ -e "binary/$INITFS/filesystem.packages-remove" ]; then
124        # Not a typo, empty manifest-remove has a single LF in it. :/
125        if [ $(cat binary/$INITFS/filesystem.packages-remove | wc -c) -gt 1 ]; then
126                ln "binary/$INITFS/filesystem.packages-remove" "$PREFIX.manifest-remove"
127                chmod 644 "$PREFIX.manifest-remove"
128        fi
129fi
130
131
132for FLAVOUR in $LB_LINUX_FLAVOURS; do
133        if [ -z "$LB_LINUX_FLAVOURS" ] || [ "$LB_LINUX_FLAVOURS" = "none" ]; then
134                continue
135        fi
136        if [ "$FLAVOUR" = "virtual" ]; then
137                # The virtual kernel is named generic in /boot
138                FLAVOUR="generic"
139        fi
140        KVERS="$( (cd "binary/$INITFS"; ls vmlinu?-* 2>/dev/null || true) | (fgrep -v .efi || true) | sed -n "s/^vmlinu.-\\([^-]*-[^-]*-$FLAVOUR\\)$/\\1/p" )"
141        if [ -z "$KVERS" ]; then
142                if [ -e "binary/$INITFS/vmlinuz" ]; then
143                        # already renamed by ubuntu-defaults-image
144                        break
145                fi
146                echo "No kernel output for $FLAVOUR!" >&2
147                exit 1
148        fi
149        NUMKVERS="$(set -- $KVERS; echo $#)"
150        if [ "$NUMKVERS" -gt 1 ]; then
151                echo "Cannot handle more than one kernel for $FLAVOUR ($KVERS)!" >&2
152                exit 1
153        fi
154        ln "binary/$INITFS/"vmlinu?-"$KVERS" "$PREFIX.kernel-$FLAVOUR"
155        if [ -e "binary/$INITFS/"vmlinu?-"$KVERS.efi.signed" ]; then
156                ln "binary/$INITFS/"vmlinu?-"$KVERS.efi.signed" "$PREFIX.kernel-$FLAVOUR.efi.signed"
157                chmod 644 "$PREFIX.kernel-$FLAVOUR.efi.signed"
158        fi
159        chmod 644 "$PREFIX.kernel-$FLAVOUR"
160        if [ -e "binary/$INITFS/initrd.img-$KVERS" ]; then
161                ln "binary/$INITFS/initrd.img-$KVERS" "$PREFIX.initrd-$FLAVOUR"
162                chmod 644 "$PREFIX.initrd-$FLAVOUR"
163        fi
164done
165
166NUMFLAVOURS="$(set -- $LB_LINUX_FLAVOURS; echo $#)"
167if [ "$NUMFLAVOURS" = 1 ] && [ "$LB_LINUX_FLAVOURS" != "none" ]; then
168        # only one kernel flavour
169        if [ -e "binary/$INITFS/vmlinuz" ]; then
170                ln "binary/$INITFS/vmlinuz" "$PREFIX.kernel"
171                chmod 644 "$PREFIX.kernel"
172        else
173                ln -sf "$PREFIX.kernel-$LB_LINUX_FLAVOURS" "$PREFIX.kernel"
174        fi
175        if [ -e "binary/$INITFS/initrd.lz" ]; then
176                ln "binary/$INITFS/initrd.lz" "$PREFIX.initrd"
177                chmod 644 "$PREFIX.initrd"
178        else
179                ln -sf "$PREFIX.initrd-$LB_LINUX_FLAVOURS" "$PREFIX.initrd"
180        fi
181fi
Note: See TracBrowser for help on using the repository browser.