slitaz-arm view rpi/tazbian @ rev 196

tazbian: misc fixes
author Pascal Bellard <pascal.bellard@slitaz.org>
date Sun Nov 16 13:34:10 2014 +0100 (2014-11-16)
parents 99ef615a944a
children c0c88b71a4b4
line source
1 #!/bin/sh
2 #
3 # (C) 2014 SliTaz GNU/Linux - GPL2
4 #
5 # creates a debian package to install SliTaz on a RaspBian without
6 # repartitionning.
7 #
8 # AUTHORS: Pascal Bellard <pascal.bellard@slitaz.org>
9 #
11 [ $(id -u) -ne 0 ] && echo "Must be root. Abort." && exit 1
13 CURDIR=$PWD
14 TMPDIR=/tmp/rasp$$
15 mkdir -p $TMPDIR
16 cd $TMPDIR
17 DESTDIR=var/os/slitaz
18 URL=http://mirror.slitaz.org/arm/rpi/
19 wget -O - $URL | sed '/slitaz-rpi/!d;s/.*href=.\([a-zA-Z0-9._-]*\).*/\1/' | sort -r > index
20 VERSION="$(sed '/rpi-desktop/!d' index | sed 's/.*-desktop-\([0-9_-]*\).*/\1/;q')"
22 wget -O - $URL$(sed '/rpi-base/!d;q' index) | tar xjf -
23 wget -O - $URL$(sed '/rpi-desktop/!d;q' index) | tar xjf -
25 mkdir -p fs/$DESTDIR fs/boot/slitaz fs/boot/slitaz-base \
26 fs/boot/raspbian
28 # setup boot configuration
29 BASE=$(ls -d slitaz-rpi-base-*/boot)
30 [ ! -d "$BASE" ] && echo "Abort ($BASE) !" && exit 1
31 mv $BASE/kernel.img fs/boot/slitaz
32 cp $BASE/config.txt fs/boot/slitaz
33 cp $BASE/config.txt fs/boot/slitaz-base
34 echo "initrd rootfs-base.gz" >> fs/boot/slitaz/config.txt
35 echo "entry=SliTaz $VERSION on SD-card" > fs/boot/slitaz/menu.txt
36 sed -i 's|kernel.img|../slitaz/&|' fs/boot/slitaz-base/config.txt
37 cp -a fs/boot/slitaz-base fs/boot/slitaz-live
38 echo "initrd ../slitaz/rootfs-base.gz" >> fs/boot/slitaz-base/config.txt
39 echo "entry=SliTaz base $VERSION in RAM" > fs/boot/slitaz-base/menu.txt
40 echo "initrd ../slitaz/rootfs-base.gz ../slitaz/rootfs-live.gz" >> fs/boot/slitaz-live/config.txt
41 echo "entry=SliTaz desktop $VERSION in RAM" > fs/boot/slitaz-live/menu.txt
43 # update base package
44 BASE=$(ls -d slitaz-rpi-base-*/rootfs)
45 [ ! -d "$BASE" ] && echo "Abort ($BASE) !" && exit 1
46 wget http://hg.slitaz.org/slitaz-arm/raw-file/tip/rpi/piboot
47 wget http://hg.slitaz.org/slitaz-boot-scripts/raw-file/tip/init
48 chmod +x piboot init
49 mv piboot $BASE/sbin
50 mv init $BASE/sbin/pisubroot
51 wget http://cook.slitaz.org/cross/arm/packages/packages.list
52 while read file pkg extra ; do
53 [ -s boot$file ] && continue
54 [ -n "$extra" ] && continue
55 pkg=$(grep ^$pkg- packages.list | sort | sed q).tazpkg
56 wget http://cook.slitaz.org/cross/arm/packages/$pkg
57 tazpkg install $pkg --root=$BASE/
58 done <<EOT
59 /usr/lib/libz.so zlib
60 /usr/sbin/kexec kexec-tools
61 /usr/bin/tset ncursesw
62 /usr/bin/dialog dialog
63 /usr/lib/libxml2.so libxml2 aria2
64 /usr/bin/gpg-error libgpg-error aria2
65 /usr/lib/libgcrypt.so libgcrypt aria2
66 /usr/lib/libgmp.so gmp aria2
67 /usr/lib/libnettle.so nettle aria2
68 /usr/lib/libreadline.so readline aria2
69 /usr/bin/p11-kit p11-kit aria2
70 /usr/lib/libgnutls.so libgnutls aria2
71 /usr/lib/libtasn1.so libtasn1 aria2
72 /usr/bin/gnutls-cli gnutls aria2
73 /usr/bin/aria2c aria2 aria2
74 EOT
76 # deduplicate base & live
77 LIVE=$(ls -d slitaz-rpi-desktop-*/rootfs)
78 [ ! -d "$LIVE" ] && echo "Abort ($LIVE) !" && exit 1
79 LIVESZ=$(du -ks $LIVE | cut -f1)
80 ( cd $BASE/ ; find ! -type d ) | while read file; do
81 if [ -L $BASE/$file ]; then
82 [ -L $LIVE/$file ] &&
83 [ "$(readlink $BASE/$file)" == "$(readlink $LIVE/$file)" ] &&
84 rm -f $LIVE/$file
85 elif [ -f $BASE/$file ]; then
86 [ -f $LIVE/$file ] &&
87 cmp $BASE/$file $LIVE/$file > /dev/null 2>&1 &&
88 rm -f $LIVE/$file
89 elif [ -b $BASE/$file ]; then
90 [ -b $LIVE/$file ] &&
91 [ "$(stat -c '%a:%u:%g:%t:%T' $BASE/$file)" == \
92 "$(stat -c '%a:%u:%g:%t:%T' $LIVE/$file)" ] &&
93 rm -f $LIVE/$file
94 elif [ -c $BASE/$file ]; then
95 [ -c $LIVE/$file ] &&
96 [ "$(stat -c '%a:%u:%g:%t:%T' $BASE/$file)" == \
97 "$(stat -c '%a:%u:%g:%t:%T' $LIVE/$file)" ] &&
98 rm -f $LIVE/$file
99 fi
100 done
101 ( cd $BASE/ ; find -type d ) | while read dir; do
102 rmdir $LIVE/$dir 2> /dev/null
103 done
105 ( cd $BASE ; find * | cpio -o -H newc ) | \
106 gzip -9 > fs/boot/slitaz/rootfs-base.gz
107 ( cd $LIVE ; find * | cpio -o -H newc ) | \
108 gzip -9 > fs/boot/slitaz/rootfs-live.gz
109 if [ -x /usr/bin/advdef ]; then
110 advdef -z4 fs/boot/slitaz/rootfs-base.gz
111 advdef -z4 fs/boot/slitaz/rootfs-live.gz
112 fi
114 # Create raspbian package
115 echo "2.0" > debian-binary
116 cat > control <<EOT
117 Package: slitaz
118 Version: $VERSION-1
119 Architecture: armhf
120 Maintainer: Pascal Bellard <pascal.bellard@slitaz.org>
121 Installed-Size: $(($(du -ks fs | cut -f1) + $LIVESZ))
122 Section: miscellaneous
123 Priority: optional
124 Homepage: http://arm.slitaz.org/
125 Description: Tiny Linux distribution with multi boot feature
126 SliTaz can run fully in RAM or can be installed on the SD card in a
127 subdirectory of your Raspbian (example /$DESTDIR).
128 EOT
129 ( cd fs ; find * -type f -exec md5sum {} \; ) > md5sums
130 cat > postinst <<EOT
131 #!/bin/sh
133 set -e
135 set -- \$(awk '/ \/ / { if (\$1 != "rootfs") print \$1 " " \$3 }' < /proc/mounts)
136 RDEV=\$1
137 FSTYPE=\$2
139 cd /$DESTDIR
140 zcat /boot/slitaz/rootfs-base.gz | cpio -idmu
141 zcat /boot/slitaz/rootfs-core.gz | cpio -idmu
142 mkdir mnt/raspbian 2> /dev/null
143 cat >> etc/inittab <<EOM
144 \$RDEV /mnt/raspbian \$FSTYPE defaults 0 0
145 tmpfs /mnt/raspbian/$DESTDIR tmpfs size=0 0 0
146 EOM
147 cd -
149 if [ ! -f /boot/menu.txt ]; then
151 for i in i18n keyboard ; do
152 [ -s /etc/sysconfig/\$i ] && . /etc/sysconfig/\$i
153 done
154 KMAP=
155 find /$DESTDIR/usr/share/kbd/keymaps | grep /\$KEYTABLE.map.gz\$ && KMAP=kmap=\$KEYTABLE
156 cat > /boot/menu.txt <<EOM
157 title=Raspberry PI boot menu
158 subtitle=Select the OS with ARROW keys and hit RETURN
159 timeout=30
160 default=raspbian
161 \$KMAP
162 edittitle=Edit menu
163 readonly
164 #noedit
165 #nowebboot
166 #webpath=http://my.home.web.site/pxe/rpi/index.php http://or.this.one/rpi.txt
167 EOM
168 cp /boot/config.txt /boot/raspbian/
169 mv /boot/\$(sed '/^kernel/!d;s/.*=//' /boot/config.txt) /boot/raspbian/
170 echo "entry=Raspbian \$(cat /etc/debian_version)" > /boot/raspbian/menu.txt
171 sed -i '/^kernel/d;/^initrd/d' /boot/config.txt
172 echo "kernel=slitaz/kernel.img" >> /boot/config.txt
173 echo "initrd=slitaz/rootfs-base.gz" >> /boot/config.txt
174 echo "root=/dev/null rdinit=/sbin/piboot quiet" > /boot/cmdline.txt
175 echo "root=/dev/null rdinit=/sbin/pisubroot mount=\$RDEV subroot=$DESTDIR rootwait quiet" > /boot/slitaz/cmdline.txt
176 L=
177 [ -s /$DESTDIR/usr/share/i18n/locales/\${LANG%.*} ] && L=lang=\${LANG%.*}
178 echo "root=/dev/null \$L \$KMAP quiet" > /boot/slitaz-base/cmdline.txt
179 cp /boot/slitaz-base/cmdline.txt /boot/slitaz-live/cmdline.txt
181 fi
183 echo "The SliTaz boot menu is available for next (re)boot."
185 exit 0
186 EOT
187 cat > postrm <<EOT
188 #!/bin/sh
190 purge()
191 {
192 rm -rf /$DESTDIR /boot/slitaz*
193 }
195 disable()
196 {
197 if [ -d /boot/rasbian ]; then
198 mv -f /boot/rasbian/* /boot
199 rm -rf /boot/rasbian
200 fi
201 rm -f /boot/menu.txt
202 }
204 case "\$1" in
205 purge)
206 disable
207 purge
208 ;;
209 remove|upgrade|failed-upgrade|abort-install|abort-upgrade|disappear)
210 disable
211 ;;
212 *)
213 echo "postrm called with unknown argument \\\`\$1'" >&2
214 exit 0
215 esac
216 EOT
217 chmod +x postinst postrm
218 tar czf control.tar.gz md5sums control postinst postrm
219 rm -rf fs/$DESTDIR/*
220 cd fs ; tar czf ../data.tar.gz . ; cd ..
221 [ -x /usr/bin/ar ] || tazpkg get-install binutils
222 ar rcs slitaz-$VERSION-1_armhf.deb debian-binary control.tar.gz data.tar.gz
223 mv slitaz-$VERSION-1_armhf.deb $CURDIR
224 cd $CURDIR
225 rm -rf $TMPDIR
226 ls -l slitaz-$VERSION-1_armhf.deb