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

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

build repository

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