From: Hugo Villeneuve Date: Wed, 9 Oct 2024 15:45:55 +0000 (-0400) Subject: hvk: add support for creating compressed archive X-Git-Url: http://gitweb.hugovil.com/?a=commitdiff_plain;h=f106a276ff0bc9de52d31c96676365306b53e2c2;p=hvutilities.git hvk: add support for creating compressed archive --- diff --git a/scripts/hvk-compile.sh b/scripts/hvk-compile.sh index ce0384f..cdc4470 100755 --- a/scripts/hvk-compile.sh +++ b/scripts/hvk-compile.sh @@ -5,6 +5,9 @@ SCRIPT="`readlink -e $0`" SCRIPTPATH=$(dirname ${SCRIPT}) source ${SCRIPTPATH}/hvk-common.sh +DEPLOYDIR=rootfs +ARCHIVE=kernel.tar.xz + print_usage() { echo "${PROG_NAME} -- U-Boot/kernel compile script" @@ -14,13 +17,15 @@ print_usage() echo " -h display this help and exit" echo " -r reboot after deploying files" echo " -w compile with W=1" + echo " -z create archive" echo } reboot=0 warnings_opts="" +archive=0 -while getopts "hrw" flag ;do +while getopts "hrwz" flag ;do case ${flag} in h) print_usage @@ -32,6 +37,9 @@ while getopts "hrw" flag ;do w) warnings_opts="W=1" ;; + z) + archive=1 + ;; ?) echo "${PROG_NAME}: Invalid option: ${OPTARG}." echo "Try \`${PROG_NAME} -h' for more information." @@ -53,6 +61,12 @@ if [ ${#} -eq 1 ]; then EVK_IP="${1}" fi +if [ "${reboot}" = "1" -a "${archive}" = "1" ]; then + echo "${PROG_NAME}: You must specify only one of \"-r\" or \"-z\" option" + echo "Try \`${PROG_NAME} -h' for more information." + exit 1 +fi + if [ ! -f .config ]; then echo "Missing configuration file .config." echo "Configure your kernel by running 'hvk-init.sh'" @@ -82,23 +96,37 @@ elif [ x"${mode}" = x"uboot" ]; then ${KMAKE} u-boot-initial-env fi -if [ "${EVK_IP}" != "" ]; then - scp ${BOOT_SRC}/Image root@${EVK_IP}:${BOOT_DEST}/Image-latest - - scp ${DTB_SRC} root@${EVK_IP}:${BOOT_DEST}/latest.dtb +function rootfs_install() { + rm -rf ${DEPLOYDIR}/lib + mkdir -p ${DEPLOYDIR} if [ x"${CONFIG_MODULES}" = x"1" ]; then - rm -rf modules-tmp - ${KMAKE} INSTALL_MOD_PATH=modules-tmp modules_install - pushd modules-tmp/lib/ - tar cf - modules/* | gzip -9 > /tmp/modules.tar.gz - popd + ${KMAKE} INSTALL_MOD_PATH=${DEPLOYDIR} modules_install + fi - scp /tmp/modules.tar.gz root@${EVK_IP}:/tmp + mkdir -p ${DEPLOYDIR}/boot - ssh root@${EVK_IP} "cd /lib && tar -xf /tmp/modules.tar.gz" - rm /tmp/modules.tar.gz - fi + cp ${BOOT_SRC}/Image ${DEPLOYDIR}/boot/Image-latest + cp ${DTB_SRC} ${DEPLOYDIR}/boot/latest.dtb +} + +function rootfs_archive() { + pushd ${DEPLOYDIR} + tar cf - * | xz > ../${ARCHIVE} + popd +} + +if [ "${archive}" = "1" ]; then + rootfs_install + rootfs_archive +fi + +if [ "${EVK_IP}" != "" ]; then + rootfs_install + rootfs_archive + + scp ${ARCHIVE} root@${EVK_IP}:/tmp + ssh root@${EVK_IP} "cd / && tar -xf /tmp/${ARCHIVE}" # Determine if using extlinux on target: ssh -q root@${EVK_IP} [[ -f /boot/extlinux/extlinux.conf ]] && EXTLINUX=1 || EXTLINUX=0;