From 84eb782badd03a1bbdfa5a0861da7aeb3adef2f2 Mon Sep 17 00:00:00 2001 From: Michael Lynch Date: Mon, 10 Apr 2023 16:13:52 -0400 Subject: [PATCH 01/74] Set up TinyPilot virtual environment from Debian package --- ansible-role/tasks/main.yml | 18 ------------------ debian-pkg/Dockerfile | 1 + debian-pkg/debian/rules | 7 ++++++- debian-pkg/debian/tinypilot.triggers | 6 ++++++ 4 files changed, 13 insertions(+), 19 deletions(-) create mode 100644 debian-pkg/debian/tinypilot.triggers diff --git a/ansible-role/tasks/main.yml b/ansible-role/tasks/main.yml index 5a9c6ff38..2886da250 100644 --- a/ansible-role/tasks/main.yml +++ b/ansible-role/tasks/main.yml @@ -29,24 +29,6 @@ apt: deb: "{{ tinypilot_debian_package_path }}" -- name: find absolute path to python3 - shell: realpath $(which python3) - register: realpath_python3 - changed_when: false - -- name: save absolute path to python3 - set_fact: - python3_abs_path: "{{ realpath_python3.stdout }}" - -- name: create TinyPilot virtualenv - pip: - virtualenv: "{{ tinypilot_dir }}/venv" - virtualenv_command: "{{ python3_abs_path }} -m venv venv" - requirements: "{{ tinypilot_dir }}/requirements.txt" - extra_args: "{{ tinypilot_pip_args }}" - notify: - - restart TinyPilot service - - name: create TinyPilot app settings template: src: tinypilot-app-settings.cfg.j2 diff --git a/debian-pkg/Dockerfile b/debian-pkg/Dockerfile index d2daccb19..646f38f9c 100644 --- a/debian-pkg/Dockerfile +++ b/debian-pkg/Dockerfile @@ -8,6 +8,7 @@ RUN set -x && \ apt-get update && \ DEBIAN_FRONTEND=noninteractive apt-get install -y \ debhelper \ + dh-virtualenv \ dpkg-dev # The canonical, SemVer-compliant TinyPilot version. diff --git a/debian-pkg/debian/rules b/debian-pkg/debian/rules index 4ac002b8c..f74b8423f 100755 --- a/debian-pkg/debian/rules +++ b/debian-pkg/debian/rules @@ -1,7 +1,12 @@ #!/usr/bin/make -f +export DH_VIRTUALENV_INSTALL_ROOT=/opt/tinypilot + %: - dh $@ + dh $@ --with python-virtualenv override_dh_installsystemd: dh_installsystemd --name=tinypilot-updater --no-start --no-enable + +override_dh_virtualenv: + dh_virtualenv --skip-install diff --git a/debian-pkg/debian/tinypilot.triggers b/debian-pkg/debian/tinypilot.triggers new file mode 100644 index 000000000..48cc5af6b --- /dev/null +++ b/debian-pkg/debian/tinypilot.triggers @@ -0,0 +1,6 @@ +# Register interest in Python interpreter changes and don't make the Python +# package dependent on the virtualenv package processing (noawait). +interest-noawait /usr/bin/python3 + +# Also provide a symbolic trigger for all dh-virtualenv packages. +interest dh-virtualenv-interpreter-update From d4315185c9cdd8472242f27b20f140de921c0a9e Mon Sep 17 00:00:00 2001 From: Michael Lynch Date: Mon, 10 Apr 2023 16:15:20 -0400 Subject: [PATCH 02/74] work in progress --- debian-pkg/debian/tinypilot.triggers | 3 +++ 1 file changed, 3 insertions(+) diff --git a/debian-pkg/debian/tinypilot.triggers b/debian-pkg/debian/tinypilot.triggers index 48cc5af6b..80a876eb6 100644 --- a/debian-pkg/debian/tinypilot.triggers +++ b/debian-pkg/debian/tinypilot.triggers @@ -1,3 +1,6 @@ +# These triggers are based on guidance from the dh-virtualenv documentation. +# https://dh-virtualenv.readthedocs.io/en/1.2.1/tutorial.html#step-2-set-up-packaging-for-your-project + # Register interest in Python interpreter changes and don't make the Python # package dependent on the virtualenv package processing (noawait). interest-noawait /usr/bin/python3 From 216a61cfc7535741111561f108358675185017fa Mon Sep 17 00:00:00 2001 From: Michael Lynch Date: Mon, 10 Apr 2023 16:18:08 -0400 Subject: [PATCH 03/74] Spaces to tabs --- debian-pkg/debian/rules | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/debian-pkg/debian/rules b/debian-pkg/debian/rules index f74b8423f..cabac1627 100755 --- a/debian-pkg/debian/rules +++ b/debian-pkg/debian/rules @@ -9,4 +9,4 @@ override_dh_installsystemd: dh_installsystemd --name=tinypilot-updater --no-start --no-enable override_dh_virtualenv: - dh_virtualenv --skip-install + dh_virtualenv --skip-install From 895eb98b209b49017424f5d5b28aeb53a2a6e2f4 Mon Sep 17 00:00:00 2001 From: Michael Lynch Date: Mon, 10 Apr 2023 16:20:16 -0400 Subject: [PATCH 04/74] work in progress --- .vscode/settings.json | 3 +++ 1 file changed, 3 insertions(+) diff --git a/.vscode/settings.json b/.vscode/settings.json index 8afb97f43..b27341a95 100644 --- a/.vscode/settings.json +++ b/.vscode/settings.json @@ -8,6 +8,9 @@ "editor.defaultFormatter": "ms-python.python", "editor.tabSize": 4 }, + "[rules]": { + "editor.insertSpaces": false + }, "python.formatting.provider": "yapf", "python.linting.pylintEnabled": true, "python.linting.enabled": true, From d31b42a8bae0f5c2c371183472f5d08e592fc24e Mon Sep 17 00:00:00 2001 From: Michael Lynch Date: Mon, 10 Apr 2023 16:25:17 -0400 Subject: [PATCH 05/74] Use venv as suffix --- debian-pkg/debian/rules | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/debian-pkg/debian/rules b/debian-pkg/debian/rules index cabac1627..2ec503106 100755 --- a/debian-pkg/debian/rules +++ b/debian-pkg/debian/rules @@ -9,4 +9,4 @@ override_dh_installsystemd: dh_installsystemd --name=tinypilot-updater --no-start --no-enable override_dh_virtualenv: - dh_virtualenv --skip-install + dh_virtualenv --skip-install --install-suffix venv From 2e1c955867ae1032097750da24f55ba4778a2b92 Mon Sep 17 00:00:00 2001 From: Michael Lynch Date: Mon, 10 Apr 2023 16:30:45 -0400 Subject: [PATCH 06/74] Declare armhf arch --- debian-pkg/Dockerfile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/debian-pkg/Dockerfile b/debian-pkg/Dockerfile index 646f38f9c..bed400fc3 100644 --- a/debian-pkg/Dockerfile +++ b/debian-pkg/Dockerfile @@ -23,7 +23,7 @@ ARG PKG_VERSION ARG PKG_NAME="tinypilot" ARG PKG_BUILD_NUMBER="1" -ARG PKG_ARCH="all" +ARG PKG_ARCH="armhf" ARG PKG_ID="${PKG_NAME}-${PKG_VERSION}-${PKG_BUILD_NUMBER}-${PKG_ARCH}" RUN mkdir -p "/releases/${PKG_ID}" From 2de5d2d327366420022024809584a9bdce5b89cb Mon Sep 17 00:00:00 2001 From: Michael Lynch Date: Mon, 10 Apr 2023 16:36:44 -0400 Subject: [PATCH 07/74] work in progress --- debian-pkg/Dockerfile | 2 +- debian-pkg/debian/tinypilot.triggers | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/debian-pkg/Dockerfile b/debian-pkg/Dockerfile index bed400fc3..256afd1a0 100644 --- a/debian-pkg/Dockerfile +++ b/debian-pkg/Dockerfile @@ -51,7 +51,7 @@ Build-Depends: debhelper (>= 11) Package: ${PKG_NAME} Architecture: ${PKG_ARCH} -Depends: adduser, python3, python3-pip, python3-venv, sudo +Depends: ${shlibs:Depends}, adduser, python3, python3-pip, python3-venv, sudo Homepage: https://tinypilotkvm.com Description: Simple, easy-to-use KVM over IP XBS-Tinypilot-Version: ${TINYPILOT_VERSION} diff --git a/debian-pkg/debian/tinypilot.triggers b/debian-pkg/debian/tinypilot.triggers index 80a876eb6..4d4aae6f5 100644 --- a/debian-pkg/debian/tinypilot.triggers +++ b/debian-pkg/debian/tinypilot.triggers @@ -6,4 +6,4 @@ interest-noawait /usr/bin/python3 # Also provide a symbolic trigger for all dh-virtualenv packages. -interest dh-virtualenv-interpreter-update +interest -await dh-virtualenv-interpreter-update From 62fd67987ada32325fa99700f6a1e3893d3a2c1e Mon Sep 17 00:00:00 2001 From: Michael Lynch Date: Mon, 10 Apr 2023 16:43:59 -0400 Subject: [PATCH 08/74] Build with ARM emulation --- .circleci/config.yml | 3 +++ dev-scripts/build-debian-pkg | 1 + dev-scripts/enable-multiarch-docker | 29 +++++++++++++++++++++++++++++ 3 files changed, 33 insertions(+) create mode 100755 dev-scripts/enable-multiarch-docker diff --git a/.circleci/config.yml b/.circleci/config.yml index df457ce59..8b4233199 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -80,6 +80,9 @@ jobs: - checkout - setup_remote_docker: version: 20.10.11 + - run: + name: Enable multiarch builds with QEMU + command: ./dev-scripts/enable-multiarch-docker - run: name: Build Debian package command: ./dev-scripts/build-debian-pkg diff --git a/dev-scripts/build-debian-pkg b/dev-scripts/build-debian-pkg index 21622965c..2b06fa39a 100755 --- a/dev-scripts/build-debian-pkg +++ b/dev-scripts/build-debian-pkg @@ -30,6 +30,7 @@ readonly DOCKER_PROGRESS DOCKER_BUILDKIT=1 docker build \ --file debian-pkg/Dockerfile \ + --platform linux/arm/v7 \ --build-arg TINYPILOT_VERSION="${TINYPILOT_VERSION}" \ --build-arg PKG_VERSION="${PKG_VERSION}" \ --target=artifact \ diff --git a/dev-scripts/enable-multiarch-docker b/dev-scripts/enable-multiarch-docker new file mode 100755 index 000000000..26f6e218d --- /dev/null +++ b/dev-scripts/enable-multiarch-docker @@ -0,0 +1,29 @@ +#!/bin/bash + +# Exit build script on first failure. +set -e + +# Echo commands before executing them, by default to stderr. +set -x + +# Exit on unset variable. +set -u + +# Enable multiarch builds with QEMU +docker run \ + --rm \ + --privileged \ + multiarch/qemu-user-static \ + --reset \ + -p yes +# Create multiarch build context +docker context create builder + +# Create multiplatform builder +docker buildx create builder \ + --name builder \ + --driver docker-container \ + --use + +# Ensure builder has booted +docker buildx inspect --bootstrap From 638ca2fafedf4ce38a056be752e30d1162c8d39b Mon Sep 17 00:00:00 2001 From: Michael Lynch Date: Mon, 10 Apr 2023 16:46:30 -0400 Subject: [PATCH 09/74] Escape backslash --- debian-pkg/Dockerfile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/debian-pkg/Dockerfile b/debian-pkg/Dockerfile index 256afd1a0..eafd5f225 100644 --- a/debian-pkg/Dockerfile +++ b/debian-pkg/Dockerfile @@ -51,7 +51,7 @@ Build-Depends: debhelper (>= 11) Package: ${PKG_NAME} Architecture: ${PKG_ARCH} -Depends: ${shlibs:Depends}, adduser, python3, python3-pip, python3-venv, sudo +Depends: \${shlibs:Depends}, adduser, python3, python3-pip, python3-venv, sudo Homepage: https://tinypilotkvm.com Description: Simple, easy-to-use KVM over IP XBS-Tinypilot-Version: ${TINYPILOT_VERSION} From 239f801400683813f4d8c8c252ca8771893db606 Mon Sep 17 00:00:00 2001 From: Michael Lynch Date: Mon, 10 Apr 2023 17:37:08 -0400 Subject: [PATCH 10/74] Disable debug symbols --- debian-pkg/debian/rules | 2 ++ 1 file changed, 2 insertions(+) diff --git a/debian-pkg/debian/rules b/debian-pkg/debian/rules index 2ec503106..25efb4df9 100755 --- a/debian-pkg/debian/rules +++ b/debian-pkg/debian/rules @@ -1,6 +1,8 @@ #!/usr/bin/make -f export DH_VIRTUALENV_INSTALL_ROOT=/opt/tinypilot +# Prevent debhelper from generating an extra package with debug symbols. +export DEB_BUILD_OPTIONS=noddebs %: dh $@ --with python-virtualenv From 5d515121dffab505146b12bc53f12a05b6096349 Mon Sep 17 00:00:00 2001 From: Michael Lynch Date: Mon, 10 Apr 2023 17:37:25 -0400 Subject: [PATCH 11/74] Drop unused var --- ansible-role/defaults/main.yml | 1 - 1 file changed, 1 deletion(-) diff --git a/ansible-role/defaults/main.yml b/ansible-role/defaults/main.yml index a3ab18405..e7dba64ae 100644 --- a/ansible-role/defaults/main.yml +++ b/ansible-role/defaults/main.yml @@ -12,7 +12,6 @@ tinypilot_port: 8000 tinypilot_keyboard_interface: /dev/hidg0 tinypilot_mouse_interface: /dev/hidg1 tinypilot_enable_debug_logging: no -tinypilot_pip_args: "" tinypilot_app_settings_file: "/home/{{ tinypilot_user }}/app_settings.cfg" # uStreamer version to use on systems prior to Raspbian Bullseye (Debian 11). From bf54f5afaaab7f584f31a1cb4a4f1e5a4046a574 Mon Sep 17 00:00:00 2001 From: Michael Lynch Date: Mon, 10 Apr 2023 17:37:51 -0400 Subject: [PATCH 12/74] Add doc --- dev-scripts/build-debian-pkg | 3 +++ 1 file changed, 3 insertions(+) diff --git a/dev-scripts/build-debian-pkg b/dev-scripts/build-debian-pkg index 2b06fa39a..baef5f8f5 100755 --- a/dev-scripts/build-debian-pkg +++ b/dev-scripts/build-debian-pkg @@ -1,5 +1,8 @@ #!/bin/bash +# Note: You must run ./dev-scripts/enable-multiarch-docker on your system at +# least once before running this script. + # Exit build script on first failure. set -e From fe5447bce2b023220ee51941d3260f21994e7ae0 Mon Sep 17 00:00:00 2001 From: Michael Lynch Date: Mon, 10 Apr 2023 17:57:35 -0400 Subject: [PATCH 13/74] work in progress --- .lintianignore | 4 ++++ debian-pkg/debian/rules | 4 ++++ 2 files changed, 8 insertions(+) diff --git a/.lintianignore b/.lintianignore index 64682aa83..bf8d34b7d 100644 --- a/.lintianignore +++ b/.lintianignore @@ -26,3 +26,7 @@ systemd-service-file-refers-to-unusual-wantedby-target # user-defined fields, though. # https://lintian.debian.org/tags/unknown-field unknown-field + +# Lintian doesn't recognize the Python interpreter within the Python virtual +# environment. +unusual-interpreter diff --git a/debian-pkg/debian/rules b/debian-pkg/debian/rules index 25efb4df9..09bae2eda 100755 --- a/debian-pkg/debian/rules +++ b/debian-pkg/debian/rules @@ -12,3 +12,7 @@ override_dh_installsystemd: override_dh_virtualenv: dh_virtualenv --skip-install --install-suffix venv + +override_dh_clean: + dh_clean opt/tinypilot/venv/.gitignore + find . -type d -name __pycache__ -delete From 6d0dd9e7a004e95d6ccfe7e9e3f0b5819b0544f8 Mon Sep 17 00:00:00 2001 From: Michael Lynch Date: Mon, 10 Apr 2023 18:00:00 -0400 Subject: [PATCH 14/74] Use environment variable --- debian-pkg/debian/rules | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/debian-pkg/debian/rules b/debian-pkg/debian/rules index 09bae2eda..0e2985e28 100755 --- a/debian-pkg/debian/rules +++ b/debian-pkg/debian/rules @@ -14,5 +14,5 @@ override_dh_virtualenv: dh_virtualenv --skip-install --install-suffix venv override_dh_clean: - dh_clean opt/tinypilot/venv/.gitignore + dh_clean $(DH_VIRTUALENV_INSTALL_ROOT)/venv/.gitignore find . -type d -name __pycache__ -delete From d5e295f081de5cc6e9fb5dbad3aed70cbea38242 Mon Sep 17 00:00:00 2001 From: Michael Lynch Date: Mon, 10 Apr 2023 18:03:10 -0400 Subject: [PATCH 15/74] Fix characters --- debian-pkg/debian/rules | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/debian-pkg/debian/rules b/debian-pkg/debian/rules index 0e2985e28..61d6967fa 100755 --- a/debian-pkg/debian/rules +++ b/debian-pkg/debian/rules @@ -14,5 +14,5 @@ override_dh_virtualenv: dh_virtualenv --skip-install --install-suffix venv override_dh_clean: - dh_clean $(DH_VIRTUALENV_INSTALL_ROOT)/venv/.gitignore - find . -type d -name __pycache__ -delete + dh_clean $(DH_VIRTUALENV_INSTALL_ROOT)/venv/.gitignore + find . -type d -name __pycache__ -delete From 1201645a097ade48ed21839a36ecff41ce986675 Mon Sep 17 00:00:00 2001 From: Michael Lynch Date: Mon, 10 Apr 2023 18:06:50 -0400 Subject: [PATCH 16/74] Fix interest command --- debian-pkg/debian/tinypilot.triggers | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/debian-pkg/debian/tinypilot.triggers b/debian-pkg/debian/tinypilot.triggers index 4d4aae6f5..a00b0c99d 100644 --- a/debian-pkg/debian/tinypilot.triggers +++ b/debian-pkg/debian/tinypilot.triggers @@ -6,4 +6,4 @@ interest-noawait /usr/bin/python3 # Also provide a symbolic trigger for all dh-virtualenv packages. -interest -await dh-virtualenv-interpreter-update +interest-await dh-virtualenv-interpreter-update From bb0a7ab19be10fba55b616ac5db445ca04442a07 Mon Sep 17 00:00:00 2001 From: Michael Lynch Date: Mon, 10 Apr 2023 18:08:22 -0400 Subject: [PATCH 17/74] Add TODO --- dev-scripts/install-from-source | 1 + 1 file changed, 1 insertion(+) diff --git a/dev-scripts/install-from-source b/dev-scripts/install-from-source index 811b8f41d..017b5a2c6 100755 --- a/dev-scripts/install-from-source +++ b/dev-scripts/install-from-source @@ -33,6 +33,7 @@ if [[ "$(lsb_release --id --short)" == "Raspbian" && \ ./debian-pkg/Dockerfile fi +# TODO: Update this to not use QEMU on TinyPilot device. ./dev-scripts/build-debian-pkg # Shellcheck recommends find instead of ls for non-alphanumeric filenames, but From 41f098d5519d1daeef1b26a5d1eeee5f14950b07 Mon Sep 17 00:00:00 2001 From: Michael Lynch Date: Mon, 10 Apr 2023 18:26:26 -0400 Subject: [PATCH 18/74] Remove junk after dh_virtualenv --- debian-pkg/debian/rules | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/debian-pkg/debian/rules b/debian-pkg/debian/rules index 61d6967fa..cfc2656ab 100755 --- a/debian-pkg/debian/rules +++ b/debian-pkg/debian/rules @@ -12,7 +12,5 @@ override_dh_installsystemd: override_dh_virtualenv: dh_virtualenv --skip-install --install-suffix venv - -override_dh_clean: - dh_clean $(DH_VIRTUALENV_INSTALL_ROOT)/venv/.gitignore + rm $(DH_VIRTUALENV_INSTALL_ROOT)/venv/.gitignore find . -type d -name __pycache__ -delete From be7322d2f82ada6bb8dd936f06d9410b865df43e Mon Sep 17 00:00:00 2001 From: Michael Lynch Date: Mon, 10 Apr 2023 18:41:00 -0400 Subject: [PATCH 19/74] Fix path --- debian-pkg/debian/rules | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/debian-pkg/debian/rules b/debian-pkg/debian/rules index cfc2656ab..03cc1f7a7 100755 --- a/debian-pkg/debian/rules +++ b/debian-pkg/debian/rules @@ -12,5 +12,5 @@ override_dh_installsystemd: override_dh_virtualenv: dh_virtualenv --skip-install --install-suffix venv - rm $(DH_VIRTUALENV_INSTALL_ROOT)/venv/.gitignore + rm opt/tinypilot/venv/.gitignore find . -type d -name __pycache__ -delete From 736269b9bfc28fc558e1202f465788649f0b09aa Mon Sep 17 00:00:00 2001 From: Michael Lynch Date: Mon, 10 Apr 2023 19:12:23 -0400 Subject: [PATCH 20/74] Remove gitignore rule --- debian-pkg/debian/rules | 1 - 1 file changed, 1 deletion(-) diff --git a/debian-pkg/debian/rules b/debian-pkg/debian/rules index 03cc1f7a7..0cb929d7d 100755 --- a/debian-pkg/debian/rules +++ b/debian-pkg/debian/rules @@ -12,5 +12,4 @@ override_dh_installsystemd: override_dh_virtualenv: dh_virtualenv --skip-install --install-suffix venv - rm opt/tinypilot/venv/.gitignore find . -type d -name __pycache__ -delete From a46a6e3e85543917fd2c16f73d43ad4cdea80a24 Mon Sep 17 00:00:00 2001 From: Michael Lynch Date: Mon, 10 Apr 2023 19:30:56 -0400 Subject: [PATCH 21/74] Fix find command --- debian-pkg/debian/rules | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/debian-pkg/debian/rules b/debian-pkg/debian/rules index 0cb929d7d..40eb733a6 100755 --- a/debian-pkg/debian/rules +++ b/debian-pkg/debian/rules @@ -12,4 +12,4 @@ override_dh_installsystemd: override_dh_virtualenv: dh_virtualenv --skip-install --install-suffix venv - find . -type d -name __pycache__ -delete + find . -type d -name __pycache__ -prune -exec rm -rf {} \; From a6ecb787684077080ac39eaa7df0e94685f6f444 Mon Sep 17 00:00:00 2001 From: Michael Lynch Date: Mon, 10 Apr 2023 19:31:52 -0400 Subject: [PATCH 22/74] Build multi-arch --- .circleci/config.yml | 2 +- debian-pkg/debian/rules | 1 - dev-scripts/build-debian-pkg | 4 +++- dev-scripts/install-from-source | 3 +-- 4 files changed, 5 insertions(+), 5 deletions(-) diff --git a/.circleci/config.yml b/.circleci/config.yml index 8b4233199..43b6dba77 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -85,7 +85,7 @@ jobs: command: ./dev-scripts/enable-multiarch-docker - run: name: Build Debian package - command: ./dev-scripts/build-debian-pkg + command: ./dev-scripts/build-debian-pkg "linux/arm/v7,linux/amd64" - run: name: Print Debian package contents command: dpkg --contents debian-pkg/releases/tinypilot*.deb diff --git a/debian-pkg/debian/rules b/debian-pkg/debian/rules index 40eb733a6..25efb4df9 100755 --- a/debian-pkg/debian/rules +++ b/debian-pkg/debian/rules @@ -12,4 +12,3 @@ override_dh_installsystemd: override_dh_virtualenv: dh_virtualenv --skip-install --install-suffix venv - find . -type d -name __pycache__ -prune -exec rm -rf {} \; diff --git a/dev-scripts/build-debian-pkg b/dev-scripts/build-debian-pkg index baef5f8f5..7a7f1a655 100755 --- a/dev-scripts/build-debian-pkg +++ b/dev-scripts/build-debian-pkg @@ -12,6 +12,8 @@ set -x # Exit on unset variable. set -u +BUILD_TARGETS="$1" + print_tinypilot_version() { # Format build hash suffix according to SemVer (`-ghhhhhhh` -> `+hhhhhhh`). git describe --tags --long | @@ -33,7 +35,7 @@ readonly DOCKER_PROGRESS DOCKER_BUILDKIT=1 docker build \ --file debian-pkg/Dockerfile \ - --platform linux/arm/v7 \ + --platform "${BUILD_TARGETS}" \ --build-arg TINYPILOT_VERSION="${TINYPILOT_VERSION}" \ --build-arg PKG_VERSION="${PKG_VERSION}" \ --target=artifact \ diff --git a/dev-scripts/install-from-source b/dev-scripts/install-from-source index 017b5a2c6..7663d504f 100755 --- a/dev-scripts/install-from-source +++ b/dev-scripts/install-from-source @@ -33,8 +33,7 @@ if [[ "$(lsb_release --id --short)" == "Raspbian" && \ ./debian-pkg/Dockerfile fi -# TODO: Update this to not use QEMU on TinyPilot device. -./dev-scripts/build-debian-pkg +./dev-scripts/build-debian-pkg "linux/arm/v7" # Shellcheck recommends find instead of ls for non-alphanumeric filenames, but # we don't expect non-alphanumeric filenames, and the find equivalent is more From ea20152320d5d6f06bc155798b154e5e2edb0bb9 Mon Sep 17 00:00:00 2001 From: Michael Lynch Date: Mon, 10 Apr 2023 20:06:20 -0400 Subject: [PATCH 23/74] Remove more cruft --- debian-pkg/debian/rules | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/debian-pkg/debian/rules b/debian-pkg/debian/rules index 40eb733a6..477eb0536 100755 --- a/debian-pkg/debian/rules +++ b/debian-pkg/debian/rules @@ -12,4 +12,9 @@ override_dh_installsystemd: override_dh_virtualenv: dh_virtualenv --skip-install --install-suffix venv + rm ./debian/tinypilot$(DH_VIRTUALENV_INSTALL_ROOT)/venv/.gitignore + rm -rf ./debian/tinypilot$(DH_VIRTUALENV_INSTALL_ROOT)/venv/lib/python3.9/site-packages/werkzeug/debug/ + rm -rf ./debian/tinypilot$(DH_VIRTUALENV_INSTALL_ROOT)/venv/lib/python3.9/site-packages/greenlet/tests/ find . -type d -name __pycache__ -prune -exec rm -rf {} \; + chmod +x ./debian/tinypilot$(DH_VIRTUALENV_INSTALL_ROOT)/venv/lib/python3.9/site-packages/pkg_resources/_vendor/appdirs.py + chmod +x ./debian/tinypilot$(DH_VIRTUALENV_INSTALL_ROOT)/venv/lib/python3.9/site-packages/setuptools/command/easy_install.py From 0fa25b51c22275dd99cd11bd801095539d158ff0 Mon Sep 17 00:00:00 2001 From: Michael Lynch Date: Mon, 10 Apr 2023 20:15:17 -0400 Subject: [PATCH 24/74] work in progress --- debian-pkg/Dockerfile | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/debian-pkg/Dockerfile b/debian-pkg/Dockerfile index eafd5f225..da317d28b 100644 --- a/debian-pkg/Dockerfile +++ b/debian-pkg/Dockerfile @@ -42,7 +42,14 @@ RUN echo "${TINYPILOT_VERSION}" > VERSION WORKDIR "/releases/${PKG_ID}/debian" -RUN cat >control <control < Date: Mon, 10 Apr 2023 20:15:50 -0400 Subject: [PATCH 25/74] Don't hardcode python version --- debian-pkg/debian/rules | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/debian-pkg/debian/rules b/debian-pkg/debian/rules index 477eb0536..2cd484167 100755 --- a/debian-pkg/debian/rules +++ b/debian-pkg/debian/rules @@ -13,8 +13,8 @@ override_dh_installsystemd: override_dh_virtualenv: dh_virtualenv --skip-install --install-suffix venv rm ./debian/tinypilot$(DH_VIRTUALENV_INSTALL_ROOT)/venv/.gitignore - rm -rf ./debian/tinypilot$(DH_VIRTUALENV_INSTALL_ROOT)/venv/lib/python3.9/site-packages/werkzeug/debug/ - rm -rf ./debian/tinypilot$(DH_VIRTUALENV_INSTALL_ROOT)/venv/lib/python3.9/site-packages/greenlet/tests/ + rm -rf ./debian/tinypilot$(DH_VIRTUALENV_INSTALL_ROOT)/venv/lib/python*/site-packages/werkzeug/debug/ + rm -rf ./debian/tinypilot$(DH_VIRTUALENV_INSTALL_ROOT)/venv/lib/python*/site-packages/greenlet/tests/ find . -type d -name __pycache__ -prune -exec rm -rf {} \; - chmod +x ./debian/tinypilot$(DH_VIRTUALENV_INSTALL_ROOT)/venv/lib/python3.9/site-packages/pkg_resources/_vendor/appdirs.py - chmod +x ./debian/tinypilot$(DH_VIRTUALENV_INSTALL_ROOT)/venv/lib/python3.9/site-packages/setuptools/command/easy_install.py + chmod +x ./debian/tinypilot$(DH_VIRTUALENV_INSTALL_ROOT)/venv/lib/python*/site-packages/pkg_resources/_vendor/appdirs.py + chmod +x ./debian/tinypilot$(DH_VIRTUALENV_INSTALL_ROOT)/venv/lib/python*/site-packages/setuptools/command/easy_install.py From ce3fe2530c7180fab07a9e4bfbba2f37eff52507 Mon Sep 17 00:00:00 2001 From: Michael Lynch Date: Mon, 10 Apr 2023 20:16:14 -0400 Subject: [PATCH 26/74] work in progress --- debian-pkg/debian/rules | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/debian-pkg/debian/rules b/debian-pkg/debian/rules index 2cd484167..175dc290c 100755 --- a/debian-pkg/debian/rules +++ b/debian-pkg/debian/rules @@ -12,9 +12,9 @@ override_dh_installsystemd: override_dh_virtualenv: dh_virtualenv --skip-install --install-suffix venv + find . -type d -name __pycache__ -prune -exec rm -rf {} \; rm ./debian/tinypilot$(DH_VIRTUALENV_INSTALL_ROOT)/venv/.gitignore rm -rf ./debian/tinypilot$(DH_VIRTUALENV_INSTALL_ROOT)/venv/lib/python*/site-packages/werkzeug/debug/ rm -rf ./debian/tinypilot$(DH_VIRTUALENV_INSTALL_ROOT)/venv/lib/python*/site-packages/greenlet/tests/ - find . -type d -name __pycache__ -prune -exec rm -rf {} \; chmod +x ./debian/tinypilot$(DH_VIRTUALENV_INSTALL_ROOT)/venv/lib/python*/site-packages/pkg_resources/_vendor/appdirs.py chmod +x ./debian/tinypilot$(DH_VIRTUALENV_INSTALL_ROOT)/venv/lib/python*/site-packages/setuptools/command/easy_install.py From ecb44ff6ed1eda9c38e6f68016e9e70d08a5e824 Mon Sep 17 00:00:00 2001 From: Michael Lynch Date: Mon, 10 Apr 2023 20:31:08 -0400 Subject: [PATCH 27/74] work in progress --- debian-pkg/Dockerfile | 16 ++++++++++------ dev-scripts/build-debian-pkg | 2 +- 2 files changed, 11 insertions(+), 7 deletions(-) diff --git a/debian-pkg/Dockerfile b/debian-pkg/Dockerfile index da317d28b..a83217648 100644 --- a/debian-pkg/Dockerfile +++ b/debian-pkg/Dockerfile @@ -24,11 +24,11 @@ ARG PKG_VERSION ARG PKG_NAME="tinypilot" ARG PKG_BUILD_NUMBER="1" ARG PKG_ARCH="armhf" -ARG PKG_ID="${PKG_NAME}-${PKG_VERSION}-${PKG_BUILD_NUMBER}-${PKG_ARCH}" +RUN echo "${PKG_NAME}-${PKG_VERSION}-${PKG_BUILD_NUMBER}-${PKG_ARCH}" > /tmp/pkg-id -RUN mkdir -p "/releases/${PKG_ID}" +RUN mkdir -p "/releases/temp-pkg-id" -WORKDIR "/releases/${PKG_ID}" +WORKDIR "/releases/temp-pkg-id" COPY ./debian-pkg ./ COPY ./COPYRIGHT ./ @@ -40,7 +40,7 @@ COPY ./scripts ./scripts RUN echo "${TINYPILOT_VERSION}" > VERSION -WORKDIR "/releases/${PKG_ID}/debian" +WORKDIR "/releases/temp-pkg-id/debian" RUN set -x && \ if [ "$TARGETPLATFORM" = "linux/arm/v7" ]; then \ @@ -72,8 +72,12 @@ tinypilot (${PKG_VERSION}) buster; urgency=medium -- TinyPilot Support $(date '+%a, %d %b %Y %H:%M:%S %z') EOF -WORKDIR "/releases/${PKG_ID}" -RUN dpkg-buildpackage --build=binary +# Rename the temporary release directory to the final package ID. +WORKDIR "/releases" +RUN set -x && \ + mv tmp-pkg-id "$(cat /tmp/pkg-id)" && \ + cd "$(cat /tmp/pkg-id)" && \ + dpkg-buildpackage --build=binary FROM scratch as artifact diff --git a/dev-scripts/build-debian-pkg b/dev-scripts/build-debian-pkg index 7a7f1a655..b4a4a808b 100755 --- a/dev-scripts/build-debian-pkg +++ b/dev-scripts/build-debian-pkg @@ -12,7 +12,7 @@ set -x # Exit on unset variable. set -u -BUILD_TARGETS="$1" +BUILD_TARGETS="${1:-linux/arm/v7,linux/amd64}" print_tinypilot_version() { # Format build hash suffix according to SemVer (`-ghhhhhhh` -> `+hhhhhhh`). From c0c88841f5657f6a0c86159252ced1348019bd96 Mon Sep 17 00:00:00 2001 From: Michael Lynch Date: Mon, 10 Apr 2023 20:34:25 -0400 Subject: [PATCH 28/74] Docker buildx --- dev-scripts/build-debian-pkg | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/dev-scripts/build-debian-pkg b/dev-scripts/build-debian-pkg index b4a4a808b..cd73f2b16 100755 --- a/dev-scripts/build-debian-pkg +++ b/dev-scripts/build-debian-pkg @@ -33,7 +33,7 @@ if [[ -n "${CI:-}" ]]; then fi readonly DOCKER_PROGRESS -DOCKER_BUILDKIT=1 docker build \ +DOCKER_BUILDKIT=1 docker buildx build \ --file debian-pkg/Dockerfile \ --platform "${BUILD_TARGETS}" \ --build-arg TINYPILOT_VERSION="${TINYPILOT_VERSION}" \ From 913a471803212b7521dc03d64ec0bfd0c0dd2956 Mon Sep 17 00:00:00 2001 From: Michael Lynch Date: Mon, 10 Apr 2023 20:57:26 -0400 Subject: [PATCH 29/74] work in progress --- .circleci/config.yml | 7 ++++--- debian-pkg/Dockerfile | 37 ++++++++++++++++++++++++------------- 2 files changed, 28 insertions(+), 16 deletions(-) diff --git a/.circleci/config.yml b/.circleci/config.yml index 43b6dba77..46c874b31 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -92,7 +92,8 @@ jobs: - persist_to_workspace: root: ./debian-pkg/releases paths: - - "*.deb" + - "linux_amd64/*.deb" + - "linux_arm_v7/*.deb" - persist_to_workspace: root: ./ paths: @@ -121,7 +122,7 @@ jobs: --suppress-tags-from-file .lintianignore \ --no-cfg \ --fail-on warning,error \ - tinypilot*.deb + tinypilot*armhf.deb build_ansible_role: machine: image: ubuntu-2004:202010-01 @@ -135,7 +136,7 @@ jobs: - run: name: Add TinyPilot Debian package name as an environment variable command: | - TINYPILOT_DEBIAN_PACKAGE="$(ls ./debian-pkgs/tinypilot*.deb | xargs basename)" + TINYPILOT_DEBIAN_PACKAGE="$(ls ./debian-pkgs/tinypilot*amd64.deb | xargs basename)" echo "export TINYPILOT_DEBIAN_PACKAGE="${TINYPILOT_DEBIAN_PACKAGE}"" >> "${BASH_ENV}" - run: name: Create virtual environment diff --git a/debian-pkg/Dockerfile b/debian-pkg/Dockerfile index a83217648..0e9b7f0fe 100644 --- a/debian-pkg/Dockerfile +++ b/debian-pkg/Dockerfile @@ -11,6 +11,9 @@ RUN set -x && \ dh-virtualenv \ dpkg-dev +# Set by docker. +ARG TARGETPLATFORM + # The canonical, SemVer-compliant TinyPilot version. ARG TINYPILOT_VERSION @@ -23,12 +26,23 @@ ARG PKG_VERSION ARG PKG_NAME="tinypilot" ARG PKG_BUILD_NUMBER="1" -ARG PKG_ARCH="armhf" -RUN echo "${PKG_NAME}-${PKG_VERSION}-${PKG_BUILD_NUMBER}-${PKG_ARCH}" > /tmp/pkg-id -RUN mkdir -p "/releases/temp-pkg-id" +RUN set -x && \ + if [ "$TARGETPLATFORM" = "linux/arm/v7" ]; then \ + echo "armhf" > /tmp/pkg-arch; \ + elif [ "$TARGETPLATFORM" = "linux/amd64" ]; then \ + echo "amd64" > /tmp/pkg-arch; \ + else \ + echo "Unrecognized target platform: ${TARGETPLATFORM}" >&2; \ + exit 1; \ + fi +RUN set -u && \ + PKG_ARCH="$(cat /tmp/pkg-arch)" && \ + echo "${PKG_NAME}-${PKG_VERSION}-${PKG_BUILD_NUMBER}-${PKG_ARCH}" > /tmp/pkg-id -WORKDIR "/releases/temp-pkg-id" +RUN mkdir -p "/releases/placeholder-pkg-id" + +WORKDIR "/releases/placeholder-pkg-id" COPY ./debian-pkg ./ COPY ./COPYRIGHT ./ @@ -40,14 +54,10 @@ COPY ./scripts ./scripts RUN echo "${TINYPILOT_VERSION}" > VERSION -WORKDIR "/releases/temp-pkg-id/debian" +WORKDIR "/releases/placeholder-pkg-id/debian" RUN set -x && \ - if [ "$TARGETPLATFORM" = "linux/arm/v7" ]; then \ - PKG_ARCH="armhf"; \ - else \ - PKG_ARCH="amd64"; \ - fi && \ + PKG_ARCH="$(cat /tmp/pkg-arch)" && \ set -u && \ cat >control < $(date '+%a, %d %b %Y %H:%M:%S %z') EOF -# Rename the temporary release directory to the final package ID. +# Rename the placeholder release directory to the final package ID. WORKDIR "/releases" RUN set -x && \ - mv tmp-pkg-id "$(cat /tmp/pkg-id)" && \ - cd "$(cat /tmp/pkg-id)" && \ + PKG_ID="$(cat /tmp/pkg-id)" && \ + mv placeholder-pkg-id "${PKG_ID}" && \ + cd "${PKG_ID}" && \ dpkg-buildpackage --build=binary FROM scratch as artifact From 16007186f345deb7c12732bdb96e8fb8d81d6d73 Mon Sep 17 00:00:00 2001 From: Michael Lynch Date: Mon, 10 Apr 2023 21:08:08 -0400 Subject: [PATCH 30/74] work in progress --- .circleci/config.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.circleci/config.yml b/.circleci/config.yml index 46c874b31..a2d4c5aca 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -88,7 +88,7 @@ jobs: command: ./dev-scripts/build-debian-pkg "linux/arm/v7,linux/amd64" - run: name: Print Debian package contents - command: dpkg --contents debian-pkg/releases/tinypilot*.deb + command: dpkg --contents debian-pkg/releases/linux_arm_v7/tinypilot*.deb - persist_to_workspace: root: ./debian-pkg/releases paths: From dda0807772141964fbf41ab992dea414834bfda5 Mon Sep 17 00:00:00 2001 From: Michael Lynch Date: Mon, 10 Apr 2023 21:22:02 -0400 Subject: [PATCH 31/74] work in progress --- .circleci/config.yml | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/.circleci/config.yml b/.circleci/config.yml index a2d4c5aca..1fbd5177f 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -90,10 +90,13 @@ jobs: name: Print Debian package contents command: dpkg --contents debian-pkg/releases/linux_arm_v7/tinypilot*.deb - persist_to_workspace: - root: ./debian-pkg/releases + root: ./debian-pkg/releases/linux_amd64 paths: - - "linux_amd64/*.deb" - - "linux_arm_v7/*.deb" + - "*.deb" + - persist_to_workspace: + root: ./debian-pkg/releases/linux_arm_v7 + paths: + - "*.deb" - persist_to_workspace: root: ./ paths: From 70a363a6410d39fcf6e941c19eb5b59d3695fe98 Mon Sep 17 00:00:00 2001 From: Michael Lynch Date: Mon, 10 Apr 2023 21:35:01 -0400 Subject: [PATCH 32/74] Fix verify-bundle --- bundler/verify-bundle | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/bundler/verify-bundle b/bundler/verify-bundle index bcff441d3..028050715 100755 --- a/bundler/verify-bundle +++ b/bundler/verify-bundle @@ -42,7 +42,7 @@ if [[ ! -f install ]]; then fi # List Debian package contents. -dpkg --contents tinypilot*.deb +dpkg --contents tinypilot*armhf.deb # Check that Ansible roles exist. readonly ANSIBLE_ROLES=( From 9ff701d8d7ed6d8d3ecaaf7ddb850f0cd1bb1bc2 Mon Sep 17 00:00:00 2001 From: Michael Lynch Date: Mon, 10 Apr 2023 21:38:08 -0400 Subject: [PATCH 33/74] Fix create-bundle --- bundler/create-bundle | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/bundler/create-bundle b/bundler/create-bundle index 57a1726c7..5951bb44d 100755 --- a/bundler/create-bundle +++ b/bundler/create-bundle @@ -44,7 +44,7 @@ print_tinypilot_version() { dpkg-deb \ --show \ --showformat '${Tinypilot-Version}' \ - "${BUNDLE_DIR}/tinypilot"*.deb + "${BUNDLE_DIR}/tinypilot"*armhf.deb } # Compose bundle file name, which consists of these hyphen-separated parts: From b80d22ad26cb8f2ebf2ac9bf786e0b8798aeaa0a Mon Sep 17 00:00:00 2001 From: Michael Lynch Date: Mon, 10 Apr 2023 21:40:35 -0400 Subject: [PATCH 34/74] Exclude amd64 build --- bundler/create-bundle | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/bundler/create-bundle b/bundler/create-bundle index 5951bb44d..bd06497a6 100755 --- a/bundler/create-bundle +++ b/bundler/create-bundle @@ -27,8 +27,11 @@ readonly OUTPUT_DIR='dist' readonly ANSIBLE_ROLES_DIR="${BUNDLE_DIR}/roles" readonly ANSIBLE_ROLE_TINYPILOT_DIR="${ANSIBLE_ROLES_DIR}/ansible-role-tinypilot" +# Exclude the AMD64 package from the production bundle. +rm "${BUNDLE_DIR}/tinypilot"*amd64.deb" + # Ensure that a TinyPilot Debian package exists. -if ! ls "${BUNDLE_DIR}/tinypilot"*.deb 1> /dev/null 2>&1; then +if ! ls "${BUNDLE_DIR}/tinypilot"*armhf.deb 1> /dev/null 2>&1; then echo 'Failed to create bundle: no TinyPilot Debian package found.' >&2 exit 1 fi From 2e4959c92517ef4c32009b806d27ea3f2e19b3f5 Mon Sep 17 00:00:00 2001 From: Michael Lynch Date: Mon, 10 Apr 2023 21:41:54 -0400 Subject: [PATCH 35/74] Fix quote --- bundler/create-bundle | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/bundler/create-bundle b/bundler/create-bundle index bd06497a6..f6141782e 100755 --- a/bundler/create-bundle +++ b/bundler/create-bundle @@ -28,7 +28,7 @@ readonly ANSIBLE_ROLES_DIR="${BUNDLE_DIR}/roles" readonly ANSIBLE_ROLE_TINYPILOT_DIR="${ANSIBLE_ROLES_DIR}/ansible-role-tinypilot" # Exclude the AMD64 package from the production bundle. -rm "${BUNDLE_DIR}/tinypilot"*amd64.deb" +rm "${BUNDLE_DIR}/tinypilot"*amd64.deb # Ensure that a TinyPilot Debian package exists. if ! ls "${BUNDLE_DIR}/tinypilot"*armhf.deb 1> /dev/null 2>&1; then From 9e70e7f83a522c30257e2854b438f81247f9b17b Mon Sep 17 00:00:00 2001 From: Michael Lynch Date: Tue, 11 Apr 2023 06:38:55 -0400 Subject: [PATCH 36/74] Fix rules --- debian-pkg/debian/rules | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/debian-pkg/debian/rules b/debian-pkg/debian/rules index 175dc290c..3ade4a186 100755 --- a/debian-pkg/debian/rules +++ b/debian-pkg/debian/rules @@ -10,11 +10,19 @@ export DEB_BUILD_OPTIONS=noddebs override_dh_installsystemd: dh_installsystemd --name=tinypilot-updater --no-start --no-enable +# override_dh_virtualenv: + # Skip install because TinyPilot doesn't need to run setup.py to install. + # Use the venv directory because that's where we've historically kept it. dh_virtualenv --skip-install --install-suffix venv + # dh_virtualenv doesn't remove __pycache__ directories, so we clean them up + # manually. find . -type d -name __pycache__ -prune -exec rm -rf {} \; + # Lintian will complain if the .gitignore stays in venv. rm ./debian/tinypilot$(DH_VIRTUALENV_INSTALL_ROOT)/venv/.gitignore - rm -rf ./debian/tinypilot$(DH_VIRTUALENV_INSTALL_ROOT)/venv/lib/python*/site-packages/werkzeug/debug/ + # Lintian complains about this folder, but we don't need it in production, so + # we delete it. rm -rf ./debian/tinypilot$(DH_VIRTUALENV_INSTALL_ROOT)/venv/lib/python*/site-packages/greenlet/tests/ + # Lintian complains if it sees that these scripts are not executable. chmod +x ./debian/tinypilot$(DH_VIRTUALENV_INSTALL_ROOT)/venv/lib/python*/site-packages/pkg_resources/_vendor/appdirs.py chmod +x ./debian/tinypilot$(DH_VIRTUALENV_INSTALL_ROOT)/venv/lib/python*/site-packages/setuptools/command/easy_install.py From 52acfc072824c20e1e893407cbe83718da4e24f3 Mon Sep 17 00:00:00 2001 From: Michael Lynch Date: Tue, 11 Apr 2023 06:53:39 -0400 Subject: [PATCH 37/74] work in progress --- .lintianignore | 4 ---- debian-pkg/debian/rules | 4 ++-- 2 files changed, 2 insertions(+), 6 deletions(-) diff --git a/.lintianignore b/.lintianignore index bf8d34b7d..64682aa83 100644 --- a/.lintianignore +++ b/.lintianignore @@ -26,7 +26,3 @@ systemd-service-file-refers-to-unusual-wantedby-target # user-defined fields, though. # https://lintian.debian.org/tags/unknown-field unknown-field - -# Lintian doesn't recognize the Python interpreter within the Python virtual -# environment. -unusual-interpreter diff --git a/debian-pkg/debian/rules b/debian-pkg/debian/rules index 3ade4a186..073b95838 100755 --- a/debian-pkg/debian/rules +++ b/debian-pkg/debian/rules @@ -20,8 +20,8 @@ override_dh_virtualenv: find . -type d -name __pycache__ -prune -exec rm -rf {} \; # Lintian will complain if the .gitignore stays in venv. rm ./debian/tinypilot$(DH_VIRTUALENV_INSTALL_ROOT)/venv/.gitignore - # Lintian complains about this folder, but we don't need it in production, so - # we delete it. + # Lintian complains about issues in certain packages' tests folders, but we + # don't need them in production, so we delete them. rm -rf ./debian/tinypilot$(DH_VIRTUALENV_INSTALL_ROOT)/venv/lib/python*/site-packages/greenlet/tests/ # Lintian complains if it sees that these scripts are not executable. chmod +x ./debian/tinypilot$(DH_VIRTUALENV_INSTALL_ROOT)/venv/lib/python*/site-packages/pkg_resources/_vendor/appdirs.py From acedf1a44695ea25de7ef7268994eb550bcf0591 Mon Sep 17 00:00:00 2001 From: Michael Lynch Date: Tue, 11 Apr 2023 07:22:56 -0400 Subject: [PATCH 38/74] work in progress --- .lintianignore | 3 +++ 1 file changed, 3 insertions(+) diff --git a/.lintianignore b/.lintianignore index 64682aa83..9599917c4 100644 --- a/.lintianignore +++ b/.lintianignore @@ -1,3 +1,6 @@ +# These are rules for Lintian to ignore globally. For more targeted rules, see +# debian-pkg/debian/tinypilot.lintian-overrides. + # Debian doesn't want packages to install to /opt, but it also doesn't give # clear guidance on where they *should* go. It's too much churn at this point to # change, so we're going to ignore this. From 0c9c5134fda6054fb2c6cfd90093b9a32454dd58 Mon Sep 17 00:00:00 2001 From: Michael Lynch Date: Tue, 11 Apr 2023 08:12:57 -0400 Subject: [PATCH 39/74] work in progress --- debian-pkg/debian/tinypilot.lintian-overrides | 20 +++++++++++++++++++ 1 file changed, 20 insertions(+) create mode 100644 debian-pkg/debian/tinypilot.lintian-overrides diff --git a/debian-pkg/debian/tinypilot.lintian-overrides b/debian-pkg/debian/tinypilot.lintian-overrides new file mode 100644 index 000000000..6c4fd1837 --- /dev/null +++ b/debian-pkg/debian/tinypilot.lintian-overrides @@ -0,0 +1,20 @@ +# This is from a third-party dependency we don't control. +tinypilot: embedded-javascript-library opt/tinypilot/venv/lib/python3.9/site-packages/werkzeug/debug/shared/jquery.js please use libjs-jquery + +# Lintian doesn't recognize the Python interpreter when it's within the +# virtualenv. +tinypilot: unusual-interpreter /opt/tinypilot/venv/bin/python [opt/tinypilot/venv/bin/easy_install-3.9] +tinypilot: unusual-interpreter /opt/tinypilot/venv/bin/python [opt/tinypilot/venv/bin/easy_install3.9] +tinypilot: unusual-interpreter /opt/tinypilot/venv/bin/python [opt/tinypilot/venv/bin/easy_install3] +tinypilot: unusual-interpreter /opt/tinypilot/venv/bin/python [opt/tinypilot/venv/bin/easy_install] +tinypilot: unusual-interpreter /opt/tinypilot/venv/bin/python [opt/tinypilot/venv/bin/flask] +tinypilot: unusual-interpreter /opt/tinypilot/venv/bin/python [opt/tinypilot/venv/bin/pip-3.9] +tinypilot: unusual-interpreter /opt/tinypilot/venv/bin/python [opt/tinypilot/venv/bin/pip3.9] +tinypilot: unusual-interpreter /opt/tinypilot/venv/bin/python [opt/tinypilot/venv/bin/pip3] +tinypilot: unusual-interpreter /opt/tinypilot/venv/bin/python [opt/tinypilot/venv/bin/pip] +tinypilot: unusual-interpreter /opt/tinypilot/venv/bin/python [opt/tinypilot/venv/bin/wheel-3.9] +tinypilot: unusual-interpreter /opt/tinypilot/venv/bin/python [opt/tinypilot/venv/bin/wheel3.9] +tinypilot: unusual-interpreter /opt/tinypilot/venv/bin/python [opt/tinypilot/venv/bin/wheel3] +tinypilot: unusual-interpreter /opt/tinypilot/venv/bin/python [opt/tinypilot/venv/bin/wheel] +tinypilot: unusual-interpreter python [opt/tinypilot/venv/lib/python3.9/site-packages/pkg_resources/_vendor/appdirs.py] +tinypilot: unusual-interpreter python [opt/tinypilot/venv/lib/python3.9/site-packages/setuptools/command/easy_install.py] From cafb9274458dabf6f65968b89b079182fbe50662 Mon Sep 17 00:00:00 2001 From: Michael Lynch Date: Tue, 11 Apr 2023 08:42:04 -0400 Subject: [PATCH 40/74] work in progress --- debian-pkg/debian/rules | 7 ------- 1 file changed, 7 deletions(-) diff --git a/debian-pkg/debian/rules b/debian-pkg/debian/rules index 073b95838..634618126 100755 --- a/debian-pkg/debian/rules +++ b/debian-pkg/debian/rules @@ -10,7 +10,6 @@ export DEB_BUILD_OPTIONS=noddebs override_dh_installsystemd: dh_installsystemd --name=tinypilot-updater --no-start --no-enable -# override_dh_virtualenv: # Skip install because TinyPilot doesn't need to run setup.py to install. # Use the venv directory because that's where we've historically kept it. @@ -20,9 +19,3 @@ override_dh_virtualenv: find . -type d -name __pycache__ -prune -exec rm -rf {} \; # Lintian will complain if the .gitignore stays in venv. rm ./debian/tinypilot$(DH_VIRTUALENV_INSTALL_ROOT)/venv/.gitignore - # Lintian complains about issues in certain packages' tests folders, but we - # don't need them in production, so we delete them. - rm -rf ./debian/tinypilot$(DH_VIRTUALENV_INSTALL_ROOT)/venv/lib/python*/site-packages/greenlet/tests/ - # Lintian complains if it sees that these scripts are not executable. - chmod +x ./debian/tinypilot$(DH_VIRTUALENV_INSTALL_ROOT)/venv/lib/python*/site-packages/pkg_resources/_vendor/appdirs.py - chmod +x ./debian/tinypilot$(DH_VIRTUALENV_INSTALL_ROOT)/venv/lib/python*/site-packages/setuptools/command/easy_install.py From 60eed624b2bda6180ddd3de7919fc112a50ac63d Mon Sep 17 00:00:00 2001 From: Michael Lynch Date: Tue, 11 Apr 2023 08:54:57 -0400 Subject: [PATCH 41/74] Update lintian overrides --- debian-pkg/debian/tinypilot.lintian-overrides | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/debian-pkg/debian/tinypilot.lintian-overrides b/debian-pkg/debian/tinypilot.lintian-overrides index 6c4fd1837..c89164735 100644 --- a/debian-pkg/debian/tinypilot.lintian-overrides +++ b/debian-pkg/debian/tinypilot.lintian-overrides @@ -1,5 +1,8 @@ -# This is from a third-party dependency we don't control. +# Suppress complaints about third-party dependencies we don't control. tinypilot: embedded-javascript-library opt/tinypilot/venv/lib/python3.9/site-packages/werkzeug/debug/shared/jquery.js please use libjs-jquery +tinypilot: script-not-executable opt/tinypilot/venv/lib/python3.9/site-packages/greenlet/tests/test_version.py +tinypilot: script-not-executable opt/tinypilot/venv/lib/python3.9/site-packages/pkg_resources/_vendor/appdirs.py +tinypilot: script-not-executable opt/tinypilot/venv/lib/python3.9/site-packages/setuptools/command/easy_install.py # Lintian doesn't recognize the Python interpreter when it's within the # virtualenv. @@ -16,5 +19,6 @@ tinypilot: unusual-interpreter /opt/tinypilot/venv/bin/python [opt/tinypilot/ven tinypilot: unusual-interpreter /opt/tinypilot/venv/bin/python [opt/tinypilot/venv/bin/wheel3.9] tinypilot: unusual-interpreter /opt/tinypilot/venv/bin/python [opt/tinypilot/venv/bin/wheel3] tinypilot: unusual-interpreter /opt/tinypilot/venv/bin/python [opt/tinypilot/venv/bin/wheel] +tinypilot: unusual-interpreter python [opt/tinypilot/venv/lib/python3.9/site-packages/greenlet/tests/test_version.py] tinypilot: unusual-interpreter python [opt/tinypilot/venv/lib/python3.9/site-packages/pkg_resources/_vendor/appdirs.py] tinypilot: unusual-interpreter python [opt/tinypilot/venv/lib/python3.9/site-packages/setuptools/command/easy_install.py] From 6a3631b91fe69f0a721439b0888af6b5f69b7f9f Mon Sep 17 00:00:00 2001 From: Michael Lynch Date: Tue, 11 Apr 2023 09:05:59 -0400 Subject: [PATCH 42/74] work in progress --- debian-pkg/debian/tinypilot.lintian-overrides | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/debian-pkg/debian/tinypilot.lintian-overrides b/debian-pkg/debian/tinypilot.lintian-overrides index c89164735..425237145 100644 --- a/debian-pkg/debian/tinypilot.lintian-overrides +++ b/debian-pkg/debian/tinypilot.lintian-overrides @@ -1,8 +1,8 @@ # Suppress complaints about third-party dependencies we don't control. tinypilot: embedded-javascript-library opt/tinypilot/venv/lib/python3.9/site-packages/werkzeug/debug/shared/jquery.js please use libjs-jquery -tinypilot: script-not-executable opt/tinypilot/venv/lib/python3.9/site-packages/greenlet/tests/test_version.py -tinypilot: script-not-executable opt/tinypilot/venv/lib/python3.9/site-packages/pkg_resources/_vendor/appdirs.py -tinypilot: script-not-executable opt/tinypilot/venv/lib/python3.9/site-packages/setuptools/command/easy_install.py +tinypilot: script-not-executable [opt/tinypilot/venv/lib/python3.9/site-packages/greenlet/tests/test_version.py] +tinypilot: script-not-executable [opt/tinypilot/venv/lib/python3.9/site-packages/pkg_resources/_vendor/appdirs.py] +tinypilot: script-not-executable [opt/tinypilot/venv/lib/python3.9/site-packages/setuptools/command/easy_install.py] # Lintian doesn't recognize the Python interpreter when it's within the # virtualenv. From 7b8160f980565f03151169e7406c46d11f983e3b Mon Sep 17 00:00:00 2001 From: Michael Lynch Date: Tue, 11 Apr 2023 09:18:06 -0400 Subject: [PATCH 43/74] Simplify overrides with wildcards --- debian-pkg/debian/tinypilot.lintian-overrides | 25 ++++--------------- 1 file changed, 5 insertions(+), 20 deletions(-) diff --git a/debian-pkg/debian/tinypilot.lintian-overrides b/debian-pkg/debian/tinypilot.lintian-overrides index 425237145..85d8e5e5c 100644 --- a/debian-pkg/debian/tinypilot.lintian-overrides +++ b/debian-pkg/debian/tinypilot.lintian-overrides @@ -1,24 +1,9 @@ # Suppress complaints about third-party dependencies we don't control. -tinypilot: embedded-javascript-library opt/tinypilot/venv/lib/python3.9/site-packages/werkzeug/debug/shared/jquery.js please use libjs-jquery -tinypilot: script-not-executable [opt/tinypilot/venv/lib/python3.9/site-packages/greenlet/tests/test_version.py] -tinypilot: script-not-executable [opt/tinypilot/venv/lib/python3.9/site-packages/pkg_resources/_vendor/appdirs.py] -tinypilot: script-not-executable [opt/tinypilot/venv/lib/python3.9/site-packages/setuptools/command/easy_install.py] +tinypilot: embedded-javascript-library opt/tinypilot/venv/lib/python*/site-packages/werkzeug/debug/shared/jquery.js please use libjs-jquery +tinypilot: script-not-executable [opt/tinypilot/venv/lib/python*/site-packages/greenlet/tests/test_version.py] +tinypilot: script-not-executable [opt/tinypilot/venv/lib/python*/site-packages/pkg_resources/_vendor/appdirs.py] +tinypilot: script-not-executable [opt/tinypilot/venv/lib/python*/site-packages/setuptools/command/easy_install.py] # Lintian doesn't recognize the Python interpreter when it's within the # virtualenv. -tinypilot: unusual-interpreter /opt/tinypilot/venv/bin/python [opt/tinypilot/venv/bin/easy_install-3.9] -tinypilot: unusual-interpreter /opt/tinypilot/venv/bin/python [opt/tinypilot/venv/bin/easy_install3.9] -tinypilot: unusual-interpreter /opt/tinypilot/venv/bin/python [opt/tinypilot/venv/bin/easy_install3] -tinypilot: unusual-interpreter /opt/tinypilot/venv/bin/python [opt/tinypilot/venv/bin/easy_install] -tinypilot: unusual-interpreter /opt/tinypilot/venv/bin/python [opt/tinypilot/venv/bin/flask] -tinypilot: unusual-interpreter /opt/tinypilot/venv/bin/python [opt/tinypilot/venv/bin/pip-3.9] -tinypilot: unusual-interpreter /opt/tinypilot/venv/bin/python [opt/tinypilot/venv/bin/pip3.9] -tinypilot: unusual-interpreter /opt/tinypilot/venv/bin/python [opt/tinypilot/venv/bin/pip3] -tinypilot: unusual-interpreter /opt/tinypilot/venv/bin/python [opt/tinypilot/venv/bin/pip] -tinypilot: unusual-interpreter /opt/tinypilot/venv/bin/python [opt/tinypilot/venv/bin/wheel-3.9] -tinypilot: unusual-interpreter /opt/tinypilot/venv/bin/python [opt/tinypilot/venv/bin/wheel3.9] -tinypilot: unusual-interpreter /opt/tinypilot/venv/bin/python [opt/tinypilot/venv/bin/wheel3] -tinypilot: unusual-interpreter /opt/tinypilot/venv/bin/python [opt/tinypilot/venv/bin/wheel] -tinypilot: unusual-interpreter python [opt/tinypilot/venv/lib/python3.9/site-packages/greenlet/tests/test_version.py] -tinypilot: unusual-interpreter python [opt/tinypilot/venv/lib/python3.9/site-packages/pkg_resources/_vendor/appdirs.py] -tinypilot: unusual-interpreter python [opt/tinypilot/venv/lib/python3.9/site-packages/setuptools/command/easy_install.py] +tinypilot: unusual-interpreter [opt/tinypilot/venv/*] From 5481ca6a9a39e580fa5290cc1db92bf074a17c7e Mon Sep 17 00:00:00 2001 From: Michael Lynch Date: Tue, 11 Apr 2023 09:29:15 -0400 Subject: [PATCH 44/74] work in progress --- debian-pkg/debian/tinypilot.lintian-overrides | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/debian-pkg/debian/tinypilot.lintian-overrides b/debian-pkg/debian/tinypilot.lintian-overrides index 85d8e5e5c..fc86d7581 100644 --- a/debian-pkg/debian/tinypilot.lintian-overrides +++ b/debian-pkg/debian/tinypilot.lintian-overrides @@ -6,4 +6,10 @@ tinypilot: script-not-executable [opt/tinypilot/venv/lib/python*/site-packages/s # Lintian doesn't recognize the Python interpreter when it's within the # virtualenv. -tinypilot: unusual-interpreter [opt/tinypilot/venv/*] +tinypilot: unusual-interpreter /opt/tinypilot/venv/bin/python [opt/tinypilot/venv/bin/easy_install*] +tinypilot: unusual-interpreter /opt/tinypilot/venv/bin/python [opt/tinypilot/venv/bin/flask] +tinypilot: unusual-interpreter /opt/tinypilot/venv/bin/python [opt/tinypilot/venv/bin/pip*] +tinypilot: unusual-interpreter /opt/tinypilot/venv/bin/python [opt/tinypilot/venv/bin/wheel*] +tinypilot: unusual-interpreter python [opt/tinypilot/venv/lib/python*/site-packages/greenlet/tests/test_version.py] +tinypilot: unusual-interpreter python [opt/tinypilot/venv/lib/python*/site-packages/pkg_resources/_vendor/appdirs.py] +tinypilot: unusual-interpreter python [opt/tinypilot/venv/lib/python*/site-packages/setuptools/command/easy_install.py] From c23ab0b155264bdec1f4df7b67b04fcd22e610a4 Mon Sep 17 00:00:00 2001 From: Michael Lynch Date: Tue, 11 Apr 2023 09:33:06 -0400 Subject: [PATCH 45/74] Revert changes to VS code settings --- .vscode/settings.json | 3 --- 1 file changed, 3 deletions(-) diff --git a/.vscode/settings.json b/.vscode/settings.json index b27341a95..8afb97f43 100644 --- a/.vscode/settings.json +++ b/.vscode/settings.json @@ -8,9 +8,6 @@ "editor.defaultFormatter": "ms-python.python", "editor.tabSize": 4 }, - "[rules]": { - "editor.insertSpaces": false - }, "python.formatting.provider": "yapf", "python.linting.pylintEnabled": true, "python.linting.enabled": true, From b63183f6e8c4025286e6eb3db52f4679b99d111a Mon Sep 17 00:00:00 2001 From: Michael Lynch Date: Wed, 12 Apr 2023 11:27:29 -0400 Subject: [PATCH 46/74] Document multiarch better --- CONTRIBUTING.md | 3 ++- dev-scripts/build-debian-pkg | 15 +++++++++++++-- dev-scripts/enable-multiarch-docker | 4 ++++ 3 files changed, 19 insertions(+), 3 deletions(-) diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index 5584aec10..1ea9372d5 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -22,7 +22,8 @@ python3 -m venv venv && \ . venv/bin/activate && \ pip install --requirement requirements.txt && \ pip install --requirement dev_requirements.txt && \ - npm install + npm install && \ + ./dev-scripts/enable-multiarch-docker ``` ### Run automated tests diff --git a/dev-scripts/build-debian-pkg b/dev-scripts/build-debian-pkg index cd73f2b16..55552f118 100755 --- a/dev-scripts/build-debian-pkg +++ b/dev-scripts/build-debian-pkg @@ -1,7 +1,18 @@ #!/bin/bash -# Note: You must run ./dev-scripts/enable-multiarch-docker on your system at -# least once before running this script. +# Build TinyPilot Debian packages +# +# Usage: +# build-debian-pkg [target architectures] +# +# target architecture: A comma-separated list of architectures that Docker +# accepts for its --platform argument. If omitted, defaults to +# "linux/arm/v7,linux/amd64". +# See https://docs.docker.com/build/building/multi-platform/ for other target +# platform options. +# +# Examples +# build-debian-pkg "linux/arm/v7,linux/arm64" # Exit build script on first failure. set -e diff --git a/dev-scripts/enable-multiarch-docker b/dev-scripts/enable-multiarch-docker index 26f6e218d..e51c8ed0c 100755 --- a/dev-scripts/enable-multiarch-docker +++ b/dev-scripts/enable-multiarch-docker @@ -1,5 +1,8 @@ #!/bin/bash +# Configure Docker to support multiarch builds, allowing it to use QEMU to build +# images targeting different CPU architectures. + # Exit build script on first failure. set -e @@ -16,6 +19,7 @@ docker run \ multiarch/qemu-user-static \ --reset \ -p yes + # Create multiarch build context docker context create builder From 7680b4432d0bd80633dd4a22839b9b67529dcd15 Mon Sep 17 00:00:00 2001 From: Michael Lynch Date: Wed, 12 Apr 2023 16:37:08 -0400 Subject: [PATCH 47/74] Stop testing Debian 10 in molecule --- ansible-role/molecule/default/molecule.yml | 8 -------- 1 file changed, 8 deletions(-) diff --git a/ansible-role/molecule/default/molecule.yml b/ansible-role/molecule/default/molecule.yml index dacb97ae3..36c886086 100644 --- a/ansible-role/molecule/default/molecule.yml +++ b/ansible-role/molecule/default/molecule.yml @@ -4,14 +4,6 @@ dependency: driver: name: docker platforms: - - name: debian10 - image: geerlingguy/docker-debian10-ansible - command: ${MOLECULE_DOCKER_COMMAND:-""} - volumes: - - /sys/fs/cgroup:/sys/fs/cgroup:ro - - "${PWD}/debian-pkgs:/opt/debian-pkgs:ro" - privileged: true - pre_build_image: true - name: debian11 image: geerlingguy/docker-debian11-ansible command: ${MOLECULE_DOCKER_COMMAND:-""} From c14dfeb162a32d6df4f8d6a01941bae86e232520 Mon Sep 17 00:00:00 2001 From: Michael Lynch Date: Wed, 12 Apr 2023 16:42:42 -0400 Subject: [PATCH 48/74] Only build bundles from master --- .circleci/config.yml | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/.circleci/config.yml b/.circleci/config.yml index 5274d9b40..9a086d508 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -252,6 +252,12 @@ workflows: - build_bundle: requires: - build_debian_package + # Creating the bundle assumes an ARMv7 build, so we only do this on + # master, because it's slow building the ARMv7 binaries from a + # CircleCI AMD64 instance. + filters: + branches: + only: master - verify_bundle: requires: - build_bundle From 075ca3e65c44679b59b33650eb7fa0a5d83aaba5 Mon Sep 17 00:00:00 2001 From: Michael Lynch Date: Wed, 12 Apr 2023 16:44:16 -0400 Subject: [PATCH 49/74] work in progress --- debian-pkg/Dockerfile | 3 ++- dev-scripts/build-debian-pkg | 2 +- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/debian-pkg/Dockerfile b/debian-pkg/Dockerfile index 0e9b7f0fe..08eaf278a 100644 --- a/debian-pkg/Dockerfile +++ b/debian-pkg/Dockerfile @@ -11,7 +11,8 @@ RUN set -x && \ dh-virtualenv \ dpkg-dev -# Set by docker. +# Docker populates this value from the --platform argument. See +# https://docs.docker.com/build/building/multi-platform/ ARG TARGETPLATFORM # The canonical, SemVer-compliant TinyPilot version. diff --git a/dev-scripts/build-debian-pkg b/dev-scripts/build-debian-pkg index 55552f118..23e79c5a8 100755 --- a/dev-scripts/build-debian-pkg +++ b/dev-scripts/build-debian-pkg @@ -1,6 +1,6 @@ #!/bin/bash -# Build TinyPilot Debian packages +# Build TinyPilot Debian packages. # # Usage: # build-debian-pkg [target architectures] From 6160b59537bde8044ae71838bb28a30c3333e4dc Mon Sep 17 00:00:00 2001 From: Michael Lynch Date: Fri, 14 Apr 2023 10:58:58 -0400 Subject: [PATCH 50/74] Add better documentation --- debian-pkg/Dockerfile | 7 +++++++ dev-scripts/build-debian-pkg | 8 ++++---- 2 files changed, 11 insertions(+), 4 deletions(-) diff --git a/debian-pkg/Dockerfile b/debian-pkg/Dockerfile index 08eaf278a..ca233e061 100644 --- a/debian-pkg/Dockerfile +++ b/debian-pkg/Dockerfile @@ -28,6 +28,9 @@ ARG PKG_VERSION ARG PKG_NAME="tinypilot" ARG PKG_BUILD_NUMBER="1" +# Docker's platform names don't match Debian's platform names, so we translate +# the platform name from the Docker version to the Debian version and save the +# result to a file so we can re-use it in later stages. RUN set -x && \ if [ "$TARGETPLATFORM" = "linux/arm/v7" ]; then \ echo "armhf" > /tmp/pkg-arch; \ @@ -41,6 +44,10 @@ RUN set -u && \ PKG_ARCH="$(cat /tmp/pkg-arch)" && \ echo "${PKG_NAME}-${PKG_VERSION}-${PKG_BUILD_NUMBER}-${PKG_ARCH}" > /tmp/pkg-id +# We ultimately need the directory name to be the package ID, but there's no +# way to specify a dynamic value in Docker's WORKDIR command, so we use a +# placeholder directory name to assemble the Debian package and then rename the +# directory to its package ID name in the final stages of packaging. RUN mkdir -p "/releases/placeholder-pkg-id" WORKDIR "/releases/placeholder-pkg-id" diff --git a/dev-scripts/build-debian-pkg b/dev-scripts/build-debian-pkg index 23e79c5a8..e98fd091b 100755 --- a/dev-scripts/build-debian-pkg +++ b/dev-scripts/build-debian-pkg @@ -7,12 +7,12 @@ # # target architecture: A comma-separated list of architectures that Docker # accepts for its --platform argument. If omitted, defaults to -# "linux/arm/v7,linux/amd64". -# See https://docs.docker.com/build/building/multi-platform/ for other target -# platform options. +# "linux/arm/v7,linux/amd64". The only supported targets are linux/arm/v7 and +# linux/amd64. # # Examples -# build-debian-pkg "linux/arm/v7,linux/arm64" +# build-debian-pkg "linux/arm/v7" +# build-debian-pkg "linux/arm/v7,linux/amd64" # Exit build script on first failure. set -e From f7d8f84e53ba8ca34acc3248428215e088db0f66 Mon Sep 17 00:00:00 2001 From: Michael Lynch Date: Fri, 14 Apr 2023 11:00:50 -0400 Subject: [PATCH 51/74] Adjust syntax for lintian override I don't think the previous syntax was correct and don't understand why it worked, so let's see what happens. --- debian-pkg/debian/tinypilot.lintian-overrides | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/debian-pkg/debian/tinypilot.lintian-overrides b/debian-pkg/debian/tinypilot.lintian-overrides index fc86d7581..cea6bea4e 100644 --- a/debian-pkg/debian/tinypilot.lintian-overrides +++ b/debian-pkg/debian/tinypilot.lintian-overrides @@ -1,5 +1,5 @@ # Suppress complaints about third-party dependencies we don't control. -tinypilot: embedded-javascript-library opt/tinypilot/venv/lib/python*/site-packages/werkzeug/debug/shared/jquery.js please use libjs-jquery +tinypilot: embedded-javascript-library [opt/tinypilot/venv/lib/python*/site-packages/werkzeug/debug/shared/jquery.js] tinypilot: script-not-executable [opt/tinypilot/venv/lib/python*/site-packages/greenlet/tests/test_version.py] tinypilot: script-not-executable [opt/tinypilot/venv/lib/python*/site-packages/pkg_resources/_vendor/appdirs.py] tinypilot: script-not-executable [opt/tinypilot/venv/lib/python*/site-packages/setuptools/command/easy_install.py] From fa2e97a11777bd5d7ff58c9aa68450e52490a72a Mon Sep 17 00:00:00 2001 From: Michael Lynch Date: Mon, 8 May 2023 17:12:41 -0400 Subject: [PATCH 52/74] Revert "Adjust syntax for lintian override" This reverts commit f7d8f84e53ba8ca34acc3248428215e088db0f66. --- debian-pkg/debian/tinypilot.lintian-overrides | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/debian-pkg/debian/tinypilot.lintian-overrides b/debian-pkg/debian/tinypilot.lintian-overrides index cea6bea4e..fc86d7581 100644 --- a/debian-pkg/debian/tinypilot.lintian-overrides +++ b/debian-pkg/debian/tinypilot.lintian-overrides @@ -1,5 +1,5 @@ # Suppress complaints about third-party dependencies we don't control. -tinypilot: embedded-javascript-library [opt/tinypilot/venv/lib/python*/site-packages/werkzeug/debug/shared/jquery.js] +tinypilot: embedded-javascript-library opt/tinypilot/venv/lib/python*/site-packages/werkzeug/debug/shared/jquery.js please use libjs-jquery tinypilot: script-not-executable [opt/tinypilot/venv/lib/python*/site-packages/greenlet/tests/test_version.py] tinypilot: script-not-executable [opt/tinypilot/venv/lib/python*/site-packages/pkg_resources/_vendor/appdirs.py] tinypilot: script-not-executable [opt/tinypilot/venv/lib/python*/site-packages/setuptools/command/easy_install.py] From 3f562845c014f082b6a98d5372ffc036e5ca6d41 Mon Sep 17 00:00:00 2001 From: Michael Lynch Date: Mon, 8 May 2023 17:38:31 -0400 Subject: [PATCH 53/74] Fix script comments --- dev-scripts/enable-multiarch-docker | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/dev-scripts/enable-multiarch-docker b/dev-scripts/enable-multiarch-docker index e51c8ed0c..e39b20c98 100755 --- a/dev-scripts/enable-multiarch-docker +++ b/dev-scripts/enable-multiarch-docker @@ -3,7 +3,7 @@ # Configure Docker to support multiarch builds, allowing it to use QEMU to build # images targeting different CPU architectures. -# Exit build script on first failure. +# Exit script on first failure. set -e # Echo commands before executing them, by default to stderr. @@ -12,7 +12,7 @@ set -x # Exit on unset variable. set -u -# Enable multiarch builds with QEMU +# Enable multiarch builds with QEMU. docker run \ --rm \ --privileged \ @@ -20,14 +20,14 @@ docker run \ --reset \ -p yes -# Create multiarch build context +# Create multiarch build context. docker context create builder -# Create multiplatform builder +# Create multiplatform builder. docker buildx create builder \ --name builder \ --driver docker-container \ --use -# Ensure builder has booted +# Ensure builder has booted. docker buildx inspect --bootstrap From e09e2dc216ed0dc3224ea619b819e9f99f0f7b02 Mon Sep 17 00:00:00 2001 From: Michael Lynch Date: Mon, 8 May 2023 17:39:09 -0400 Subject: [PATCH 54/74] Remove old workaround --- dev-scripts/install-from-source | 11 ----------- 1 file changed, 11 deletions(-) diff --git a/dev-scripts/install-from-source b/dev-scripts/install-from-source index 7663d504f..dcd6a03dd 100755 --- a/dev-scripts/install-from-source +++ b/dev-scripts/install-from-source @@ -22,17 +22,6 @@ SCRIPT_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" &> /dev/null && pwd )" readonly SCRIPT_DIR cd "${SCRIPT_DIR}/.." -# Work around a Docker bug on Raspbian Buster. -# https://github.com/debuerreotype/docker-debian-artifacts/issues/122 -if [[ "$(lsb_release --id --short)" == "Raspbian" && \ - "$(lsb_release --release --short)" == "10" ]]; then - sed \ - --in-place \ - --regexp-extended \ - 's/debian:bullseye-[0-9]+-slim/debian:buster-slim/g' \ - ./debian-pkg/Dockerfile -fi - ./dev-scripts/build-debian-pkg "linux/arm/v7" # Shellcheck recommends find instead of ls for non-alphanumeric filenames, but From 2e53b36f8c73064e04e7fb6fa84e695e957b8576 Mon Sep 17 00:00:00 2001 From: Jason Wallace Date: Tue, 30 May 2023 14:19:40 +0200 Subject: [PATCH 55/74] Ignore if the AMD64 doesn't exist. --- bundler/create-bundle | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/bundler/create-bundle b/bundler/create-bundle index f6141782e..45ada16e9 100755 --- a/bundler/create-bundle +++ b/bundler/create-bundle @@ -28,7 +28,7 @@ readonly ANSIBLE_ROLES_DIR="${BUNDLE_DIR}/roles" readonly ANSIBLE_ROLE_TINYPILOT_DIR="${ANSIBLE_ROLES_DIR}/ansible-role-tinypilot" # Exclude the AMD64 package from the production bundle. -rm "${BUNDLE_DIR}/tinypilot"*amd64.deb +rm -f "${BUNDLE_DIR}/tinypilot"*amd64.deb # Ensure that a TinyPilot Debian package exists. if ! ls "${BUNDLE_DIR}/tinypilot"*armhf.deb 1> /dev/null 2>&1; then From af18c572dd2588e2e4f18d9812bc9eb8f63ce589 Mon Sep 17 00:00:00 2001 From: Jason Wallace Date: Tue, 30 May 2023 15:22:44 +0200 Subject: [PATCH 56/74] Overwrite destination directory. --- bundler/create-bundle | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/bundler/create-bundle b/bundler/create-bundle index 45ada16e9..e4a22c40e 100755 --- a/bundler/create-bundle +++ b/bundler/create-bundle @@ -73,8 +73,10 @@ pip install "pip>=21.3.1" pip install --requirement "${BUNDLE_DIR}/requirements.txt" # Copy Ansible role. -mkdir "${ANSIBLE_ROLES_DIR}" -cp -r ../ansible-role "${ANSIBLE_ROLE_TINYPILOT_DIR}" +mkdir -p "${ANSIBLE_ROLES_DIR}" +cp -r \ + --no-target-directory \ + ../ansible-role "${ANSIBLE_ROLE_TINYPILOT_DIR}" # Download Ansible role dependencies. ansible-galaxy install \ From 53b394c6cd17e500fd9c5c26bf446b71b6dfba11 Mon Sep 17 00:00:00 2001 From: Jason Wallace Date: Tue, 30 May 2023 16:14:57 +0200 Subject: [PATCH 57/74] Only build armv7 binaries on master branch. --- .circleci/continue_config.yml | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/.circleci/continue_config.yml b/.circleci/continue_config.yml index 3b8effa67..9822ffefb 100644 --- a/.circleci/continue_config.yml +++ b/.circleci/continue_config.yml @@ -89,7 +89,16 @@ jobs: command: ./dev-scripts/enable-multiarch-docker - run: name: Build Debian package - command: ./dev-scripts/build-debian-pkg "linux/arm/v7,linux/amd64" + # Building ARMv7 binaries is slow, so we only build them on the master + # branch. + command: | + set -exu + if [[ "${CIRCLE_BRANCH}" == 'master' ]]; then + readonly BUILD_TARGETS='linux/arm/v7,linux/amd64' + else + readonly BUILD_TARGETS='linux/amd64' + fi + ./dev-scripts/build-debian-pkg "${BUILD_TARGETS}" - run: name: Print Debian package contents command: dpkg --contents debian-pkg/releases/linux_arm_v7/tinypilot*.deb From ede73517ac628daa9fb84ecfc54c2b53fd9cfdb5 Mon Sep 17 00:00:00 2001 From: Jason Wallace Date: Tue, 30 May 2023 16:25:11 +0200 Subject: [PATCH 58/74] Handle dynamic architecture directory structure. --- .circleci/continue_config.yml | 31 +++++++++++++++++-------------- 1 file changed, 17 insertions(+), 14 deletions(-) diff --git a/.circleci/continue_config.yml b/.circleci/continue_config.yml index 9822ffefb..0a56d42fb 100644 --- a/.circleci/continue_config.yml +++ b/.circleci/continue_config.yml @@ -101,15 +101,15 @@ jobs: ./dev-scripts/build-debian-pkg "${BUILD_TARGETS}" - run: name: Print Debian package contents - command: dpkg --contents debian-pkg/releases/linux_arm_v7/tinypilot*.deb - - persist_to_workspace: - root: ./debian-pkg/releases/linux_amd64 - paths: - - "*.deb" + command: | + set -exu + while read -r file; do + dpkg --contents "${file}" + done < <(find . -name '*.deb') - persist_to_workspace: - root: ./debian-pkg/releases/linux_arm_v7 + root: ./debian-pkg/releases paths: - - "*.deb" + - ./*/*.deb lint_debian_package: docker: - image: cimg/base:2022.11-22.04 @@ -129,13 +129,16 @@ jobs: - run: name: Run lintian command: | - lintian \ - --check \ - --no-tag-display-limit \ - --suppress-tags-from-file .lintianignore \ - --no-cfg \ - --fail-on warning,error \ - tinypilot*armhf.deb + set -exu + while read -r file; do + lintian \ + --check \ + --no-tag-display-limit \ + --suppress-tags-from-file .lintianignore \ + --no-cfg \ + --fail-on warning,error \ + "${file}" + done < <(find . -name '*.deb') build_ansible_role: machine: image: ubuntu-2004:202010-01 From ac0988723147f1ca21b581c33b4beaadbba16101 Mon Sep 17 00:00:00 2001 From: Jason Wallace Date: Tue, 30 May 2023 17:13:45 +0200 Subject: [PATCH 59/74] Move Debian packages to a predictable location. --- .circleci/continue_config.yml | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/.circleci/continue_config.yml b/.circleci/continue_config.yml index 0a56d42fb..ce075fe41 100644 --- a/.circleci/continue_config.yml +++ b/.circleci/continue_config.yml @@ -99,17 +99,20 @@ jobs: readonly BUILD_TARGETS='linux/amd64' fi ./dev-scripts/build-debian-pkg "${BUILD_TARGETS}" + - run: + name: Move Debian packages to a predictable location + command: find . -name '*.deb' -exec mv {} ./debian-pkg/releases/ \; - run: name: Print Debian package contents command: | set -exu while read -r file; do dpkg --contents "${file}" - done < <(find . -name '*.deb') + done < <(ls ./debian-pkg/releases/*.deb) - persist_to_workspace: root: ./debian-pkg/releases paths: - - ./*/*.deb + - "*.deb" lint_debian_package: docker: - image: cimg/base:2022.11-22.04 @@ -138,7 +141,7 @@ jobs: --no-cfg \ --fail-on warning,error \ "${file}" - done < <(find . -name '*.deb') + done < <(ls *.deb) build_ansible_role: machine: image: ubuntu-2004:202010-01 From ebb2caf1f1b749e1055d2aad2ccbba8e3b51ab75 Mon Sep 17 00:00:00 2001 From: Jason Wallace Date: Tue, 30 May 2023 17:16:07 +0200 Subject: [PATCH 60/74] Enable Docker later caching. --- .circleci/continue_config.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.circleci/continue_config.yml b/.circleci/continue_config.yml index ce075fe41..81598dc66 100644 --- a/.circleci/continue_config.yml +++ b/.circleci/continue_config.yml @@ -84,6 +84,7 @@ jobs: - checkout - setup_remote_docker: version: 20.10.11 + docker_layer_caching: true - run: name: Enable multiarch builds with QEMU command: ./dev-scripts/enable-multiarch-docker From 95ba48b050eec1dd154d3ba8210a9c5214e098d8 Mon Sep 17 00:00:00 2001 From: Jason Wallace Date: Wed, 31 May 2023 14:51:40 +0200 Subject: [PATCH 61/74] Enable hardening. --- debian-pkg/debian/rules | 1 + 1 file changed, 1 insertion(+) diff --git a/debian-pkg/debian/rules b/debian-pkg/debian/rules index 634618126..f583bafc0 100755 --- a/debian-pkg/debian/rules +++ b/debian-pkg/debian/rules @@ -1,6 +1,7 @@ #!/usr/bin/make -f export DH_VIRTUALENV_INSTALL_ROOT=/opt/tinypilot +export DEB_BUILD_MAINT_OPTIONS = hardening=+all # Prevent debhelper from generating an extra package with debug symbols. export DEB_BUILD_OPTIONS=noddebs From c30c1d6b1b25c50990ffc5543700c993ccb4dcb7 Mon Sep 17 00:00:00 2001 From: Jason Wallace Date: Wed, 31 May 2023 15:02:56 +0200 Subject: [PATCH 62/74] Enable hardening build flags. --- debian-pkg/debian/rules | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/debian-pkg/debian/rules b/debian-pkg/debian/rules index f583bafc0..50f6acc21 100755 --- a/debian-pkg/debian/rules +++ b/debian-pkg/debian/rules @@ -1,7 +1,11 @@ #!/usr/bin/make -f -export DH_VIRTUALENV_INSTALL_ROOT=/opt/tinypilot +# Enable hardening build flags. export DEB_BUILD_MAINT_OPTIONS = hardening=+all +DPKG_EXPORT_BUILDFLAGS = 1 +include /usr/share/dpkg/buildflags.mk + +export DH_VIRTUALENV_INSTALL_ROOT=/opt/tinypilot # Prevent debhelper from generating an extra package with debug symbols. export DEB_BUILD_OPTIONS=noddebs From 36157927b776b4831ed9c3d770925c6d2d39daa5 Mon Sep 17 00:00:00 2001 From: Jason Wallace Date: Wed, 31 May 2023 18:28:59 +0200 Subject: [PATCH 63/74] Suppress lintian tags. --- debian-pkg/debian/tinypilot.lintian-overrides | 2 ++ 1 file changed, 2 insertions(+) diff --git a/debian-pkg/debian/tinypilot.lintian-overrides b/debian-pkg/debian/tinypilot.lintian-overrides index fc86d7581..035159dcf 100644 --- a/debian-pkg/debian/tinypilot.lintian-overrides +++ b/debian-pkg/debian/tinypilot.lintian-overrides @@ -3,6 +3,8 @@ tinypilot: embedded-javascript-library opt/tinypilot/venv/lib/python*/site-packa tinypilot: script-not-executable [opt/tinypilot/venv/lib/python*/site-packages/greenlet/tests/test_version.py] tinypilot: script-not-executable [opt/tinypilot/venv/lib/python*/site-packages/pkg_resources/_vendor/appdirs.py] tinypilot: script-not-executable [opt/tinypilot/venv/lib/python*/site-packages/setuptools/command/easy_install.py] +tinypilot: embedded-library opt/tinypilot/venv/* +tinypilot: hardening-no-relro opt/tinypilot/venv/* # Lintian doesn't recognize the Python interpreter when it's within the # virtualenv. From eb82746d7bae499ee4b156346d0ed90624acda9f Mon Sep 17 00:00:00 2001 From: Jason Wallace Date: Wed, 31 May 2023 18:33:40 +0200 Subject: [PATCH 64/74] Suppress lintian tags. --- debian-pkg/debian/tinypilot.lintian-overrides | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/debian-pkg/debian/tinypilot.lintian-overrides b/debian-pkg/debian/tinypilot.lintian-overrides index 035159dcf..843762438 100644 --- a/debian-pkg/debian/tinypilot.lintian-overrides +++ b/debian-pkg/debian/tinypilot.lintian-overrides @@ -3,8 +3,8 @@ tinypilot: embedded-javascript-library opt/tinypilot/venv/lib/python*/site-packa tinypilot: script-not-executable [opt/tinypilot/venv/lib/python*/site-packages/greenlet/tests/test_version.py] tinypilot: script-not-executable [opt/tinypilot/venv/lib/python*/site-packages/pkg_resources/_vendor/appdirs.py] tinypilot: script-not-executable [opt/tinypilot/venv/lib/python*/site-packages/setuptools/command/easy_install.py] -tinypilot: embedded-library opt/tinypilot/venv/* -tinypilot: hardening-no-relro opt/tinypilot/venv/* +tinypilot: embedded-library opt/tinypilot/venv/lib/python*/site-packages/yaml/*.so: libyaml +tinypilot: hardening-no-relro [opt/tinypilot/venv/lib/python*/site-packages/yaml/*.so] # Lintian doesn't recognize the Python interpreter when it's within the # virtualenv. From 117089588a7930ac941d7010b876808bae6ba88e Mon Sep 17 00:00:00 2001 From: Jason Wallace Date: Wed, 31 May 2023 18:37:43 +0200 Subject: [PATCH 65/74] Suppress lintian tags. --- debian-pkg/debian/tinypilot.lintian-overrides | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/debian-pkg/debian/tinypilot.lintian-overrides b/debian-pkg/debian/tinypilot.lintian-overrides index 843762438..67fbe93f7 100644 --- a/debian-pkg/debian/tinypilot.lintian-overrides +++ b/debian-pkg/debian/tinypilot.lintian-overrides @@ -3,7 +3,7 @@ tinypilot: embedded-javascript-library opt/tinypilot/venv/lib/python*/site-packa tinypilot: script-not-executable [opt/tinypilot/venv/lib/python*/site-packages/greenlet/tests/test_version.py] tinypilot: script-not-executable [opt/tinypilot/venv/lib/python*/site-packages/pkg_resources/_vendor/appdirs.py] tinypilot: script-not-executable [opt/tinypilot/venv/lib/python*/site-packages/setuptools/command/easy_install.py] -tinypilot: embedded-library opt/tinypilot/venv/lib/python*/site-packages/yaml/*.so: libyaml +tinypilot: embedded-library libyaml opt/tinypilot/venv/lib/python*/site-packages/yaml/*.so tinypilot: hardening-no-relro [opt/tinypilot/venv/lib/python*/site-packages/yaml/*.so] # Lintian doesn't recognize the Python interpreter when it's within the From 3a9408aa796edacd89db5bb0da73c0913ea986d5 Mon Sep 17 00:00:00 2001 From: Jason Wallace Date: Thu, 1 Jun 2023 13:54:53 +0200 Subject: [PATCH 66/74] Use case statement for deciding target arch. --- debian-pkg/Dockerfile | 28 ++++++++++++++++------------ 1 file changed, 16 insertions(+), 12 deletions(-) diff --git a/debian-pkg/Dockerfile b/debian-pkg/Dockerfile index a2a9267b9..b571740da 100644 --- a/debian-pkg/Dockerfile +++ b/debian-pkg/Dockerfile @@ -31,18 +31,22 @@ ARG PKG_BUILD_NUMBER="1" # Docker's platform names don't match Debian's platform names, so we translate # the platform name from the Docker version to the Debian version and save the # result to a file so we can re-use it in later stages. -RUN set -x && \ - if [ "$TARGETPLATFORM" = "linux/arm/v7" ]; then \ - echo "armhf" > /tmp/pkg-arch; \ - elif [ "$TARGETPLATFORM" = "linux/amd64" ]; then \ - echo "amd64" > /tmp/pkg-arch; \ - else \ - echo "Unrecognized target platform: ${TARGETPLATFORM}" >&2; \ - exit 1; \ - fi -RUN set -u && \ - PKG_ARCH="$(cat /tmp/pkg-arch)" && \ - echo "${PKG_NAME}-${PKG_VERSION}-${PKG_BUILD_NUMBER}-${PKG_ARCH}" > /tmp/pkg-id +RUN cat | bash <<'EOF' +set -exu +case "${TARGETPLATFORM}" in + 'linux/amd64') + PKG_ARCH='amd64' + ;; + 'linux/arm/v7') + PKG_ARCH='armhf' + ;; + *) + echo "Unrecognized target platform: ${TARGETPLATFORM}" >&2 + exit 1 +esac +echo "${PKG_ARCH}" > /tmp/pkg-arch +echo "${PKG_NAME}-${PKG_VERSION}-${PKG_BUILD_NUMBER}-${PKG_ARCH}" > /tmp/pkg-id +EOF # We ultimately need the directory name to be the package ID, but there's no # way to specify a dynamic value in Docker's WORKDIR command, so we use a From 3564a54f25073d12ce995e9c357ef818116c7e5c Mon Sep 17 00:00:00 2001 From: Jason Wallace Date: Thu, 1 Jun 2023 13:57:00 +0200 Subject: [PATCH 67/74] Remove unnecessary mkdir. --- debian-pkg/Dockerfile | 2 -- 1 file changed, 2 deletions(-) diff --git a/debian-pkg/Dockerfile b/debian-pkg/Dockerfile index b571740da..b204022aa 100644 --- a/debian-pkg/Dockerfile +++ b/debian-pkg/Dockerfile @@ -52,8 +52,6 @@ EOF # way to specify a dynamic value in Docker's WORKDIR command, so we use a # placeholder directory name to assemble the Debian package and then rename the # directory to its package ID name in the final stages of packaging. -RUN mkdir -p "/releases/placeholder-pkg-id" - WORKDIR "/releases/placeholder-pkg-id" COPY ./debian-pkg ./ From e7279f04bd915aa6a1e0fdab72ab977d7099546f Mon Sep 17 00:00:00 2001 From: Jason Wallace Date: Thu, 1 Jun 2023 14:20:16 +0200 Subject: [PATCH 68/74] Always clear Ansible roles. --- bundler/create-bundle | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/bundler/create-bundle b/bundler/create-bundle index e4a22c40e..604913537 100755 --- a/bundler/create-bundle +++ b/bundler/create-bundle @@ -72,8 +72,11 @@ python3 -m venv venv pip install "pip>=21.3.1" pip install --requirement "${BUNDLE_DIR}/requirements.txt" +# Clear Ansible roles. +rm -rf "${ANSIBLE_ROLES_DIR}" +mkdir "${ANSIBLE_ROLES_DIR}" + # Copy Ansible role. -mkdir -p "${ANSIBLE_ROLES_DIR}" cp -r \ --no-target-directory \ ../ansible-role "${ANSIBLE_ROLE_TINYPILOT_DIR}" From 67d2fee89480a1b4011bcea7e9b786b5abec67fd Mon Sep 17 00:00:00 2001 From: Jason Wallace Date: Thu, 1 Jun 2023 14:37:06 +0200 Subject: [PATCH 69/74] Fix quote style. --- debian-pkg/Dockerfile | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/debian-pkg/Dockerfile b/debian-pkg/Dockerfile index b204022aa..47abc3b53 100644 --- a/debian-pkg/Dockerfile +++ b/debian-pkg/Dockerfile @@ -25,8 +25,8 @@ ARG TINYPILOT_VERSION # recently built TinyPilot package. ARG PKG_VERSION -ARG PKG_NAME="tinypilot" -ARG PKG_BUILD_NUMBER="1" +ARG PKG_NAME='tinypilot' +ARG PKG_BUILD_NUMBER='1' # Docker's platform names don't match Debian's platform names, so we translate # the platform name from the Docker version to the Debian version and save the @@ -52,7 +52,7 @@ EOF # way to specify a dynamic value in Docker's WORKDIR command, so we use a # placeholder directory name to assemble the Debian package and then rename the # directory to its package ID name in the final stages of packaging. -WORKDIR "/releases/placeholder-pkg-id" +WORKDIR /releases/placeholder-pkg-id COPY ./debian-pkg ./ COPY ./COPYRIGHT ./ @@ -64,7 +64,7 @@ COPY ./scripts ./scripts RUN echo "${TINYPILOT_VERSION}" > VERSION -WORKDIR "/releases/placeholder-pkg-id/debian" +WORKDIR /releases/placeholder-pkg-id/debian RUN set -x && \ PKG_ARCH="$(cat /tmp/pkg-arch)" && \ @@ -93,7 +93,7 @@ tinypilot (${PKG_VERSION}) bullseye; urgency=medium EOF # Rename the placeholder release directory to the final package ID. -WORKDIR "/releases" +WORKDIR /releases RUN set -x && \ PKG_ID="$(cat /tmp/pkg-id)" && \ mv placeholder-pkg-id "${PKG_ID}" && \ @@ -102,4 +102,4 @@ RUN set -x && \ FROM scratch as artifact -COPY --from=build "/releases/*.deb" ./ +COPY --from=build /releases/*.deb ./ From e968c193009aeb03a6ada4f78411ddd8e0e5a97e Mon Sep 17 00:00:00 2001 From: Jason Wallace Date: Thu, 1 Jun 2023 15:45:22 +0200 Subject: [PATCH 70/74] Move clean up to dh_auto_clean. --- debian-pkg/debian/rules | 3 +++ 1 file changed, 3 insertions(+) diff --git a/debian-pkg/debian/rules b/debian-pkg/debian/rules index 50f6acc21..615f39eba 100755 --- a/debian-pkg/debian/rules +++ b/debian-pkg/debian/rules @@ -19,6 +19,9 @@ override_dh_virtualenv: # Skip install because TinyPilot doesn't need to run setup.py to install. # Use the venv directory because that's where we've historically kept it. dh_virtualenv --skip-install --install-suffix venv + +override_dh_auto_clean: + dh_auto_clean -- # dh_virtualenv doesn't remove __pycache__ directories, so we clean them up # manually. find . -type d -name __pycache__ -prune -exec rm -rf {} \; From 79fe3e6a37cec4fd654d57d1dd2da057c15f8f7f Mon Sep 17 00:00:00 2001 From: Jason Wallace Date: Thu, 1 Jun 2023 15:51:19 +0200 Subject: [PATCH 71/74] Revert "Move clean up to dh_auto_clean." --- debian-pkg/debian/rules | 3 --- 1 file changed, 3 deletions(-) diff --git a/debian-pkg/debian/rules b/debian-pkg/debian/rules index 3879ff361..cb69017f4 100755 --- a/debian-pkg/debian/rules +++ b/debian-pkg/debian/rules @@ -20,9 +20,6 @@ override_dh_virtualenv: # Skip install because TinyPilot doesn't need to run setup.py to install. # Use the venv directory because that's where we've historically kept it. dh_virtualenv --skip-install --install-suffix venv - -override_dh_auto_clean: - dh_auto_clean -- # dh_virtualenv doesn't remove __pycache__ directories, so we clean them up # manually. find . -type d -name __pycache__ -prune -exec rm -rf {} \; From e84daf39f2de03b4c5f702d1a8266490759c822f Mon Sep 17 00:00:00 2001 From: Jason Wallace Date: Fri, 2 Jun 2023 14:20:36 +0200 Subject: [PATCH 72/74] Set bash options. --- debian-pkg/Dockerfile | 20 +++++++++++--------- 1 file changed, 11 insertions(+), 9 deletions(-) diff --git a/debian-pkg/Dockerfile b/debian-pkg/Dockerfile index 47abc3b53..7e19f7b37 100644 --- a/debian-pkg/Dockerfile +++ b/debian-pkg/Dockerfile @@ -4,7 +4,7 @@ FROM debian:bullseye-20220328-slim AS build -RUN set -x && \ +RUN set -exu && \ apt-get update && \ DEBIAN_FRONTEND=noninteractive apt-get install -y \ debhelper \ @@ -66,9 +66,8 @@ RUN echo "${TINYPILOT_VERSION}" > VERSION WORKDIR /releases/placeholder-pkg-id/debian -RUN set -x && \ +RUN set -exu && \ PKG_ARCH="$(cat /tmp/pkg-arch)" && \ - set -u && \ cat >control <changelog <changelog < Date: Fri, 2 Jun 2023 14:33:23 +0200 Subject: [PATCH 73/74] Add comment explaining Debian package paths. --- .circleci/continue_config.yml | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/.circleci/continue_config.yml b/.circleci/continue_config.yml index 81598dc66..02f8c17f7 100644 --- a/.circleci/continue_config.yml +++ b/.circleci/continue_config.yml @@ -102,6 +102,14 @@ jobs: ./dev-scripts/build-debian-pkg "${BUILD_TARGETS}" - run: name: Move Debian packages to a predictable location + # Building for multiple architectures at once, changes the path of the + # resulting Debian package. For example: + # - Building for both AMD64 and ARMv7, produces files in: + # - `releases/linux_arm_v7/*.deb` + # - `releases/linux_amd64/*.deb` + # - Building for only AMD64, produces files in: + # - `releases/*.deb` + # For consistency, we move all packages to `releases/*.deb`. command: find . -name '*.deb' -exec mv {} ./debian-pkg/releases/ \; - run: name: Print Debian package contents From 4ebe94a86b6a09d5fcc888325357fad740d7865b Mon Sep 17 00:00:00 2001 From: Jason Wallace Date: Fri, 2 Jun 2023 14:57:19 +0200 Subject: [PATCH 74/74] Expand comment. --- bundler/create-bundle | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/bundler/create-bundle b/bundler/create-bundle index 604913537..2fb4ce866 100755 --- a/bundler/create-bundle +++ b/bundler/create-bundle @@ -72,7 +72,7 @@ python3 -m venv venv pip install "pip>=21.3.1" pip install --requirement "${BUNDLE_DIR}/requirements.txt" -# Clear Ansible roles. +# Clear Ansible roles from any previous bundle builds. rm -rf "${ANSIBLE_ROLES_DIR}" mkdir "${ANSIBLE_ROLES_DIR}"