wok view linld/stuff/tobzimage @ rev 18611
Up slitaz-tools(959)
author | Aleksej Bobylev <al.bobylev@gmail.com> |
---|---|
date | Tue Nov 17 16:13:43 2015 +0200 (2015-11-17) |
parents | 38b9b5003833 |
children | 86c9fae82f47 |
line source
1 #!/bin/sh
3 if [ "$1" == "--build" ]; then #install-begin
4 cat tobzimage.bin | gzip -9 | uuencode -m - | sed \
5 -e '/^tobzimage$/r/dev/stdin' -e '/^tobzimage$/d' \
6 -e '/install-begin$/,/install-end$/d' -i $0
7 exit
8 fi #install-end
9 [ -s "$1" -a "$2" ] || {
10 cat << EOT
11 Usage: $0 zImage-to-read bzImage-to-create [version-string]
12 EOT
13 exit 1
14 }
16 ddq()
17 {
18 dd "$@" 2> /dev/null
19 }
21 get()
22 {
23 echo $( od -v -j $(($1)) -N ${4:-${3:-2}} -t u${3:-2} -w${3:-2} \
24 -An $2 2>/dev/null )
25 }
27 store()
28 {
29 n=$3; for i in $(seq 8 8 $1); do
30 printf '\\\\x%02X' $(($n & 255))
31 n=$(($n >> 8))
32 done | xargs echo -en | ddq bs=1 conv=notrunc of=$4 seek=$(($2))
33 }
35 create_bzImage()
36 {
37 ddq bs=512 count=1 of=$1
38 # from http://hg.slitaz.org/wok/file/7184ec55b1aa/linux/stuff/linux-header.u
39 uudecode <<EOT | ddq of=$1 conv=notrunc
40 begin-base64 644 -
41 TVrrIEAAAAACAAAQ//8ACASeAABfAvD/TmV4dCEHDQA/owCeUuiwAZkfoPF9
42 QA+hxXd4XwZXsQbzpRYfZGaPR3jGRfg/+pdYQejIAL4AAoFMECCAxkQlm+hv
43 AVuJ5v9IEMdAFAiTgPMIdfOhFQJmix70AWZLZsHrBWZDvwAQOcd1AzWAFolE
44 G2a/gAAAAGYp+5xzAgHfUFZTMdtoAIAH6GEAW16MwbSHFgfNFVgFAAEQTB+/
45 gAedd8WITB/GRBwQx0QTgAa0h80Vl80T6gAAIJBaOMF3NGDNE/noeABhUlAo
46 yHcCsAE5+HICifhQtALNE1pYctyVAdGO6QDXANcp11p0UozplTjBddSIyLEB
47 MM51zP7FgP1QdcW1AGC+GABT6KoAW+g+AHUVUpjNE7gBAs0TWtDUOmT+depG
48 SHXm650x0ugAAAYftD+J+cHhCInrzSGSFh+wMRwDtA67BwDNEDwNdPPDv2wE
49 ZMYFprgNAWQ6JXQKzRZ09JjNFo7nR8PoVgCg0QJAvoAAigxG86SXgHz/P77g
50 AnQyDwHgJAF1K45fLEM5D3X7jVcEtD3NIXInleiM/4AGoAA9uwICOV8EcgXH
51 RyeeCR5qTMsDdA6wDeiH/6w8AH/4w16/xp1oAJAXifwWBzHAuTsA86pPW1bD
52 AA==
53 ====
54 EOT
55 # from tobzimage.S
56 uudecode <<EOT | gunzip >> $1
57 tobzimage
58 EOT
59 if [ "$2" ]; then
60 s="$2"
61 [ -s "$2" ] && s="$(cat "$2")"
62 echo -e "\n$2" | tr '\n' '\r' | cat - /dev/zero | \
63 dd conv=notrunc of=$1 bs=1 seek=640 count=383
64 fi
65 setupsz=$(get 497 $1 1)
66 [ $setupsz -eq 0 ] && setupsz=4
67 ddq bs=512 count=$setupsz >> $1
68 store 8 497 $(($setupsz+1)) $1
69 ddq >> $1
70 }
72 create_bzImage $2 "$3" < $1