Skip to content

Commit 86f4536

Browse files
committed
update: rewrite logic
Signed-off-by: AuxXxilium <[email protected]>
1 parent 5965140 commit 86f4536

File tree

6 files changed

+26
-48
lines changed

6 files changed

+26
-48
lines changed

.github/workflows/build.yml

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -128,9 +128,7 @@ jobs:
128128
sed -i 's|ARC_TITLE="Arc ${ARC_VERSION}"|ARC_TITLE="Arc Essential ${ARC_VERSION}"|g' files/initrd/opt/arc/include/consts.sh
129129
sed -i 's|P_FILE="${MODEL_CONFIG_PATH}/platforms.yml"|P_FILE="${MODEL_CONFIG_PATH}/platforms-essential.yml"|g' files/initrd/opt/arc/include/consts.sh
130130
sed -i 's|https://api.github.com/repos/AuxXxilium/arc/releases|https://api.github.com/repos/AuxXxilium/arc-essential/releases|g' files/initrd/opt/arc/include/consts.sh
131-
sed -i 's|https://github.com/AuxXxilium/arc/releases/download/${TAG}/arc-${TAG}.img.zip|https://github.com/AuxXxilium/arc-essential/releases/download/${TAG}/arc-${TAG}.img.zip|g' files/initrd/opt/arc/include/consts.sh
132-
sed -i 's|https://github.com/AuxXxilium/arc/releases/download/${TAG}/update-${TAG}.zip|https://github.com/AuxXxilium/arc-essential/releases/download/${TAG}/update-${TAG}.zip|g' files/initrd/opt/arc/include/consts.sh
133-
sed -i 's|https://github.com/AuxXxilium/arc/releases/download/${TAG}/update-${TAG}.hash|https://github.com/AuxXxilium/arc-essential/releases/download/${TAG}/update-${TAG}.hash|g' files/initrd/opt/arc/include/consts.sh
131+
sed -i 's|https://github.com/AuxXxilium/arc/releases/download|https://github.com/AuxXxilium/arc-essential/releases/download|g' files/initrd/opt/arc/include/consts.sh
134132
sed -i '/2 "Beta \${BETATAG}" \\/d' files/initrd/opt/arc/arc-functions.sh
135133
sed -i '/3 "Update Dependencies \\Z1(maybe not stable)\\Zn" \\/d' files/initrd/opt/arc/arc-functions.sh
136134

