summaryrefslogtreecommitdiffstats
path: root/scripts
diff options
context:
space:
mode:
authorDaniel Golle <daniel@makrotopia.org>2024-02-16 05:32:51 +0000
committerDaniel Golle <daniel@makrotopia.org>2024-02-16 05:32:51 +0000
commit67beab2b2b39c4fe3e48a021aefbfac15ffa70ce (patch)
treec9d7105936fec1b77d8de04b7abddc6e6ea40bd8 /scripts
parentdc0cf0fc509d7d2ae1250144d4615275094b943e (diff)
downloadopenwrt-67beab2b2b39c4fe3e48a021aefbfac15ffa70ce.tar.gz
openwrt-67beab2b2b39c4fe3e48a021aefbfac15ffa70ce.tar.bz2
openwrt-67beab2b2b39c4fe3e48a021aefbfac15ffa70ce.zip
scripts: ubinize-image.sh: fix on POSIX shell, allow custom images
Make sure ubinize-image.sh also works with more simple POSIX Shell and allow creating complete custom images to be used as ARTIFACT/foo.img and thereby allow including uImage.FIT, TF-A FIP and what ever else is required on a specific board. Fixes: 6c17d71973 ("scripts: ubinize-image.sh: support static volumes, make size optional") Signed-off-by: Daniel Golle <daniel@makrotopia.org>
Diffstat (limited to 'scripts')
-rwxr-xr-xscripts/ubinize-image.sh33
1 files changed, 17 insertions, 16 deletions
diff --git a/scripts/ubinize-image.sh b/scripts/ubinize-image.sh
index cd516e8afc..06a6310980 100755
--- a/scripts/ubinize-image.sh
+++ b/scripts/ubinize-image.sh
@@ -12,10 +12,10 @@ err=""
ubinize_seq=""
ubivol() {
- local volid=$1
- local name=$2
- local image=$3
- local autoresize=$4
+ local volid="$1"
+ local name="$2"
+ local image="$3"
+ local autoresize="$4"
local size="$5"
local voltype="${6:-dynamic}"
echo "[$name]"
@@ -36,16 +36,17 @@ ubivol() {
ubilayout() {
local vol_id=0
- local rootsize=
- local autoresize=
- local rootfs_type="$( get_fs_type "$2" )"
+ local rootsize
+ local autoresize
+ local rootfs_type
local voltype
+ rootfs_type="$( get_fs_type "$2" )"
if [ "$1" = "ubootenv" ]; then
ubivol $vol_id ubootenv
- vol_id=$(( $vol_id + 1 ))
+ vol_id=$(( vol_id + 1 ))
ubivol $vol_id ubootenv2
- vol_id=$(( $vol_id + 1 ))
+ vol_id=$(( vol_id + 1 ))
fi
for part in $parts; do
name="${part%%=*}"
@@ -55,9 +56,9 @@ ubilayout() {
[ "$prev" = "$part" ] && part=
image="${part%%=*}"
- if [ "${image:0:1}" = ":" ]; then
+ if [ "${image#:}" != "$image" ]; then
voltype=static
- image="${image:1}"
+ image="${image#:}"
fi
prev="$part"
part="${part#*=}"
@@ -71,11 +72,11 @@ ubilayout() {
fi
ubivol $vol_id "$name" "$image" "" "${size}" "$voltype"
- vol_id=$(( $vol_id + 1 ))
+ vol_id=$(( vol_id + 1 ))
done
if [ "$3" ]; then
ubivol $vol_id kernel "$3"
- vol_id=$(( $vol_id + 1 ))
+ vol_id=$(( vol_id + 1 ))
fi
if [ "$2" ]; then
@@ -91,7 +92,7 @@ ubilayout() {
esac
ubivol $vol_id rootfs "$2" "$autoresize" "$rootsize" dynamic
- vol_id=$(( $vol_id + 1 ))
+ vol_id=$(( vol_id + 1 ))
[ "$rootfs_type" = "ubifs" ] || ubivol $vol_id rootfs_data "" 1 dymamic
fi
}
@@ -128,7 +129,7 @@ while [ "$1" ]; do
continue
;;
"-"*)
- ubinize_param="$@"
+ ubinize_param="$*"
break
;;
*)
@@ -141,7 +142,7 @@ while [ "$1" ]; do
esac
done
-if [ ! -r "$rootfs" -a ! -r "$kernel" -a ! "$outfile" ]; then
+if [ ! -r "$rootfs" ] && [ ! -r "$kernel" ] && [ ! "$parts" ] && [ ! "$outfile" ]; then
echo "syntax: $0 [--uboot-env] [--part <name>=<file>] [--kernel kernelimage] [--rootfs rootfsimage] out [ubinize opts]"
exit 1
fi