From aa6473e37e9b698bbdac144ce92db0396f2447bc Mon Sep 17 00:00:00 2001 From: Fabio Belavenuto Date: Thu, 12 Jan 2023 19:42:15 -0300 Subject: [PATCH] Improving the updater to support folders --- .github/workflows/main.yml | 19 ++++++++++++++----- VERSION | 2 +- .../arpl/overlayfs/opt/arpl/include/consts.sh | 2 +- files/board/arpl/overlayfs/opt/arpl/menu.sh | 14 ++++++++++---- files/board/arpl/p1/ARPL-VERSION | 2 +- img-gen.sh | 18 ++++++++++++++---- update-list.yml | 6 ++---- 7 files changed, 43 insertions(+), 20 deletions(-) diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index e3d295c7..3a423c0b 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -106,11 +106,20 @@ jobs: zip -9 "arpl-${{ steps.build.outputs.VERSION }}.vmdk-dyn.zip" arpl-dyn.vmdk zip -9 "arpl-${{ steps.build.outputs.VERSION }}.vmdk-flat.zip" arpl.vmdk arpl-flat.vmdk sha256sum update-list.yml > sha256sum - yq '.replace | explode(.) | to_entries | map([.key])[] | .[]' update-list.yml | while read F; do - (cd `dirname ${F}` && sha256sum `basename ${F}`) >> sha256sum - done - yq '.replace | explode(.) | to_entries | map([.key])[] | .[]' update-list.yml | xargs zip -9j "update.zip" sha256sum update-list.yml - + zip -9j update.zip update-list.yml + while read F; do + if [ -d "${F}" ]; then + FTGZ="`basename "${F}"`.tgz" + tar czf "${FTGZ}" -C "${F}" . + sha256sum "${FTGZ}" >> sha256sum + zip -9j update.zip "${FTGZ}" + rm "${FTGZ}" + else + (cd `dirname ${F}` && sha256sum `basename ${F}`) >> sha256sum + zip -9j update.zip "${F}" + fi + done < <(yq '.replace | explode(.) | to_entries | map([.key])[] | .[]' update-list.yml) + zip -9j update.zip sha256sum # Upload artifact - name: Upload uses: actions/upload-artifact@v3 diff --git a/VERSION b/VERSION index 0fb471aa..d3bc27e1 100644 --- a/VERSION +++ b/VERSION @@ -1 +1 @@ -1.0-beta11 +1.0-beta11a diff --git a/files/board/arpl/overlayfs/opt/arpl/include/consts.sh b/files/board/arpl/overlayfs/opt/arpl/include/consts.sh index 85bf429e..32f5b53f 100644 --- a/files/board/arpl/overlayfs/opt/arpl/include/consts.sh +++ b/files/board/arpl/overlayfs/opt/arpl/include/consts.sh @@ -1,5 +1,5 @@ -ARPL_VERSION="1.0-beta11" +ARPL_VERSION="1.0-beta11a" # Define paths TMP_PATH="/tmp" diff --git a/files/board/arpl/overlayfs/opt/arpl/menu.sh b/files/board/arpl/overlayfs/opt/arpl/menu.sh index eb77c084..19abb2fb 100755 --- a/files/board/arpl/overlayfs/opt/arpl/menu.sh +++ b/files/board/arpl/overlayfs/opt/arpl/menu.sh @@ -1026,14 +1026,20 @@ function updateMenu() { dialog --backtitle "`backtitle`" --title "Update arpl" --aspect 18 \ --infobox "Installing new files" 0 0 # Process update-list.yml - while IFS="=" read KEY VALUE; do - mkdir -p "`dirname "${VALUE}"`" - mv /tmp/`basename "${KEY}"` "${VALUE}" - done < <(readConfigMap "replace" "/tmp/update-list.yml") while read F; do [ -f "${F}" ] && rm -f "${F}" [ -d "${F}" ] && rm -Rf "${F}" done < <(readConfigArray "remove" "/tmp/update-list.yml") + while IFS="=" read KEY VALUE; do + if [ "${KEY: -1}" = "/" ]; then + rm -Rf "${VALUE}" + mkdir -p "${VALUE}" + gzip -dc "/tmp/`basename "${KEY}"`.tgz" | tar xf - -C "${VALUE}" + else + mkdir -p "`dirname "${VALUE}"`" + mv "/tmp/`basename "${KEY}"`" "${VALUE}" + fi + done < <(readConfigMap "replace" "/tmp/update-list.yml") dialog --backtitle "`backtitle`" --title "Update arpl" --aspect 18 \ --yesno "Arpl updated with success to ${TAG}!\nReboot?" 0 0 [ $? -ne 0 ] && continue diff --git a/files/board/arpl/p1/ARPL-VERSION b/files/board/arpl/p1/ARPL-VERSION index 0fb471aa..d3bc27e1 100644 --- a/files/board/arpl/p1/ARPL-VERSION +++ b/files/board/arpl/p1/ARPL-VERSION @@ -1 +1 @@ -1.0-beta11 +1.0-beta11a diff --git a/img-gen.sh b/img-gen.sh index d79b569d..912207a6 100755 --- a/img-gen.sh +++ b/img-gen.sh @@ -89,8 +89,18 @@ zip -9 "arpl-${VERSION}.img.zip" arpl.img zip -9 "arpl-${VERSION}.vmdk-dyn.zip" arpl-dyn.vmdk zip -9 "arpl-${VERSION}.vmdk-flat.zip" arpl.vmdk arpl-flat.vmdk sha256sum update-list.yml > sha256sum -yq '.replace | explode(.) | to_entries | map([.key])[] | .[]' update-list.yml | while read F; do - (cd `dirname ${F}` && sha256sum `basename ${F}`) >> sha256sum -done -yq '.replace | explode(.) | to_entries | map([.key])[] | .[]' update-list.yml | xargs zip -9j "update.zip" sha256sum update-list.yml +zip -9j update.zip update-list.yml +while read F; do + if [ -d "${F}" ]; then + FTGZ="`basename "${F}"`.tgz" + tar czf "${FTGZ}" -C "${F}" . + sha256sum "${FTGZ}" >> sha256sum + zip -9j update.zip "${FTGZ}" + rm "${FTGZ}" + else + (cd `dirname ${F}` && sha256sum `basename ${F}`) >> sha256sum + zip -9j update.zip "${F}" + fi +done < <(yq '.replace | explode(.) | to_entries | map([.key])[] | .[]' update-list.yml) +zip -9j update.zip sha256sum rm -f sha256sum diff --git a/update-list.yml b/update-list.yml index 7aa66276..cb699339 100644 --- a/update-list.yml +++ b/update-list.yml @@ -1,8 +1,6 @@ +remove: replace: ".buildroot/output/images/bzImage": "/mnt/p3/bzImage-arpl" ".buildroot/output/images/rootfs.cpio.xz": "/mnt/p3/initrd-arpl" - "files/board/arpl/p1/grub/grub.cfg": "/mnt/p1/grub/grub.cfg" "files/board/arpl/p1/ARPL-VERSION" : "/mnt/p1/ARPL-VERSION" - "files/board/arpl/p1/grub/fonts/unicode.pf2": "/mnt/p1/grub/fonts/unicode.pf2" -remove: - "/mnt/p1/grub/locales" + "files/board/arpl/p1/grub/": "/mnt/p1/grub/"