[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[ImageBuilder][PATCH v2 1/4] scripts: Add support for prepending path to file names


  • To: xen-devel@xxxxxxxxxxxxxxxxxxxx
  • From: "Andrei Cherechesu (OSS)" <andrei.cherechesu@xxxxxxxxxxx>
  • Date: Thu, 30 Jun 2022 17:00:26 +0300
  • Arc-authentication-results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=oss.nxp.com; dmarc=pass action=none header.from=oss.nxp.com; dkim=pass header.d=oss.nxp.com; arc=none
  • Arc-message-signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=7giP8A1iOXK4r5YaK7UVvP9/j+xU4cgR7sxpc6z2ONI=; b=GieAOesNy7rYgjEKVCPDOMjUvJJGdkNuuuwBavfMGjHZmzQBdcD2CU/caecYoLhwNgwcNdXPxI/1TQuPOm22vIEZfgMegA+prtPy/Z2M8TZvBXsi2BnH2vouskn/SVmBX9ikYuMU6ndd7VMQTu7EVYqFYmwpNLzx+gpg2+g10pZONnn6+qVQN3r0fCdycrEGCaVTNHZH+TZYyppr3cblXOTVxBcUkyZKHxaDFN1kIfmj00BivrFSqrGecYo8k5BcydqU2YluCIPAP5hu6nRPYeJ0ExtL9VanNVQc4mW0nQHz6tz1iyKjAMJ0eqowcJj7gzWqR8ewS0ATSMspRBogow==
  • Arc-seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=iXY1k/P0bk3m/GfBSMjWRH/ulnetKmgn6JNt09emUVtWhvCIDRzeOG6JjBVuQRWJ09l2t24WvRmzC35k2VlcOUfN21SyrHOkeZyBb+jy1PqhN0xcj6/37merMNIV+Q6ChDuo7cYzz41W5iPUhPJ8voMXymuIQ/9ki7lEa2bmqSJmLDnv5eccTSQZikjvYHDOFY8TJd7L3llcKEKsYC8DK99G18z+wtUsb0yKILxjmSP1U0/XjvKDnIPx9NGTO81Qm9T1yTJ4/MnCVi1A0Mm2e7NSd2cnoZYFENFtEs0jh1319cKecuO1CFeDVFlWGD/w2auZbHWrBIkLBNAht8y8Pg==
  • Authentication-results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=oss.nxp.com;
  • Cc: viryaos-discuss@xxxxxxxxxxxxxxxxxxxxx, sstabellini@xxxxxxxxxx, Andrei Cherechesu <andrei.cherechesu@xxxxxxx>
  • Delivery-date: Thu, 30 Jun 2022 14:05:05 +0000
  • List-id: Xen developer discussion <xen-devel.lists.xenproject.org>

From: Andrei Cherechesu <andrei.cherechesu@xxxxxxx>

Added support for prepending path to file names in the final generated
u-boot script, for the use-case where we have the files in a separate
folder that can be accessed with a given $LOAD_CMD.

For example, we can have "fatload mmc 0:2" as LOAD_CMD but the
files would need to be loaded from the /boot folder within the 2nd
partition, not from the root ("/"). By specifying the "-p <path>"
parameter when running the script, paths like "/boot" can be
automatically prepended to the generated u-boot commands used
to load the files in board's memory.

Also added the support to disk_image script, to enable generating
a FAT partition with the binaries deployed in a custom folder
within it, if the "-p" parameter is specified.

Signed-off-by: Andrei Cherechesu <andrei.cherechesu@xxxxxxx>
---
 scripts/disk_image       | 37 +++++++++++++++++++++++--------------
 scripts/uboot-script-gen | 12 ++++++++----
 2 files changed, 31 insertions(+), 18 deletions(-)

diff --git a/scripts/disk_image b/scripts/disk_image
index 12fb06b..97e798f 100755
--- a/scripts/disk_image
+++ b/scripts/disk_image
@@ -539,7 +539,7 @@ function write_rootfs()
 function print_help
 {
     echo "usage:"
-    echo "     $0 -c CONFIG_FILE -d UBOOT_DIRECTORY -t UBOOT_TYPE <-w 
WORK_DIRECTORY> <-s SLACK> <-a> -o IMG_FILE"
+    echo "     $0 -c CONFIG_FILE -d UBOOT_DIRECTORY -t UBOOT_TYPE <-w 
WORK_DIRECTORY> <-s SLACK> <-a> -o IMG_FILE <-p PREPEND_PATH>"
     echo "     $0 -h"
     echo "where:"
     echo "     -c CONFIG_FILE - configuration file"
@@ -553,6 +553,7 @@ function print_help
     echo "     -s SLACK - free MB to add to each partition, default 128"
     echo "     -a specifies that the size of IMG_FILE has to be aligned to the 
nearest power of two"
     echo "     -o IMG_FILE - the output img file "
+    echo "     -p PREPEND_PATH - path to be appended before file names to 
customize deploy location within rootfs"
     echo "Example:"
     echo "     $0 -c ../config -d ./build42 -w tmp -o disk.img"
 }
@@ -564,7 +565,7 @@ then
     exit 1
 fi
 
-while getopts ":w:d:c:t:s:o:ah" opt
+while getopts ":w:d:c:t:s:o:ahp:" opt
 do
     case ${opt} in
     t )
