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

Last change on this file since 2267 was 2267, checked in by kbut, 4 years ago

wip

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