Skip to content

Commit

Permalink
Refactor install-bundle to align with get-tinypilot.sh style (#1465)
Browse files Browse the repository at this point in the history
Related #1462
Dependent on #1464

Our `install-bundle` script is based on the `get-tinypilot.sh` script,
with a few changes to install TinyPilot from a specified bundle file.

This PR is a non-functional change to avoid creating an extra temporary
directory and to keep the code aligned with `get-tinypilot.sh`.

<a data-ca-tag
href="https://codeapprove.com/pr/tiny-pilot/tinypilot/1465"><img
src="https://codeapprove.com/external/github-tag-allbg.png" alt="Review
on CodeApprove" /></a>

---------

Co-authored-by: Michael Lynch <[email protected]>
  • Loading branch information
jdeanwallace and mtlynch authored Jun 23, 2023
1 parent d94ff9a commit bc069bd
Showing 1 changed file with 12 additions and 10 deletions.
22 changes: 12 additions & 10 deletions scripts/install-bundle
Original file line number Diff line number Diff line change
Expand Up @@ -60,15 +60,6 @@ set -x

readonly BUNDLE_PATH="$1"

if [[ "${BUNDLE_PATH}" == http* ]]; then
cd "$(mktemp --directory)"
wget "${BUNDLE_PATH}"
BUNDLE_FILE_PATH="${PWD}/$(find . -name '*.tgz')"
readonly BUNDLE_FILE_PATH
else
readonly BUNDLE_FILE_PATH="${BUNDLE_PATH}"
fi

# Historically, the TinyPilot bundle was unpacked to the device's disk, where it
# persisted. Since then, we've moved to the use of a volatile RAMdisk, which
# avoids excessive writes to the filesystem. As a result, this legacy installer
Expand Down Expand Up @@ -142,11 +133,22 @@ readonly TMPDIR="${INSTALLER_DIR}/tmp"
export TMPDIR
mkdir "${TMPDIR}"

if [[ "${BUNDLE_PATH}" == http* ]]; then
readonly BUNDLE_FILE="${INSTALLER_DIR}/bundle.tgz"
curl "${BUNDLE_PATH}" \
--location \
--output "${BUNDLE_FILE}" \
--show-error \
--silent
else
readonly BUNDLE_FILE="${BUNDLE_PATH}"
fi

# Extract tarball to installer directory.
tar \
--gunzip \
--extract \
--file "${BUNDLE_FILE_PATH}" \
--file "${BUNDLE_FILE}" \
--directory "${INSTALLER_DIR}"

# Run install.
Expand Down

0 comments on commit bc069bd

Please sign in to comment.