aboutsummaryrefslogtreecommitdiff
path: root/scripts/uboot-script-gen
diff options
context:
space:
mode:
authorBrian Woods2020-01-16 18:04:03 -0800
committerStefano Stabellini2020-01-17 15:32:20 -0800
commit0fce3d4b9e05d9ff225948cf9b28060d62e643ce (patch)
treea69a83947987eca3b5bcd66e86e91e3ad7ae9f3b /scripts/uboot-script-gen
parentd324dce16bc280c475f4b5381e9b205662654333 (diff)
Add stricter checking of files in config
The boot script files would still be generated even if the files used in the config don't exist. This checks to make sure the files exist and if they don't, it exits and errs out. Signed-off-by: Brian Woods <brian.woods@xilinx.com> Reviewed-by: Stefano Stabellini <sstabellini@kernel.org>
Diffstat (limited to 'scripts/uboot-script-gen')
-rw-r--r--scripts/uboot-script-gen24
1 files changed, 22 insertions, 2 deletions
diff --git a/scripts/uboot-script-gen b/scripts/uboot-script-gen
index f17d8ac..0382478 100644
--- a/scripts/uboot-script-gen
+++ b/scripts/uboot-script-gen
@@ -13,6 +13,13 @@ function remove_tmp_files()
done
}
+function cleanup_and_return_err()
+{
+ rm -f $UBOOT_SOURCE $UBOOT_SCRIPT
+ remove_tmp_files
+ exit 1
+}
+
function add_device_tree_kernel()
{
local path=$1
@@ -118,6 +125,12 @@ function check_file_type()
local filename=$1
local type="$2"
+ if [ ! -f $filename ]
+ then
+ echo "File $filename doesn't exist, exiting";
+ cleanup_and_return_err
+ fi
+
# if file doesn't know what it is, it outputs data, so include that
# since some executables aren't recongnized
if [ "$type" = "executable" ]
@@ -128,7 +141,8 @@ function check_file_type()
file $filename | grep "$type" &> /dev/null
if test $? != 0
then
- echo Wrong file type "$filename". It should be "$type".
+ echo Wrong file type "$filename". It should be "$type", exiting.
+ clean_up_and_err_out
fi
}
@@ -137,6 +151,12 @@ function check_compressed_file_type()
local filename=$1
local type="$2"
+ if [ ! -f $filename ]
+ then
+ echo "File $filename doesn't exist, exiting";
+ cleanup_and_return_err
+ fi
+
file $filename | grep "gzip compressed data" &> /dev/null
if test $? == 0
then
@@ -298,7 +318,7 @@ memaddr=$(( $MEMORY_END - $memaddr - $offset ))
if test $memaddr -lt 0
then
echo Error, not enough memory to load all binaries
- exit 1
+ cleanup_and_return_err
fi
echo "Generated uboot script $UBOOT_SCRIPT, to be loaded at address $uboot_addr:"