slitaz-arm view rpi/tazbian @ rev 194

tazbian: fix piboot perms
author Pascal Bellard <pascal.bellard@slitaz.org>
date Sun Nov 16 00:36:16 2014 +0100 (2014-11-16)
parents 9f10e89995a2
children 2fe7d33c6d4c
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 chmod +x piboot
48 mv piboot $BASE/sbin
49 wget http://cook.slitaz.org/cross/arm/packages/packages.list
50 while read file pkg extra ; do
51 [ -s boot$file ] && continue
52 [ -n "$extra" ] && continue
53 pkg=$(grep ^$pkg- packages.list | sort | sed q).tazpkg
54 wget http://cook.slitaz.org/cross/arm/packages/$pkg
55 tazpkg install $pkg --root=$BASE/
56 done <<EOT
57 /usr/lib/libz.so zlib
58 /usr/sbin/kexec kexec-tools
59 /usr/bin/tset ncursesw
60 /usr/bin/dialog dialog
61 /usr/lib/libxml2.so libxml2 aria2
62 /usr/bin/gpg-error libgpg-error aria2
63 /usr/lib/libgcrypt.so libgcrypt aria2
64 /usr/lib/libgmp.so gmp aria2
65 /usr/lib/libnettle.so nettle aria2
66 /usr/share/terminfo/l/linux ncurses-common aria2
67 /lib/libncurses.so ncurses aria2
68 /usr/lib/libreadline.so readline aria2
69 /usr/lib/libstdc++.so gcc-lib-base p11-kit aria2
70 /usr/lib/libgnutls.so libgnutls aria2
71 /usr/lib/libcrypto.so libcrypto aria2
72 /usr/lib/libtasn1.so libtasn1 aria2
73 /usr/bin/gnutls-cli gnutls aria2
74 /usr/bin/aria2c aria2 aria2
75 EOT
77 # deduplicate base & live
78 LIVE=$(ls -d slitaz-rpi-desktop-*/rootfs)
79 [ ! -d "$LIVE" ] && echo "Abort ($LIVE) !" && exit 1
80 LIVESZ=$(du -ks $LIVE | cut -f1)
81 ( cd $BASE/ ; find ! -type d ) | while read file; do
82 if [ -L $BASE/$file ]; then
83 [ -L $LIVE/$file ] &&
84 [ "$(readlink $BASE/$file)" == "$(readlink $LIVE/$file)" ] &&
85 rm -f $LIVE/$file
86 elif [ -f $BASE/$file ]; then
87 [ -f $LIVE/$file ] &&
88 cmp $BASE/$file $LIVE/$file > /dev/null 2>&1 &&
89 rm -f $LIVE/$file
90 elif [ -b $BASE/$file ]; then
91 [ -b $LIVE/$file ] &&
92 [ "$(stat -c '%a:%u:%g:%t:%T' $BASE/$file)" == \
93 "$(stat -c '%a:%u:%g:%t:%T' $LIVE/$file)" ] &&
94 rm -f $LIVE/$file
95 elif [ -c $BASE/$file ]; then
96 [ -c $LIVE/$file ] &&
97 [ "$(stat -c '%a:%u:%g:%t:%T' $BASE/$file)" == \
98 "$(stat -c '%a:%u:%g:%t:%T' $LIVE/$file)" ] &&
99 rm -f $LIVE/$file
100 fi
101 done
102 ( cd $BASE/ ; find -type d ) | while read dir; do
103 rmdir $LIVE/$file 2> /dev/null
104 done
106 ( cd $BASE ; find * | cpio -o -H newc ) | \
107 gzip -9 > fs/boot/slitaz/rootfs-base.gz
108 ( cd $LIVE ; find * | cpio -o -H newc ) | \
109 gzip -9 > fs/boot/slitaz/rootfs-live.gz
112 # Create raspbian package
113 echo "2.0" > debian-binary
114 cat > control <<EOT
115 Package: slitaz
116 Version: $VERSION-1
117 Architecture: armhf
118 Maintainer: Pascal Bellard <pascal.bellard@slitaz.org>
119 Installed-Size: $(($(du -ks fs | cut -f1) + $LIVESZ))
120 Section: miscellaneous
121 Priority: optional
122 Homepage: http://arm.slitaz.org/
123 Description: Tiny Linux distribution with multi boot feature
124 SliTaz can run fully in RAM or can be installed on the SD card in a
125 subdirectory of your Raspbian (example /$DESTDIR).
126 EOT
127 ( cd fs ; find * -type f -exec md5sum {} \; ) > md5sums
128 cat > postinst <<EOT
129 #!/bin/sh
131 set -e
133 cd /$DESTDIR
134 zcat /boot/slitaz/rootfs-base.gz | cpio -idmu
135 zcat /boot/slitaz/rootfs-core.gz | cpio -idmu
136 mkdir mnt/raspbian 2> /dev/null
137 cat >> etc/inittab <<EOM
138 \$RDEV /mnt/raspbian \$FSTYPE defaults 0 0
139 tmpfs /mnt/raspbian/$DESTDIR tmpfs size=0 0 0
140 EOM
141 cd -
143 if [ ! -f /boot/menu.txt ]; then
145 for i in i18n keyboard ; di
146 [ -s /etc/sysconfig/\$i ] && . /etc/sysconfig/\$i
147 done
148 find /$DESTDIR/usr/share/kbd/keymaps | grep /\$KEYTABLE.map.gz\$ && KMAP=\$KEYTABLE
149 cat > /boot/menu.txt <<EOM
150 title=Raspberry PI boot menu
151 subtitle=Select the OS with ARROW keys and hit RETURN
152 timeout=30
153 default=raspbian
154 #kmap=\${KMAP:-us}
155 edittitle=Edit menu
156 #noedit
157 #webpath=http://my.home.web.site/pxe/rpi/index.php
158 EOM
159 cp /boot/config.txt /boot/raspbian/
160 mv /boot/\$(sed '/^kernel/!d;s/.*=//' /boot/config.txt) /boot/raspbian/
161 echo "entry=Raspbian \$(cat /etc/debian_version)" > /boot/raspbian/menu.txt
162 sed -i '/^kernel/d;/^initrd/d' /boot/config.txt
163 echo "kernel=slitaz/kernel.img" >> /boot/config.txt
164 echo "initrd=slitaz/rootfs-base.gz" >> /boot/config.txt
165 set -- \$(awk '/ \/ / { if (\$1 != "rootfs") print \$1 " " \$3 }')
166 RDEV=\$1
167 FSTYPE=\$2
168 echo "root=/dev/null rdinit=/sbin/piboot quiet" > /boot/cmdline.txt
169 echo "root=/dev/null mount=\$RDEV subroot=$DESTDIR rootwait quiet" > /boot/slitaz/cmdline.txt
170 if [ -s /$DESTDIR/usr/share/i18n/locales/\${LANG%.*} -a -n "\$KMAP" ]; then
171 echo "root=/dev/null lang=\${LANG%.*} kmap=\$KMAP quiet"
172 else
173 echo "root=/dev/null quiet"
174 fi > /boot/slitaz-base/cmdline.txt
175 cp /boot/slitaz-base/cmdline.txt /boot/slitaz-live/cmdline.txt
177 fi
179 exit 0
180 EOT
181 cat > postrm <<EOT
182 #!/bin/sh
184 purge()
185 {
186 rm -rf /$DESTDIR /boot/slitaz*
187 }
189 disable()
190 {
191 if [ -d /boot/rasbian ]; then
192 mv -f /boot/rasbian/* /boot
193 rm -rf /boot/rasbian
194 fi
195 rm -f /boot/menu.txt
196 }
198 case "\$1" in
199 purge)
200 disable
201 purge
202 ;;
203 remove|upgrade|failed-upgrade|abort-install|abort-upgrade|disappear)
204 disable
205 ;;
206 *)
207 echo "postrm called with unknown argument \\\`\$1'" >&2
208 exit 0
209 esac
210 EOT
211 chmod +x postinst postrm
212 tar czf control.tar.gz md5sums control postinst postrm
213 rm -rf fs/$DESTDIR/*
214 cd fs ; tar czf ../data.tar.gz . ; cd ..
215 [ -x /usr/bin/ar ] || tazpkg get-install binutils
216 ar rcs slitaz-$VERSION-1_armhf.deb debian-binary control.tar.gz data.tar.gz
217 mv slitaz-$VERSION-1_armhf.deb $CURDIR
218 cd $CURDIR
219 ls -l slitaz-$VERSION-1_armhf.deb