slitaz-arm diff rpi/tazbian @ rev 192

Add tazbian
author Pascal Bellard <pascal.bellard@slitaz.org>
date Sat Nov 15 23:40:30 2014 +0100 (2014-11-15)
parents
children 9f10e89995a2
line diff
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/rpi/tazbian	Sat Nov 15 23:40:30 2014 +0100
     1.3 @@ -0,0 +1,218 @@
     1.4 +#!/bin/sh
     1.5 +#
     1.6 +# (C) 2014 SliTaz GNU/Linux - GPL2
     1.7 +#
     1.8 +# creates a debian package to install SliTaz on a RaspBian with
     1.9 +# repartitionning.
    1.10 +#
    1.11 +# AUTHORS: Pascal Bellard <pascal.bellard@slitaz.org>
    1.12 +#
    1.13 +
    1.14 +[ $(id -u) -ne 0 ] && echo "Must be root. Abort." && exit 1
    1.15 +
    1.16 +CURDIR=$PWD
    1.17 +TMPDIR=/tmp/rasp$$
    1.18 +mkdir -p $TMPDIR
    1.19 +cd $TMPDIR
    1.20 +DESTDIR=var/os/slitaz
    1.21 +URL=http://mirror.slitaz.org/arm/rpi/
    1.22 +wget -O - $URL | sed '/slitaz-rpi/!d;s/.*href=.\([a-zA-Z0-9._-]*\).*/\1/' | sort -r > index
    1.23 +VERSION="$(sed '/rpi-desktop/!d' index | sed 's/.*-desktop-\([0-9_-]*\).*/\1/;q')"
    1.24 +
    1.25 +wget -O - $URL$(sed '/rpi-base/!d;q' index) | tar xjf -
    1.26 +wget -O - $URL$(sed '/rpi-desktop/!d;q' index) | tar xjf -
    1.27 +
    1.28 +mkdir -p fs/$DESTDIR fs/boot/slitaz fs/boot/slitaz-base \
    1.29 +	 fs/boot/raspbian
    1.30 +
    1.31 +# setup boot configuration 
    1.32 +BASE=$(ls -d slitaz-rpi-base-*/boot)
    1.33 +[ ! -d "$BASE" ] && echo "Abort ($BASE) !" && exit 1
    1.34 +mv $BASE/kernel.img fs/boot/slitaz
    1.35 +cp $BASE/config.txt fs/boot/slitaz
    1.36 +cp $BASE/config.txt fs/boot/slitaz-base
    1.37 +echo "initrd rootfs-base.gz" >> fs/boot/slitaz/config.txt
    1.38 +echo "entry=SliTaz $VERSION on SD-card" > fs/boot/slitaz/menu.txt
    1.39 +sed -i 's|kernel.img|../slitaz/&|' fs/boot/slitaz-base/config.txt
    1.40 +cp -a fs/boot/slitaz-base fs/boot/slitaz-live
    1.41 +echo "initrd ../slitaz/rootfs-base.gz" >> fs/boot/slitaz-base/config.txt
    1.42 +echo "entry=SliTaz base $VERSION in RAM" > fs/boot/slitaz-base/menu.txt
    1.43 +echo "initrd ../slitaz/rootfs-base.gz ../slitaz/rootfs-live.gz" >> fs/boot/slitaz-live/config.txt
    1.44 +echo "entry=SliTaz desktop $VERSION in RAM" > fs/boot/slitaz-live/menu.txt
    1.45 +
    1.46 +# update base package
    1.47 +BASE=$(ls -d slitaz-rpi-base-*/rootfs)
    1.48 +[ ! -d "$BASE" ] && echo "Abort ($BASE) !" && exit 1
    1.49 +wget http://hg.slitaz.org/slitaz-arm/raw-file/tip/rpi/piboot
    1.50 +mv piboot $BASE/sbin
    1.51 +wget http://cook.slitaz.org/cross/arm/packages/packages.list
    1.52 +while read file pkg extra ; do
    1.53 +	[ -s boot$file ] && continue
    1.54 +	[ -n "$extra" ] && continue
    1.55 +	pkg=$(grep ^$pkg- packages.list | sort | sed q).tazpkg
    1.56 +	wget http://cook.slitaz.org/cross/arm/packages/$pkg
    1.57 +	tazpkg install $pkg --root=$BASE/
    1.58 +done <<EOT
    1.59 +/usr/lib/libz.so		zlib
    1.60 +/usr/sbin/kexec			kexec-tools
    1.61 +/usr/bin/tset			ncursesw
    1.62 +/usr/bin/dialog			dialog
    1.63 +/usr/lib/libxml2.so		libxml2			aria2
    1.64 +/usr/bin/gpg-error		libgpg-error		aria2
    1.65 +/usr/lib/libgcrypt.so		libgcrypt		aria2
    1.66 +/usr/lib/libgmp.so		gmp			aria2
    1.67 +/usr/lib/libnettle.so		nettle			aria2
    1.68 +/usr/share/terminfo/l/linux	ncurses-common		aria2
    1.69 +/lib/libncurses.so		ncurses			aria2
    1.70 +/usr/lib/libreadline.so		readline		aria2
    1.71 +/usr/lib/libstdc++.so		gcc-lib-base p11-kit	aria2
    1.72 +/usr/lib/libgnutls.so		libgnutls		aria2
    1.73 +/usr/lib/libcrypto.so		libcrypto		aria2
    1.74 +/usr/lib/libtasn1.so		libtasn1		aria2
    1.75 +/usr/bin/gnutls-cli		gnutls			aria2
    1.76 +/usr/bin/aria2c			aria2			aria2
    1.77 +EOT
    1.78 +
    1.79 +# deduplicate base & live
    1.80 +LIVE=$(ls -d slitaz-rpi-desktop-*/rootfs)
    1.81 +[ ! -d "$LIVE" ] && echo "Abort ($LIVE) !" && exit 1
    1.82 +LIVESZ=$(du -ks $LIVE | cut -f1)
    1.83 +( cd $BASE/ ; find ! -type d ) | while read file; do
    1.84 +	if [ -L $BASE/$file ]; then
    1.85 +		[ -L $LIVE/$file ] &&
    1.86 +		[ "$(readlink $BASE/$file)" == "$(readlink $LIVE/$file)" ] &&
    1.87 +		rm -f $LIVE/$file
    1.88 +	elif [ -f $BASE/$file ]; then
    1.89 +		[ -f $LIVE/$file ] &&
    1.90 +		cmp $BASE/$file $LIVE/$file > /dev/null 2>&1 &&
    1.91 +		rm -f $LIVE/$file
    1.92 +	elif [ -b $BASE/$file ]; then
    1.93 +		[ -b $LIVE/$file ] &&
    1.94 +		[ "$(stat -c '%a:%u:%g:%t:%T' $BASE/$file)" == \
    1.95 +		  "$(stat -c '%a:%u:%g:%t:%T' $LIVE/$file)" ] &&
    1.96 +		rm -f $LIVE/$file
    1.97 +	elif [ -c $BASE/$file ]; then
    1.98 +		[ -c $LIVE/$file ] &&
    1.99 +		[ "$(stat -c '%a:%u:%g:%t:%T' $BASE/$file)" == \
   1.100 +		  "$(stat -c '%a:%u:%g:%t:%T' $LIVE/$file)" ] &&
   1.101 +		rm -f $LIVE/$file
   1.102 +	fi
   1.103 +done
   1.104 +( cd $BASE/ ; find -type d ) | while read dir; do
   1.105 +	rmdir $LIVE/$file 2> /dev/null
   1.106 +done
   1.107 +
   1.108 +( cd $BASE ; find * | cpio -o -H newc ) | \
   1.109 +	gzip -9 > fs/boot/slitaz/rootfs-base.gz
   1.110 +( cd $LIVE ; find * | cpio -o -H newc ) | \
   1.111 +	gzip -9 > fs/boot/slitaz/rootfs-live.gz
   1.112 +
   1.113 +
   1.114 +# Create raspbian package
   1.115 +echo "2.0" > debian-binary
   1.116 +cat > control <<EOT
   1.117 +Package: slitaz
   1.118 +Version: $VERSION-1
   1.119 +Architecture: armhf
   1.120 +Maintainer: Pascal Bellard <pascal.bellard@slitaz.org>
   1.121 +Installed-Size: $(($(du -ks fs | cut -f1) + $LIVESZ))
   1.122 +Section: miscellaneous
   1.123 +Priority: optional
   1.124 +Homepage: http://arm.slitaz.org/
   1.125 +Description: Tiny Linux distribution with multi boot feature
   1.126 + SliTaz can run fully in RAM or can be installed on the SD card in a
   1.127 + subdirectory of your Raspbian (example /$DESTDIR).
   1.128 +EOT
   1.129 +( cd fs ; find * -type f -exec md5sum {} \; ) > md5sums
   1.130 +cat > postinst <<EOT
   1.131 +#!/bin/sh
   1.132 +
   1.133 +set -e
   1.134 +
   1.135 +cd /$DESTDIR
   1.136 +zcat /boot/slitaz/rootfs-base.gz | cpio -idmu
   1.137 +zcat /boot/slitaz/rootfs-core.gz | cpio -idmu
   1.138 +mkdir mnt/raspbian 2> /dev/null
   1.139 +cat >> etc/inittab <<EOM
   1.140 +\$RDEV	/mnt/raspbian	\$FSTYPE	defaults	0	0
   1.141 +tmpfs	/mnt/raspbian/$DESTDIR	tmpfs	size=0	0	0
   1.142 +EOM
   1.143 +cd -
   1.144 +
   1.145 +if [ ! -f /boot/menu.txt ]; then
   1.146 +
   1.147 +for i in i18n keyboard ; di
   1.148 +	[ -s /etc/sysconfig/\$i ] && . /etc/sysconfig/\$i
   1.149 +done
   1.150 +find /$DESTDIR/usr/share/kbd/keymaps | grep /\$KEYTABLE.map.gz\$ && KMAP=\$KEYTABLE
   1.151 +cat > /boot/menu.txt <<EOM
   1.152 +title=Raspberry PI boot menu
   1.153 +subtitle=Select the OS with ARROW keys and hit RETURN
   1.154 +timeout=30
   1.155 +default=raspbian
   1.156 +#kmap=\${KMAP:-us}
   1.157 +edittitle=Edit menu
   1.158 +#noedit
   1.159 +#webpath=http://my.home.web.site/pxe/rpi/index.php
   1.160 +EOM
   1.161 +cp /boot/config.txt /boot/raspbian/
   1.162 +mv /boot/\$(sed '/^kernel/!d;s/.*=//' /boot/config.txt) /boot/raspbian/
   1.163 +echo "entry=Raspbian \$(cat /etc/debian_version)" > /boot/raspbian/menu.txt
   1.164 +sed -i '/^kernel/d;/^initrd/d' /boot/config.txt
   1.165 +echo "kernel=slitaz/kernel.img" >> /boot/config.txt
   1.166 +echo "initrd=slitaz/rootfs-base.gz" >> /boot/config.txt
   1.167 +set -- \$(awk '/ \/ / { if (\$1 != "rootfs") print \$1 " " \$3 }')
   1.168 +RDEV=\$1
   1.169 +FSTYPE=\$2
   1.170 +echo "root=/dev/null rdinit=/sbin/piboot quiet" > /boot/cmdline.txt
   1.171 +echo "root=/dev/null mount=\$RDEV subroot=$DESTDIR rootwait quiet" > /boot/slitaz/cmdline.txt
   1.172 +if [ -s /$DESTDIR/usr/share/i18n/locales/\${LANG%.*} -a -n "\$KMAP" ]; then
   1.173 +	echo "root=/dev/null lang=\${LANG%.*} kmap=\$KMAP quiet"
   1.174 +else
   1.175 +	echo "root=/dev/null quiet"
   1.176 +fi > /boot/slitaz-base/cmdline.txt
   1.177 +cp /boot/slitaz-base/cmdline.txt /boot/slitaz-live/cmdline.txt
   1.178 +
   1.179 +fi
   1.180 +
   1.181 +exit 0
   1.182 +EOT
   1.183 +cat > postrm <<EOT
   1.184 +#!/bin/sh
   1.185 +
   1.186 +purge()
   1.187 +{
   1.188 +	rm -rf /$DESTDIR /boot/slitaz*
   1.189 +}
   1.190 +
   1.191 +disable()
   1.192 +{
   1.193 +	if [ -d /boot/rasbian ]; then
   1.194 +		mv -f /boot/rasbian/* /boot
   1.195 +		rm -rf /boot/rasbian
   1.196 +	fi
   1.197 +	rm -f /boot/menu.txt
   1.198 +}
   1.199 +
   1.200 +case "\$1" in
   1.201 +purge)
   1.202 +	disable
   1.203 +	purge
   1.204 +	;;
   1.205 +remove|upgrade|failed-upgrade|abort-install|abort-upgrade|disappear)
   1.206 +	disable
   1.207 +	;;
   1.208 +*)
   1.209 +	echo "postrm called with unknown argument \\\`\$1'" >&2
   1.210 +	exit 0
   1.211 +esac
   1.212 +EOT
   1.213 +chmod +x postinst postrm
   1.214 +tar czf control.tar.gz md5sums control postinst postrm
   1.215 +rm -rf fs/$DESTDIR/*
   1.216 +cd fs ; tar czf ../data.tar.gz . ; cd ..
   1.217 +[ -x /usr/bin/ar ] || tazpkg get-install binutils
   1.218 +ar rcs slitaz-$VERSION-1_armhf.deb debian-binary control.tar.gz data.tar.gz
   1.219 +mv slitaz-$VERSION-1_armhf.deb $CURDIR
   1.220 +cd $CURDIR
   1.221 +ls -l slitaz-$VERSION-1_armhf.deb