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

Last change on this file since 1349 was 1349, checked in by mabarracus, 4 years ago

update

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