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