@@ -606,6 +607,9 @@ do
     a )
         ALIGN=1
         ;;
+    p )
+        PREPEND_PATH="$OPTARG"
+        ;;
     h )
         print_help
         exit 0
@@ -828,56 +832,61 @@ mount /dev/mapper/diskimage1 $DESTDIR/part/disk1
 
 # only copy over files that were counted for the partition size
 cd "$UBOOT_OUT"
-cp --parents "$DOM0_KERNEL" "${DESTDIR_ABS}/part/disk1/"
-cp --parents "$DEVICE_TREE" "${DESTDIR_ABS}/part/disk1/"
-cp --parents "$UBOOT_SCRIPT" "${DESTDIR_ABS}/part/disk1/"
+if [ -n "$PREPEND_PATH" ]
+then
+    mkdir -p "${DESTDIR_ABS}/part/disk1/${PREPEND_PATH}"
+fi
+
+cp --parents "$DOM0_KERNEL" "${DESTDIR_ABS}/part/disk1/${PREPEND_PATH}"
+cp --parents "$DEVICE_TREE" "${DESTDIR_ABS}/part/disk1/${PREPEND_PATH}"
+cp --parents "$UBOOT_SCRIPT" "${DESTDIR_ABS}/part/disk1/${PREPEND_PATH}"
 
 if test "${DOM0_RAMDISK}"
 then
-    cp --parents "$DOM0_RAMDISK" "${DESTDIR_ABS}/part/disk1/"
+    cp --parents "$DOM0_RAMDISK" "${DESTDIR_ABS}/part/disk1/${PREPEND_PATH}"
 fi
 if test "$NUM_DT_OVERLAY" && test "$NUM_DT_OVERLAY" -gt 0
 then
     i=0
     while test $i -lt "$NUM_DT_OVERLAY"
     do
-        cp --parents "${DT_OVERLAY[$i]}" "${DESTDIR_ABS}/part/disk1/"
+        cp --parents "${DT_OVERLAY[$i]}" 
"${DESTDIR_ABS}/part/disk1/${PREPEND_PATH}"
         i=$(( $i + 1 ))
     done
 fi
 if test "${UBOOT_SOURCE}"
 then
-    cp --parents "$UBOOT_SOURCE" "${DESTDIR_ABS}/part/disk1/"
+    cp --parents "$UBOOT_SOURCE" "${DESTDIR_ABS}/part/disk1/${PREPEND_PATH}"
 fi
 if test "${XEN}"
 then
-    cp --parents "$XEN" "${DESTDIR_ABS}/part/disk1/"
+    cp --parents "$XEN" "${DESTDIR_ABS}/part/disk1/${PREPEND_PATH}"
 fi
 if test "$NUM_BOOT_AUX_FILE" && test "$NUM_BOOT_AUX_FILE" -gt 0
 then
     i=0
     while test $i -lt "$NUM_BOOT_AUX_FILE"
     do
-        cp --parents "${BOOT_AUX_FILE[$i]}" "${DESTDIR_ABS}/part/disk1/"
+        cp --parents "${BOOT_AUX_FILE[$i]}" 
"${DESTDIR_ABS}/part/disk1/${PREPEND_PATH}"
         i=$(( $i + 1 ))
     done
 fi
 if test "${BITSTREAM}"
 then
-    cp --parents "$BITSTREAM" "${DESTDIR_ABS}/part/disk1/"
+    cp --parents "$BITSTREAM" "${DESTDIR_ABS}/part/disk1/${PREPEND_PATH}"
 fi
 
 i=0
 while test $i -lt $NUM_DOMUS
 do
