From d93d15950a3d3a3bc56702fe1a31543eb66342c4 Mon Sep 17 00:00:00 2001 From: throwaway96 <68320646+throwaway96@users.noreply.github.com> Date: Sun, 28 Jan 2024 04:58:04 -0500 Subject: [PATCH] install.sh: remove timeout The timeout command has incompatible changes on webOS 7+. It's too annoying to work around, so switch to luna-send's builtin timeout mechanism. --- tools/install.sh | 18 ++++++++++++------ 1 file changed, 12 insertions(+), 6 deletions(-) diff --git a/tools/install.sh b/tools/install.sh index a62ff8e..d55a5da 100755 --- a/tools/install.sh +++ b/tools/install.sh @@ -7,7 +7,7 @@ MANIFEST_URL="${MANIFEST_URL:-https://github.com/webosbrew/webos-homebrew-channe export MANIFEST_URL echo "[ ] Downloading manifest..." -export MANIFEST_JSON="$(curl -L $MANIFEST_URL)" +export MANIFEST_JSON="$(curl -L -- "$MANIFEST_URL")" export $(node -e ' var manifest = JSON.parse(process.env.MANIFEST_JSON); @@ -16,19 +16,25 @@ console.info("IPK_SHA256=" + manifest.ipkHash.sha256); ') echo "[ ] Downloading $IPK_URL..." -curl -L $IPK_URL -o /tmp/hbchannel.ipk +curl -L -o /tmp/hbchannel.ipk -- "$IPK_URL" echo "$IPK_SHA256 /tmp/hbchannel.ipk" | sha256sum -c rm -rf /tmp/luna-install mkfifo /tmp/luna-install echo "[ ] Installing..." -luna-send-pub -i 'luna://com.webos.appInstallService/dev/install' '{"id":"com.ares.defaultName","ipkUrl":"/tmp/hbchannel.ipk","subscribe":true}' >/tmp/luna-install & +luna-send-pub -w 15000 -i 'luna://com.webos.appInstallService/dev/install' '{"id":"com.ares.defaultName","ipkUrl":"/tmp/hbchannel.ipk","subscribe":true}' >/tmp/luna-install & LUNA_PID=$! -result="$(timeout -t 15 egrep -i -m 1 'installed|failed' /tmp/luna-install || echo timeout)" -kill -term $LUNA_PID + +if ! result="$(fgrep -m 1 -e 'installed' -e 'failed' /tmp/luna-install)"; then + rm /tmp/luna-install + echo "[!] Install timed out" + exit 1 +fi + +kill -TERM "$LUNA_PID" 2>/dev/null || true rm /tmp/luna-install -case $result in +case "$result" in *installed*) ;; *) echo "[!] Install failed - $result"