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

Last change on this file since 5476 was 5476, checked in by hectorgh, 23 months ago

cleaning apt list cache

  • Property svn:executable set to *
File size: 6.0 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        rm -rf /var/lib/apt/lists/lliurex.net*
81        cp -r config/final_apt/* chroot/etc/apt/ 2>/dev/null || true
82
83        cp /usr/lib/live/build/lb_binary custom_binary
84        cp /usr/lib/live/build/lb_binary_disk custom_binary_disk
85        chmod +x custom_binary custom_binary_disk
86
87        # Enabling custom_binary_disk
88        sed -i -e 's%^lb binary_disk ${\*}%./custom_binary_disk ${*}%g' custom_binary
89        # Fixing disk/info
90        sed -i -e 's%Ubuntu%LliureX%g' custom_binary_disk
91
92
93        if [ "${LB_ARCHITECTURES}" = 'amd64' ]; then
94                echo "===== Detected AMD64 hooking to custom_binary build ====="
95                sed -i -e 's%^lb binary_iso ${\*}%auto/lliurexbuildiso ${*}%g' custom_binary
96        fi
97        ./custom_binary "$@"
98        touch binary.success
99) 2>&1 | tee binary.log
100
101# bash has trouble with the build.sh sourcing arrangement at the top of this
102# file, so we use this cheap-and-cheerful approach rather than the more
103# correct 'set -o pipefail'.
104if [ -e binary.success ]; then
105        rm -f binary.success
106else
107        exit 1
108fi
109
110# Link output files somewhere BuildLiveCD will be able to find them.
111PREFIX="livecd.$PROJECT${SUBARCH:+-$SUBARCH}"
112
113case $LB_INITRAMFS in
114        casper)
115                INITFS="casper"
116                ;;
117
118        live-boot)
119                INITFS="live"
120                ;;
121
122        *)
123                INITFS="boot"
124                ;;
125esac
126
127for OUTPUT in ext2 ext3 ext4 manifest manifest-remove size squashfs; do
128        [ -e "binary/$INITFS/filesystem.$OUTPUT" ] || continue
129        ln "binary/$INITFS/filesystem.$OUTPUT" "$PREFIX.$OUTPUT"
130        chmod 644 "$PREFIX.$OUTPUT"
131done
132
133for ISO in binary.iso binary.hybrid.iso; do
134        [ -e "$ISO" ] || continue
135        ln "$ISO" "$PREFIX.iso"
136        chmod 644 "$PREFIX.iso"
137        break
138done
139
140if [ -e "binary/$INITFS/filesystem.dir" ]; then
141        (cd "binary/$INITFS/filesystem.dir/" && tar -c *) | \
142                gzip -9 --rsyncable > "$PREFIX.rootfs.tar.gz"
143        chmod 644 "$PREFIX.rootfs.tar.gz"
144elif [ -e binary-tar.tar.gz ]; then
145        cp -a binary-tar.tar.gz "$PREFIX.rootfs.tar.gz"
146fi
147
148# '--initramfs none' produces different manifest names.
149if [ -e "binary/$INITFS/filesystem.packages" ]; then
150        ln "binary/$INITFS/filesystem.packages" "$PREFIX.manifest"
151        chmod 644 "$PREFIX.manifest"
152fi
153if [ -e "binary/$INITFS/filesystem.packages-remove" ]; then
154        # Not a typo, empty manifest-remove has a single LF in it. :/
155        if [ $(cat binary/$INITFS/filesystem.packages-remove | wc -c) -gt 1 ]; then
156                ln "binary/$INITFS/filesystem.packages-remove" "$PREFIX.manifest-remove"
157                chmod 644 "$PREFIX.manifest-remove"
158        fi
159fi
160
161
162for FLAVOUR in $LB_LINUX_FLAVOURS; do
163        if [ -z "$LB_LINUX_FLAVOURS" ] || [ "$LB_LINUX_FLAVOURS" = "none" ]; then
164                continue
165        fi
166        if [ "$FLAVOUR" = "virtual" ]; then
167                # The virtual kernel is named generic in /boot
168                FLAVOUR="generic"
169        fi
170        KVERS="$( (cd "binary/$INITFS"; ls vmlinu?-* 2>/dev/null || true) | (fgrep -v .efi || true) | sed -n "s/^vmlinu.-\\([^-]*-[^-]*-$FLAVOUR\\)$/\\1/p" )"
171        if [ -z "$KVERS" ]; then
172                if [ -e "binary/$INITFS/vmlinuz" ]; then
173                        # already renamed by ubuntu-defaults-image
174                        break
175                fi
176                echo "No kernel output for $FLAVOUR!" >&2
177                exit 1
178        fi
179        NUMKVERS="$(set -- $KVERS; echo $#)"
180        if [ "$NUMKVERS" -gt 1 ]; then
181                echo "Cannot handle more than one kernel for $FLAVOUR ($KVERS)!" >&2
182                exit 1
183        fi
184        ln "binary/$INITFS/"vmlinu?-"$KVERS" "$PREFIX.kernel-$FLAVOUR"
185        if [ -e "binary/$INITFS/"vmlinu?-"$KVERS.efi.signed" ]; then
186                ln "binary/$INITFS/"vmlinu?-"$KVERS.efi.signed" "$PREFIX.kernel-$FLAVOUR.efi.signed"
187                chmod 644 "$PREFIX.kernel-$FLAVOUR.efi.signed"
188        fi
189        chmod 644 "$PREFIX.kernel-$FLAVOUR"
190        if [ -e "binary/$INITFS/initrd.img-$KVERS" ]; then
191                ln "binary/$INITFS/initrd.img-$KVERS" "$PREFIX.initrd-$FLAVOUR"
192                chmod 644 "$PREFIX.initrd-$FLAVOUR"
193        fi
194done
195
196NUMFLAVOURS="$(set -- $LB_LINUX_FLAVOURS; echo $#)"
197if [ "$NUMFLAVOURS" = 1 ] && [ "$LB_LINUX_FLAVOURS" != "none" ]; then
198        # only one kernel flavour
199        if [ -e "binary/$INITFS/vmlinuz" ]; then
200                ln "binary/$INITFS/vmlinuz" "$PREFIX.kernel"
201                chmod 644 "$PREFIX.kernel"
202        else
203                ln -sf "$PREFIX.kernel-$LB_LINUX_FLAVOURS" "$PREFIX.kernel"
204        fi
205        if [ -e "binary/$INITFS/initrd.lz" ]; then
206                ln "binary/$INITFS/initrd.lz" "$PREFIX.initrd"
207                chmod 644 "$PREFIX.initrd"
208        else
209                ln -sf "$PREFIX.initrd-$LB_LINUX_FLAVOURS" "$PREFIX.initrd"
210        fi
211fi
Note: See TracBrowser for help on using the repository browser.