-
-
Notifications
You must be signed in to change notification settings - Fork 289
Expand file tree
/
Copy pathcreate-bundle
More file actions
executable file
·91 lines (76 loc) · 3.03 KB
/
create-bundle
File metadata and controls
executable file
·91 lines (76 loc) · 3.03 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
#!/bin/bash
# Creates a TinyPilot installation bundle from the bundle/ folder.
#
# You have to provide the TinyPilot Debian package and place it in the `bundle/`
# folder. The script fetches all other required dependencies automatically.
# Exit on first error.
set -e
# Exit on unset variable.
set -u
# Echo commands before executing them, by default to stderr.
set -x
# Change directory to repository root.
SCRIPT_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" &> /dev/null && pwd )"
readonly SCRIPT_DIR
cd "${SCRIPT_DIR}/.."
cd ./bundler
readonly BUNDLE_DIR='bundle'
readonly OUTPUT_DIR='dist'
# Ensure that a TinyPilot Debian package exists.
if ! ls "${BUNDLE_DIR}/tinypilot"*arm64.deb 1> /dev/null 2>&1; then
echo 'Failed to create bundle: no TinyPilot Debian package found.' >&2
exit 1
fi
# Ensure that a build timestamp file exists.
if [[ ! -e "${BUNDLE_DIR}/build-timestamp.txt" ]]; then
echo 'Failed to create bundle: no build timestamp file found.' >&2
exit 1
fi
# Prints the TinyPilot release version as populated in the Debian package. The
# Debian package stores the version string in a header field of its control
# file. The header is named: `Tinypilot-Version`.
print_tinypilot_version() {
# Shellcheck incorrectly warns that the `${...}` placeholder in `--showformat`
# doesn’t expand, due to the single-quotes. The format string is not meant to
# contain a bash variable, though, the placeholder is specific to `dpkg-deb`.
# shellcheck disable=SC2016
dpkg-deb \
--show \
--showformat '${Tinypilot-Version}' \
"${BUNDLE_DIR}/tinypilot"*arm64.deb
}
# Compose bundle file name, which consists of these hyphen-separated parts:
# 1. `tinypilot`
# 2. The TinyPilot variant: `community` or `pro`
# 3. A timestamp (which allows lexical sorting of bundles by their file names).
# 4. The SemVer-compliant TinyPilot version.
# Examples for bundle names:
# - `tinypilot-pro-20220620T1713Z-2.4.1.tgz` (Pro)
# - `tinypilot-community-20220620T1611Z-1.8.0-23+649a6b2.tgz` (Community)
TIMESTAMP="$(sed 's/-//g' "${BUNDLE_DIR}/build-timestamp.txt")"
readonly TIMESTAMP
TINYPILOT_VERSION="$(print_tinypilot_version)"
readonly TINYPILOT_VERSION
readonly TINYPILOT_VARIANT='community'
readonly BUNDLE_FILENAME="tinypilot-${TINYPILOT_VARIANT}-${TIMESTAMP}-${TINYPILOT_VERSION}.tgz"
# Download Janus Debian package.
wget \
--directory-prefix="${BUNDLE_DIR}" \
https://github.com/tiny-pilot/janus-debian/releases/download/1.3.2-20250929125525/janus_1.3.2-20250929125525_armhf.deb
# Download uStreamer Debian package.
wget \
--directory-prefix="${BUNDLE_DIR}" \
https://github.com/tiny-pilot/ustreamer-debian/releases/download/6.36-20250811120059/ustreamer_6.36-20250811120059_armhf.deb
# Download yq binary
wget \
https://github.com/mikefarah/yq/releases/download/v4.35.1/yq_linux_arm \
--output-document="${BUNDLE_DIR}/yq"
# Generate tarball bundle and meta file.
mkdir -p "${OUTPUT_DIR}"
ls -lahR "${BUNDLE_DIR}" > "${OUTPUT_DIR}/files.txt"
tar \
--create \
--gzip \
--file "${OUTPUT_DIR}/${BUNDLE_FILENAME}" \
--directory "${BUNDLE_DIR}" \
.