slitaz-arm view sat @ rev 10

Update the README
author Christophe Lincoln <pankso@slitaz.org>
date Fri May 25 23:00:33 2012 +0200 (2012-05-25)
parents 41bdd0275ceb
children 9d5bbd785383
line source
1 #!/bin/sh
2 #
3 # Sat - SliTaz ARM Tool
4 #
5 # Copyright (C) 2012 SliTaz GNU/Linux - BSD License
6 # Author: Christophe Lincoln <pankso@slitaz.org>
7 #
8 . /lib/libtaz.sh
9 #. /usr/lib/slitaz/libpkg.sh
10 . /etc/slitaz/slitaz.conf
12 # Internal variables.
13 : ${work=$(pwd)}
14 packages=$work/packages
15 distro=$work/distro
16 # http://mirror.slitaz.org/packages/cooking/arm/
17 mirror="http://cook.slitaz.org/cross/arm/packages/"
18 # libtaz.sh handle: --init=
19 [ "$init" ] || init="gz"
20 initramfs="slitaz-arm.$init"
22 # Help and usage
23 usage() {
24 cat << EOT
26 $(boldify "Usage:") $(basename $0) [command|--options]
28 $(boldify "Commands:")
29 gen Generate a disto cpio/gzip initramfs
30 clean Clean up the work directory
31 vdisk Create a virtual disk to be used by Qemu
32 emu Emulate the distro with qemu-system-arm
33 mirror Download or sync the SliTaz ARM mirror
35 $(boldify "Options:")
36 --kmap Dump current keymap and include it in distro
37 --spk Include Spk package manager in the distro
38 --work= Path to work dir with packages and rootfs
39 --size= Specify optional vdisk size (default 20Mb)
40 --init= Specify the initramfs compression: gz xz
42 EOT
43 }
45 # --> use libpkg.sh when release (function is shared with spk)
46 # Check mirror ID: return 1 if no changes or mirror unreachable
47 check_mirror_id() {
48 [ "$forced" ] && rm -f ID
49 [ -f "ID" ] || echo $$ > ID
50 mv ID ID.bak
51 if wget -qs ${mirror%/}/ID; then
52 wget -q ${mirror%/}/ID
53 else
54 gettext "Mirror is unreachable"; false
55 status && return 1
56 fi
57 if [ "$(cat ID)" == "$(cat ID.bak)" ]; then
58 gettext "Mirror is up-to-date"; true
59 status && return 1
60 fi
61 }
63 #
64 # Commands
65 #
67 case "$1" in
68 gen)
69 time=$(date +%s)
70 check_root
71 rm -rf $distro slitaz-arm.xz
72 mkdir -p $distro
74 # Packages. Dep install it not well handled by tazpkg/spk actually
75 # so simply install all packages and dont resolv deps or use equiv.
76 cd $packages
77 for pkg in $packages/*.tazpkg
78 do
79 pkgdir=$(basename $pkg .tazpkg)
80 db=$distro/var/lib/tazpkg
81 echo -n "Installing: $(basename $pkg)"
82 tazpkg extract $pkg >/dev/null
83 . $pkgdir/receipt
84 mkdir -p $db/installed/$PACKAGE
85 cp $pkgdir/receipt $pkgdir/files.list \
86 $db/installed/$PACKAGE
87 cp -a $pkgdir/fs/* $distro && rm -rf $pkgdir
88 md5sum $(basename $pkg) >> $db/installed.md5
89 status
90 done
92 # Install spk if requested. Spk multiarch support must be tested
93 if [ "$spk" ]; then
94 hg=http://hg.slitaz.org
95 echo -n "Installing: spk ($hg)"
96 cd $work
97 [ -d "spk" ] || hg clone $hg/spk >/dev/null
98 cd $work/spk
99 [ "$noup" ] || hg pull -u >/dev/null
100 make DESTDIR=$distro install >/dev/null
101 status
102 fi
104 # Move kernel outside the distro
105 cd $work && mv -f $distro/boot/linux-* linux-arm
107 # Get a default kmap: we kbd-base and tazkeymap working now :-)
108 if [ "$kmap" ]; then
109 echo -n "Dumping current keymap..."
110 mkdir $distro/usr/share/kmap
111 /bin/busybox dumpkmap > $distro/usr/share/kmap/default.kmap
112 status
113 fi
115 # Fixes: udev not yet cross-compiled
116 echo -n "Applying SliTaz ARM fixes..."
117 sed -i s"/UDEV=.*/UDEV=\"\"/" $distro/etc/rcS.conf
118 status
120 # SLITAZ_ARCH
121 echo -n "Setting SliTaz arch to: arm"
122 sed -i s"/SLITAZ_ARCH=.*/SLITAZ_ARCH=\"arm\"/" \
123 $distro/etc/slitaz/slitaz.conf
124 status
126 # Mirror
127 echo "$mirror" > $distro/var/lib/tazpkg/mirror
129 # /usr/cross/arm/lib: Must be FIXED when cross-compiling
130 # Only used by Busybox before LD_LIBRARY_PATH is set.
131 mkdir -p $distro/usr/cross/arm/lib
132 cd $distro/usr/cross/arm/lib
133 ln -s /lib/libc-2.13.so libc.so.6
134 ln -s /lib/ld-2.13.so ld-linux.so.3
135 cd $distro
137 # /init
138 rm init && ln -s /bin/busybox init
140 # Update modules.dep
141 depmod -b . 3.2.14-slitaz
143 # Custom rootfs
144 if [ -d "$work/rootfs" ]; then
145 echo -n "Copying custom ARM rootfs..."
146 cp -r $work/rootfs/* $distro
147 status
148 fi
150 # Rootfs cpio: gzip xz
151 echo -n "Compressing initramfs: slitaz-arm.$format"
152 case $format in
153 bz) find . | cpio -o -H newc | bzip2 > ../$initramfs ;;
154 gz) find . | cpio -o -H newc | gzip -9 > ../$initramfs ;;
155 xz) find . | cpio -o -H newc | xz -9 --format=lzma \
156 > ../$initramfs ;;
157 esac
158 status
159 time=$(($(date +%s) - $time))
160 echo "Build time : ${time}s"
161 echo -n "Distro size : "
162 cd $work && du -sh $initramfs | awk '{print $1}' ;;
163 clean)
164 check_root
165 for r in distro linux-arm *.*z spk; do
166 echo -n "Cleaning: $r"
167 rm -rf $work/$r && status
168 done ;;
169 vdisk)
170 # Let use and HD in Qemu to store files|packages|whatever
171 vdisk="vdisk.img"
172 : ${size=20}
173 cd $work
174 dd if=/dev/zero of=$vdisk bs=1M count=$size
175 mkfs.ext4 -q -T ext4 -L "SliTaz" -F $vdisk ;;
176 emu)
177 cd $work
178 [ -f "vdisk.img" ] && opts="-hda vdisk.img"
179 qemu-system-arm -m 256 $opts \
180 -M versatilepb -cpu arm1176 \
181 -kernel linux-arm \
182 -initrd $initramfs ;;
183 mirror)
184 #
185 # --> spk-mirror $mirror --sync --dest=/path ???
186 #
187 count=0
188 mkdir -p $work/mirror && cd $work/mirror
189 if ! check_mirror_id; then
190 exit 0
191 fi
192 for list in packages.list packages.desc packages.md5; do
193 echo -n "Fetching: $list"
194 rm -f $list && wget -q ${mirror%/}/$list
195 status
196 done
197 echo -n "Checking packages $SUM..."
198 for pkg in $(cat $work/mirror/packages.list); do
199 pkg=${pkg}.tazpkg
200 if [ ! -f "$pkg" ]; then
201 count=$(($count + 1))
202 [ "$count" == 1 ] && newline
203 echo -n "Fetching: ${pkg}.tazpkg"
204 wget -q ${mirror%/}/$pkg
205 status
206 fi
207 pkgsum=$($CHECKSUM $pkg)
208 debug "$pkgsum"
209 [ "$pkgsum" ] || pkgsum=$$
210 mirsum=$(fgrep -h $pkgsum packages.$SUM)
211 debug "$mirsum"
212 if [ ! "$pkgsum" == "$mirsum" ]; then
213 count=$(($count + 1))
214 [ "$count" == 1 ] && newline
215 echo -n "Fetching: ${pkg}.tazpkg"
216 rm -f $pkg
217 wget -q ${mirror%/}/$pkg
218 status
219 fi
220 done
221 [ "$count" == 0 ] && status
222 ;;
223 *) usage ;;
224 esac
225 exit 0