slitaz-arm view sat @ rev 104
Bunch of modif, use dillo and some fltk apps in next desktop release, better JWM menu, PiTFT info
author | Christophe Lincoln <pankso@slitaz.org> |
---|---|
date | Fri Apr 18 02:46:52 2014 +0200 (2014-04-18) |
parents | c6d3db386d89 |
children | 464a84405363 |
line source
1 #!/bin/sh
2 #
3 # Sat - SliTaz ARM Tool
4 #
5 # Copyright (C) 2012-2014 SliTaz ARM - 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: libtaz.sh set: --work= --init=
13 [ "$work" ] || work="$(pwd)"
14 [ "$init" ] || init="gz"
15 initramfs="slitaz-arm.$init"
16 packages="$work/packages"
17 distro="$work/distro"
18 flavors="$work/flavors"
19 rootfs="$distro/rootfs"
20 cache="$distro/cache"
22 # http://mirror.slitaz.org/packages/cooking/arm/
23 mirror="http://cook.slitaz.org/cross/arm/packages/"
25 #
26 # Functions
27 #
29 # Help and usage
30 usage() {
31 cat << EOT
33 $(boldify "Usage:") $(basename $0) [command|--options]
35 SliTaz ARM Tool - http://arm.slitaz.org
37 $(boldify "Commands:")
38 gen Generate a distro cpio/gzip initramfs
39 flavors List and give info about flavors
40 ckpkgs Distro packages dependencies check
41 clean Clean up the work directory
42 emu Emulate the distro with qemu-system-arm
43 mirror Download or sync the SliTaz ARM mirror
45 $(boldify "Options:")
46 --kmap Include the system keymap config in the distro
47 --spk Clean or include Spk package manager in the distro
48 --noinit Don't create the compressed initramfs
49 --work= Path to work dir with packages and rootfs
50 --size= Specify optional vdisk size (default 50Mb)
51 --init= Specify the initramfs compression: gz bz2 xz
52 --flavor= Generate specific SliTaz ARM flavor
53 --append= SliTaz and Kernel bootime arguments for Qemu
54 --debug Keep cache dir and display debugging info
56 EOT
57 }
59 # --> use libpkg.sh when released (function is shared with spk)
60 # Check mirror ID: return 1 if no changes or mirror unreachable
61 check_mirror_id() {
62 [ "$forced" ] && rm -f ID
63 [ -f "ID" ] || echo $$ > ID
64 mv ID ID.bak
65 if busybox wget -qs ${mirror%/}/ID 2>/dev/null; then
66 busybox wget -q ${mirror%/}/ID
67 else
68 echo "Mirror is unreachable"; newline
69 return 1
70 fi
71 if [ "$(cat ID)" == "$(cat ID.bak)" ]; then
72 echo "Mirror is up-to-date"; newline
73 return 1
74 fi
75 }
77 #
78 # Commands
79 #
81 case "$1" in
82 gen)
83 time=$(date +%s)
84 check_root
85 newline && boldify "Generating SliTaz ARM distro"
86 separator
87 rm -rf ${distro} && mkdir -p ${rootfs} ${cache}
89 # Get --flavor= packages lists
90 if [ "$flavor" ]; then
91 echo -n "Getting $flavor packages.list..."
92 cp -f $flavors/$flavor/packages.list ${cache} 2>/dev/null &&
93 cp -f $flavors/$flavor/flavor.conf ${cache} 2>/dev/null
94 status
95 fi
97 # Packages
98 rm -f ${cache}/packages.full
99 if [ -f "${cache}/packages.list" ]; then
100 for pkg in $(cat ${cache}/packages.list)
101 do
102 IFS="|"
103 grep "^$pkg |" $work/mirror/packages.desc | while read pkg version desc
104 do
105 echo ${pkg}-${version}-arm.tazpkg | sed s'/ //'g \
106 >> ${cache}/packages.full
107 done
108 unset IFS
109 done
110 cd ${work}/mirror
111 else
112 if [ ! -d "$packages" ]; then
113 echo "Missing distro/packages.list or packages/ directory"
114 echo "" && exit 1
115 fi
116 echo -n "Using packages directory..."
117 cd $packages && ls -1 >${cache}/packages.full
118 status
119 fi
121 # Deps install is not well handled by tazpkg/spk actually.
122 # So simply install all packages and don't resolve deps.
123 for pkg in $(cat ${cache}/packages.full)
124 do
125 pkgdir=$(basename $pkg .tazpkg)
126 db=${rootfs}/var/lib/tazpkg
127 echo -n "Installing: $(basename $pkg)"
128 tazpkg extract $pkg >/dev/null
129 . $pkgdir/receipt
130 mkdir -p $db/installed/$PACKAGE
131 cp $pkgdir/receipt $pkgdir/files.list \
132 $db/installed/$PACKAGE
133 cp -a $pkgdir/fs/* $distro/rootfs && rm -rf $pkgdir
134 md5sum $(basename $pkg) >> $db/installed.md5
135 status
136 done
138 # Install spk Hg if requested. Spk multiarch support must be tested
139 if [ "$spk" ]; then
140 hg=http://hg.slitaz.org
141 echo -n "Installing: spk ($hg)"
142 cd $work
143 [ -d "spk" ] || hg clone $hg/spk >/dev/null 2>/dev/null
144 cd $work/spk
145 [ "$noup" ] || hg pull -u >/dev/null
146 make DESTDIR=${rootfs} install >/dev/null
147 status
148 fi
150 # SLITAZ_ARCH
151 if [ -f "${rootfs}/etc/slitaz/slitaz.conf" ]; then
152 echo -n "Setting SliTaz arch to: arm"
153 sed -i s"/SLITAZ_ARCH=.*/SLITAZ_ARCH=\"arm\"/" \
154 ${rootfs}/etc/slitaz/slitaz.conf
155 status
156 else
157 echo -n "Missing distro: /etc/slitaz/slitaz.conf"; false
158 status && exit 1
159 fi
161 # Mirror
162 echo "$mirror" > ${rootfs}/var/lib/tazpkg/mirror
164 # /init & /var/run
165 cd ${rootfs}
166 rm init var/run && ln -s /bin/busybox init
167 mkdir -p run var/run
169 # Update modules.dep
170 if [ -f "var/lib/tazpkg/installed/linux/receipt" ]; then
171 . var/lib/tazpkg/installed/linux/receipt
172 depmod -b . ${VERSION}-slitaz
173 fi
175 # CGI Admin
176 if [ -d "$work/cgi-adm" ]; then
177 echo -n "Installing SliTaz ARM CGI Admin interface..."
178 mkdir -p ${rootfs}/var/www/adm
179 cp -a ${work}/cgi-adm/* ${rootfs}/var/www/adm
180 status
181 fi
183 # Custom rootfs: make sure all files belong to root
184 if [ -d "$work/rootfs" ]; then
185 size=$(du -sh $work/rootfs | awk '{print $1}')
186 echo -n "Copying custom ARM rootfs: $size"
187 tmp=$distro/tmp-$$
188 mkdir -p $tmp
189 cp -r $work/rootfs/* $tmp
190 chown -R root.root $tmp
191 cp -a $tmp/* ${rootfs} && rm -rf $tmp
192 status
193 fi
195 # Custom flavor rootfs
196 if [ -f "${cache}/flavor.conf" ]; then
197 . ${cache}/flavor.conf
198 fi
199 if [ -d "$flavors/${FLAVOR}/rootfs" ]; then
200 size=$(du -sh $flavors/${FLAVOR}/rootfs | awk '{print $1}')
201 echo -n "Copying ${FLAVOR} ARM rootfs: $size"
202 tmp=$distro/tmp-$$
203 mkdir -p $tmp
204 cp -r $flavors/${FLAVOR}/rootfs/* $tmp
205 chown -R root.root $tmp
206 cp -a $tmp/* ${rootfs} && rm -rf $tmp
207 status
208 fi
210 # --kmap
211 if [ "$kmap" ]; then
212 echo -n "Copying local: /etc/keymap.conf"
213 cp -f /etc/keymap.conf ${rootfs}/etc
214 status
215 fi
217 # Distro: /etc/slitaz/flavor.conf
218 if [ -f "${cache}/flavor.conf" ]; then
219 echo -n "Including $FLAVOR: flavor.conf"
220 echo "BUILD_DATE=\"$(date '+%Y%m%d')\"" >> ${cache}/flavor.conf
221 cp -f ${cache}/flavor.conf ${rootfs}/etc/slitaz
222 status
223 fi
225 # Move /boot outside the rootfs
226 mkdir -p ${rootfs}/boot
227 if [ "$(ls $rootfs/boot | wc -l)" != 0 ]; then
228 echo -n "Moving /boot outside the rootfs..."
229 mkdir -p ${distro}/boot
230 mv -f ${rootfs}/boot/* ${distro}/boot
231 status
233 # ! wok/linux pkg must be modified to install /boot/kernel.img
234 if ls ${distro}/boot/linux-* >/dev/null 2>/dev/null; then
235 mv ${distro}/boot/linux-* ${distro}/boot/kernel.img
236 chmod -x ${distro}/boot/kernel.img
237 fi
239 fi
241 # Rootfs cpio: gzip xz --> /usr/lib/slitaz/liblive.sh ???
242 if [ ! "$noinit" ]; then
243 echo -n "Compressing initramfs: $initramfs"
244 case "$initramfs" in
245 *.bz2) find . | cpio -o -H newc | bzip2 > ../$initramfs ;;
246 *.gz) find . | cpio -o -H newc | gzip -9 > ../$initramfs ;;
247 *.xz) find . | cpio -o -H newc | xz -9 --format=lzma > ../$initramfs ;;
248 esac
249 status
250 fi
252 # Clean if no debug mode
253 [ "$debug" ] || rm -rf ${cache}
255 # Summary
256 time=$(($(date +%s) - $time))
257 rootfs_size="$(du -sh ${rootfs} | awk '{print $1}')"
258 pkgs_count="$(ls $db/installed | wc -l)"
259 [ "$noinit" ] || \
260 initramfs_size="$(du -sh $distro/$initramfs | awk '{print $1}')"
261 separator && newline
262 boldify "SliTaz ARM distro summary"
263 separator
264 [ "$FLAVOR" ] && echo "Flavor name : $FLAVOR"
265 echo "Build time : ${time}s"
266 [ "$noinit" ] || echo "Initramfs : $initramfs"
267 [ "$noinit" ] || echo "Initramfs size : $initramfs_size"
268 echo "Rootfs size : $rootfs_size"
269 echo "Packages : $pkgs_count"
270 separator
271 [ "$rpi" ] || newline ;;
273 flavors)
274 newline
275 echo -n "$(boldify 'Flavor')" &&
276 echo -n "$(indent 12 $(boldify 'Packages'))"
277 indent 24 $(boldify 'Description')
278 separator
279 for flavor in $(ls $flavors)
280 do
281 . $flavors/$flavor/flavor.conf
282 pkgs=$(cat $flavors/$flavor/packages.list | wc -l)
283 echo -n "$flavor" &&
284 echo -n "$(indent 12 $pkgs)" && indent 24 "$SHORT_DESC"
285 unset SHORT_DESC
286 done
287 newline ;;
289 ckpkgs)
290 installed="${rootfs}/var/lib/tazpkg/installed"
291 SLITAZ_ARCH="arm"
292 count=0
293 if [ ! -d "$installed" ]; then
294 echo "Missing distro rootfs" && exit 1
295 fi
296 echo ""
297 echo -n "$(boldify 'Package name')"
298 indent 24 "$(boldify 'Missing dependencies')"
299 separator
300 for pkg in ${installed}/*
301 do
302 . $pkg/receipt
303 for dep in $DEPENDS
304 do
305 if [ ! -d "${installed}/$dep" ]; then
306 if [ ! "$raw" ]; then
307 echo -n "$(colorize 34 $PACKAGE)" && indent 24 "$dep"
308 else
309 echo "$dep"
310 fi
311 count=$(($count + 1))
312 fi
313 done
314 unset DEPENDS
315 done
316 if [ "$count" == 0 ]; then
317 echo "No missing dependencies"
318 fi
319 separator
320 echo -n "Installed packages: "; colorize 32 $(ls $installed | wc -l)
321 newline ;;
323 clean)
324 check_root
325 echo -n "Cleaning: distro"
326 rm -rf $distro && status
327 if [ "$spk" ]; then
328 echo -n "Cleaning: spk"
329 rm -rf $work/spk && status
330 fi ;;
332 emu)
333 cd $work
334 [ -f "vdisk.img" ] && opts="-hda vdisk.img"
335 [ "$append" ] && append="-append ${append}"
336 qemu-system-arm -m 256 ${opts} \
337 -M versatilepb -cpu arm1176 \
338 -kernel ${distro}/boot/kernel.img \
339 -initrd ${distro}/${initramfs} ${append} ;;
341 mirror)
342 #
343 # --> spk-mirror $mirror --sync --dest=/path ???
344 #
345 count=0
346 newline && boldify "Syncing SliTaz ARM mirror"
347 separator
348 mkdir -p $work/mirror && cd $work/mirror
350 echo -n "URL: " && colorize 34 "$mirror"
351 if ! check_mirror_id; then
352 exit 0
353 fi
354 for list in packages.list packages.desc packages.md5; do
355 echo -n "Fetching: $list"
356 rm -f $list && wget -q ${mirror%/}/$list
357 status
358 done
359 echo -n "Checking packages $SUM..."
360 for pkg in $(cat $work/mirror/packages.list); do
361 pkg=${pkg}.tazpkg
362 if [ ! -f "$pkg" ]; then
363 count=$(($count + 1))
364 [ "$count" == 1 ] && newline
365 echo -n "Fetching: ${pkg}"
366 wget -q ${mirror%/}/$pkg
367 status
368 fi
369 pkgsum=$($CHECKSUM $pkg)
370 debug "$pkgsum"
371 [ "$pkgsum" ] || pkgsum=$$
372 mirsum=$(fgrep -h $pkgsum packages.$SUM)
373 debug "$mirsum"
374 if [ ! "$pkgsum" == "$mirsum" ]; then
375 count=$(($count + 1))
376 [ "$count" == 1 ] && newline
377 echo -n "Fetching: ${pkg}.tazpkg"
378 rm -f $pkg
379 wget -q ${mirror%/}/$pkg
380 status
381 fi
382 done
383 [ "$count" == 0 ] && status
384 separator && newline ;;
386 *) usage ;;
387 esac
388 exit 0