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

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

fix bug

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