wok-6.x view linld/stuff/tobzimage @ rev 18228
linld: add tobzimage
author | Pascal Bellard <pascal.bellard@slitaz.org> |
---|---|
date | Thu Jul 23 09:44:18 2015 +0200 (2015-07-23) |
parents | |
children | 347588653a93 |
line source
1 #!/bin/sh
3 [ -s "$1" -a "$2" ] || {
4 cat << EOT
5 Usage: $0 zImage-to-read bzImage-to-create [version-string]
6 EOT
7 exit 1
8 }
10 ddq()
11 {
12 dd "$@" 2> /dev/null
13 }
15 get()
16 {
17 echo $( od -v -j $(($1)) -N ${4:-${3:-2}} -t u${3:-2} -w${3:-2} \
18 -An $2 2>/dev/null )
19 }
21 store()
22 {
23 n=$3; for i in $(seq 8 8 $1); do
24 printf '\\\\x%02X' $(($n & 255))
25 n=$(($n >> 8))
26 done | xargs echo -en | ddq bs=1 conv=notrunc of=$4 seek=$(($2))
27 }
29 create_bzImage()
30 {
31 ddq bs=512 count=1 of=$1
32 # from http://hg.slitaz.org/wok/file/7184ec55b1aa/linux/stuff/linux-header.u
33 uudecode <<EOT | ddq of=$1 conv=notrunc
34 begin-base64 644 -
35 TVrrIEAAAAACAAAQ//8ACASeAABfAvD/TmV4dCEHDQA/owCeUuiwAZkfoPF9
36 QA+hxXd4XwZXsQbzpRYfZGaPR3jGRfg/+pdYQejIAL4AAoFMECCAxkQlm+hv
37 AVuJ5v9IEMdAFAiTgPMIdfOhFQJmix70AWZLZsHrBWZDvwAQOcd1AzWAFolE
38 G2a/gAAAAGYp+5xzAgHfUFZTMdtoAIAH6GEAW16MwbSHFgfNFVgFAAEQTB+/
39 gAedd8WITB/GRBwQx0QTgAa0h80Vl80T6gAAIJBaOMF3NGDNE/noeABhUlAo
40 yHcCsAE5+HICifhQtALNE1pYctyVAdGO6QDXANcp11p0UozplTjBddSIyLEB
41 MM51zP7FgP1QdcW1AGC+GABT6KoAW+g+AHUVUpjNE7gBAs0TWtDUOmT+depG
42 SHXm650x0ugAAAYftD+J+cHhCInrzSGSFh+wMRwDtA67BwDNEDwNdPPDv2wE
43 ZMYFprgNAWQ6JXQKzRZ09JjNFo7nR8PoVgCg0QJAvoAAigxG86SXgHz/P77g
44 AnQyDwHgJAF1K45fLEM5D3X7jVcEtD3NIXInleiM/4AGoAA9uwICOV8EcgXH
45 RyeeCR5qTMsDdA6wDeiH/6w8AH/4w16/xp1oAJAXifwWBzHAuTsA86pPW1bD
46 AA==
47 ====
48 EOT
49 # from tobzimage.S
50 uudecode <<EOT | gunzip >> $1
51 begin-base64 644 -
52 H4sIACpPrlUCA3ut4pFSFMzAxAACAg0MDIwMQEKAARXM+cOXxZAgx76vhsnw
53 P1v40qX7GZg6n+7kZMhiePRnB+PkmQGBQYELxJiA1EYOkFh36JfOZzsZGra0
54 nxX97yLy30Wm4Z1A+ZvON/sYWAxP/vP92JX78fTnpYnnqzxzE9NTFQz0DBlG
55 wQAAAJkasY8AAgAA
56 ====
57 EOT
58 if [ "$2" ]; then
59 s="$2"
60 [ -s "$2" ] && s="$(cat "$2")"
61 echo -e "\n$2" | tr '\n' '\r' | cat - /dev/zero | \
62 dd conv=notrunc of=$1 bs=1 seek=640 count=383
63 fi
64 setupsz=$(get 497 $1 1)
65 [ $setupsz -eq 0 ] && setupsz=4
66 ddq bs=512 count=$setupsz >> $1
67 store 8 497 $(($setupsz+1)) $1
68 ddq >> $1
69 }
71 create_bzImage $2 "$3" < $1