wok-next diff 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 diff
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/linld/stuff/tobzimage	Thu Jul 23 09:44:18 2015 +0200
     1.3 @@ -0,0 +1,71 @@
     1.4 +#!/bin/sh
     1.5 +
     1.6 +[ -s "$1" -a "$2" ] || {
     1.7 +	cat << EOT
     1.8 +Usage: $0 zImage-to-read bzImage-to-create [version-string]
     1.9 +EOT
    1.10 +	exit 1
    1.11 +}
    1.12 +
    1.13 +ddq()
    1.14 +{
    1.15 +	dd "$@" 2> /dev/null
    1.16 +}
    1.17 +
    1.18 +get()
    1.19 +{
    1.20 +	echo $( od -v -j $(($1)) -N ${4:-${3:-2}} -t u${3:-2} -w${3:-2} \
    1.21 +		-An $2 2>/dev/null )
    1.22 +}
    1.23 +
    1.24 +store()
    1.25 +{
    1.26 +	n=$3; for i in $(seq 8 8 $1); do
    1.27 +		printf '\\\\x%02X' $(($n & 255))
    1.28 +		n=$(($n >> 8))
    1.29 +	done | xargs echo -en | ddq bs=1 conv=notrunc of=$4 seek=$(($2))
    1.30 +}
    1.31 +
    1.32 +create_bzImage()
    1.33 +{
    1.34 +	ddq bs=512 count=1 of=$1
    1.35 +	# from http://hg.slitaz.org/wok/file/7184ec55b1aa/linux/stuff/linux-header.u
    1.36 +	uudecode <<EOT | ddq of=$1 conv=notrunc
    1.37 +begin-base64 644 -
    1.38 +TVrrIEAAAAACAAAQ//8ACASeAABfAvD/TmV4dCEHDQA/owCeUuiwAZkfoPF9
    1.39 +QA+hxXd4XwZXsQbzpRYfZGaPR3jGRfg/+pdYQejIAL4AAoFMECCAxkQlm+hv
    1.40 +AVuJ5v9IEMdAFAiTgPMIdfOhFQJmix70AWZLZsHrBWZDvwAQOcd1AzWAFolE
    1.41 +G2a/gAAAAGYp+5xzAgHfUFZTMdtoAIAH6GEAW16MwbSHFgfNFVgFAAEQTB+/
    1.42 +gAedd8WITB/GRBwQx0QTgAa0h80Vl80T6gAAIJBaOMF3NGDNE/noeABhUlAo
    1.43 +yHcCsAE5+HICifhQtALNE1pYctyVAdGO6QDXANcp11p0UozplTjBddSIyLEB
    1.44 +MM51zP7FgP1QdcW1AGC+GABT6KoAW+g+AHUVUpjNE7gBAs0TWtDUOmT+depG
    1.45 +SHXm650x0ugAAAYftD+J+cHhCInrzSGSFh+wMRwDtA67BwDNEDwNdPPDv2wE
    1.46 +ZMYFprgNAWQ6JXQKzRZ09JjNFo7nR8PoVgCg0QJAvoAAigxG86SXgHz/P77g
    1.47 +AnQyDwHgJAF1K45fLEM5D3X7jVcEtD3NIXInleiM/4AGoAA9uwICOV8EcgXH
    1.48 +RyeeCR5qTMsDdA6wDeiH/6w8AH/4w16/xp1oAJAXifwWBzHAuTsA86pPW1bD
    1.49 +AA==
    1.50 +====
    1.51 +EOT
    1.52 +	# from tobzimage.S
    1.53 +	uudecode <<EOT | gunzip >> $1
    1.54 +begin-base64 644 -
    1.55 +H4sIACpPrlUCA3ut4pFSFMzAxAACAg0MDIwMQEKAARXM+cOXxZAgx76vhsnw
    1.56 +P1v40qX7GZg6n+7kZMhiePRnB+PkmQGBQYELxJiA1EYOkFh36JfOZzsZGra0
    1.57 +nxX97yLy30Wm4Z1A+ZvON/sYWAxP/vP92JX78fTnpYnnqzxzE9NTFQz0DBlG
    1.58 +wQAAAJkasY8AAgAA
    1.59 +====
    1.60 +EOT
    1.61 +	if [ "$2" ]; then
    1.62 +		s="$2"
    1.63 +		[ -s "$2" ] && s="$(cat "$2")"
    1.64 +		echo -e "\n$2" | tr '\n' '\r' | cat - /dev/zero | \
    1.65 +		dd conv=notrunc of=$1 bs=1 seek=640 count=383
    1.66 +	fi
    1.67 +	setupsz=$(get 497 $1 1)
    1.68 +	[ $setupsz -eq 0 ] && setupsz=4
    1.69 +	ddq bs=512 count=$setupsz >> $1
    1.70 +	store 8 497 $(($setupsz+1)) $1
    1.71 +	ddq >> $1
    1.72 +}
    1.73 +
    1.74 +create_bzImage $2 "$3" < $1