wok-6.x view memtest/stuff/pack @ rev 14207
w3m: config receipt to use patches
author | Richard Dunbar <mojo@slitaz.org> |
---|---|
date | Fri Mar 15 13:42:03 2013 +0000 (2013-03-15) |
parents | e76c37f7bfe6 |
children | 8d9ce0de31e0 |
line source
1 #!/bin/sh
2 if [ "$1" == "--build" ]; then
3 bin=${2:-unpack.bin}
4 cat >> $0 <<EOM
5 $(gzip -9 < $bin | uuencode -m -)
6 EOT
7 EOM
8 getip=$(grep -s getip ${bin/.bin/.lst}|sed '$!d;s/.*t:\([^ ]*\).*/\1/')
9 sed -i "s/XXX/$((515+0x${getip:-5}))/" $0
10 sed -i '/--build/,/^fi/d' $0
11 exit
12 fi
14 store()
15 {
16 n=$1
17 for i in $(seq 1 $4); do
18 printf '\\\\x%02X' $(($n & 255))
19 n=$(($n >> 8))
20 done | xargs echo -en | dd conv=notrunc bs=1 of=$2 seek=$3
21 }
23 compress()
24 {
25 lzma e -si -so
26 }
28 main()
29 {
30 dd if=$1 bs=512 count=1 >$2
31 uudecode | gunzip >>$2
32 setup="$(echo $(od -j 497 -N 1 -dAn $1))"
33 syssize="$(echo $(od -j 500 -N 2 -dAn $1))"
34 dd if=$1 bs=512 count=$setup skip=1 | compress >>$2
35 dd if=$1 bs=16 count=$syssize skip=$((32*(1+$setup))) | compress >>$2
36 size=$(stat -c %s $2)
37 store $((($size-512)/16)) $2 XXX 2
38 store $((($size-2560)/16)) $2 500 2
39 store 4 $2 497 1
40 }
42 main $1 $2 2>/dev/null <<EOT