slitaz-arm rev 206
Add tazarch
author | Pascal Bellard <pascal.bellard@slitaz.org> |
---|---|
date | Wed Mar 18 19:00:17 2015 +0100 (2015-03-18) |
parents | 66ddc0b26133 |
children | 1d2bad01f3d3 |
files | rpi/tazarch rpi/tazbian |
line diff
1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 1.2 +++ b/rpi/tazarch Wed Mar 18 19:00:17 2015 +0100 1.3 @@ -0,0 +1,1 @@ 1.4 +tazbian 1.5 \ No newline at end of file
2.1 --- a/rpi/tazbian Thu Feb 05 08:53:57 2015 +0000 2.2 +++ b/rpi/tazbian Wed Mar 18 19:00:17 2015 +0100 2.3 @@ -10,11 +10,15 @@ 2.4 2.5 [ $(id -u) -ne 0 ] && echo "Must be root. Abort." && exit 1 2.6 2.7 +DESCRIPTION="Tiny Linux distribution with multi boot features" 2.8 +WEB_SITE="http://arm.slitaz.org/rpi/" 2.9 +MAINTAINER="Pascal Bellard <pascal.bellard@slitaz.org>" 2.10 + 2.11 tazpkg() 2.12 { 2.13 if [ -x /usr/bin/tazpkg ]; then 2.14 /usr/bin/tazpkg "$@" 2.15 - exit $? 2.16 + return $? 2.17 fi 2.18 [ "$1" == "get-install" ] && echo "abort: can't find $2" && exit 1 2.19 mkdir -p tazpkg$$ 2.20 @@ -37,7 +41,8 @@ 2.21 rm -rf tazpkg$$ 2.22 } 2.23 2.24 -[ -x /usr/bin/ar -o -x /bin/ar ] || tazpkg get-install binutils 2.25 +buildfs() 2.26 +{ 2.27 CURDIR=$PWD 2.28 EXE=$(cd $(dirname $0); pwd)/$(basename $0) 2.29 TMPDIR=/tmp/rasp$$ 2.30 @@ -52,7 +57,7 @@ 2.31 wget -O - $URL$(sed '/rpi-desktop/!d;q' index) | tar xjf - 2.32 2.33 mkdir -p fs/$DESTDIR fs/boot/slitaz fs/boot/slitaz-base \ 2.34 - fs/boot/raspbian 2.35 + fs/boot/$raspos 2.36 2.37 # setup boot configuration 2.38 BASE=$(ls -d slitaz-rpi-base-*/boot) 2.39 @@ -145,28 +150,11 @@ 2.40 advdef -z4 fs/boot/slitaz/rootfs-base.gz 2.41 advdef -z4 fs/boot/slitaz/rootfs-live.gz 2.42 fi 2.43 +} 2.44 2.45 -# Create raspbian package 2.46 -echo "2.0" > debian-binary 2.47 -cat > control <<EOT 2.48 -Package: slitaz 2.49 -Version: $VERSION-1 2.50 -Architecture: armhf 2.51 -Maintainer: Pascal Bellard <pascal.bellard@slitaz.org> 2.52 -Installed-Size: $(($(du -ks fs | cut -f1) + $LIVESZ)) 2.53 -Section: miscellaneous 2.54 -Priority: optional 2.55 -Homepage: http://arm.slitaz.org/rpi/ 2.56 -Description: Tiny Linux distribution with multi boot features 2.57 - SliTaz can run fully in RAM or can be installed on the SD card in a 2.58 - subdirectory of your Raspbian (example /$DESTDIR). 2.59 -EOT 2.60 -( cd fs ; find * -type f -exec md5sum {} \; ) > md5sums 2.61 -cat > postinst <<EOT 2.62 -#!/bin/sh 2.63 - 2.64 -set -e 2.65 - 2.66 +mkpostinst() 2.67 +{ 2.68 + cat <<EOT 2.69 RDEV=\$(sed 's/.*root=\([^ ]*\).*/\1/' /boot/cmdline.txt) 2.70 FSTYPE=\$(awk '/ \/ / { if (\$1 != "rootfs") print \$3 }' < /proc/mounts) 2.71 2.72 @@ -174,13 +162,13 @@ 2.73 cd /$DESTDIR 2.74 zcat /boot/slitaz/rootfs-base.gz | cpio -idmu 2.75 zcat /boot/slitaz/rootfs-live.gz | cpio -idmu 2.76 -if ! grep -qs raspbian etc/fstab ; then 2.77 +if ! grep -qs $raspos etc/fstab ; then 2.78 echo "Update /$DESTDIR/etc/fstab ..." 2.79 - mkdir -p mnt/raspbian 2.80 + mkdir -p mnt/$raspos 2.81 sed -i 's/noauto,//' etc/fstab 2.82 cat >> etc/fstab <<EOM 2.83 -\$RDEV /mnt/raspbian \$FSTYPE noatime 0 0 2.84 -tmpfs /mnt/raspbian/$DESTDIR tmpfs size=0 0 0 2.85 +\$RDEV /mnt/$raspos \$FSTYPE noatime 0 0 2.86 +tmpfs /mnt/$raspos/$DESTDIR tmpfs size=0 0 0 2.87 EOM 2.88 fi 2.89 cd - > /dev/null 2.90 @@ -197,7 +185,7 @@ 2.91 title=Raspberry PI boot menu 2.92 subtitle=Select the OS with ARROW keys and hit RETURN 2.93 timeout=30 2.94 -default=raspbian 2.95 +default=$raspos 2.96 \$KMAP 2.97 edittitle=Edit menu 2.98 readonly 2.99 @@ -206,9 +194,9 @@ 2.100 #webpath=http://my.home.web.site/pxe/rpi/index.php http://or.this.one/rpi.txt 2.101 EOM 2.102 KERNEL=\$(sed '/^kernel/!d;s/.*=//' /boot/config.txt) 2.103 -cp /boot/config.txt /boot/cmdline.txt /boot/raspbian/ 2.104 -mv /boot/\${KERNEL:-kernel.img} /boot/raspbian/ 2.105 -echo "entry=Raspbian \$(cat /etc/debian_version)" > /boot/raspbian/menu.txt 2.106 +cp /boot/config.txt /boot/cmdline.txt /boot/$raspos/ 2.107 +mv /boot/\${KERNEL:-kernel.img} /boot/$raspos/ 2.108 +echo "entry=$menustr" > /boot/$raspos/menu.txt 2.109 sed -i '/^kernel/d;/^initramfs/d' /boot/config.txt 2.110 echo "kernel=slitaz/kernel.img" >> /boot/config.txt 2.111 echo "initramfs slitaz/rootfs-base.gz" >> /boot/config.txt 2.112 @@ -222,26 +210,67 @@ 2.113 fi 2.114 2.115 echo "The SliTaz boot menu is available for the next (re)boot." 2.116 +EOT 2.117 +} 2.118 + 2.119 +mkpurge() 2.120 +{ 2.121 + cat <<EOT 2.122 + echo "Remove /$DESTDIR & /boot/slitaz* trees..." 2.123 + rm -rf /$DESTDIR /boot/slitaz* 2.124 +EOT 2.125 +} 2.126 + 2.127 +mkdisable() 2.128 +{ 2.129 + cat <<EOT 2.130 + if [ -d /boot/$raspos ]; then 2.131 + echo "Restore $raspos boot files..." 2.132 + rm -f /boot/$raspos/menu.txt 2.133 + mv -f /boot/$raspos/* /boot 2.134 + fi 2.135 + rm -f /boot/menu.txt /boot/slitaz*/cmdline.txt 2.136 +EOT 2.137 +} 2.138 + 2.139 +pkgdebian() 2.140 +{ 2.141 + # Create raspbian package 2.142 + echo "2.0" > debian-binary 2.143 + cat > control <<EOT 2.144 +Package: slitaz 2.145 +Version: $VERSION-1 2.146 +Architecture: armhf 2.147 +Maintainer: $MAINTAINER 2.148 +Installed-Size: $(($(du -ks fs | cut -f1) + $LIVESZ)) 2.149 +Section: miscellaneous 2.150 +Priority: optional 2.151 +Homepage: $WEB_SITE 2.152 +Description: $DESCRIPTION 2.153 + SliTaz can run fully in RAM or can be installed on the SD card in a 2.154 + subdirectory of your Raspbian (example /$DESTDIR). 2.155 +EOT 2.156 + ( cd fs ; find * -type f -exec md5sum {} \; ) > md5sums 2.157 + cat > postinst <<EOT 2.158 +#!/bin/sh 2.159 + 2.160 +set -e 2.161 + 2.162 +$(mkpostinst) 2.163 2.164 exit 0 2.165 EOT 2.166 -cat > prerm <<EOT 2.167 + cat > prerm <<EOT 2.168 #!/bin/sh 2.169 2.170 purge() 2.171 { 2.172 - echo "Remove /$DESTDIR & /boot/slitaz* trees..." 2.173 - rm -rf /$DESTDIR /boot/slitaz* 2.174 +$(mkpurge) 2.175 } 2.176 2.177 disable() 2.178 { 2.179 - if [ -d /boot/raspbian ]; then 2.180 - echo "Restore raspbian boot files..." 2.181 - rm -f /boot/raspbian/menu.txt 2.182 - mv -f /boot/raspbian/* /boot 2.183 - fi 2.184 - rm -f /boot/menu.txt /boot/slitaz*/cmdline.txt 2.185 +$(mkdisable) 2.186 } 2.187 2.188 case "\$1" in 2.189 @@ -257,12 +286,83 @@ 2.190 exit 0 2.191 esac 2.192 EOT 2.193 -chmod +x postinst prerm 2.194 -tar czf control.tar.gz md5sums control postinst prerm 2.195 -rm -rf fs/$DESTDIR/* 2.196 -cd fs ; tar czf ../data.tar.gz . ; cd .. 2.197 -ar rcs slitaz-$VERSION-1_armhf.deb debian-binary control.tar.gz data.tar.gz 2.198 -mv slitaz-$VERSION-1_armhf.deb $CURDIR 2.199 -cd $CURDIR 2.200 -rm -rf $TMPDIR 2.201 -ls -l slitaz-$VERSION-1_armhf.deb 2.202 + chmod +x postinst prerm 2.203 + tar czf control.tar.gz md5sums control postinst prerm 2.204 + rm -rf fs/$DESTDIR/* 2.205 + cd fs ; tar czf ../data.tar.gz . ; cd .. 2.206 + ar rcs slitaz-$VERSION-1_armhf.deb debian-binary control.tar.gz data.tar.gz 2.207 + mv slitaz-$VERSION-1_armhf.deb $CURDIR 2.208 + cd $CURDIR 2.209 + rm -rf $TMPDIR 2.210 + ls -l slitaz-$VERSION-1_armhf.deb 2.211 +} 2.212 + 2.213 +mkmtree() 2.214 +{ 2.215 + echo "#mtree" 2.216 + echo "/set type=file uid=0 gid=0 mode=644" 2.217 + find .??* * | while read file; do 2.218 + echo -n "$file $(stat -c "time=%Y.000000" "$file")" 2.219 + n="$(stat -c "%a" "$file")"; [ "$n" == "644" ] || echo -n " mode=$n" 2.220 + n="$(stat -c "%u" "$file")"; [ "$n" == "0" ] || echo -n " uid=$n" 2.221 + n="$(stat -c "%g" "$file")"; [ "$n" == "0" ] || echo -n " gid=$n" 2.222 + if [ -f "$file" ]; then 2.223 + echo -n " $(stat -c "size=%s" "$file")" 2.224 + echo -n " md5digest=$(md5sum "$file" | sed 's/ .*//')" 2.225 + echo -n " sha256digest=$(sha256sum "$file" | sed 's/ .*//')" 2.226 + fi 2.227 + [ -d "$file" ] && echo -n " type=dir" 2.228 + echo "" 2.229 + done 2.230 +} 2.231 + 2.232 +pkgarch() 2.233 +{ 2.234 + cd fs 2.235 + VERSION=$VERSION-1 2.236 + # Create arch package 2.237 + cat > .PKGINFO <<EOT 2.238 +pkgname = slitaz 2.239 +pkgver = $VERSION 2.240 +pkgdesc = $DESCRIPTION 2.241 +url = $WEB_SITE 2.242 +builddate = $(date +%s) 2.243 +packager = $MAINTAINER 2.244 +size = $(du -s . | awk "{ print \$1*1024+$LIVESZ }") 2.245 +arch = armv6h 2.246 +license = GPL 2.247 +EOT 2.248 + cat > .INSTALL <<EOT 2.249 +post_install() { 2.250 +$(mkpostinst) 2.251 +} 2.252 + 2.253 +post_remove() { 2.254 +$(mkdisable) 2.255 +$(mkpurge) 2.256 +} 2.257 +EOT 2.258 + mkmtree | gzip -9 > ../.MTREE 2.259 + mv ../.MTREE . 2.260 + tar cvzf ../slitaz-$VERSION-armv6h.pkg.tar.gz .??* * 2.261 + mv ../slitaz-$VERSION-armv6h.pkg.tar.gz $CURDIR 2.262 + cd $CURDIR 2.263 + rm -rf $TMPDIR 2.264 + ls -l slitaz-$VERSION-armv6h.pkg.tar.gz 2.265 +} 2.266 + 2.267 +case "$(basename $0)" in 2.268 +tazarch) 2.269 + raspos=archarm 2.270 + menustr="Arch Linux ARM \\\$(uname -r)" 2.271 + buildfs 2.272 + pkgarch 2.273 + ;; 2.274 +*) 2.275 + [ -x /usr/bin/ar -o -x /bin/ar ] || tazpkg get-install binutils 2.276 + raspos=raspbian 2.277 + menustr="Raspbian \\\$(cat /etc/debian_version)" 2.278 + buildfs 2.279 + pkgdebian 2.280 + ;; 2.281 +esac