files/initrd/opt/arc/arc-functions.sh

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1672,7 +1672,7 @@ function updateMenu() {
16721672
# Ask for Tag
16731673
if [ "${ARC_OFFLINE}" = "false" ]; then
16741674
TAG="$(curl -m 10 -skL "${API_URL}" | jq -r ".[].tag_name" | grep -v "dev" | sort -rV | head -1)"
1675-
BETATAG="$(curl -m 10 -skL "https://api.github.com/repos/AuxXxilium/arc-beta/releases" | jq -r ".[].tag_name" | grep -v "dev" | sort -rV | head -1)"
1675+
BETATAG="$(curl -m 10 -skL "${BETA_API_URL}" | jq -r ".[].tag_name" | grep -v "dev" | sort -rV | head -1)"
16761676
dialog --clear --backtitle "$(backtitle)" --title "Update Loader" \
16771677
--menu "Current: ${ARC_VERSION}" 7 50 0 \
16781678
1 "Latest ${TAG}" \
@@ -1727,7 +1727,7 @@ function updateMenu() {
17271727
# Ask for Tag
17281728
if [ "${ARC_OFFLINE}" = "false" ]; then
17291729
TAG="$(curl -m 10 -skL "${API_URL}" | jq -r ".[].tag_name" | grep -v "dev" | sort -rV | head -1)"
1730-
BETATAG="$(curl -m 10 -skL "https://api.github.com/repos/AuxXxilium/arc-beta/releases" | jq -r ".[].tag_name" | grep -v "dev" | sort -rV | head -1)"
1730+
BETATAG="$(curl -m 10 -skL "${BETA_API_URL}" | jq -r ".[].tag_name" | grep -v "dev" | sort -rV | head -1)"
17311731
dialog --clear --backtitle "$(backtitle)" --title "Upgrade Loader" --colors \
17321732
--menu "\Z1Loader will be reset to defaults after upgrade!\nIf you use Hardware encryption, your key will be deleted!\Zn\nCurrent: ${ARC_VERSION}" 10 50 0 \
17331733
1 "Latest ${TAG}" \

files/initrd/opt/arc/arc.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -94,8 +94,8 @@ elif [ "${ARC_MODE}" = "config" ]; then
9494

9595
if [ "${CONFDONE}" = "true" ]; then
9696
if [ -f "${MOD_ZIMAGE_FILE}" ] && [ -f "${MOD_RDGZ_FILE}" ]; then
97+
write_menu "9" "Build Loader (clean)"
9798
write_menu "2" "Rebuild Loader (existing)"
98-
write_menu "9" "Rebuild Loader (clean)"
9999
else
100100
write_menu "2" "Build Loader"
101101
fi

files/initrd/opt/arc/include/consts.sh

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,6 @@ TTYDPORT=$(grep -i '^TTYD_PORT=' /etc/arc.conf 2>/dev/null | cut -d'=' -f2)
5858
[ -z "${TTYDPORT}" ] && TTYDPORT="7681"
5959

6060
API_URL="https://api.github.com/repos/AuxXxilium/arc/releases"
61-
UPGRADE_URL="https://github.com/AuxXxilium/arc/releases/download/${TAG}/arc-${TAG}.img.zip"
62-
UPDATE_URL="https://github.com/AuxXxilium/arc/releases/download/${TAG}/update-${TAG}.zip"
63-
HASH_URL="https://github.com/AuxXxilium/arc/releases/download/${TAG}/update-${TAG}.hash"
61+
UPDATE_URL="https://github.com/AuxXxilium/arc/releases/download"
62+
BETA_API_URL="https://api.github.com/repos/AuxXxilium/arc-beta/releases"
63+
BETA_URL="https://github.com/AuxXxilium/arc-beta/releases/download"

files/initrd/opt/arc/include/functions.sh

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -481,9 +481,9 @@ function rebootTo() {
481481
[ -z "${1}" ] && exit 1
482482
if ! echo "${MODES}" | grep -wq "${1}"; then exit 1; fi
483483
[ "${1}" = "automated" ] && echo "arc-${MODEL}-${PRODUCTVER}-${ARC_VERSION}" >"${PART3_PATH}/automated"
484-
[ ! -f "${USER_GRUBENVFILE}" ] && grub-editenv ${USER_GRUBENVFILE} create
484+
[ ! -f "${USER_GRUBENVFILE}" ] && grub-editenv "${USER_GRUBENVFILE}" create
485485
# echo -e "Rebooting to ${1} mode..."
486-
grub-editenv ${USER_GRUBENVFILE} set next_entry="${1}"
486+
grub-editenv "${USER_GRUBENVFILE}" set next_entry="${1}"
487487
exec reboot
488488
}
489489

files/initrd/opt/arc/include/update.sh

Lines changed: 17 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -17,11 +17,9 @@ function updateLoader() {
1717
done
1818
fi
1919
if [ -n "${TAG}" ]; then
20-
export URL="${UPDATE_URL}"
21-
export TAG="${TAG}"
2220
{
2321
{
24-
curl -kL "${URL}" -o "${TMP_PATH}/update.zip" 2>&3 3>&-
22+
curl -kL "${UPDATE_URL}/${TAG}/update-${TAG}.zip" -o "${TMP_PATH}/update.zip" 2>&3 3>&-
2523
} 3>&1 >&4 4>&- |
2624
perl -C -lane '
2725
BEGIN {$header = "Downloading $ENV{URL}...\n\n"; $| = 1}
@@ -40,8 +38,7 @@ function updateLoader() {
4038
fi
4139
if [ -f "${TMP_PATH}/update.zip" ] && [ $(ls -s "${TMP_PATH}/update.zip" | cut -d' ' -f1) -gt 300000 ]; then
4240
if [ "${TAG}" != "zip" ]; then
43-
HASHURL="${HASH_URL}"
44-
HASH="$(curl -skL "${HASHURL}" | awk '{print $1}')"
41+
HASH="$(curl -skL "${UPDATE_URL}/${TAG}/update-${TAG}.hash" | awk '{print $1}')"
4542
if [ "${HASH}" != "$(sha256sum "${TMP_PATH}/update.zip" | awk '{print $1}')" ]; then
4643
dialog --backtitle "$(backtitle)" --title "Update Loader" --aspect 18 \
4744
--infobox "Update failed - Hash mismatch!\nTry again later." 0 0
@@ -110,7 +107,7 @@ function updateLoaderBeta() {
110107
if [ -z "${TAG}" ]; then
111108
idx=0
112109
while [ "${idx}" -le 5 ]; do # Loop 5 times, if successful, break
113-
TAG="$(curl -m 10 -skL "https://api.github.com/repos/AuxXxilium/arc-beta/releases" | jq -r ".[].tag_name" | grep -v "dev" | sort -rV | head -1)"
110+
TAG="$(curl -m 10 -skL "${BETA_API_URL}" | jq -r ".[].tag_name" | grep -v "dev" | sort -rV | head -1)"
114111
if [ -n "${TAG}" ]; then
115112
break
116113
fi
@@ -119,11 +116,9 @@ function updateLoaderBeta() {
119116
done
120117
fi
121118
if [ -n "${TAG}" ]; then
122-
export URL="https://github.com/AuxXxilium/arc-beta/releases/download/${TAG}/update-${TAG}.zip"
123-
export TAG="${TAG}"
124119
{
125120
{
126-
curl -kL "${URL}" -o "${TMP_PATH}/update.zip" 2>&3 3>&-
121+
curl -kL "${BETA_URL}/${TAG}/update-${TAG}.zip" -o "${TMP_PATH}/update.zip" 2>&3 3>&-
127122
} 3>&1 >&4 4>&- |
128123
perl -C -lane '
129124
BEGIN {$header = "Downloading $ENV{URL}...\n\n"; $| = 1}
@@ -142,8 +137,7 @@ function updateLoaderBeta() {
142137
fi
143138
if [ -f "${TMP_PATH}/update.zip" ] && [ $(ls -s "${TMP_PATH}/update.zip" | cut -d' ' -f1) -gt 300000 ]; then
144139
if [ "${TAG}" != "zip" ]; then
145-
HASHURL="https://github.com/AuxXxilium/arc-beta/releases/download/${TAG}/update-${TAG}.hash"
146-
HASH="$(curl -skL "${HASHURL}" | awk '{print $1}')"
140+
HASH="$(curl -skL "${BETA_URL}/${TAG}/update-${TAG}.hash" | awk '{print $1}')"
147141
if [ "${HASH}" != "$(sha256sum "${TMP_PATH}/update.zip" | awk '{print $1}')" ]; then
148142
dialog --backtitle "$(backtitle)" --title "Update Loader" --aspect 18 \
149143
--infobox "Update failed - Hash mismatch!\nTry again later." 0 0
@@ -196,7 +190,7 @@ function upgradeLoader() {
196190
if [ -z "${TAG}" ]; then
197191
idx=0
198192
while [ "${idx}" -le 5 ]; do # Loop 5 times, if successful, break
199-
TAG="$(curl -m 10 -skL "${UPGRADE_URL}" | jq -r ".[].tag_name" | grep -v "dev" | sort -rV | head -1)"
193+
TAG="$(curl -m 10 -skL "${API_URL}" | jq -r ".[].tag_name" | grep -v "dev" | sort -rV | head -1)"
200194
if [ -n "${TAG}" ]; then
201195
break
202196
fi
@@ -205,11 +199,9 @@ function upgradeLoader() {
205199
done
206200
fi
207201
if [ -n "${TAG}" ]; then
208-
export URL="${ARC_URL}"
209-
export TAG="${TAG}"
210202
{
211203
{
212-
curl -kL "${URL}" -o "${TMP_PATH}/arc.img.zip" 2>&3 3>&-
204+
curl -kL "${UPDATE_URL}/${TAG}/arc-${TAG}.img.zip" -o "${TMP_PATH}/arc.img.zip" 2>&3 3>&-
213205
} 3>&1 >&4 4>&- |
214206
perl -C -lane '
215207
BEGIN {$header = "Downloading $ENV{URL}...\n\n"; $| = 1}
@@ -240,12 +232,12 @@ function upgradeLoader() {
240232
DEV2=$(blkid | grep 'LABEL="ARC2"' | cut -d: -f1)
241233
DEV3=$(blkid | grep 'LABEL="ARC3"' | cut -d: -f1)
242234
# Get the base device (e.g., /dev/sda from /dev/sda1)
243-
DEV=$(echo "$DEV1" | sed 's/[0-9]*$//')
235+
DEV=$(echo "${DEV1}" | sed 's/[0-9]*$//')
244236

245-
if [ -b "$DEV" ] && [ -f "$IMG_FILE" ]; then
237+
if [ -b "${DEV}" ] && [ -f "${IMG_FILE}" ]; then
246238
# Write the whole image to the device (overwriting all partitions)
247-
if dd if="$IMG_FILE" of="$DEV" bs=1M conv=fsync; then
248-
rm -f "$IMG_FILE"
239+
if dd if="${IMG_FILE}" of="${DEV}" bs=1M conv=fsync; then
240+
rm -f "${IMG_FILE}"
249241
dialog --backtitle "$(backtitle)" --title "Upgrade Loader" \
250242
--infobox "Upgrade done! -> Rebooting..." 3 50
251243
sleep 2
@@ -284,11 +276,9 @@ function updateAddons() {
284276
idx=$((${idx} + 1))
285277
done
286278
if [ -n "${TAG}" ]; then
287-
export URL="https://github.com/AuxXxilium/arc-addons/releases/download/${TAG}/addons-${TAG}.zip"
288-
export TAG="${TAG}"
289279
{
290280
{
291-
curl -kL "${URL}" -o "${TMP_PATH}/addons.zip" 2>&3 3>&-
281+
curl -kL "https://github.com/AuxXxilium/arc-addons/releases/download/${TAG}/addons-${TAG}.zip" -o "${TMP_PATH}/addons.zip" 2>&3 3>&-
292282
} 3>&1 >&4 4>&- |
293283
perl -C -lane '
294284
BEGIN {$header = "Downloading $ENV{URL}...\n\n"; $| = 1}
@@ -338,11 +328,9 @@ function updatePatches() {
338328
idx=$((${idx} + 1))
339329
done
340330
if [ -n "${TAG}" ]; then
341-
export URL="https://github.com/AuxXxilium/arc-patches/releases/download/${TAG}/patches-${TAG}.zip"
342-
export TAG="${TAG}"
343331
{
344332
{
345-
curl -kL "${URL}" -o "${TMP_PATH}/patches.zip" 2>&3 3>&-
333+
curl -kL "https://github.com/AuxXxilium/arc-patches/releases/download/${TAG}/patches-${TAG}.zip" -o "${TMP_PATH}/patches.zip" 2>&3 3>&-
346334
} 3>&1 >&4 4>&- |
347335
perl -C -lane '
348336
BEGIN {$header = "Downloading $ENV{URL}...\n\n"; $| = 1}
@@ -391,11 +379,9 @@ function updateCustom() {
391379
idx=$((${idx} + 1))
392380
done
393381
if [ -n "${TAG}" ]; then
394-
export URL="https://github.com/AuxXxilium/arc-custom/releases/download/${TAG}/custom-${TAG}.zip"
395-
export TAG="${TAG}"
396382
{
397383
{
398-
curl -kL "${URL}" -o "${TMP_PATH}/custom.zip" 2>&3 3>&-
384+
curl -kL "https://github.com/AuxXxilium/arc-custom/releases/download/${TAG}/custom-${TAG}.zip" -o "${TMP_PATH}/custom.zip" 2>&3 3>&-
399385
} 3>&1 >&4 4>&- |
400386
perl -C -lane '
401387
BEGIN {$header = "Downloading $ENV{URL}...\n\n"; $| = 1}
@@ -450,11 +436,9 @@ function updateModules() {
450436
if [ -n "${TAG}" ]; then
451437
rm -rf "${MODULES_PATH}"
452438
mkdir -p "${MODULES_PATH}"
453-
export URL="https://github.com/AuxXxilium/arc-modules/releases/download/${TAG}/modules-${TAG}.zip"
454-
export TAG="${TAG}"
455439
{
456440
{
457-
curl -kL "${URL}" -o "${TMP_PATH}/modules.zip" 2>&3 3>&-
441+
curl -kL "https://github.com/AuxXxilium/arc-modules/releases/download/${TAG}/modules-${TAG}.zip" -o "${TMP_PATH}/modules.zip" 2>&3 3>&-
458442
} 3>&1 >&4 4>&- |
459443
perl -C -lane '
460444
BEGIN {$header = "Downloading $ENV{URL}...\n\n"; $| = 1}
@@ -518,11 +502,9 @@ function updateConfigs() {
518502
local TAG="${1}"
519503
fi
520504
if [ -n "${TAG}" ]; then
521-
export URL="https://github.com/AuxXxilium/arc-configs/releases/download/${TAG}/configs-${TAG}.zip"
522-
export TAG="${TAG}"
523505
{
524506
{
525-
curl -kL "${URL}" -o "${TMP_PATH}/configs.zip" 2>&3 3>&-
507+
curl -kL "https://github.com/AuxXxilium/arc-configs/releases/download/${TAG}/configs-${TAG}.zip" -o "${TMP_PATH}/configs.zip" 2>&3 3>&-
526508
} 3>&1 >&4 4>&- |
527509
perl -C -lane '
528510
BEGIN {$header = "Downloading $ENV{URL}...\n\n"; $| = 1}
@@ -575,11 +557,9 @@ function updateLKMs() {
575557
local TAG="${1}"
576558
fi
577559
if [ -n "${TAG}" ]; then
578-
export URL="https://github.com/AuxXxilium/arc-lkm/releases/download/${TAG}/rp-lkms.zip"
579-
export TAG="${TAG}"
580560
{
581561
{
582-
curl -kL "${URL}" -o "${TMP_PATH}/rp-lkms.zip" 2>&3 3>&-
562+
curl -kL "https://github.com/AuxXxilium/arc-lkm/releases/download/${TAG}/rp-lkms.zip" -o "${TMP_PATH}/rp-lkms.zip" 2>&3 3>&-
583563
} 3>&1 >&4 4>&- |
584564
perl -C -lane '
585565
BEGIN {$header = "Downloading $ENV{URL}...\n\n"; $| = 1}

0 commit comments

Comments
 (0)