wok view linld/stuff/tobzimage @ rev 25276
updated reiser4progs and reiser4progs-dev (2.0.0 -> 2.0.5)
author | Hans-G?nter Theisgen |
---|---|
date | Mon Jul 18 14:19:27 2022 +0100 (2022-07-18) |
parents | 1c8a113c536a |
children |
line source
1 #!/bin/sh
3 if [ "$1" == "--build" ]; then #install-begin
4 for i in elks linux001 ; do
5 i=${i}_patch
6 n=$(sed "/$i\$/!d;s/.*text:0*\\([^ ]*\\).*/\\1/" tobzimage.lst)
7 [ -n "$n" ] && sed -i "s/$i/$((0x200 + 0x$n))/" $0
8 done
9 cat tobzimage.bin | gzip -9 | uuencode -m - | sed \
10 -e '/^tobzimage$/r/dev/stdin' -e '/^tobzimage$/d' \
11 -e '/install-begin$/,/install-end$/d' -i $0
12 exit
13 fi #install-end
14 [ -s "$1" -a "$2" ] || {
15 cat << EOT
16 Usage: $0 zImage-to-read bzImage-to-create [version-string]
17 EOT
18 exit 1
19 }
21 ddq()
22 {
23 dd "$@" 2> /dev/null
24 }
26 get()
27 {
28 echo $( od -v -j $(($1)) -N ${4:-${3:-2}} -t u${3:-2} -w${3:-2} \
29 -An $2 2>/dev/null )
30 }
32 store()
33 {
34 n=$3; for i in $(seq 8 8 $1); do
35 printf '\\\\x%02X' $(($n & 255))
36 n=$(($n >> 8))
37 done | xargs echo -en | ddq bs=1 conv=notrunc of=$4 seek=$(($2))
38 }
40 create_bzImage()
41 {
42 ddq bs=512 count=1 of=$1
43 [ "$(od -j 486 $1 -An -N 4 -a|sed 's/ //g')" == "ELKS" ] && iselks=1
44 [ " $(get 0x3F $1 2)" == " 15080" ] && islinux001=1 && cp $1 $1$$
45 # from http://hg.slitaz.org/wok/file/7184ec55b1aa/linux/stuff/linux-header.u
46 uudecode <<EOT | ddq of=$1 conv=notrunc
47 begin-base64 644 -
48 TVrrIEAAAAACAAAQ//8ACASeAABfAvD/TmV4dCEHDQA/owCeUuiwAZkfoPF9
49 QA+hxXd4XwZXsQbzpRYfZGaPR3jGRfg/+pdYQejIAL4AAoFMECCAxkQlm+hv
50 AVuJ5v9IEMdAFAiTgPMIdfOhFQJmix70AWZLZsHrBWZDvwAQOcd1AzWAFolE
51 G2a/gAAAAGYp+5xzAgHfUFZTMdtoAIAH6GEAW16MwbSHFgfNFVgFAAEQTB+/
52 gAedd8WITB/GRBwQx0QTgAa0h80Vl80T6gAAIJBaOMF3NGDNE/noeABhUlAo
53 yHcCsAE5+HICifhQtALNE1pYctyVAdGO6QDXANcp11p0UozplTjBddSIyLEB
54 MM51zP7FgP1QdcW1AGC+GABT6KoAW+g+AHUVUpjNE7gBAs0TWtDUOmT+depG
55 SHXm650x0ugAAAYftD+J+cHhCInrzSGSFh+wMRwDtA67BwDNEDwNdPPDv2wE
56 ZMYFprgNAWQ6JXQKzRZ09JjNFo7nR8PoVgCg0QJAvoAAigxG86SXgHz/P77g
57 AnQyDwHgJAF1K45fLEM5D3X7jVcEtD3NIXInleiM/4AGoAA9uwICOV8EcgXH
58 RyeeCR5qTMsDdA6wDeiH/6w8AH/4w16/xp1oAJAXifwWBzHAuTsA86pPW1bD
59 AA==
60 ====
61 EOT
62 # from tobzimage.S
63 uudecode <<EOT | gunzip >> $1
64 tobzimage
65 EOT
66 s="$2"
67 [ -s "$s" ] && s="$(cat "$s")"
68 [ -z "$s" ] && s="$(basename "$1")"
69 echo -e "\n$s" | tr '\n' '\r' | cat - /dev/zero | \
70 ddq conv=notrunc of=$1 bs=1 seek=768 count=255
71 setupsz=$(get 497 $1 1)
72 [ $setupsz -eq 0 ] && setupsz=4
73 if [ "$islinux001" == "1" ]; then
74 cat $1$$ /dev/zero | ddq bs=512 count=$setupsz >> $1
75 rm -f $1$$
76 else
77 ddq bs=512 count=$setupsz >> $1
78 if [ "$(od -j 1026 $1 -An -N 4 -a|sed 's/ //g')" == "HdrS" ] &&
79 [ $(($(get 1041 $1 1) & 1)) -eq 1 ]; then
80 echo "Already a bzImage file, abort."
81 rm -f $1
82 exit 1
83 fi
84 fi
85 store 8 497 $(($setupsz+1)) $1
86 syssz=$(get 500 $1 2)
87 [ $syssz -eq 0 ] && syssz=$((($filesz+15-512)/16-($setupsz*32)))
88 [ "$islinux001" == "1" ] && syssz=$((($filesz+15-512)/16))
89 store 16 500 $syssz $1
90 [ "$iselks" == "1" ] && store 16 elks_patch 37008 $1
91 [ "$islinux001" == "1" ] && store 16 linux001_patch 37008 $1
92 ddq >> $1
93 }
95 filesz=$(stat -c %s $1)
96 create_bzImage $2 "$3" < $1