#!/bin/sh
+part=""
ubootenv=""
-nokernel=""
ubinize_param=""
kernel=""
rootfs=""
err=""
get_magic_word() {
- dd if=$1 bs=2 count=1 2>/dev/null | hexdump -v -n 2 -e '1/1 "%02x"'
+ dd if=$1 bs=2 count=1 2>/dev/null | od -A n -N 2 -t x1 | tr -d ' '
}
is_ubifs() {
name=$2
image=$3
autoresize=$4
+ size="$5"
echo "[$name]"
echo "mode=ubi"
echo "vol_id=$volid"
echo "vol_name=$name"
if [ "$image" ]; then
echo "image=$image"
+ [ -n "$size" ] && echo "vol_size=${size}MiB"
else
echo "vol_size=1MiB"
fi
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 ))
shift
continue
;;
- "--no-kernel")
- nokernel="nokernel"
+ "--kernel")
+ kernel="$2"
+ shift
+ shift
+ continue
+ ;;
+ "--part")
+ parts="$parts $2"
+ shift
shift
continue
;;
break
;;
*)
- if [ ! "$kernel" -a ! "$nokernel" ]; then
- kernel=$1
- shift
- continue
- fi
if [ ! "$rootfs" ]; then
rootfs=$1
shift
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 <name>=<file>] [--kernel kernelimage] rootfs out [ubinize opts]"
exit 1
fi
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"
rm "$ubinizecfg"
exit $err
-