From 50e7e583472984bbe50c375a4d4f5a29c2079d11 Mon Sep 17 00:00:00 2001 From: Michael Lynch Date: Thu, 31 Aug 2023 15:53:34 -0400 Subject: [PATCH] Install yq without Ansible (#1608) Resolves #1595 As part of our continuing effort to eliminate Ansible from our install process, this installs yq from within the bundle installer rather than during Ansible. This is a slight implementation change in that we no longer download the yq binary at install time and instead pre-download it and include it in the TinyPilot bundle. This is preferable, as it does more work in the packaging stage and less work on user devices, though it does increase the size of our bundles by a few megabytes. While we're here, we're also upgrading to the latest version of yq, so we're upgrading from `v4.30.6` to `v4.35.1`. ### Manual tests For expediency, I tested builds that combined: * #1605 * #1606 * #1608 For the manual tests, I verified: * Video works under MJPEG and H.264 * Changing video settings works In these environments: - [x] Pro Voyager build - [x] Community bundle on top of bare Raspbian system - [x] Community bundle on top of bare Raspbian system with TC358743 enabled ### Peer tests To test this bundle (which combines the stack of three PRs mentioned above), run: ```bash curl \ --silent \ --show-error \ --location \ https://raw.githubusercontent.com/tiny-pilot/tinypilot/master/scripts/install-bundle | \ sudo bash -s -- \ https://output.circle-artifacts.com/output/job/e70104a2-0f1f-43b7-abe9-098d6eac2799/artifacts/0/bundler/dist/tinypilot-community-20230831T0151Z-1.9.0-87+de1916a.tgz ``` Review
on CodeApprove --- ansible-role-ustreamer/tasks/install_yq.yml | 22 --------------------- ansible-role-ustreamer/tasks/main.yml | 3 --- ansible-role-ustreamer/vars/main.yml | 2 -- bundler/.gitignore | 1 + bundler/bundle/install | 4 ++++ bundler/create-bundle | 5 +++++ bundler/verify-bundle | 4 ++-- 7 files changed, 12 insertions(+), 29 deletions(-) delete mode 100644 ansible-role-ustreamer/tasks/install_yq.yml diff --git a/ansible-role-ustreamer/tasks/install_yq.yml b/ansible-role-ustreamer/tasks/install_yq.yml deleted file mode 100644 index 70cc112e7..000000000 --- a/ansible-role-ustreamer/tasks/install_yq.yml +++ /dev/null @@ -1,22 +0,0 @@ -# The architecture names that yq uses differ from the names of the architecture -# that Ansible returns, so we have to translate certain names from the Ansible -# version to the yq version. -- name: define ansible to yq architecture mapping - set_fact: - ustreamer_yq_architecture_map: - x86_64: amd64 - armv6l: arm - armv7l: arm - aarch64: arm64 - -- name: canonicalize yq binary architecture - set_fact: - ustreamer_yq_architecture: "{{ ustreamer_yq_architecture_map[ansible_architecture] | default(ansible_architecture) }}" - -- name: install yq - get_url: - url: "https://github.com/mikefarah/yq/releases/download/{{ ustreamer_yq_version }}/yq_linux_{{ ustreamer_yq_architecture }}" - dest: /usr/bin/yq - owner: root - group: root - mode: "0755" diff --git a/ansible-role-ustreamer/tasks/main.yml b/ansible-role-ustreamer/tasks/main.yml index d29629784..3b339a3c6 100644 --- a/ansible-role-ustreamer/tasks/main.yml +++ b/ansible-role-ustreamer/tasks/main.yml @@ -30,9 +30,6 @@ import_tasks: provision_tc358743.yml when: is_tc358743_enabled | bool -- name: install yq - import_tasks: install_yq.yml - - name: create uStreamer Janus plugin config template: src: janus.plugin.ustreamer.jcfg.j2 diff --git a/ansible-role-ustreamer/vars/main.yml b/ansible-role-ustreamer/vars/main.yml index a923ad139..d6fad4bff 100644 --- a/ansible-role-ustreamer/vars/main.yml +++ b/ansible-role-ustreamer/vars/main.yml @@ -5,5 +5,3 @@ ustreamer_dir: /opt/ustreamer # These variables are only used within this role. ustreamer_janus_configs_dir: /etc/janus - -ustreamer_yq_version: v4.30.6 diff --git a/bundler/.gitignore b/bundler/.gitignore index 406434a11..255dcdc6a 100644 --- a/bundler/.gitignore +++ b/bundler/.gitignore @@ -2,6 +2,7 @@ /bundle/tinypilot /bundle/roles /bundle/*.deb +/bundle/yq # Build artifacts. /dist diff --git a/bundler/bundle/install b/bundler/bundle/install index 48c111173..e482a39c8 100755 --- a/bundler/bundle/install +++ b/bundler/bundle/install @@ -55,6 +55,10 @@ apt-get install -y \ "./${USTREAMER_DEBIAN_PACKAGE}" \ "./${TINYPILOT_DEBIAN_PACKAGE}" +# Install yq. +mv yq /usr/bin/yq +chmod 0755 /usr/bin/yq + # Bootstrap environment for installation. apt-get update --allow-releaseinfo-change-suite apt-get install -y \ diff --git a/bundler/create-bundle b/bundler/create-bundle index d78d99017..62a3700b7 100755 --- a/bundler/create-bundle +++ b/bundler/create-bundle @@ -84,6 +84,11 @@ wget \ --directory-prefix="${BUNDLE_DIR}" \ https://github.com/tiny-pilot/ustreamer-debian/releases/download/ustreamer_5.38-20230802141939/ustreamer_5.38-20230802141939_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" diff --git a/bundler/verify-bundle b/bundler/verify-bundle index 42dfde577..d19f88239 100755 --- a/bundler/verify-bundle +++ b/bundler/verify-bundle @@ -22,8 +22,8 @@ if [[ "${BUNDLE_SIZE_BYTES}" -eq 0 ]]; then >&2 echo 'Bundle size is zero.' exit 1 fi -if [[ "${BUNDLE_SIZE_BYTES}" -gt 5000000 ]]; then - >&2 echo 'Bundle size is larger than 5mb.' +if [[ "${BUNDLE_SIZE_BYTES}" -gt 10000000 ]]; then + >&2 echo 'Bundle size is larger than 10mb.' exit 1 fi