[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
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
|
Lists.xenproject.org is hosted with RackSpace, monitoring our |