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