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

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

add script to generate pool

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