-    cp --parents "${DOMU_KERNEL[$i]}" "${DESTDIR_ABS}/part/disk1/"
+    cp --parents "${DOMU_KERNEL[$i]}" 
"${DESTDIR_ABS}/part/disk1/${PREPEND_PATH}"
     if test "${DOMU_RAMDISK[$i]}"
     then
-        cp --parents "${DOMU_RAMDISK[$i]}" "${DESTDIR_ABS}/part/disk1/"
+        cp --parents "${DOMU_RAMDISK[$i]}" 
"${DESTDIR_ABS}/part/disk1/${PREPEND_PATH}"
     fi
     if test "${DOMU_PASSTHROUGH_DTB[$i]}"
     then
-        cp --parents "${DOMU_PASSTHROUGH_DTB[$i]}" "${DESTDIR_ABS}/part/disk1/"
+        cp --parents "${DOMU_PASSTHROUGH_DTB[$i]}" 
"${DESTDIR_ABS}/part/disk1/${PREPEND_PATH}"
     fi
     i=$(( $i + 1 ))
 done
diff --git a/scripts/uboot-script-gen b/scripts/uboot-script-gen
index 085e29f..8f08cd6 100755
--- a/scripts/uboot-script-gen
+++ b/scripts/uboot-script-gen
@@ -316,7 +316,7 @@ function load_file()
     then
         echo "imxtract \$fit_addr $fit_scr_name $memaddr" >> $UBOOT_SOURCE
     else
-        echo "$LOAD_CMD $memaddr $relative_path" >> $UBOOT_SOURCE
+        echo "$LOAD_CMD $memaddr 
${prepend_path:+$prepend_path/}$relative_path" >> $UBOOT_SOURCE
     fi
     add_size $filename
 }
@@ -891,7 +891,7 @@ function print_help
 {
     script=`basename "$0"`
     echo "usage:"
-    echo "     $script -c CONFIG_FILE -d DIRECTORY [-t LOAD_CMD] [-o FILE] [-k 
KEY_DIR/HINT [-u U-BOOT_DTB]] [-e] [-f]"
+    echo "     $script -c CONFIG_FILE -d DIRECTORY [-t LOAD_CMD] [-o FILE] [-k 
KEY_DIR/HINT [-u U-BOOT_DTB]] [-e] [-f] [-p PREPEND_PATH]"
     echo "     $script -h"
     echo "where:"
     echo "     CONFIG_FILE - configuration file"
@@ -907,6 +907,7 @@ function print_help
     echo "     HINT - the file name of the crt and key file minus the suffix 
(ex, hint.crt and hint.key)"
     echo "     U-BOOT_DTB - u-boot control dtb so that the public key gets 
added to it"
     echo "     -f - enable generating a FIT image"
+    echo "     PREPEND_PATH - path to be appended before file names to match 
deploy location within rootfs"
     echo "     -h - prints out the help message and exits "
     echo "Defaults:"
     echo "     CONFIG_FILE=$cfg_file, UBOOT_TYPE=\"LOAD_CMD\" env var, 
DIRECTORY=$uboot_dir"
@@ -914,7 +915,7 @@ function print_help
     echo "     $script -c ../config -d ./build42 -t \"scsi load 1:1\""
 }
 
-while getopts ":c:t:d:ho:k:u:f" opt; do
+while getopts ":c:t:d:ho:k:u:fp:" opt; do
     case ${opt} in
     t )
         case $OPTARG in
@@ -953,6 +954,9 @@ while getopts ":c:t:d:ho:k:u:f" opt; do
     f )
         fit_opt=y
         ;;
+    p )
+        prepend_path="$OPTARG"
+        ;;
     h )
         print_help
         exit 0
@@ -1179,5 +1183,5 @@ then
     echo "$LOAD_CMD $fit_addr $FIT; source $fit_addr:boot_scr"
 else
     echo "Generated uboot script $UBOOT_SCRIPT, to be loaded at address 
$uboot_addr:"
-    echo "$LOAD_CMD $uboot_addr $UBOOT_SCRIPT; source $uboot_addr"
+    echo "$LOAD_CMD $uboot_addr ${prepend_path:+$prepend_path/}$UBOOT_SCRIPT; 
source $uboot_addr"
 fi
-- 
2.35.1




 


Rackspace

Lists.xenproject.org is hosted with RackSpace, monitoring our
servers 24x7x365 and backed by RackSpace's Fanatical Support®.