slitaz-arm rev 192

Add tazbian
author Pascal Bellard <pascal.bellard@slitaz.org>
date Sat Nov 15 23:40:30 2014 +0100 (2014-11-15)
parents eef9bf1725b1
children 9f10e89995a2
files rpi/piboot rpi/tazbian
line diff
     1.1 --- a/rpi/piboot	Sun Jun 29 10:00:00 2014 +0200
     1.2 +++ b/rpi/piboot	Sat Nov 15 23:40:30 2014 +0100
     1.3 @@ -109,11 +109,15 @@
     1.4  	/etc/init.d/network.sh start
     1.5  	webpath=$(get webpath $mnt/menu.txt)
     1.6  	[ "$webpath" ] || webpath=http://mirror.slitaz.org/pxe/arm/boot.php
     1.7 -	wget -O /root/webboot.sh $webpath?mac=$(cat /sys/class/net/eth0/address) 2>&1 > /dev/null
     1.8 -	[ -s /root/webboot.sh ] || return
     1.9 -	. /root/webboot.sh
    1.10 -	webprefix=$(dirname $webpath)
    1.11 -	editbutton=""
    1.12 +	for url in ${webpath//,/ }; do
    1.13 +		wget -O /root/webboot.sh \
    1.14 +		  $url?mac=$(cat /sys/class/net/eth0/address) 2>&1 > /dev/null
    1.15 +		[ -s /root/webboot.sh ] || continue
    1.16 +		. /root/webboot.sh
    1.17 +		webprefix=$(dirname $url)
    1.18 +		editbutton=""
    1.19 +		break
    1.20 +	done
    1.21  }
    1.22  
    1.23  web_get()
     2.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     2.2 +++ b/rpi/tazbian	Sat Nov 15 23:40:30 2014 +0100
     2.3 @@ -0,0 +1,218 @@
     2.4 +#!/bin/sh
     2.5 +#
     2.6 +# (C) 2014 SliTaz GNU/Linux - GPL2
     2.7 +#
     2.8 +# creates a debian package to install SliTaz on a RaspBian with
     2.9 +# repartitionning.
    2.10 +#
    2.11 +# AUTHORS: Pascal Bellard <pascal.bellard@slitaz.org>
    2.12 +#
    2.13 +
    2.14 +[ $(id -u) -ne 0 ] && echo "Must be root. Abort." && exit 1
    2.15 +
    2.16 +CURDIR=$PWD
    2.17 +TMPDIR=/tmp/rasp$$
    2.18 +mkdir -p $TMPDIR
    2.19 +cd $TMPDIR
    2.20 +DESTDIR=var/os/slitaz
    2.21 +URL=http://mirror.slitaz.org/arm/rpi/
    2.22 +wget -O - $URL | sed '/slitaz-rpi/!d;s/.*href=.\([a-zA-Z0-9._-]*\).*/\1/' | sort -r > index
    2.23 +VERSION="$(sed '/rpi-desktop/!d' index | sed 's/.*-desktop-\([0-9_-]*\).*/\1/;q')"
    2.24 +
    2.25 +wget -O - $URL$(sed '/rpi-base/!d;q' index) | tar xjf -
    2.26 +wget -O - $URL$(sed '/rpi-desktop/!d;q' index) | tar xjf -
    2.27 +
    2.28 +mkdir -p fs/$DESTDIR fs/boot/slitaz fs/boot/slitaz-base \
    2.29 +	 fs/boot/raspbian
    2.30 +
    2.31 +# setup boot configuration 
    2.32 +BASE=$(ls -d slitaz-rpi-base-*/boot)
    2.33 +[ ! -d "$BASE" ] && echo "Abort ($BASE) !" && exit 1
    2.34 +mv $BASE/kernel.img fs/boot/slitaz
    2.35 +cp $BASE/config.txt fs/boot/slitaz
    2.36 +cp $BASE/config.txt fs/boot/slitaz-base
    2.37 +echo "initrd rootfs-base.gz" >> fs/boot/slitaz/config.txt
    2.38 +echo "entry=SliTaz $VERSION on SD-card" > fs/boot/slitaz/menu.txt
    2.39 +sed -i 's|kernel.img|../slitaz/&|' fs/boot/slitaz-base/config.txt
    2.40 +cp -a fs/boot/slitaz-base fs/boot/slitaz-live
    2.41 +echo "initrd ../slitaz/rootfs-base.gz" >> fs/boot/slitaz-base/config.txt
    2.42 +echo "entry=SliTaz base $VERSION in RAM" > fs/boot/slitaz-base/menu.txt
    2.43 +echo "initrd ../slitaz/rootfs-base.gz ../slitaz/rootfs-live.gz" >> fs/boot/slitaz-live/config.txt
    2.44 +echo "entry=SliTaz desktop $VERSION in RAM" > fs/boot/slitaz-live/menu.txt
    2.45 +
    2.46 +# update base package
    2.47 +BASE=$(ls -d slitaz-rpi-base-*/rootfs)
    2.48 +[ ! -d "$BASE" ] && echo "Abort ($BASE) !" && exit 1
    2.49 +wget http://hg.slitaz.org/slitaz-arm/raw-file/tip/rpi/piboot
    2.50 +mv piboot $BASE/sbin
    2.51 +wget http://cook.slitaz.org/cross/arm/packages/packages.list
    2.52 +while read file pkg extra ; do
    2.53 +	[ -s boot$file ] && continue
    2.54 +	[ -n "$extra" ] && continue
    2.55 +	pkg=$(grep ^$pkg- packages.list | sort | sed q).tazpkg
    2.56 +	wget http://cook.slitaz.org/cross/arm/packages/$pkg
    2.57 +	tazpkg install $pkg --root=$BASE/
    2.58 +done <<EOT
    2.59 +/usr/lib/libz.so		zlib
    2.60 +/usr/sbin/kexec			kexec-tools
    2.61 +/usr/bin/tset			ncursesw
    2.62 +/usr/bin/dialog			dialog
    2.63 +/usr/lib/libxml2.so		libxml2			aria2
    2.64 +/usr/bin/gpg-error		libgpg-error		aria2
    2.65 +/usr/lib/libgcrypt.so		libgcrypt		aria2
    2.66 +/usr/lib/libgmp.so		gmp			aria2
    2.67 +/usr/lib/libnettle.so		nettle			aria2
    2.68 +/usr/share/terminfo/l/linux	ncurses-common		aria2
    2.69 +/lib/libncurses.so		ncurses			aria2
    2.70 +/usr/lib/libreadline.so		readline		aria2
    2.71 +/usr/lib/libstdc++.so		gcc-lib-base p11-kit	aria2
    2.72 +/usr/lib/libgnutls.so		libgnutls		aria2
    2.73 +/usr/lib/libcrypto.so		libcrypto		aria2
    2.74 +/usr/lib/libtasn1.so		libtasn1		aria2
    2.75 +/usr/bin/gnutls-cli		gnutls			aria2
    2.76 +/usr/bin/aria2c			aria2			aria2
    2.77 +EOT
    2.78 +
    2.79 +# deduplicate base & live
    2.80 +LIVE=$(ls -d slitaz-rpi-desktop-*/rootfs)
    2.81 +[ ! -d "$LIVE" ] && echo "Abort ($LIVE) !" && exit 1
    2.82 +LIVESZ=$(du -ks $LIVE | cut -f1)
    2.83 +( cd $BASE/ ; find ! -type d ) | while read file; do
    2.84 +	if [ -L $BASE/$file ]; then
    2.85 +		[ -L $LIVE/$file ] &&
    2.86 +		[ "$(readlink $BASE/$file)" == "$(readlink $LIVE/$file)" ] &&
    2.87 +		rm -f $LIVE/$file
    2.88 +	elif [ -f $BASE/$file ]; then
    2.89 +		[ -f $LIVE/$file ] &&
    2.90 +		cmp $BASE/$file $LIVE/$file > /dev/null 2>&1 &&
    2.91 +		rm -f $LIVE/$file
    2.92 +	elif [ -b $BASE/$file ]; then
    2.93 +		[ -b $LIVE/$file ] &&
    2.94 +		[ "$(stat -c '%a:%u:%g:%t:%T' $BASE/$file)" == \
    2.95 +		  "$(stat -c '%a:%u:%g:%t:%T' $LIVE/$file)" ] &&
    2.96 +		rm -f $LIVE/$file
    2.97 +	elif [ -c $BASE/$file ]; then
    2.98 +		[ -c $LIVE/$file ] &&
    2.99 +		[ "$(stat -c '%a:%u:%g:%t:%T' $BASE/$file)" == \
   2.100 +		  "$(stat -c '%a:%u:%g:%t:%T' $LIVE/$file)" ] &&
   2.101 +		rm -f $LIVE/$file
   2.102 +	fi
   2.103 +done
   2.104 +( cd $BASE/ ; find -type d ) | while read dir; do
   2.105 +	rmdir $LIVE/$file 2> /dev/null
   2.106 +done
   2.107 +
   2.108 +( cd $BASE ; find * | cpio -o -H newc ) | \
   2.109 +	gzip -9 > fs/boot/slitaz/rootfs-base.gz
   2.110 +( cd $LIVE ; find * | cpio -o -H newc ) | \
   2.111 +	gzip -9 > fs/boot/slitaz/rootfs-live.gz
   2.112 +
   2.113 +
   2.114 +# Create raspbian package
   2.115 +echo "2.0" > debian-binary
   2.116 +cat > control <<EOT
   2.117 +Package: slitaz
   2.118 +Version: $VERSION-1
   2.119 +Architecture: armhf
   2.120 +Maintainer: Pascal Bellard <pascal.bellard@slitaz.org>
   2.121 +Installed-Size: $(($(du -ks fs | cut -f1) + $LIVESZ))
   2.122 +Section: miscellaneous
   2.123 +Priority: optional
   2.124 +Homepage: http://arm.slitaz.org/
   2.125 +Description: Tiny Linux distribution with multi boot feature
   2.126 + SliTaz can run fully in RAM or can be installed on the SD card in a
   2.127 + subdirectory of your Raspbian (example /$DESTDIR).
   2.128 +EOT
   2.129 +( cd fs ; find * -type f -exec md5sum {} \; ) > md5sums
   2.130 +cat > postinst <<EOT
   2.131 +#!/bin/sh
   2.132 +
   2.133 +set -e
   2.134 +
   2.135 +cd /$DESTDIR
   2.136 +zcat /boot/slitaz/rootfs-base.gz | cpio -idmu
   2.137 +zcat /boot/slitaz/rootfs-core.gz | cpio -idmu
   2.138 +mkdir mnt/raspbian 2> /dev/null
   2.139 +cat >> etc/inittab <<EOM
   2.140 +\$RDEV	/mnt/raspbian	\$FSTYPE	defaults	0	0
   2.141 +tmpfs	/mnt/raspbian/$DESTDIR	tmpfs	size=0	0	0
   2.142 +EOM
   2.143 +cd -
   2.144 +
   2.145 +if [ ! -f /boot/menu.txt ]; then
   2.146 +
   2.147 +for i in i18n keyboard ; di
   2.148 +	[ -s /etc/sysconfig/\$i ] && . /etc/sysconfig/\$i
   2.149 +done
   2.150 +find /$DESTDIR/usr/share/kbd/keymaps | grep /\$KEYTABLE.map.gz\$ && KMAP=\$KEYTABLE
   2.151 +cat > /boot/menu.txt <<EOM
   2.152 +title=Raspberry PI boot menu
   2.153 +subtitle=Select the OS with ARROW keys and hit RETURN
   2.154 +timeout=30
   2.155 +default=raspbian
   2.156 +#kmap=\${KMAP:-us}
   2.157 +edittitle=Edit menu
   2.158 +#noedit
   2.159 +#webpath=http://my.home.web.site/pxe/rpi/index.php
   2.160 +EOM
   2.161 +cp /boot/config.txt /boot/raspbian/
   2.162 +mv /boot/\$(sed '/^kernel/!d;s/.*=//' /boot/config.txt) /boot/raspbian/
   2.163 +echo "entry=Raspbian \$(cat /etc/debian_version)" > /boot/raspbian/menu.txt
   2.164 +sed -i '/^kernel/d;/^initrd/d' /boot/config.txt
   2.165 +echo "kernel=slitaz/kernel.img" >> /boot/config.txt
   2.166 +echo "initrd=slitaz/rootfs-base.gz" >> /boot/config.txt
   2.167 +set -- \$(awk '/ \/ / { if (\$1 != "rootfs") print \$1 " " \$3 }')
   2.168 +RDEV=\$1
   2.169 +FSTYPE=\$2
   2.170 +echo "root=/dev/null rdinit=/sbin/piboot quiet" > /boot/cmdline.txt
   2.171 +echo "root=/dev/null mount=\$RDEV subroot=$DESTDIR rootwait quiet" > /boot/slitaz/cmdline.txt
   2.172 +if [ -s /$DESTDIR/usr/share/i18n/locales/\${LANG%.*} -a -n "\$KMAP" ]; then
   2.173 +	echo "root=/dev/null lang=\${LANG%.*} kmap=\$KMAP quiet"
   2.174 +else
   2.175 +	echo "root=/dev/null quiet"
   2.176 +fi > /boot/slitaz-base/cmdline.txt
   2.177 +cp /boot/slitaz-base/cmdline.txt /boot/slitaz-live/cmdline.txt
   2.178 +
   2.179 +fi
   2.180 +
   2.181 +exit 0
   2.182 +EOT
   2.183 +cat > postrm <<EOT
   2.184 +#!/bin/sh
   2.185 +
   2.186 +purge()
   2.187 +{
   2.188 +	rm -rf /$DESTDIR /boot/slitaz*
   2.189 +}
   2.190 +
   2.191 +disable()
   2.192 +{
   2.193 +	if [ -d /boot/rasbian ]; then
   2.194 +		mv -f /boot/rasbian/* /boot
   2.195 +		rm -rf /boot/rasbian
   2.196 +	fi
   2.197 +	rm -f /boot/menu.txt
   2.198 +}
   2.199 +
   2.200 +case "\$1" in
   2.201 +purge)
   2.202 +	disable
   2.203 +	purge
   2.204 +	;;
   2.205 +remove|upgrade|failed-upgrade|abort-install|abort-upgrade|disappear)
   2.206 +	disable
   2.207 +	;;
   2.208 +*)
   2.209 +	echo "postrm called with unknown argument \\\`\$1'" >&2
   2.210 +	exit 0
   2.211 +esac
   2.212 +EOT
   2.213 +chmod +x postinst postrm
   2.214 +tar czf control.tar.gz md5sums control postinst postrm
   2.215 +rm -rf fs/$DESTDIR/*
   2.216 +cd fs ; tar czf ../data.tar.gz . ; cd ..
   2.217 +[ -x /usr/bin/ar ] || tazpkg get-install binutils
   2.218 +ar rcs slitaz-$VERSION-1_armhf.deb debian-binary control.tar.gz data.tar.gz
   2.219 +mv slitaz-$VERSION-1_armhf.deb $CURDIR
   2.220 +cd $CURDIR
   2.221 +ls -l slitaz-$VERSION-1_armhf.deb