slitaz-arm diff rpi/tazbian @ rev 210
tazbian: rpi2+ support
author | Pascal Bellard <pascal.bellard@slitaz.org> |
---|---|
date | Sun Mar 27 12:20:30 2016 +0200 (2016-03-27) |
parents | 1d2bad01f3d3 |
children | 425bf14d2b84 |
line diff
1.1 --- a/rpi/tazbian Sat Aug 08 23:42:01 2015 +0200 1.2 +++ b/rpi/tazbian Sun Mar 27 12:20:30 2016 +0200 1.3 @@ -1,6 +1,6 @@ 1.4 #!/bin/sh 1.5 # 1.6 -# (C) 2014-2015 SliTaz GNU/Linux - GPL2 1.7 +# (C) 2014-2016 SliTaz GNU/Linux - GPL2 1.8 # 1.9 # Creates a Debian package to install SliTaz on a Raspbian without 1.10 # repartitioning. 1.11 @@ -10,6 +10,7 @@ 1.12 1.13 [ $(id -u) -ne 0 ] && echo "Must be root. Abort." && exit 1 1.14 1.15 +REVISION=2 1.16 DESTDIR=var/os/slitaz 1.17 DESCRIPTION="Tiny Linux distribution with multi boot features" 1.18 LONG_DESCRIPTION="SliTaz can run fully in RAM or can be installed \ 1.19 @@ -19,17 +20,17 @@ 1.20 1.21 tazpkg() 1.22 { 1.23 - if [ -x /usr/bin/tazpkg ]; then 1.24 + if [ -x /usr/bin/tazpkg -a "$1" == "get-install" ]; then 1.25 /usr/bin/tazpkg "$@" 1.26 return $? 1.27 fi 1.28 [ "$1" == "get-install" ] && echo "abort: can't find $2" && exit 1 1.29 mkdir -p tazpkg$$ 1.30 cd tazpkg$$ 1.31 - cpio -i < ../$2 1.32 + cpio -i < ../$2 > /dev/null 2>&1 1.33 gunzip fs.cpio.gz 2> /dev/null 1.34 [ -s fs.cpio ] || unlzma fs.cpio.lzma 1.35 - cpio -idmu < fs.cpio 1.36 + cpio -idmu < fs.cpio > /dev/null 2>&1 1.37 cd .. 1.38 sh <<EOT 1.39 . tazpkg$$/receipt 1.40 @@ -47,50 +48,72 @@ 1.41 buildfs() 1.42 { 1.43 CURDIR=$PWD 1.44 -EXE=$(cd $(dirname $0); pwd)/$(basename $0) 1.45 TMPDIR=/tmp/rasp$$ 1.46 mkdir -p $TMPDIR 1.47 cd $TMPDIR 1.48 URL=http://mirror.slitaz.org/arm/rpi/ 1.49 +echo "Read $URL" 1.50 wget -O - $URL | sed '/slitaz-rpi/!d;s/.*href=.\([a-zA-Z0-9._-]*\).*/\1/' | sort -r > index 1.51 VERSION="$(sed '/rpi-desktop/!d' index | sed 's/.*-desktop-\([0-9_-]*\).*/\1/;q')" 1.52 1.53 -wget -O - $URL$(sed '/rpi-base/!d;q' index) | tar xjf - 1.54 -wget -O - $URL$(sed '/rpi-desktop/!d;q' index) | tar xjf - 1.55 +for file in $(sed '/rpi-base/!d;q' index) $(sed '/rpi-desktop/!d;q' index); do 1.56 + echo "Get $file " 1.57 + wget -O - $URL$file | tar xjf - 1.58 +done 1.59 1.60 -mkdir -p fs/$DESTDIR fs/boot/slitaz fs/boot/slitaz-base \ 1.61 +mkdir -p fs/$DESTDIR fs/boot/slitaz fs/boot/slitaz-base fs/boot/slitaz-live \ 1.62 fs/boot/$raspos 1.63 1.64 +BOOT=$(ls -d slitaz-rpi-base-*/boot) 1.65 +[ ! -d "$BOOT" ] && echo "Abort ($BOOT) !" && exit 1 1.66 + 1.67 # setup boot configuration 1.68 -BASE=$(ls -d slitaz-rpi-base-*/boot) 1.69 -[ ! -d "$BASE" ] && echo "Abort ($BASE) !" && exit 1 1.70 -mv $BASE/kernel.img fs/boot/slitaz 1.71 -cp $BASE/config.txt fs/boot/slitaz 1.72 -cp $BASE/config.txt fs/boot/slitaz-base 1.73 +echo "entry=SliTaz $VERSION on SD-card" > fs/boot/slitaz/menu.txt 1.74 +echo "entry=SliTaz base $VERSION in RAM" > fs/boot/slitaz-base/menu.txt 1.75 +echo "entry=SliTaz desktop $VERSION in RAM" > fs/boot/slitaz-live/menu.txt 1.76 +cp $BOOT/config.txt fs/boot/slitaz 1.77 +grep -q ^kernel= fs/boot/slitaz/config.txt || 1.78 +echo "kernel=kernel.img >> fs/boot/slitaz/config.txt" 1.79 +sed -i '/^initramfs/d' fs/boot/slitaz/config.txt 1.80 +cp fs/boot/slitaz/config.txt fs/boot/slitaz-base 1.81 +cp fs/boot/slitaz/config.txt fs/boot/slitaz-live 1.82 echo "initramfs rootfs-base.gz" >> fs/boot/slitaz/config.txt 1.83 -echo "entry=SliTaz $VERSION on SD-card" > fs/boot/slitaz/menu.txt 1.84 -sed -i 's|kernel.img|../slitaz/&|' fs/boot/slitaz-base/config.txt 1.85 -cp -a fs/boot/slitaz-base fs/boot/slitaz-live 1.86 echo "initramfs ../slitaz/rootfs-base.gz" >> fs/boot/slitaz-base/config.txt 1.87 -echo "entry=SliTaz base $VERSION in RAM" > fs/boot/slitaz-base/menu.txt 1.88 -echo "initramfs ../slitaz/rootfs-base.gz ../slitaz/rootfs-live.gz" >> fs/boot/slitaz-live/config.txt 1.89 -echo "entry=SliTaz desktop $VERSION in RAM" > fs/boot/slitaz-live/menu.txt 1.90 +echo "initramfs ../slitaz/rootfs-base.gz,../slitaz/rootfs-live.gz" >> fs/boot/slitaz-live/config.txt 1.91 + 1.92 +if [ -s $BOOT/kernel7.img ]; then 1.93 + mv $BOOT/kernel*.img fs/boot/slitaz 1.94 + sed -i 's|kernel.img|../slitaz/&|' fs/boot/slitaz-*/config.txt 1.95 +else 1.96 + rm -rf slitaz-rpi-*/boot/kernel.img \ 1.97 + slitaz-rpi-*/rootfs/lib/modules/* \ 1.98 + slitaz-rpi-*/rootfs/lib/firmware/* 1.99 + sed -i 's|kernel.img|../&|' fs/boot/slitaz-*/config.txt 1.100 +fi 1.101 1.102 # update base package 1.103 BASE=$(ls -d slitaz-rpi-base-*/rootfs) 1.104 +[ ! -d "$BASE" ] && echo "Abort ($BASE) !" && exit 1 1.105 LIVE=$(ls -d slitaz-rpi-desktop-*/rootfs) 1.106 [ ! -d "$LIVE" ] && echo "Abort ($LIVE) !" && exit 1 1.107 LIVESZ=$(du -ks $LIVE | cut -f1) 1.108 -[ ! -d "$BASE" ] && echo "Abort ($BASE) !" && exit 1 1.109 wget http://hg.slitaz.org/slitaz-arm/raw-file/tip/rpi/piboot 1.110 wget http://hg.slitaz.org/slitaz-boot-scripts/raw-file/tip/init 1.111 chmod +x piboot init 1.112 mv piboot $BASE/sbin 1.113 sed -i 's|mnt /mnt|mnt "/mnt -o noatime"|' init 1.114 -mv init $BASE/sbin/pisubroot 1.115 +sed -i 's#.*remount,ro#grep -q "tmpfs /mnt tmpfs" /proc/mounts || &#' init 1.116 mknod -m 660 $BASE/dev/mmcblk0 b 179 0 1.117 -mknod -m 660 $BASE/dev/mmcblk0p1 b 179 1 1.118 -mknod -m 660 $BASE/dev/mmcblk0p2 b 179 2 1.119 +for i in $(seq 1 5); do 1.120 + mknod -m 660 $BASE/dev/mmcblk0p$i b 179 $i 1.121 +done 1.122 +grep /dev/pts $BASE/etc/fstab || cat >> $BASE/etc/fstab <<EOT 1.123 +devpts /dev/pts devpts rw,gid=5,mode=0620 0 0 1.124 +EOT 1.125 + 1.126 +[ -s slitaz-rpi-base*/boot/kernel7.img ] || 1.127 +sed -i 's#.*d /proc/sys/dev/cdrom#grep -q subroot= /proc/cmdline || for d in /dev/mmc*p[2-9]; do\n\tumount /mnt\n\tmount -r $d /mnt \&\&\n\tcp -a /mnt/lib/firmware /lib/ \&\&\n\tcp -a /mnt/lib/modules/$(uname -r) /lib/modules/ \&\& break\ndone 2> /dev/null\numount /mnt\n\n&#' init 1.128 +mv init $BASE/rdinit 1.129 sed -i 's/.*mmcblk0p[2-9].*/# &/;s/noatime/noauto,&/' $BASE/etc/fstab $LIVE/etc/fstab 1.130 wget http://cook.slitaz.org/cross/arm/packages/packages.list 1.131 while read file pkg extra ; do 1.132 @@ -117,7 +140,7 @@ 1.133 /usr/bin/aria2c aria2 aria2 1.134 EOT 1.135 1.136 -# deduplicate base & live 1.137 +echo "Deduplicate base & live" 1.138 ( cd $BASE/ ; find ! -type d ) | while read file; do 1.139 if [ -L $BASE/$file ]; then 1.140 [ -L $LIVE/$file ] && 1.141 @@ -139,31 +162,45 @@ 1.142 rm -f $LIVE/$file 1.143 fi 1.144 done 1.145 -cp $EXE $BASE/root/ 1.146 ( cd $BASE/ ; find -type d ) | while read dir; do 1.147 rmdir $LIVE/$dir 2> /dev/null 1.148 done 1.149 1.150 -( cd $BASE ; find * | cpio -o -H newc ) | \ 1.151 - gzip -9 > fs/boot/slitaz/rootfs-base.gz 1.152 -( cd $LIVE ; find * | cpio -o -H newc ) | \ 1.153 - gzip -9 > fs/boot/slitaz/rootfs-live.gz 1.154 -if [ -x /usr/bin/advdef ]; then 1.155 - advdef -z4 fs/boot/slitaz/rootfs-base.gz 1.156 - advdef -z4 fs/boot/slitaz/rootfs-live.gz 1.157 -fi 1.158 +while read dir suffix ; do 1.159 + echo "Build $suffix archive" 1.160 + ( cd $dir ; find * | cpio -o -H newc ) | if [ -x /usr/bin/zopfli ]; then 1.161 + cat > fs/boot/slitaz/rootfs-$suffix 1.162 + zopfli fs/boot/slitaz/rootfs-$suffix 1.163 + rm -f fs/boot/slitaz/rootfs-$suffix 1.164 + else 1.165 + gzip -9 > fs/boot/slitaz/rootfs-$suffix.gz 1.166 + fi 1.167 + [ -x /usr/bin/advdef ] && advdef -z4 fs/boot/slitaz/rootfs-$suffix.gz 1.168 + r=$(($(stat -c %s fs/boot/slitaz/rootfs-$suffix.gz) % 4)) 1.169 + [ $r -eq 0 ] || dd if=/dev/zero bs=1 count=$((4 - $r)) \ 1.170 + >> fs/boot/slitaz/rootfs-$suffix.gz 2> /dev/null 1.171 +done <<EOT 1.172 +$BASE base 1.173 +$LIVE live 1.174 +EOT 1.175 } 1.176 1.177 mkpostinst() 1.178 { 1.179 cat <<EOT 1.180 -RDEV=\$(sed 's/.*root=\([^ ]*\).*/\1/' /boot/cmdline.txt) 1.181 +RDEV=\$(sed 's/^\(\|.* \)root=\([^ ]*\).*/\2/' /boot/cmdline.txt) 1.182 FSTYPE=\$(awk '/ \/ / { if (\$1 != "rootfs") print \$3 }' < /proc/mounts) 1.183 1.184 echo "Extracting /$DESTDIR ..." 1.185 cd /$DESTDIR 1.186 zcat /boot/slitaz/rootfs-base.gz | cpio -idmu 1.187 zcat /boot/slitaz/rootfs-live.gz | cpio -idmu 1.188 +EOT 1.189 + [ -s slitaz-rpi-base*/boot/kernel7.img ] || cat <<EOT 1.190 +echo "Get modules & firmwares ..." 1.191 +cp -a /lib/modules /lib/firmware lib 1.192 +EOT 1.193 + cat <<EOT 1.194 if ! grep -qs $raspos etc/fstab ; then 1.195 echo "Update /$DESTDIR/etc/fstab ..." 1.196 mkdir -p mnt/$raspos 1.197 @@ -175,11 +212,7 @@ 1.198 fi 1.199 cd - > /dev/null 1.200 1.201 -if ! grep -qs ARMv6-compatible /proc/cpuinfo ; then 1.202 - 1.203 -echo "CPU unknown. Can't update /boot. Not RPI model 1?" 1.204 - 1.205 -elif [ ! -f /boot/menu.txt ]; then 1.206 +if [ ! -f /boot/menu.txt ]; then 1.207 1.208 echo "Update /boot ..." 1.209 for i in keyboard locale ; do 1.210 @@ -190,7 +223,7 @@ 1.211 cat > /boot/menu.txt <<EOM 1.212 title=Raspberry PI boot menu 1.213 subtitle=Select the OS with ARROW keys and hit RETURN 1.214 -timeout=30 1.215 +timeout=10 1.216 default=$raspos 1.217 \$KMAP 1.218 edittitle=Edit menu 1.219 @@ -199,18 +232,27 @@ 1.220 #nowebboot 1.221 #webpath=http://my.home.web.site/pxe/rpi/index.php http://or.this.one/rpi.txt 1.222 EOM 1.223 +echo "entry=$menustr" > /boot/$raspos/menu.txt 1.224 KERNEL=\$(sed '/^kernel/!d;s/.*=//' /boot/config.txt) 1.225 cp /boot/config.txt /boot/cmdline.txt /boot/$raspos/ 1.226 +sed -i '/^initramfs/d' /boot/config.txt 1.227 +echo "initramfs slitaz/rootfs-base.gz" >> /boot/config.txt 1.228 +EOT 1.229 + [ -s slitaz-rpi-base*/boot/kernel7.img ] && cat <<EOT 1.230 mv /boot/\${KERNEL:-kernel.img} /boot/$raspos/ 1.231 -echo "entry=$menustr" > /boot/$raspos/menu.txt 1.232 -sed -i '/^kernel/d;/^initramfs/d' /boot/config.txt 1.233 +sed -i '/^kernel/d' /boot/config.txt 1.234 echo "kernel=slitaz/kernel.img" >> /boot/config.txt 1.235 -echo "initramfs slitaz/rootfs-base.gz" >> /boot/config.txt 1.236 -echo "root=/dev/null rdinit=/sbin/piboot quiet" > /boot/cmdline.txt 1.237 +EOT 1.238 + cat <<EOT 1.239 L= 1.240 -[ -s /$DESTDIR/usr/share/i18n/locales/\${LANG%.*} ] && L=lang=\${LANG%.*} 1.241 -echo "root=/dev/null \$L \$KMAP rdinit=/sbin/pisubroot mount=\$RDEV subroot=$DESTDIR rootwait quiet" > /boot/slitaz/cmdline.txt 1.242 -echo "root=/dev/null \$L \$KMAP quiet" > /boot/slitaz-base/cmdline.txt 1.243 +for i in \$LANG \${LANG%.*} \${LANG%@*} \${LANG%_*} ; do 1.244 + [ -s /$DESTDIR/usr/share/i18n/locales/\$i ] && L=lang=\$i 1.245 +done 1.246 +TZ=\$(cat /etc/timezone 2> /dev/null || true) 1.247 +X="\$L \$KMAP \${TZ:+tz=\$TZ} quiet" 1.248 +echo "\$(cat /boot/cmdline.txt) \$X rdinit=/sbin/piboot" > /boot/cmdline.txt 1.249 +echo "root=/dev/null \$X rdinit=/rdinit mount=\$RDEV subroot=$DESTDIR rootwait" > /boot/slitaz/cmdline.txt 1.250 +echo "root=/dev/null \$X" > /boot/slitaz-base/cmdline.txt 1.251 cp /boot/slitaz-base/cmdline.txt /boot/slitaz-live/cmdline.txt 1.252 echo "The SliTaz boot menu is available for the next (re)boot." 1.253 1.254 @@ -233,6 +275,7 @@ 1.255 echo "Restore $raspos boot files..." 1.256 rm -f /boot/$raspos/menu.txt 1.257 mv -f /boot/$raspos/* /boot 1.258 + rmdir /boot/$raspos 1.259 fi 1.260 rm -f /boot/menu.txt /boot/slitaz*/cmdline.txt 1.261 EOT 1.262 @@ -244,7 +287,7 @@ 1.263 echo "2.0" > debian-binary 1.264 cat > control <<EOT 1.265 Package: slitaz 1.266 -Version: $VERSION-1 1.267 +Version: $VERSION-$REVISION 1.268 Architecture: armhf 1.269 Maintainer: $MAINTAINER 1.270 Installed-Size: $(($(du -ks fs | cut -f1) + $LIVESZ)) 1.271 @@ -252,7 +295,7 @@ 1.272 Priority: optional 1.273 Homepage: $WEB_SITE 1.274 Description: $DESCRIPTION 1.275 -$(echo $LONG_DESCRIPTION | sed 's/^/ /') 1.276 +$(echo -e $LONG_DESCRIPTION | sed 's/^/ /') 1.277 EOT 1.278 ( cd fs ; find * -type f -exec md5sum {} \; ) > md5sums 1.279 cat > postinst <<EOT 1.280 @@ -294,11 +337,11 @@ 1.281 tar czf control.tar.gz md5sums control postinst prerm 1.282 rm -rf fs/$DESTDIR/* 1.283 cd fs ; tar czf ../data.tar.gz . ; cd .. 1.284 - ar rcs slitaz-$VERSION-1_armhf.deb debian-binary control.tar.gz data.tar.gz 1.285 - mv slitaz-$VERSION-1_armhf.deb $CURDIR 1.286 + ar rcs slitaz-$VERSION-${REVISION}_armhf.deb debian-binary control.tar.gz data.tar.gz 1.287 + mv slitaz-$VERSION-${REVISION}_armhf.deb $CURDIR 1.288 cd $CURDIR 1.289 rm -rf $TMPDIR 1.290 - ls -l slitaz-$VERSION-1_armhf.deb 1.291 + ls -l slitaz-$VERSION-${REVISION}_armhf.deb 1.292 } 1.293 1.294 mkmtree() 1.295 @@ -323,7 +366,7 @@ 1.296 pkgarch() 1.297 { 1.298 cd fs 1.299 - VERSION=$VERSION-1 1.300 + VERSION=$VERSION-$REVISION 1.301 # Create arch package 1.302 cat > .PKGINFO <<EOT 1.303 pkgname = slitaz 1.304 @@ -358,14 +401,14 @@ 1.305 case "$(basename $0)" in 1.306 tazarch) 1.307 raspos=archarm 1.308 - menustr="Arch Linux ARM \\\$(uname -r)" 1.309 + menustr="Arch Linux ARM \$(uname -r)" 1.310 buildfs 1.311 pkgarch 1.312 ;; 1.313 *) 1.314 [ -x /usr/bin/ar -o -x /bin/ar ] || tazpkg get-install binutils 1.315 raspos=raspbian 1.316 - menustr="Raspbian \\\$(cat /etc/debian_version)" 1.317 + menustr="Raspbian \$(cat /etc/debian_version)" 1.318 buildfs 1.319 pkgdebian 1.320 ;;