wok-next annotate memtest/stuff/pack @ rev 13727

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