From c1bdea0e5767f7dbca90a49682a07b52c9ee61ce Mon Sep 17 00:00:00 2001 From: AuxXxilium Date: Fri, 27 Sep 2024 20:52:14 +0200 Subject: [PATCH] tree: rework loader update Signed-off-by: AuxXxilium --- .github/workflows/autobuild.yml | 4 +- .github/workflows/build.yml | 4 +- files/initrd/opt/arc/arc-functions.sh | 70 +++++++++++--------------- files/initrd/opt/arc/include/update.sh | 14 +++--- files/initrd/opt/arc/update.sh | 22 ++------ 5 files changed, 44 insertions(+), 70 deletions(-) diff --git a/.github/workflows/autobuild.yml b/.github/workflows/autobuild.yml index 0d06e551..7e8f8cdc 100644 --- a/.github/workflows/autobuild.yml +++ b/.github/workflows/autobuild.yml @@ -124,7 +124,7 @@ jobs: convertova "${IMAGE_FILE}" "arc.ova" # Zip update and generate checksum - zip -9j update.zip "files/p3/bzImage-arc" "files/p3/initrd-arc" "files/p1/ARC-VERSION" "files/p1/ARC-BRANCH" "files/p1/boot/grub/grub.cfg" "files/p3/offline/offline.json" + zip -9j update.zip "files/p3/*" "files/p1/ARC-VERSION" "files/p1/ARC-BRANCH" "files/p1/boot/grub/grub.cfg" sha256sum update.zip >checksum.sha256 # Build incremental @@ -182,7 +182,7 @@ jobs: convertova "${IMAGE_FILE}" "arc-next.ova" # Zip update and generate checksum - zip -9j update-next.zip "files/p3/bzImage-arc" "files/p3/initrd-arc" "files/p1/ARC-VERSION" "files/p1/ARC-BRANCH" "files/p1/boot/grub/grub.cfg" "files/p3/offline/offline.json" + zip -9j update-next.zip "files/p3/*" "files/p1/ARC-VERSION" "files/p1/ARC-BRANCH" "files/p1/boot/grub/grub.cfg" sha256sum update-next.zip >checksum-next.sha256 # Zip image and generate checksum diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 21689578..5e79c341 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -162,7 +162,7 @@ jobs: convertova "${IMAGE_FILE}" "arc.ova" # Zip update and generate checksum - zip -9j update.zip "files/p3/bzImage-arc" "files/p3/initrd-arc" "files/p1/ARC-VERSION" "files/p1/ARC-BRANCH" "files/p1/boot/grub/grub.cfg" "files/p3/offline/offline.json" + zip -9j update.zip "files/p3/*" "files/p1/ARC-VERSION" "files/p1/ARC-BRANCH" "files/p1/boot/grub/grub.cfg" sha256sum update.zip >checksum.sha256 # Build incremental @@ -220,7 +220,7 @@ jobs: convertova "${IMAGE_FILE}" "arc-next.ova" # Zip update and generate checksum - zip -9j update-next.zip "files/p3/bzImage-arc" "files/p3/initrd-arc" "files/p1/ARC-VERSION" "files/p1/ARC-BRANCH" "files/p1/boot/grub/grub.cfg" "files/p3/offline/offline.json" + zip -9j update-next.zip "files/p3/*" "files/p1/ARC-VERSION" "files/p1/ARC-BRANCH" "files/p1/boot/grub/grub.cfg" sha256sum update-next.zip >checksum-next.sha256 # Zip image and generate checksum diff --git a/files/initrd/opt/arc/arc-functions.sh b/files/initrd/opt/arc/arc-functions.sh index ebe09336..d824ec6b 100755 --- a/files/initrd/opt/arc/arc-functions.sh +++ b/files/initrd/opt/arc/arc-functions.sh @@ -817,8 +817,8 @@ function updateMenu() { --menu "Choose an Option" 0 0 0 \ 0 "Buildroot Branch: \Z1${ARCBRANCH}\Zn" \ 1 "Automated Update Mode" \ - 2 "Full-Upgrade Loader \Z1(reflash)\Zn" \ - 3 "\Z4Advanced:\Zn Update Loader" \ + 2 "Full-Update Loader \Z1(update)\Zn" \ + 3 "Full-Upgrade Loader \Z1(reflash)\Zn" \ 4 "\Z4Advanced:\Zn Update Addons" \ 5 "\Z4Advanced:\Zn Update Configs" \ 6 "\Z4Advanced:\Zn Update LKMs" \ @@ -834,6 +834,33 @@ function updateMenu() { . ${ARC_PATH}/update.sh ;; 2) + # Ask for Tag + TAG="" + NEWVER="$(curl -m 10 -skL "https://api.github.com/repos/AuxXxilium/arc/releases" | jq -r ".[].tag_name" | sort -rV | head -1)" + OLDVER="$(cat ${PART1_PATH}/ARC-VERSION)" + dialog --clear --backtitle "$(backtitle)" --title "Full-Update Loader" \ + --menu "Current: ${OLDVER} -> Which Version?" 7 50 0 \ + 1 "Latest ${NEWVER}" \ + 2 "Select Version" \ + 2>"${TMP_PATH}/opts" + [ $? -ne 0 ] && break + opts=$(cat ${TMP_PATH}/opts) + if [ ${opts} -eq 1 ]; then + TAG="" + elif [ ${opts} -eq 2 ]; then + dialog --backtitle "$(backtitle)" --title "Full-Update Loader" \ + --inputbox "Type the Version!" 0 0 \ + 2>"${TMP_PATH}/input" + TAG=$(cat "${TMP_PATH}/input") + [ -z "${TAG}" ] && return 1 + fi + if updateLoader "${TAG}"; then + writeConfigKey "arc.builddone" "false" "${USER_CONFIG_FILE}" + BUILDDONE="$(readConfigKey "arc.builddone" "${USER_CONFIG_FILE}")" + exec reboot && exit 0 + fi + ;; + 3) # Ask for Tag TAG="" NEWVER="$(curl -m 10 -skL "https://api.github.com/repos/AuxXxilium/arc/releases" | jq -r ".[].tag_name" | sort -rV | head -1)" @@ -860,45 +887,6 @@ function updateMenu() { exec reboot && exit 0 fi ;; - 3) - # Ask for Tag - TAG="" - NEWVER="$(curl -m 10 -skL "https://api.github.com/repos/AuxXxilium/arc/releases" | jq -r ".[].tag_name" | sort -rV | head -1)" - OLDVER="$(cat ${PART1_PATH}/ARC-VERSION)" - dialog --clear --backtitle "$(backtitle)" --title "Update Loader" \ - --menu "Current: ${OLDVER} -> Which Version?" 7 50 0 \ - 1 "Latest ${NEWVER}" \ - 2 "Select Version" \ - 2>"${TMP_PATH}/opts" - [ $? -ne 0 ] && break - opts=$(cat ${TMP_PATH}/opts) - if [ ${opts} -eq 1 ]; then - TAG="" - elif [ ${opts} -eq 2 ]; then - dialog --backtitle "$(backtitle)" --title "Update Loader" \ - --inputbox "Type the Version!" 0 0 \ - 2>"${TMP_PATH}/input" - TAG=$(cat "${TMP_PATH}/input") - [ -z "${TAG}" ] && return 1 - fi - if updateLoader "${TAG}"; then - writeConfigKey "arc.builddone" "false" "${USER_CONFIG_FILE}" - BUILDDONE="$(readConfigKey "arc.builddone" "${USER_CONFIG_FILE}")" - # Ask for Reboot - dialog --clear --backtitle "$(backtitle)" --title "Update done"\ - --no-cancel --menu "Reboot now?" 7 40 0 \ - 1 "Yes - Reboot Arc Loader now" \ - 2 "No - I want to update more" \ - 2>"${TMP_PATH}/resp" - resp=$(cat ${TMP_PATH}/resp) - [ -z "${resp}" ] && return 1 - if [ ${resp} -eq 1 ]; then - rebootTo config - elif [ ${resp} -eq 2 ]; then - return 0 - fi - fi - ;; 4) # Ask for Tag TAG="" diff --git a/files/initrd/opt/arc/include/update.sh b/files/initrd/opt/arc/include/update.sh index cafb678b..405e1e54 100755 --- a/files/initrd/opt/arc/include/update.sh +++ b/files/initrd/opt/arc/include/update.sh @@ -134,7 +134,7 @@ function updateLoader() { return 1 fi elif [ ${ARC_VERSION} -lt ${UPDATE_VERSION} ] && [ "${AUTOMATED}" == "true" ]; then - dialog --backtitle "$(backtitle)" --title "Update Loader" \ + dialog --backtitle "$(backtitle)" --title "Full-Update Loader" \ --infobox "Config is not compatible to new Version!\nUpdate not possible!\nPlease reflash Loader." 0 0 sleep 5 updateFaileddialog @@ -171,13 +171,11 @@ function updateLoader() { echo "Download successful!" if [ "$(sha256sum "${TMP_PATH}/update.zip" | awk '{print $1}')" == "$(cat ${TMP_PATH}/checksum.sha256 | awk '{print $1}')" ]; then echo "Download successful!" - unzip -oq "${TMP_PATH}/update.zip" -d "${TMP_PATH}" + unzip -oq "${TMP_PATH}/update.zip" -d "${PART3_PATH}" echo "Installing new Loader Image..." - cp -f "${TMP_PATH}/grub.cfg" "${USER_GRUB_CONFIG}" - cp -f "${TMP_PATH}/ARC-VERSION" "${PART1_PATH}/ARC-VERSION" - cp -f "${TMP_PATH}/ARC-BRANCH" "${PART1_PATH}/ARC-BRANCH" - cp -f "${TMP_PATH}/bzImage-arc" "${ARC_BZIMAGE_FILE}" - cp -f "${TMP_PATH}/initrd-arc" "${ARC_RAMDISK_FILE}" + mv -f "${PART3_PATH}/grub.cfg" "${USER_GRUB_CONFIG}" + mv -f "${PART3_PATH}/ARC-VERSION" "${PART1_PATH}/ARC-VERSION" + mv -f "${PART3_PATH}/ARC-BRANCH" "${PART1_PATH}/ARC-BRANCH" rm -f "${TMP_PATH}/update.zip" echo "Update done!" sleep 2 @@ -191,7 +189,7 @@ function updateLoader() { sleep 5 updateFailed fi - ) 2>&1 | dialog --backtitle "$(backtitle)" --title "Update Loader" \ + ) 2>&1 | dialog --backtitle "$(backtitle)" --title "Full-Update Loader" \ --progressbox "Updating Loader..." 20 70 fi return 0 diff --git a/files/initrd/opt/arc/update.sh b/files/initrd/opt/arc/update.sh index 66495006..9fd2afc5 100755 --- a/files/initrd/opt/arc/update.sh +++ b/files/initrd/opt/arc/update.sh @@ -62,7 +62,7 @@ function arcUpdate() { fi FAILED="false" if echo "${ARC_VERSION}" | grep -q "dev"; then - dialog --backtitle "$(backtitle)" --title "Update Loader" --aspect 18 \ + dialog --backtitle "$(backtitle)" --title "Full-Update Loader" --aspect 18 \ --infobox "Development Version detected." 0 0 sleep 2 DEV="true" @@ -70,31 +70,19 @@ function arcUpdate() { # Automatic Update [ "${DEV}" == "true" ] && updateLoader "${ARC_VERSION}" || updateLoader [ $? -ne 0 ] && FAILED="true" - [ "${FAILED}" == "false" ] && updateAddons || true - [ $? -ne 0 ] && FAILED="true" - [ "${FAILED}" == "false" ] && updateConfigs || true - [ $? -ne 0 ] && FAILED="true" - [ "${FAILED}" == "false" ] && updateLKMs || true - [ $? -ne 0 ] && FAILED="true" - [ "${FAILED}" == "false" ] && updateModules || true - [ $? -ne 0 ] && FAILED="true" - [ "${FAILED}" == "false" ] && updatePatches || true - [ $? -ne 0 ] && FAILED="true" - [ "${FAILED}" == "false" ] && updateCustom || true - [ $? -ne 0 ] && FAILED="true" if [ "${FAILED}" == "true" ] && [ "${UPDATEMODE}" == "true" ]; then - dialog --backtitle "$(backtitle)" --title "Update Loader" --aspect 18 \ + dialog --backtitle "$(backtitle)" --title "Full-Update Loader" --aspect 18 \ --infobox "Update failed!\nPlease try again later." 0 0 sleep 3 exec reboot elif [ "${FAILED}" == "true" ]; then - dialog --backtitle "$(backtitle)" --title "Update Loader" --aspect 18 \ + dialog --backtitle "$(backtitle)" --title "Full-Update Loader" --aspect 18 \ --infobox "Update failed!\nRebooting to Config Mode..." 0 0 sleep 3 rebootTo config fi # Ask for Boot - dialog --backtitle "$(backtitle)" --title "Update Loader" --aspect 18 \ + dialog --backtitle "$(backtitle)" --title "Full-Update Loader" --aspect 18 \ --infobox "Update successful!" 0 0 boot } @@ -123,7 +111,7 @@ function boot() { if [ "${OFFLINE}" == "false" ]; then arcUpdate else - dialog --backtitle "$(backtitle)" --title "Update Loader" --aspect 18 \ + dialog --backtitle "$(backtitle)" --title "Full-Update Loader" --aspect 18 \ --infobox "Offline Mode enabled.\nCan't Update Loader!" 0 0 sleep 5 exec reboot