slitaz-arm rev 1
Add 'sat' aka Slitaz ARM Tool
author | Christophe Lincoln <pankso@slitaz.org> |
---|---|
date | Thu May 24 21:54:54 2012 +0200 (2012-05-24) |
parents | 462255ba106e |
children | b10f51049b8e |
files | sat |
line diff
1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 1.2 +++ b/sat Thu May 24 21:54:54 2012 +0200 1.3 @@ -0,0 +1,154 @@ 1.4 +#!/bin/sh 1.5 +# 1.6 +# Sat - SliTaz ARM Tool 1.7 +# 1.8 +# Copyright (C) 2012 SliTaz GNU/Linux - BSD License 1.9 +# Author: Christophe Lincoln <pankso@slitaz.org> 1.10 +# 1.11 +. /lib/libtaz.sh 1.12 + 1.13 +# Internal variables. 1.14 +: ${work=$(pwd)} 1.15 +packages=$work/packages 1.16 +distro=$work/distro 1.17 + 1.18 +# Help and usage 1.19 +usage() { 1.20 + cat << EOT 1.21 + 1.22 +$(boldify "Usage:") $(basename $0) [command|--options] 1.23 + 1.24 +$(boldify "Commands:") 1.25 + gen Generate a disto cpio/gzip initramfs 1.26 + clean Clean up the work directory 1.27 + vdisk Create a virtual disk to be used by Qemu 1.28 + emu Emulate the distro with qemu-system-arm 1.29 + 1.30 +$(boldify "Options:") 1.31 + --kmap Dump current keymap and include it in distro 1.32 + --spk Include Spk package manager in the distro 1.33 + --work= Path to work dir with packages and rootfs 1.34 + --size= Specify optional vdisk size (default 20Mb) 1.35 + 1.36 +EOT 1.37 +} 1.38 + 1.39 +# 1.40 +# Commands 1.41 +# 1.42 + 1.43 +case "$1" in 1.44 + gen) 1.45 + time=$(date +%s) 1.46 + check_root 1.47 + rm -rf $distro distro-arm.gz 1.48 + mkdir -p $distro 1.49 + 1.50 + # Packages. Dep install it not well handled by tazpkg/spk actually 1.51 + # so simply install all packages and dont resolv deps or use equiv. 1.52 + cd $packages 1.53 + for pkg in $packages/*.tazpkg 1.54 + do 1.55 + pkgdir=$(basename $pkg .tazpkg) 1.56 + echo -n "Installing: $(basename $pkg)" 1.57 + tazpkg extract $pkg >/dev/null 1.58 + . $pkgdir/receipt 1.59 + mkdir -p $distro/var/lib/tazpkg/installed/$PACKAGE 1.60 + cp $pkgdir/receipt $pkgdir/files.list \ 1.61 + $distro/var/lib/tazpkg/installed/$PACKAGE 1.62 + cp -a $pkgdir/fs/* $distro && rm -rf $pkgdir 1.63 + status 1.64 + done 1.65 + 1.66 + # Install spk if requested. Spk multiarch support must be tested 1.67 + if [ "$spk" ]; then 1.68 + hg=http://hg.slitaz.org 1.69 + echo -n "Installing: spk ($hg)" 1.70 + cd $work 1.71 + [ -d "spk" ] || hg clone $hg/spk >/dev/null 1.72 + cd spk 1.73 + [ "$noup" ] || hg pull -u >/dev/null 1.74 + make DESTDIR=$distro install >/dev/null 1.75 + status 1.76 + fi 1.77 + 1.78 + # Move kernel outside the distro 1.79 + cd $work && mv -f $distro/boot/linux-* linux-arm 1.80 + 1.81 + # Get a default kmap 1.82 + if [ "$kmap" ]; then 1.83 + echo -n "Dumping current keymap..." 1.84 + mkdir $distro/usr/share/kmap 1.85 + /bin/busybox dumpkmap > $distro/usr/share/kmap/default.kmap 1.86 + status 1.87 + fi 1.88 + 1.89 + # Fixes: udev not yet cross-compiled 1.90 + echo -n "Applying SliTaz ARM fixes..." 1.91 + sed -i s"/UDEV=.*/UDEV=\"\"/" $distro/etc/rcS.conf 1.92 + status 1.93 + 1.94 + # SLITAZ_ARCH 1.95 + echo -n "Setting SliTaz arch to: arm" 1.96 + sed -i s"/SLITAZ_ARCH=.*/SLITAZ_ARCH=\"arm\"/" \ 1.97 + $distro/etc/slitaz/slitaz.conf 1.98 + status 1.99 + 1.100 + # Mirror --> http://mirror.slitaz.org/packages/cooking/arm/ 1.101 + echo 'http://cook.slitaz.org/cross/arm/packages/' \ 1.102 + > $distro/var/lib/tazpkg/mirror 1.103 + #wget -q http://cook.slitaz.org/cross/arm/packages/packages.desc \ 1.104 + #-O $distro/var/lib/tazpkg/packages.desc 1.105 + 1.106 + # /usr/cross/arm/lib: Must be FIXED when cross-compiling 1.107 + # Only used by Busybox before LD_LIBRARY_PATH is set. 1.108 + mkdir -p $distro/usr/cross/arm/lib 1.109 + cd $distro/usr/cross/arm/lib 1.110 + ln -s /lib/libc-2.13.so libc.so.6 1.111 + ln -s /lib/ld-2.13.so ld-linux.so.3 1.112 + cd $distro 1.113 + 1.114 + # /init 1.115 + rm init && ln -s /bin/busybox init 1.116 + 1.117 + # Update modules.dep 1.118 + depmod -b . 3.2.14-slitaz 1.119 + 1.120 + # Custom rootfs 1.121 + if [ -d "$work/rootfs" ]; then 1.122 + echo -n "Copying custom ARM rootfs..." 1.123 + cp -r $work/rootfs/* $distro 1.124 + status 1.125 + fi 1.126 + 1.127 + # Rootfs cpio/gzip 1.128 + echo -n "Compressing initramfs: cpio/gzip" 1.129 + find . -print | cpio -o -H newc | gzip -9 > ../distro-arm.gz 1.130 + status 1.131 + time=$(($(date +%s) - $time)) 1.132 + echo "Build time : ${time}s" 1.133 + echo -n "Distro size : " 1.134 + cd $work && du -sh distro-arm.gz | awk '{print $1}';; 1.135 + clean) 1.136 + check_root 1.137 + echo -n "Cleaning: $work" 1.138 + rm -rf distro linux-arm distro-arm.gz spk 1.139 + status ;; 1.140 + vdisk) 1.141 + # Let use and HD in Qemu to store files|packages|whatever 1.142 + vdisk="vdisk.img" 1.143 + : ${size=20} 1.144 + cd $work 1.145 + dd if=/dev/zero of=$vdisk bs=1M count=$size 1.146 + mkfs.ext4 -q -T ext4 -L "SliTaz" -F $vdisk ;; 1.147 + emu) 1.148 + : ${mem=256} 1.149 + cd $work 1.150 + [ -f "vdisk.img" ] && opts="-hda vdisk.img" 1.151 + qemu-system-arm -m $mem $opts \ 1.152 + -M versatilepb -cpu arm1176 \ 1.153 + -kernel linux-arm \ 1.154 + -initrd distro-arm.gz ;; 1.155 + *) usage ;; 1.156 +esac 1.157 +exit 0