slitaz-arm annotate sat @ 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 | |
children | e885f2eb3b08 |
rev | line source |
---|---|
pankso@1 | 1 #!/bin/sh |
pankso@1 | 2 # |
pankso@1 | 3 # Sat - SliTaz ARM Tool |
pankso@1 | 4 # |
pankso@1 | 5 # Copyright (C) 2012 SliTaz GNU/Linux - BSD License |
pankso@1 | 6 # Author: Christophe Lincoln <pankso@slitaz.org> |
pankso@1 | 7 # |
pankso@1 | 8 . /lib/libtaz.sh |
pankso@1 | 9 |
pankso@1 | 10 # Internal variables. |
pankso@1 | 11 : ${work=$(pwd)} |
pankso@1 | 12 packages=$work/packages |
pankso@1 | 13 distro=$work/distro |
pankso@1 | 14 |
pankso@1 | 15 # Help and usage |
pankso@1 | 16 usage() { |
pankso@1 | 17 cat << EOT |
pankso@1 | 18 |
pankso@1 | 19 $(boldify "Usage:") $(basename $0) [command|--options] |
pankso@1 | 20 |
pankso@1 | 21 $(boldify "Commands:") |
pankso@1 | 22 gen Generate a disto cpio/gzip initramfs |
pankso@1 | 23 clean Clean up the work directory |
pankso@1 | 24 vdisk Create a virtual disk to be used by Qemu |
pankso@1 | 25 emu Emulate the distro with qemu-system-arm |
pankso@1 | 26 |
pankso@1 | 27 $(boldify "Options:") |
pankso@1 | 28 --kmap Dump current keymap and include it in distro |
pankso@1 | 29 --spk Include Spk package manager in the distro |
pankso@1 | 30 --work= Path to work dir with packages and rootfs |
pankso@1 | 31 --size= Specify optional vdisk size (default 20Mb) |
pankso@1 | 32 |
pankso@1 | 33 EOT |
pankso@1 | 34 } |
pankso@1 | 35 |
pankso@1 | 36 # |
pankso@1 | 37 # Commands |
pankso@1 | 38 # |
pankso@1 | 39 |
pankso@1 | 40 case "$1" in |
pankso@1 | 41 gen) |
pankso@1 | 42 time=$(date +%s) |
pankso@1 | 43 check_root |
pankso@1 | 44 rm -rf $distro distro-arm.gz |
pankso@1 | 45 mkdir -p $distro |
pankso@1 | 46 |
pankso@1 | 47 # Packages. Dep install it not well handled by tazpkg/spk actually |
pankso@1 | 48 # so simply install all packages and dont resolv deps or use equiv. |
pankso@1 | 49 cd $packages |
pankso@1 | 50 for pkg in $packages/*.tazpkg |
pankso@1 | 51 do |
pankso@1 | 52 pkgdir=$(basename $pkg .tazpkg) |
pankso@1 | 53 echo -n "Installing: $(basename $pkg)" |
pankso@1 | 54 tazpkg extract $pkg >/dev/null |
pankso@1 | 55 . $pkgdir/receipt |
pankso@1 | 56 mkdir -p $distro/var/lib/tazpkg/installed/$PACKAGE |
pankso@1 | 57 cp $pkgdir/receipt $pkgdir/files.list \ |
pankso@1 | 58 $distro/var/lib/tazpkg/installed/$PACKAGE |
pankso@1 | 59 cp -a $pkgdir/fs/* $distro && rm -rf $pkgdir |
pankso@1 | 60 status |
pankso@1 | 61 done |
pankso@1 | 62 |
pankso@1 | 63 # Install spk if requested. Spk multiarch support must be tested |
pankso@1 | 64 if [ "$spk" ]; then |
pankso@1 | 65 hg=http://hg.slitaz.org |
pankso@1 | 66 echo -n "Installing: spk ($hg)" |
pankso@1 | 67 cd $work |
pankso@1 | 68 [ -d "spk" ] || hg clone $hg/spk >/dev/null |
pankso@1 | 69 cd spk |
pankso@1 | 70 [ "$noup" ] || hg pull -u >/dev/null |
pankso@1 | 71 make DESTDIR=$distro install >/dev/null |
pankso@1 | 72 status |
pankso@1 | 73 fi |
pankso@1 | 74 |
pankso@1 | 75 # Move kernel outside the distro |
pankso@1 | 76 cd $work && mv -f $distro/boot/linux-* linux-arm |
pankso@1 | 77 |
pankso@1 | 78 # Get a default kmap |
pankso@1 | 79 if [ "$kmap" ]; then |
pankso@1 | 80 echo -n "Dumping current keymap..." |
pankso@1 | 81 mkdir $distro/usr/share/kmap |
pankso@1 | 82 /bin/busybox dumpkmap > $distro/usr/share/kmap/default.kmap |
pankso@1 | 83 status |
pankso@1 | 84 fi |
pankso@1 | 85 |
pankso@1 | 86 # Fixes: udev not yet cross-compiled |
pankso@1 | 87 echo -n "Applying SliTaz ARM fixes..." |
pankso@1 | 88 sed -i s"/UDEV=.*/UDEV=\"\"/" $distro/etc/rcS.conf |
pankso@1 | 89 status |
pankso@1 | 90 |
pankso@1 | 91 # SLITAZ_ARCH |
pankso@1 | 92 echo -n "Setting SliTaz arch to: arm" |
pankso@1 | 93 sed -i s"/SLITAZ_ARCH=.*/SLITAZ_ARCH=\"arm\"/" \ |
pankso@1 | 94 $distro/etc/slitaz/slitaz.conf |
pankso@1 | 95 status |
pankso@1 | 96 |
pankso@1 | 97 # Mirror --> http://mirror.slitaz.org/packages/cooking/arm/ |
pankso@1 | 98 echo 'http://cook.slitaz.org/cross/arm/packages/' \ |
pankso@1 | 99 > $distro/var/lib/tazpkg/mirror |
pankso@1 | 100 #wget -q http://cook.slitaz.org/cross/arm/packages/packages.desc \ |
pankso@1 | 101 #-O $distro/var/lib/tazpkg/packages.desc |
pankso@1 | 102 |
pankso@1 | 103 # /usr/cross/arm/lib: Must be FIXED when cross-compiling |
pankso@1 | 104 # Only used by Busybox before LD_LIBRARY_PATH is set. |
pankso@1 | 105 mkdir -p $distro/usr/cross/arm/lib |
pankso@1 | 106 cd $distro/usr/cross/arm/lib |
pankso@1 | 107 ln -s /lib/libc-2.13.so libc.so.6 |
pankso@1 | 108 ln -s /lib/ld-2.13.so ld-linux.so.3 |
pankso@1 | 109 cd $distro |
pankso@1 | 110 |
pankso@1 | 111 # /init |
pankso@1 | 112 rm init && ln -s /bin/busybox init |
pankso@1 | 113 |
pankso@1 | 114 # Update modules.dep |
pankso@1 | 115 depmod -b . 3.2.14-slitaz |
pankso@1 | 116 |
pankso@1 | 117 # Custom rootfs |
pankso@1 | 118 if [ -d "$work/rootfs" ]; then |
pankso@1 | 119 echo -n "Copying custom ARM rootfs..." |
pankso@1 | 120 cp -r $work/rootfs/* $distro |
pankso@1 | 121 status |
pankso@1 | 122 fi |
pankso@1 | 123 |
pankso@1 | 124 # Rootfs cpio/gzip |
pankso@1 | 125 echo -n "Compressing initramfs: cpio/gzip" |
pankso@1 | 126 find . -print | cpio -o -H newc | gzip -9 > ../distro-arm.gz |
pankso@1 | 127 status |
pankso@1 | 128 time=$(($(date +%s) - $time)) |
pankso@1 | 129 echo "Build time : ${time}s" |
pankso@1 | 130 echo -n "Distro size : " |
pankso@1 | 131 cd $work && du -sh distro-arm.gz | awk '{print $1}';; |
pankso@1 | 132 clean) |
pankso@1 | 133 check_root |
pankso@1 | 134 echo -n "Cleaning: $work" |
pankso@1 | 135 rm -rf distro linux-arm distro-arm.gz spk |
pankso@1 | 136 status ;; |
pankso@1 | 137 vdisk) |
pankso@1 | 138 # Let use and HD in Qemu to store files|packages|whatever |
pankso@1 | 139 vdisk="vdisk.img" |
pankso@1 | 140 : ${size=20} |
pankso@1 | 141 cd $work |
pankso@1 | 142 dd if=/dev/zero of=$vdisk bs=1M count=$size |
pankso@1 | 143 mkfs.ext4 -q -T ext4 -L "SliTaz" -F $vdisk ;; |
pankso@1 | 144 emu) |
pankso@1 | 145 : ${mem=256} |
pankso@1 | 146 cd $work |
pankso@1 | 147 [ -f "vdisk.img" ] && opts="-hda vdisk.img" |
pankso@1 | 148 qemu-system-arm -m $mem $opts \ |
pankso@1 | 149 -M versatilepb -cpu arm1176 \ |
pankso@1 | 150 -kernel linux-arm \ |
pankso@1 | 151 -initrd distro-arm.gz ;; |
pankso@1 | 152 *) usage ;; |
pankso@1 | 153 esac |
pankso@1 | 154 exit 0 |