X-Git-Url: http://git.openwrt.org/?p=openwrt%2Fopenwrt.git;a=blobdiff_plain;f=scripts%2Fubinize-image.sh;h=09a00b1898cec141bf99a776eb26697d29fec864;hp=6ffedc5f32620deec6c9de494001fa59a32638be;hb=c00fbaf670494e7cd3dd05bff18cb6b407ac642d;hpb=0f39877bacc59049eb0185a93abbcbe23f180bde diff --git a/scripts/ubinize-image.sh b/scripts/ubinize-image.sh index 6ffedc5f32..09a00b1898 100755 --- a/scripts/ubinize-image.sh +++ b/scripts/ubinize-image.sh @@ -1,7 +1,7 @@ #!/bin/sh +part="" ubootenv="" -nokernel="" ubinize_param="" kernel="" rootfs="" @@ -23,6 +23,7 @@ ubivol() { name=$2 image=$3 autoresize=$4 + size="$5" echo "[$name]" echo "mode=ubi" echo "vol_id=$volid" @@ -30,6 +31,7 @@ ubivol() { echo "vol_name=$name" if [ "$image" ]; then echo "image=$image" + [ -n "$size" ] && echo "vol_size=${size}MiB" else echo "vol_size=1MiB" fi @@ -47,6 +49,22 @@ ubilayout() { ubivol $vol_id ubootenv2 vol_id=$(( $vol_id + 1 )) fi + for part in $parts; do + name="${part%%=*}" + prev="$part" + part="${part#*=}" + [ "$prev" = "$part" ] && part= + + image="${part%%=*}" + prev="$part" + part="${part#*=}" + [ "$prev" = "$part" ] && part= + + size="$part" + + ubivol $vol_id "$name" "$image" "" "$size" + vol_id=$(( $vol_id + 1 )) + done if [ "$3" ]; then ubivol $vol_id kernel "$3" vol_id=$(( $vol_id + 1 )) @@ -63,8 +81,15 @@ while [ "$1" ]; do shift continue ;; - "--no-kernel") - nokernel="nokernel" + "--kernel") + kernel="$2" + shift + shift + continue + ;; + "--part") + parts="$parts $2" + shift shift continue ;; @@ -73,11 +98,6 @@ while [ "$1" ]; do break ;; *) - if [ ! "$kernel" -a ! "$nokernel" ]; then - kernel=$1 - shift - continue - fi if [ ! "$rootfs" ]; then rootfs=$1 shift @@ -92,8 +112,8 @@ while [ "$1" ]; do esac done -if [ ! -r "$rootfs" -o ! -r "$kernel" -a ! "$nokernel" -o ! "$outfile" ]; then - echo "syntax: $0 [--no-kernel] [--uboot-env] rootfs [kernel] out [ubinize opts]" +if [ ! -r "$rootfs" -o ! -r "$kernel" -a ! "$outfile" ]; then + echo "syntax: $0 [--uboot-env] [--part =] [--kernel kernelimage] rootfs out [ubinize opts]" exit 1 fi @@ -103,7 +123,11 @@ if [ ! -x "$ubinize" ]; then exit 1 fi -ubinizecfg="$( mktemp )" +ubinizecfg="$( mktemp 2> /dev/null )" +if [ -z "$ubinizecfg" ]; then + # try OSX signature + ubinizecfg="$( mktemp -t 'ubitmp' )" +fi ubilayout "$ubootenv" "$rootfs" "$kernel" > "$ubinizecfg" cat "$ubinizecfg" @@ -113,4 +137,3 @@ err="$?" rm "$ubinizecfg" exit $err -