From aa7f643e20fe9ca6a6e1d044e6ff72cd4cff9b93 Mon Sep 17 00:00:00 2001 From: Debarshi Ray Date: Tue, 23 Feb 2021 20:19:10 +0100 Subject: [PATCH 01/18] Update to 0.0.99.1 --- .gitignore | 1 + sources | 2 +- toolbox.spec | 7 +++++-- 3 files changed, 7 insertions(+), 3 deletions(-) diff --git a/.gitignore b/.gitignore index bda8bf7..5586f4a 100644 --- a/.gitignore +++ b/.gitignore @@ -21,3 +21,4 @@ /toolbox-0.0.98.tar.xz /toolbox-0.0.98.1.tar.xz /toolbox-0.0.99.tar.xz +/toolbox-0.0.99.1.tar.xz diff --git a/sources b/sources index 6d069a5..668e2bc 100644 --- a/sources +++ b/sources @@ -1 +1 @@ -SHA512 (toolbox-0.0.99.tar.xz) = a2b750894d902575b742249ee89526e876fdbc6353e0aa8aa262f230f6b0c53266c70c93b2921eef3c2189d93dc096bdeee1be11c9aff0ee110a4fcbcb782f88 +SHA512 (toolbox-0.0.99.1.tar.xz) = 6021653eb7fbfc85ea700a9f52f9cfb552efbd4127eb3332a53bd340c8270c4d7a4e54b4a435202fd9e95ee0d90555a46ae9363a930b37fa35e63f239dffc027 diff --git a/toolbox.spec b/toolbox.spec index 358a90e..167159c 100644 --- a/toolbox.spec +++ b/toolbox.spec @@ -1,10 +1,10 @@ Name: toolbox -Version: 0.0.99 +Version: 0.0.99.1 %global goipath github.com/containers/%{name} %gometa -Release: 2%{?dist} +Release: 1%{?dist} Summary: Unprivileged development environment License: ASL 2.0 @@ -173,6 +173,9 @@ ln -s src/pkg pkg %changelog +* Tue Feb 23 2021 Debarshi Ray - 0.0.99.1-1 +- Update to 0.0.99.1 + * Wed Jan 27 2021 Fedora Release Engineering - 0.0.99-2 - Rebuilt for https://fedoraproject.org/wiki/Fedora_34_Mass_Rebuild From 0d4eca4acb3826997b4f5aa7bb34ceca0c485bc6 Mon Sep 17 00:00:00 2001 From: Debarshi Ray Date: Thu, 29 Apr 2021 01:02:13 +0200 Subject: [PATCH 02/18] Tweak the Summary No need to issue a build just for this. --- toolbox.spec | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/toolbox.spec b/toolbox.spec index 167159c..aa6245a 100644 --- a/toolbox.spec +++ b/toolbox.spec @@ -5,7 +5,7 @@ Version: 0.0.99.1 %gometa Release: 1%{?dist} -Summary: Unprivileged development environment +Summary: Tool for containerized command line environments on Linux License: ASL 2.0 URL: https://github.com/containers/%{name} From 151eea730aecb29d059836461e91a41698c5c5da Mon Sep 17 00:00:00 2001 From: Debarshi Ray Date: Sat, 26 Jun 2021 20:03:14 +0200 Subject: [PATCH 03/18] Update to 0.0.99.2 Disable the %check section because 'go test ...' isn't working as it is in the build environment. --- .gitignore | 1 + sources | 2 +- toolbox.spec | 11 ++++++++--- 3 files changed, 10 insertions(+), 4 deletions(-) diff --git a/.gitignore b/.gitignore index 5586f4a..51193d6 100644 --- a/.gitignore +++ b/.gitignore @@ -22,3 +22,4 @@ /toolbox-0.0.98.1.tar.xz /toolbox-0.0.99.tar.xz /toolbox-0.0.99.1.tar.xz +/toolbox-0.0.99.2.tar.xz diff --git a/sources b/sources index 668e2bc..c553232 100644 --- a/sources +++ b/sources @@ -1 +1 @@ -SHA512 (toolbox-0.0.99.1.tar.xz) = 6021653eb7fbfc85ea700a9f52f9cfb552efbd4127eb3332a53bd340c8270c4d7a4e54b4a435202fd9e95ee0d90555a46ae9363a930b37fa35e63f239dffc027 +SHA512 (toolbox-0.0.99.2.tar.xz) = 8e775d500755181f22f62dde4da32d5eff446590e54587633a545f880e9d58dc36ace9e7b37e5ec7a4713f570ceb3d27569f9421ad27fd95f0bb6499b470d0b6 diff --git a/toolbox.spec b/toolbox.spec index aa6245a..b101c40 100644 --- a/toolbox.spec +++ b/toolbox.spec @@ -1,5 +1,5 @@ Name: toolbox -Version: 0.0.99.1 +Version: 0.0.99.2 %global goipath github.com/containers/%{name} %gometa @@ -27,6 +27,7 @@ BuildRequires: golang(github.com/fsnotify/fsnotify) >= 1.4.7 BuildRequires: golang(github.com/godbus/dbus) >= 5.0.3 BuildRequires: golang(github.com/mattn/go-isatty) >= 0.0.12 BuildRequires: golang(github.com/sirupsen/logrus) >= 1.4.2 +# BuildRequires: golang(github.com/stretchr/testify) >= 1.7.0 BuildRequires: golang(github.com/spf13/cobra) >= 0.0.5 BuildRequires: golang(golang.org/x/sys/unix) BuildRequires: meson @@ -86,6 +87,7 @@ Requires: man-db Requires: man-pages Requires: mlocate Requires: mtr +Requires: nano-default-editor Requires: nss-mdns Requires: openssh-clients Requires: pigz @@ -146,8 +148,8 @@ ln -s src/pkg pkg %meson_build -%check -%meson_test +# %%check +# %%meson_test %install @@ -173,6 +175,9 @@ ln -s src/pkg pkg %changelog +* Sat Jun 26 2021 Debarshi Ray - 0.0.99.2-1 +- Update to 0.0.99.2 + * Tue Feb 23 2021 Debarshi Ray - 0.0.99.1-1 - Update to 0.0.99.1 From 9853bf5d8f725e5f5487324c6a1aed777f1f63eb Mon Sep 17 00:00:00 2001 From: Debarshi Ray Date: Thu, 8 Jul 2021 20:59:14 +0200 Subject: [PATCH 04/18] Add bc and iproute to the toolbox-experience sub-package No need to issue a build just for this. --- toolbox.spec | 2 ++ 1 file changed, 2 insertions(+) diff --git a/toolbox.spec b/toolbox.spec index b101c40..ebbe463 100644 --- a/toolbox.spec +++ b/toolbox.spec @@ -66,6 +66,7 @@ Summary: Set of packages to enhance the %{name} experience Requires: %{name}-support = %{version}-%{release} Requires: bash-completion +Requires: bc Requires: bzip2 Requires: diffutils Requires: dnf-plugins-core @@ -77,6 +78,7 @@ Requires: gnupg Requires: gnupg2-smime Requires: gvfs-client Requires: hostname +Requires: iproute Requires: iputils Requires: jwhois Requires: keyutils From c208cde9a4ac8ee7a0153475bca5a3b4cc06353f Mon Sep 17 00:00:00 2001 From: Oliver Gutierrez Date: Wed, 25 Aug 2021 15:24:37 +0100 Subject: [PATCH 05/18] Added gating and version bump for gating checks --- gating.yaml | 9 +++ tests/roles/nonroot_user/tasks/main.yml | 7 ++ .../run_bats_tests/files/run_bats_tests.sh | 72 +++++++++++++++++++ tests/roles/run_bats_tests/tasks/main.yml | 37 ++++++++++ .../run_bats_tests/tasks/run_one_test.yml | 52 ++++++++++++++ tests/tests.yml | 15 ++++ toolbox.spec | 5 +- 7 files changed, 196 insertions(+), 1 deletion(-) create mode 100644 gating.yaml create mode 100644 tests/roles/nonroot_user/tasks/main.yml create mode 100755 tests/roles/run_bats_tests/files/run_bats_tests.sh create mode 100644 tests/roles/run_bats_tests/tasks/main.yml create mode 100644 tests/roles/run_bats_tests/tasks/run_one_test.yml create mode 100644 tests/tests.yml diff --git a/gating.yaml b/gating.yaml new file mode 100644 index 0000000..5ab3627 --- /dev/null +++ b/gating.yaml @@ -0,0 +1,9 @@ +--- !Policy +product_versions: + - fedora-* +decision_contexts: + - bodhi_update_push_stable + - bodhi_update_push_testing +subject_type: koji_build +rules: + - !PassingTestCaseRule {test_case_name: fedora-ci.koji-build.tier0.functional} diff --git a/tests/roles/nonroot_user/tasks/main.yml b/tests/roles/nonroot_user/tasks/main.yml new file mode 100644 index 0000000..51bf44a --- /dev/null +++ b/tests/roles/nonroot_user/tasks/main.yml @@ -0,0 +1,7 @@ +--- +- name: create nonroot user + user: + name: testuser + shell: /bin/bash +- name: enable linger + command: loginctl enable-linger testuser diff --git a/tests/roles/run_bats_tests/files/run_bats_tests.sh b/tests/roles/run_bats_tests/files/run_bats_tests.sh new file mode 100755 index 0000000..e9f5f5f --- /dev/null +++ b/tests/roles/run_bats_tests/files/run_bats_tests.sh @@ -0,0 +1,72 @@ +#!/bin/bash +# +# Run bats tests for a given $TEST_PACKAGE, e.g. buildah, podman +# +# This is invoked by the 'run_bats_tests' role; we assume that +# the package foo has a foo-tests subpackage which provides the +# directory /usr/share/foo/test/system, containing one or more .bats +# test files. +# + +export PATH=/usr/local/bin:/usr/sbin:/usr/bin + +FULL_LOG=/tmp/test.debug.log +BATS_LOG=/tmp/test.bats.log +rm -f $FULL_LOG $BATS_LOG +touch $FULL_LOG $BATS_LOG + +exec &> $FULL_LOG + +# Log program versions +echo "Packages:" +rpm -q ${TEST_PACKAGE} ${TEST_PACKAGE}-tests + +echo "------------------------------" +printenv | sort + +testdir=/usr/share/${TEST_PACKAGE}/test/system + +if ! cd $testdir; then + echo "FAIL ${TEST_NAME} : cd $testdir" >> /tmp/test.log + exit 0 +fi + +if [ -e /tmp/helper.sh ]; then + echo "------------------------------" + echo ". /tmp/helper.sh" + . /tmp/helper.sh +fi + +if [ "$(type -t setup)" = "function" ]; then + echo "------------------------------" + echo "\$ setup" + setup + if [ $? -ne 0 ]; then + echo "FAIL ${TEST_NAME} : setup" >> /tmp/test.log + exit 0 + fi +fi + +echo "------------------------------" +echo "\$ bats ." +bats . &> $BATS_LOG +rc=$? + +echo "------------------------------" +echo "bats completed with status $rc" + +status=PASS +if [ $rc -ne 0 ]; then + status=FAIL +fi + +echo "${status} ${TEST_NAME}" >> /tmp/test.log + +if [ "$(type -t teardown)" = "function" ]; then + echo "------------------------------" + echo "\$ teardown" + teardown +fi + +# FIXME: for CI purposes, always exit 0. This allows subsequent tests. +exit 0 diff --git a/tests/roles/run_bats_tests/tasks/main.yml b/tests/roles/run_bats_tests/tasks/main.yml new file mode 100644 index 0000000..da79a4c --- /dev/null +++ b/tests/roles/run_bats_tests/tasks/main.yml @@ -0,0 +1,37 @@ +--- +# Create empty results file, world-writable +- name: initialize test.log file + copy: dest=/tmp/test.log content='' force=yes mode=0666 + +- name: execute tests + include: run_one_test.yml + with_items: "{{ tests }}" + loop_control: + loop_var: test + +- name: pull test.log results + fetch: + src: "/tmp/test.log" + dest: "{{ artifacts }}/test.log" + flat: yes + +# Copied from standard-test-basic +- name: check results + shell: grep "^FAIL" /tmp/test.log + register: test_fails + # Never fail at this step. Just store result of tests. + failed_when: False + +- name: preserve results + set_fact: + role_result_failed: "{{ (test_fails.stdout|d|length > 0) or (test_fails.stderr|d|length > 0) }}" + role_result_msg: "{{ test_fails.stdout|d('tests failed.') }}" + +- name: display results + vars: + msg: | + Tests failed: {{ role_result_failed|d('Undefined') }} + Tests msg: {{ role_result_msg|d('None') }} + debug: + msg: "{{ msg.split('\n') }}" + failed_when: "role_result_failed|bool" diff --git a/tests/roles/run_bats_tests/tasks/run_one_test.yml b/tests/roles/run_bats_tests/tasks/run_one_test.yml new file mode 100644 index 0000000..b44ed42 --- /dev/null +++ b/tests/roles/run_bats_tests/tasks/run_one_test.yml @@ -0,0 +1,52 @@ +--- +- name: "{{ test.name }} | install test packages" + dnf: name="{{ test.package }}-tests" state=installed + +- name: "{{ test.name }} | define helper variables" + set_fact: + test_name_oneword: "{{ test.name | replace(' ','-') }}" + +# UGH. This is necessary because our caller sets some environment variables +# and we need to set a few more based on other caller variables; then we +# need to combine the two dicts when running the test. This seems to be +# the only way to do it in ansible. +- name: "{{ test.name }} | define local environment" + set_fact: + local_environment: + TEST_NAME: "{{ test.name }}" + TEST_PACKAGE: "{{ test.package }}" + TEST_ENV: "{{ test.environment }}" + +- name: "{{ test.name }} | setup/teardown helper | see if exists" + local_action: stat path={{ role_path }}/files/helper.{{ test_name_oneword }}.sh + register: helper + +- name: "{{ test.name }} | setup/teardown helper | install" + copy: src=helper.{{ test_name_oneword }}.sh dest=/tmp/helper.sh + when: helper.stat.exists + +- name: "{{ test.name }} | run test" + script: ./run_bats_tests.sh + args: + chdir: /usr/share/{{ test.package }}/test/system + become: "{{ true if test.become is defined else false }}" + become_user: testuser + environment: "{{ local_environment | combine(test.environment) }}" + +- name: "{{ test.name }} | pull logs" + fetch: + src: "/tmp/test.{{ item }}.log" + dest: "{{ artifacts }}/test.{{ test_name_oneword }}.{{ item }}.log" + flat: yes + with_items: + - bats + - debug + +- name: "{{ test.name }} | remove remote logs and helpers" + file: + dest=/tmp/{{ item }} + state=absent + with_items: + - test.bats.log + - test.debug.log + - helper.sh diff --git a/tests/tests.yml b/tests/tests.yml new file mode 100644 index 0000000..0048a3e --- /dev/null +++ b/tests/tests.yml @@ -0,0 +1,15 @@ +--- +- hosts: localhost + tags: classic + vars: + - artifacts: ./artifacts + roles: + - role: nonroot_user + - role: run_bats_tests + tests: + - name: toolbox + package: toolbox + environment: + PODMAN: /usr/bin/podman + become: true + \ No newline at end of file diff --git a/toolbox.spec b/toolbox.spec index ebbe463..f964fd9 100644 --- a/toolbox.spec +++ b/toolbox.spec @@ -4,7 +4,7 @@ Version: 0.0.99.2 %global goipath github.com/containers/%{name} %gometa -Release: 1%{?dist} +Release: 2%{?dist} Summary: Tool for containerized command line environments on Linux License: ASL 2.0 @@ -177,6 +177,9 @@ ln -s src/pkg pkg %changelog +* Sat Jun 26 2021 Debarshi Ray - 0.0.99.2-2 +- Rebuild for gating checks + * Sat Jun 26 2021 Debarshi Ray - 0.0.99.2-1 - Update to 0.0.99.2 From fb735e6175fa20f21c2f291379ac9ccf734bab7f Mon Sep 17 00:00:00 2001 From: Oliver Gutierrez Date: Thu, 26 Aug 2021 11:47:43 +0100 Subject: [PATCH 06/18] Updated sources to 0.0.99.2^3.git075b9a8d2779 snapshot --- .gitignore | 1 + sources | 2 +- toolbox.spec | 7 +++++-- 3 files changed, 7 insertions(+), 3 deletions(-) diff --git a/.gitignore b/.gitignore index 51193d6..399488c 100644 --- a/.gitignore +++ b/.gitignore @@ -23,3 +23,4 @@ /toolbox-0.0.99.tar.xz /toolbox-0.0.99.1.tar.xz /toolbox-0.0.99.2.tar.xz +/toolbox-0.0.99.2^3.git075b9a8d2779.tar.xz diff --git a/sources b/sources index c553232..529eaaf 100644 --- a/sources +++ b/sources @@ -1 +1 @@ -SHA512 (toolbox-0.0.99.2.tar.xz) = 8e775d500755181f22f62dde4da32d5eff446590e54587633a545f880e9d58dc36ace9e7b37e5ec7a4713f570ceb3d27569f9421ad27fd95f0bb6499b470d0b6 +SHA512 (toolbox-0.0.99.2^3.git075b9a8d2779.tar.xz) = e9ebb306fa3fe72dede4d08e1428dbfde12fe44274b4ea7cd356cba28a90daff728c4182f13e20f8a05603aeefb4cf484611805dac2776ab38c37764e6069c5d diff --git a/toolbox.spec b/toolbox.spec index f964fd9..4cc5c43 100644 --- a/toolbox.spec +++ b/toolbox.spec @@ -1,10 +1,10 @@ Name: toolbox -Version: 0.0.99.2 +Version: 0.0.99.2^3.git075b9a8d2779 %global goipath github.com/containers/%{name} %gometa -Release: 2%{?dist} +Release: 1%{?dist} Summary: Tool for containerized command line environments on Linux License: ASL 2.0 @@ -177,6 +177,9 @@ ln -s src/pkg pkg %changelog +* Thu Aug 26 2021 Oliver Gutiérrez - 0.0.99.2^3.git075b9a8d2779-1 +- Updated sources to 0.0.99.2^3.git075b9a8d2779 snapshot + * Sat Jun 26 2021 Debarshi Ray - 0.0.99.2-2 - Rebuild for gating checks From b6672a2359f42bddb444b6000cbd96314caa0320 Mon Sep 17 00:00:00 2001 From: Oliver Gutierrez Date: Thu, 26 Aug 2021 12:52:07 +0100 Subject: [PATCH 07/18] Updated sources to 0.0.99.2^4.git0bdfa53bb2ce snapshot Vendored required bats modules for gating tests --- .gitignore | 1 + sources | 2 +- toolbox.spec | 6 +++++- 3 files changed, 7 insertions(+), 2 deletions(-) diff --git a/.gitignore b/.gitignore index 399488c..a10a7f6 100644 --- a/.gitignore +++ b/.gitignore @@ -24,3 +24,4 @@ /toolbox-0.0.99.1.tar.xz /toolbox-0.0.99.2.tar.xz /toolbox-0.0.99.2^3.git075b9a8d2779.tar.xz +/toolbox-0.0.99.2^4.git0bdfa53bb2ce.tar.xz diff --git a/sources b/sources index 529eaaf..58dc18a 100644 --- a/sources +++ b/sources @@ -1 +1 @@ -SHA512 (toolbox-0.0.99.2^3.git075b9a8d2779.tar.xz) = e9ebb306fa3fe72dede4d08e1428dbfde12fe44274b4ea7cd356cba28a90daff728c4182f13e20f8a05603aeefb4cf484611805dac2776ab38c37764e6069c5d +SHA512 (toolbox-0.0.99.2^4.git0bdfa53bb2ce.tar.xz) = cbf2d9f700a1643e6e1896d9500d713f7f5ba29a46912a610b3764475821432e2b4b995b78bdd8de7ef3dae290acf62924fc98b4d2042e466a1249137917417b diff --git a/toolbox.spec b/toolbox.spec index 4cc5c43..fa332e2 100644 --- a/toolbox.spec +++ b/toolbox.spec @@ -1,5 +1,5 @@ Name: toolbox -Version: 0.0.99.2^3.git075b9a8d2779 +Version: 0.0.99.2^4.git0bdfa53bb2ce %global goipath github.com/containers/%{name} %gometa @@ -177,6 +177,10 @@ ln -s src/pkg pkg %changelog +* Thu Aug 26 2021 Oliver Gutiérrez - 0.0.99.2^4.git0bdfa53bb2ce-1 +- Updated sources to 0.0.99.2^4.git0bdfa53bb2ce snapshot +- Vendored required bats modules for gating tests + * Thu Aug 26 2021 Oliver Gutiérrez - 0.0.99.2^3.git075b9a8d2779-1 - Updated sources to 0.0.99.2^3.git075b9a8d2779 snapshot From db1d2531130699fee2eb39a913c295d09b3cbaf4 Mon Sep 17 00:00:00 2001 From: Oliver Gutierrez Date: Wed, 1 Sep 2021 14:28:29 +0100 Subject: [PATCH 08/18] Fixes required for enabling gating tests in f34 Reverted sources to 0.0.99.2 Vendored required bats modules for gating tests Added a patch for checking the XDG_RUNTIME_DIR --- sources | 2 +- ...t-of-tests-check-for-XDG_RUNTIME_DIR.patch | 123 ++++++++++++++++++ toolbox.spec | 6 + 3 files changed, 130 insertions(+), 1 deletion(-) create mode 100644 toolbox-Backport-of-tests-check-for-XDG_RUNTIME_DIR.patch diff --git a/sources b/sources index 58dc18a..f134cae 100644 --- a/sources +++ b/sources @@ -1 +1 @@ -SHA512 (toolbox-0.0.99.2^4.git0bdfa53bb2ce.tar.xz) = cbf2d9f700a1643e6e1896d9500d713f7f5ba29a46912a610b3764475821432e2b4b995b78bdd8de7ef3dae290acf62924fc98b4d2042e466a1249137917417b +SHA512 (toolbox-0.0.99.2.tar.xz) = fcd081cc7d48253fd44fcb46314e471bd2aadd17fb5c5e1b5170da421f2e95226421948ef8661f28024432f5f6e1464d7780231044232da569e8f517ad62608d diff --git a/toolbox-Backport-of-tests-check-for-XDG_RUNTIME_DIR.patch b/toolbox-Backport-of-tests-check-for-XDG_RUNTIME_DIR.patch new file mode 100644 index 0000000..b9cafb5 --- /dev/null +++ b/toolbox-Backport-of-tests-check-for-XDG_RUNTIME_DIR.patch @@ -0,0 +1,123 @@ +From c0f6af1cc8d1cf881f6fd1c19bad07bb6861e16c Mon Sep 17 00:00:00 2001 +From: Oliver Gutierrez +Date: Wed, 1 Sep 2021 14:21:22 +0100 +Subject: [PATCH] Fixed tests to check for XDG_RUNTIME_DIR + +--- + test/system/002-help.bats | 4 ++++ + test/system/101-create.bats | 1 + + test/system/102-list.bats | 7 ++++--- + test/system/103-run.bats | 2 +- + test/system/104-rm.bats | 1 + + test/system/105-rmi.bats | 1 + + test/system/libs/helpers.bash | 8 ++++++++ + 7 files changed, 20 insertions(+), 4 deletions(-) + +diff --git a/test/system/002-help.bats b/test/system/002-help.bats +index 8a057dd..bf863ef 100644 +--- a/test/system/002-help.bats ++++ b/test/system/002-help.bats +@@ -4,6 +4,10 @@ load 'libs/bats-support/load' + load 'libs/bats-assert/load' + load 'libs/helpers.bash' + ++setup() { ++ check_xdg_runtime_dir ++} ++ + @test "help: Try to run toolbox with no command (shows usage screen)" { + run $TOOLBOX + +diff --git a/test/system/101-create.bats b/test/system/101-create.bats +index dfb4d89..63d4fcb 100644 +--- a/test/system/101-create.bats ++++ b/test/system/101-create.bats +@@ -5,6 +5,7 @@ load 'libs/bats-assert/load' + load 'libs/helpers' + + setup() { ++ check_xdg_runtime_dir + cleanup_containers + } + +diff --git a/test/system/102-list.bats b/test/system/102-list.bats +index ea74645..42000c7 100644 +--- a/test/system/102-list.bats ++++ b/test/system/102-list.bats +@@ -5,6 +5,7 @@ load 'libs/bats-assert/load' + load 'libs/helpers' + + setup() { ++ check_xdg_runtime_dir + cleanup_all + } + +@@ -89,9 +90,9 @@ teardown() { + run $PODMAN build "$BATS_TMPDIR" + + assert_success +- assert_line --index 0 "STEP 1: FROM scratch" +- assert_line --index 1 "STEP 2: LABEL com.github.containers.toolbox=\"true\"" +- assert_line --index 2 "STEP 3: COMMIT" ++ assert_line --index 0 "STEP 1/2: FROM scratch" ++ assert_line --index 1 "STEP 2/2: LABEL com.github.containers.toolbox=\"true\"" ++ assert_line --index 2 "COMMIT" + assert_line --index 3 --regexp "^--> [a-z0-9]*$" + + run $TOOLBOX list +diff --git a/test/system/103-run.bats b/test/system/103-run.bats +index 8b58e42..6fc840e 100644 +--- a/test/system/103-run.bats ++++ b/test/system/103-run.bats +@@ -10,7 +10,7 @@ load 'libs/helpers' + readonly CURDIR=$PWD + + setup() { +- cd "$HOME" || return 1 ++ check_xdg_runtime_dir + cleanup_containers + } + +diff --git a/test/system/104-rm.bats b/test/system/104-rm.bats +index 9f1435b..68e3c03 100644 +--- a/test/system/104-rm.bats ++++ b/test/system/104-rm.bats +@@ -5,6 +5,7 @@ load 'libs/bats-assert/load' + load 'libs/helpers' + + setup() { ++ check_xdg_runtime_dir + cleanup_containers + } + +diff --git a/test/system/105-rmi.bats b/test/system/105-rmi.bats +index 0ef0ebe..b48f802 100644 +--- a/test/system/105-rmi.bats ++++ b/test/system/105-rmi.bats +@@ -5,6 +5,7 @@ load 'libs/bats-assert/load' + load 'libs/helpers' + + setup() { ++ check_xdg_runtime_dir + cleanup_all + } + +diff --git a/test/system/libs/helpers.bash b/test/system/libs/helpers.bash +index d59d661..282b379 100644 +--- a/test/system/libs/helpers.bash ++++ b/test/system/libs/helpers.bash +@@ -271,3 +271,11 @@ function get_system_version() { + + echo $(awk -F= '/VERSION_ID/ {print $2}' $os_release | head -n 1) + } ++ ++ ++# Setup the XDG_RUNTIME_DIR variable if not set ++function check_xdg_runtime_dir() { ++ if [[ -z "${XDG_RUNTIME_DIR}" ]]; then ++ export XDG_RUNTIME_DIR="/run/user/${UID}" ++ fi ++} +-- +2.31.1 + diff --git a/toolbox.spec b/toolbox.spec index fa332e2..762fc2e 100644 --- a/toolbox.spec +++ b/toolbox.spec @@ -15,6 +15,7 @@ Source0: https://github.com/containers/%{name}/releases/download/%{version Patch100: toolbox-Don-t-use-Go-s-semantic-import-versioning.patch Patch101: toolbox-Make-the-build-flags-match-Fedora-s-gobuild.patch Patch102: toolbox-Make-the-build-flags-match-Fedora-s-gobuild-for-PPC64.patch +Patch103: toolbox-Backport-of-tests-check-for-XDG_RUNTIME_DIR.patch BuildRequires: ShellCheck BuildRequires: golang >= 1.13 @@ -177,6 +178,11 @@ ln -s src/pkg pkg %changelog +* Wed Sep 01 2021 Oliver Gutiérrez - 0.0.99.2-3 +- Reverted sources to 0.0.99.2 +- Vendored required bats modules for gating tests +- Added a patch for checking the XDG_RUNTIME_DIR + * Thu Aug 26 2021 Oliver Gutiérrez - 0.0.99.2^4.git0bdfa53bb2ce-1 - Updated sources to 0.0.99.2^4.git0bdfa53bb2ce snapshot - Vendored required bats modules for gating tests From 57e3838fc0bfce7dace9a4ecb0eb641c915070a7 Mon Sep 17 00:00:00 2001 From: Oliver Gutierrez Date: Wed, 1 Sep 2021 14:34:47 +0100 Subject: [PATCH 09/18] Fixed specfile version numbers --- toolbox.spec | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/toolbox.spec b/toolbox.spec index 762fc2e..0e65ca9 100644 --- a/toolbox.spec +++ b/toolbox.spec @@ -1,10 +1,10 @@ Name: toolbox -Version: 0.0.99.2^4.git0bdfa53bb2ce +Version: 0.0.99.2 %global goipath github.com/containers/%{name} %gometa -Release: 1%{?dist} +Release: 3%{?dist} Summary: Tool for containerized command line environments on Linux License: ASL 2.0 From 96f60fe49612f8b1c850f1f15001a111403c9359 Mon Sep 17 00:00:00 2001 From: Oliver Gutierrez Date: Thu, 2 Sep 2021 12:29:18 +0100 Subject: [PATCH 10/18] Applied patch for XDG_RUNTIME_DIR checks in tests --- toolbox.spec | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/toolbox.spec b/toolbox.spec index 0e65ca9..5a9533c 100644 --- a/toolbox.spec +++ b/toolbox.spec @@ -4,7 +4,7 @@ Version: 0.0.99.2 %global goipath github.com/containers/%{name} %gometa -Release: 3%{?dist} +Release: 4%{?dist} Summary: Tool for containerized command line environments on Linux License: ASL 2.0 @@ -138,6 +138,8 @@ The %{name}-tests package contains system tests for %{name}. %patch102 -p1 %endif +%patch103 -p1 + %gomkdir From 53038fd08d15e1d3456bee96ccf6a4120023d6e4 Mon Sep 17 00:00:00 2001 From: Oliver Gutierrez Date: Thu, 2 Sep 2021 13:10:31 +0100 Subject: [PATCH 11/18] Added skopeo as dependency of tests subpackage --- toolbox.spec | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/toolbox.spec b/toolbox.spec index 5a9533c..8629d55 100644 --- a/toolbox.spec +++ b/toolbox.spec @@ -4,7 +4,7 @@ Version: 0.0.99.2 %global goipath github.com/containers/%{name} %gometa -Release: 4%{?dist} +Release: 5%{?dist} Summary: Tool for containerized command line environments on Linux License: ASL 2.0 @@ -123,6 +123,7 @@ Summary: Tests for %{name} Requires: %{name}%{?_isa} = %{version}-%{release} Requires: bats +Requires: skopeo %description tests The %{name}-tests package contains system tests for %{name}. @@ -180,6 +181,12 @@ ln -s src/pkg pkg %changelog +* Wed Sep 01 2021 Oliver Gutiérrez - 0.0.99.2-5 +- Added skopeo as dependency of tests subpackage + +* Thu Sep 02 2021 Oliver Gutiérrez - 0.0.99.2-4 +- Added directive to apply patch for checking the XDG_RUNTIME_DIR + * Wed Sep 01 2021 Oliver Gutiérrez - 0.0.99.2-3 - Reverted sources to 0.0.99.2 - Vendored required bats modules for gating tests From d08939d62d4c370b4da9c1e8133360302f361715 Mon Sep 17 00:00:00 2001 From: Oliver Gutierrez Date: Thu, 2 Sep 2021 13:11:15 +0100 Subject: [PATCH 12/18] Fixed changelog typo --- toolbox.spec | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/toolbox.spec b/toolbox.spec index 8629d55..46729d4 100644 --- a/toolbox.spec +++ b/toolbox.spec @@ -181,7 +181,7 @@ ln -s src/pkg pkg %changelog -* Wed Sep 01 2021 Oliver Gutiérrez - 0.0.99.2-5 +* Thu Sep 02 2021 Oliver Gutiérrez - 0.0.99.2-5 - Added skopeo as dependency of tests subpackage * Thu Sep 02 2021 Oliver Gutiérrez - 0.0.99.2-4 From 08bd0ad4a2f2b75cb7394be9c389e28e0aea6cae Mon Sep 17 00:00:00 2001 From: Oliver Gutierrez Date: Thu, 2 Sep 2021 13:44:38 +0100 Subject: [PATCH 13/18] Updated patch for tests fixes required for gating --- ...tch => toolbox-Test-fixes-for-gating.patch | 29 ++++++++++--------- toolbox.spec | 7 +++-- 2 files changed, 20 insertions(+), 16 deletions(-) rename toolbox-Backport-of-tests-check-for-XDG_RUNTIME_DIR.patch => toolbox-Test-fixes-for-gating.patch (83%) diff --git a/toolbox-Backport-of-tests-check-for-XDG_RUNTIME_DIR.patch b/toolbox-Test-fixes-for-gating.patch similarity index 83% rename from toolbox-Backport-of-tests-check-for-XDG_RUNTIME_DIR.patch rename to toolbox-Test-fixes-for-gating.patch index b9cafb5..160c1ee 100644 --- a/toolbox-Backport-of-tests-check-for-XDG_RUNTIME_DIR.patch +++ b/toolbox-Test-fixes-for-gating.patch @@ -1,17 +1,8 @@ -From c0f6af1cc8d1cf881f6fd1c19bad07bb6861e16c Mon Sep 17 00:00:00 2001 +From a0ff01b52ffc8980cba501149a4e3606481cbefb Mon Sep 17 00:00:00 2001 From: Oliver Gutierrez -Date: Wed, 1 Sep 2021 14:21:22 +0100 -Subject: [PATCH] Fixed tests to check for XDG_RUNTIME_DIR +Date: Thu, 2 Sep 2021 13:41:14 +0100 +Subject: [PATCH] Fixes in tests for fedora gating ---- - test/system/002-help.bats | 4 ++++ - test/system/101-create.bats | 1 + - test/system/102-list.bats | 7 ++++--- - test/system/103-run.bats | 2 +- - test/system/104-rm.bats | 1 + - test/system/105-rmi.bats | 1 + - test/system/libs/helpers.bash | 8 ++++++++ - 7 files changed, 20 insertions(+), 4 deletions(-) diff --git a/test/system/002-help.bats b/test/system/002-help.bats index 8a057dd..bf863ef 100644 @@ -103,10 +94,20 @@ index 0ef0ebe..b48f802 100644 } diff --git a/test/system/libs/helpers.bash b/test/system/libs/helpers.bash -index d59d661..282b379 100644 +index d59d661..5d48957 100644 --- a/test/system/libs/helpers.bash +++ b/test/system/libs/helpers.bash -@@ -271,3 +271,11 @@ function get_system_version() { +@@ -8,8 +8,7 @@ readonly TOOLBOX=${TOOLBOX:-toolbox} + readonly SKOPEO=$(command -v skopeo) + + # Helpful globals +-readonly PROJECT_DIR=${PWD} +-readonly IMAGE_CACHE_DIR="${PROJECT_DIR}/image-cache" ++readonly IMAGE_CACHE_DIR="${BATS_RUN_TMPDIR}/image-cache" + + # Images + declare -Ag IMAGES=([busybox]="docker.io/library/busybox" \ +@@ -271,3 +270,11 @@ function get_system_version() { echo $(awk -F= '/VERSION_ID/ {print $2}' $os_release | head -n 1) } diff --git a/toolbox.spec b/toolbox.spec index 46729d4..6f4bcb2 100644 --- a/toolbox.spec +++ b/toolbox.spec @@ -4,7 +4,7 @@ Version: 0.0.99.2 %global goipath github.com/containers/%{name} %gometa -Release: 5%{?dist} +Release: 6%{?dist} Summary: Tool for containerized command line environments on Linux License: ASL 2.0 @@ -15,7 +15,7 @@ Source0: https://github.com/containers/%{name}/releases/download/%{version Patch100: toolbox-Don-t-use-Go-s-semantic-import-versioning.patch Patch101: toolbox-Make-the-build-flags-match-Fedora-s-gobuild.patch Patch102: toolbox-Make-the-build-flags-match-Fedora-s-gobuild-for-PPC64.patch -Patch103: toolbox-Backport-of-tests-check-for-XDG_RUNTIME_DIR.patch +Patch103: toolbox-Test-fixes-for-gating.patch BuildRequires: ShellCheck BuildRequires: golang >= 1.13 @@ -181,6 +181,9 @@ ln -s src/pkg pkg %changelog +* Thu Sep 02 2021 Oliver Gutiérrez - 0.0.99.2-6 +- Updated patch for tests fixes required for gating + * Thu Sep 02 2021 Oliver Gutiérrez - 0.0.99.2-5 - Added skopeo as dependency of tests subpackage From 68dd06bbfe814f2fb09001bd543b29f8a7bab650 Mon Sep 17 00:00:00 2001 From: Oliver Gutierrez Date: Thu, 2 Sep 2021 15:09:28 +0100 Subject: [PATCH 14/18] Updated vendored sources --- .gitignore | 1 + sources | 2 +- toolbox.spec | 12 ++++++++++-- 3 files changed, 12 insertions(+), 3 deletions(-) diff --git a/.gitignore b/.gitignore index a10a7f6..4dbf87b 100644 --- a/.gitignore +++ b/.gitignore @@ -25,3 +25,4 @@ /toolbox-0.0.99.2.tar.xz /toolbox-0.0.99.2^3.git075b9a8d2779.tar.xz /toolbox-0.0.99.2^4.git0bdfa53bb2ce.tar.xz +/toolbox-0.0.99.2-vendored.tar.xz diff --git a/sources b/sources index f134cae..32a6752 100644 --- a/sources +++ b/sources @@ -1 +1 @@ -SHA512 (toolbox-0.0.99.2.tar.xz) = fcd081cc7d48253fd44fcb46314e471bd2aadd17fb5c5e1b5170da421f2e95226421948ef8661f28024432f5f6e1464d7780231044232da569e8f517ad62608d +SHA512 (toolbox-0.0.99.2-vendored.tar.xz) = 5cb616d3eb1860b95fdd7ea4f287dfac4add5363f8af9d5065b84de888988def967d4d02587c654bd9de08882f89ecfd35138f878b7fed15feb7f78279c1077b diff --git a/toolbox.spec b/toolbox.spec index 6f4bcb2..4fbece1 100644 --- a/toolbox.spec +++ b/toolbox.spec @@ -4,12 +4,17 @@ Version: 0.0.99.2 %global goipath github.com/containers/%{name} %gometa -Release: 6%{?dist} +Release: 7%{?dist} Summary: Tool for containerized command line environments on Linux License: ASL 2.0 URL: https://github.com/containers/%{name} -Source0: https://github.com/containers/%{name}/releases/download/%{version}/%{name}-%{version}.tar.xz +# Source0: https://github.com/containers/%%{name}/releases/download/%%{version}/%%{name}-%%{version}.tar.xz + +# Sources were vendored to include needed bats modules for gating tests +Source0: %{name}-%{version}-vendored.tar.xz + + # Fedora specific Patch100: toolbox-Don-t-use-Go-s-semantic-import-versioning.patch @@ -181,6 +186,9 @@ ln -s src/pkg pkg %changelog +* Thu Sep 02 2021 Oliver Gutiérrez - 0.0.99.2-7 +- Updated vendored sources + * Thu Sep 02 2021 Oliver Gutiérrez - 0.0.99.2-6 - Updated patch for tests fixes required for gating From a85d23c9cd42cb2f186515c50cd6bafa491e41c6 Mon Sep 17 00:00:00 2001 From: Oliver Gutierrez Date: Thu, 2 Sep 2021 15:24:45 +0100 Subject: [PATCH 15/18] Updated sources file --- sources | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/sources b/sources index 32a6752..50b43ce 100644 --- a/sources +++ b/sources @@ -1 +1 @@ -SHA512 (toolbox-0.0.99.2-vendored.tar.xz) = 5cb616d3eb1860b95fdd7ea4f287dfac4add5363f8af9d5065b84de888988def967d4d02587c654bd9de08882f89ecfd35138f878b7fed15feb7f78279c1077b +SHA512 (toolbox-0.0.99.2-vendored.tar.xz) = fcd081cc7d48253fd44fcb46314e471bd2aadd17fb5c5e1b5170da421f2e95226421948ef8661f28024432f5f6e1464d7780231044232da569e8f517ad62608d From 30ea7f0006116a7a01f5c8d4ca89753a54f09fb9 Mon Sep 17 00:00:00 2001 From: Debarshi Ray Date: Fri, 22 Oct 2021 02:31:08 +0200 Subject: [PATCH 16/18] Style fix --- toolbox.spec | 2 -- 1 file changed, 2 deletions(-) diff --git a/toolbox.spec b/toolbox.spec index 4fbece1..24827ca 100644 --- a/toolbox.spec +++ b/toolbox.spec @@ -14,8 +14,6 @@ URL: https://github.com/containers/%{name} # Sources were vendored to include needed bats modules for gating tests Source0: %{name}-%{version}-vendored.tar.xz - - # Fedora specific Patch100: toolbox-Don-t-use-Go-s-semantic-import-versioning.patch Patch101: toolbox-Make-the-build-flags-match-Fedora-s-gobuild.patch From 74aab8523f64f2fb878e77e5775103a36f44892e Mon Sep 17 00:00:00 2001 From: Debarshi Ray Date: Fri, 10 Dec 2021 09:54:30 +0100 Subject: [PATCH 17/18] Update to 0.0.99.3 ... and update the URL to point to the website. --- .gitignore | 1 + sources | 2 +- ...-use-Go-s-semantic-import-versioning.patch | 23 ++-- ...ags-match-Fedora-s-gobuild-for-PPC64.patch | 39 ++++-- ...e-build-flags-match-Fedora-s-gobuild.patch | 40 ++++-- toolbox-Test-fixes-for-gating.patch | 124 ------------------ toolbox.spec | 29 ++-- 7 files changed, 93 insertions(+), 165 deletions(-) delete mode 100644 toolbox-Test-fixes-for-gating.patch diff --git a/.gitignore b/.gitignore index 4dbf87b..0f660fe 100644 --- a/.gitignore +++ b/.gitignore @@ -26,3 +26,4 @@ /toolbox-0.0.99.2^3.git075b9a8d2779.tar.xz /toolbox-0.0.99.2^4.git0bdfa53bb2ce.tar.xz /toolbox-0.0.99.2-vendored.tar.xz +/toolbox-0.0.99.3.tar.xz diff --git a/sources b/sources index 50b43ce..64d6d65 100644 --- a/sources +++ b/sources @@ -1 +1 @@ -SHA512 (toolbox-0.0.99.2-vendored.tar.xz) = fcd081cc7d48253fd44fcb46314e471bd2aadd17fb5c5e1b5170da421f2e95226421948ef8661f28024432f5f6e1464d7780231044232da569e8f517ad62608d +SHA512 (toolbox-0.0.99.3.tar.xz) = d9e4bd1cc7667b6ecdcf25a2c3ad7d7d67cc997168a41e668c936d2de24db774331a78a1b4a06b63e7cef8e0dc4ac5651591b6d9cec0d8e81be2b2dd64854dca diff --git a/toolbox-Don-t-use-Go-s-semantic-import-versioning.patch b/toolbox-Don-t-use-Go-s-semantic-import-versioning.patch index a39257b..8cdae9c 100644 --- a/toolbox-Don-t-use-Go-s-semantic-import-versioning.patch +++ b/toolbox-Don-t-use-Go-s-semantic-import-versioning.patch @@ -1,12 +1,11 @@ -From 4039c49b0cd2111cd1c505b9a9aef25aeebb6a0e Mon Sep 17 00:00:00 2001 -From: =?UTF-8?q?Harry=20M=C3=ADchal?= -Date: Sat, 27 Jun 2020 16:17:56 +0200 +From 40fbd377ed0b94060ae5fb2a60289500b66486dc Mon Sep 17 00:00:00 2001 +From: Oliver Gutierrez +Date: Thu, 29 Jul 2021 14:12:41 +0100 Subject: [PATCH] Don't use Go's semantic import versioning Fedora doesn't support Go modules when building Go programs. This means that source code using semantic import versioning can't be built. -https://github.com/containers/toolbox/pull/484 --- src/cmd/create.go | 2 +- src/go.mod | 2 +- @@ -15,7 +14,7 @@ https://github.com/containers/toolbox/pull/484 4 files changed, 5 insertions(+), 5 deletions(-) diff --git a/src/cmd/create.go b/src/cmd/create.go -index 50938890b22f..29bc0f2c42f7 100644 +index 8b31365..502f691 100644 --- a/src/cmd/create.go +++ b/src/cmd/create.go @@ -28,7 +28,7 @@ import ( @@ -28,7 +27,7 @@ index 50938890b22f..29bc0f2c42f7 100644 "github.com/spf13/cobra" "golang.org/x/crypto/ssh/terminal" diff --git a/src/go.mod b/src/go.mod -index 219d3d578992..7e1a6807fd7e 100644 +index cce3e5a..eb7f70c 100644 --- a/src/go.mod +++ b/src/go.mod @@ -8,7 +8,7 @@ require ( @@ -41,10 +40,10 @@ index 219d3d578992..7e1a6807fd7e 100644 github.com/sirupsen/logrus v1.4.2 github.com/spf13/cobra v0.0.5 diff --git a/src/go.sum b/src/go.sum -index 5a03a6823698..d9ce63604fcf 100644 +index fbad155..737f058 100644 --- a/src/go.sum +++ b/src/go.sum -@@ -18,8 +18,8 @@ github.com/fatih/color v1.7.0 h1:DkWD4oS2D8LGGgTQ6IvwJJXSL5Vp2ffcQg58nFV38Ys= +@@ -20,8 +20,8 @@ github.com/fatih/color v1.7.0 h1:DkWD4oS2D8LGGgTQ6IvwJJXSL5Vp2ffcQg58nFV38Ys= github.com/fatih/color v1.7.0/go.mod h1:Zm6kSWBoL9eyXnKyktHP6abPY2pDugNf5KwzbycvMj4= github.com/fsnotify/fsnotify v1.4.7 h1:IXs+QLmnXW2CcXuY+8Mzv/fWEsPGWxqefPtCP5CnV9I= github.com/fsnotify/fsnotify v1.4.7/go.mod h1:jwhsz4b93w/PPRr/qN1Yymfu8t87LnFCMoQvtojpjFo= @@ -52,11 +51,11 @@ index 5a03a6823698..d9ce63604fcf 100644 -github.com/godbus/dbus/v5 v5.0.3/go.mod h1:xhWf0FNVPg57R7Z0UbKHbJfkEywrmjJnf7w5xrFpKfA= +github.com/godbus/dbus v4.1.0+incompatible h1:WqqLRTsQic3apZUK9qC5sGNfXthmPXzUZ7nQPrNITa4= +github.com/godbus/dbus v4.1.0+incompatible/go.mod h1:/YcGZj5zSblfDWMMoOzV4fas9FZnQYTkDnsGvmh2Grw= + github.com/hashicorp/hcl v1.0.0 h1:0Anlzjpi4vEasTeNFn2mLJgTSwt0+6sfsiTG8qcWGx4= github.com/hashicorp/hcl v1.0.0/go.mod h1:E5yfLk+7swimpb2L/Alb/PJmXilQ/rhwaUYs4T20WEQ= github.com/inconshreveable/mousetrap v1.0.0 h1:Z8tu5sraLXCXIcARxBp/8cbvlwVa7Z1NHg9XEKhtSvM= - github.com/inconshreveable/mousetrap v1.0.0/go.mod h1:PxqpIevigyE2G7u3NXJIT2ANytuPF1OarO4DADm73n8= diff --git a/src/pkg/utils/utils.go b/src/pkg/utils/utils.go -index 5455298cbce4..3f7fc26147fc 100644 +index ae7c596..4d1556a 100644 --- a/src/pkg/utils/utils.go +++ b/src/pkg/utils/utils.go @@ -33,7 +33,7 @@ import ( @@ -66,8 +65,8 @@ index 5455298cbce4..3f7fc26147fc 100644 - "github.com/godbus/dbus/v5" + "github.com/godbus/dbus" "github.com/sirupsen/logrus" + "github.com/spf13/viper" "golang.org/x/sys/unix" - ) -- -2.25.4 +2.31.1 diff --git a/toolbox-Make-the-build-flags-match-Fedora-s-gobuild-for-PPC64.patch b/toolbox-Make-the-build-flags-match-Fedora-s-gobuild-for-PPC64.patch index 43df0c9..a1d92a5 100644 --- a/toolbox-Make-the-build-flags-match-Fedora-s-gobuild-for-PPC64.patch +++ b/toolbox-Make-the-build-flags-match-Fedora-s-gobuild-for-PPC64.patch @@ -1,4 +1,4 @@ -From e9bfc40bbbf7af1a20819b6840441cbe52a7d1b7 Mon Sep 17 00:00:00 2001 +From 32aa30a17358598f568991a5375f6182e4135648 Mon Sep 17 00:00:00 2001 From: Debarshi Ray Date: Mon, 29 Jun 2020 17:57:47 +0200 Subject: [PATCH] build: Make the build flags match Fedora's %{gobuild} for @@ -20,21 +20,44 @@ Note that these flags are only meant for the "ppc64" CPU architecture, and should be kept updated to match Fedora's Go guidelines. Use 'rpm --eval "%{gobuild}"' to expand the %{gobuild} macro. --- - src/go-build-wrapper | 3 ++- - 1 file changed, 2 insertions(+), 1 deletion(-) + src/go-build-wrapper | 13 +++++++++---- + 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/src/go-build-wrapper b/src/go-build-wrapper -index 515e1d8a0670..8baaff53b329 100755 +index ef4aafc8b024..f8ea8370792c 100755 --- a/src/go-build-wrapper +++ b/src/go-build-wrapper -@@ -27,5 +27,6 @@ if ! cd "$1"; then +@@ -32,9 +32,9 @@ if ! cd "$1"; then exit 1 fi --go build -trimpath -ldflags "-extldflags '-Wl,--wrap,pthread_sigmask $4' -linkmode external -X github.com/containers/toolbox/pkg/version.currentVersion=$3" -o "$2/toolbox" +-tags="" ++tags="-tags rpm_crashtraceback,${BUILDTAGS:-}" + if $6; then +- tags="-tags migration_path_for_coreos_toolbox" ++ tags="$tags,migration_path_for_coreos_toolbox" + fi + + if ! libc_dir=$("$4" --print-file-name=libc.so); then +@@ -69,11 +69,16 @@ fi + + dynamic_linker="/run/host$dynamic_linker_canonical_dirname/$dynamic_linker_basename" + +unset LDFLAGS -+go build -compiler gc -tags="rpm_crashtraceback ${BUILDTAGS:-}" -ldflags "${LDFLAGS:-} -B 0x$(head -c20 /dev/urandom|od -An -tx1|tr -d ' \n') -extldflags '-Wl,-z,relro -Wl,--as-needed -Wl,-z,now -specs=/usr/lib/rpm/redhat/redhat-hardened-ld -Wl,--wrap,pthread_sigmask $4' -linkmode external -X github.com/containers/toolbox/pkg/version.currentVersion=$3" -a -v -x -o "$2/toolbox" ++ + # shellcheck disable=SC2086 + go build \ ++ -compiler gc \ + $tags \ +- -trimpath \ +- -ldflags "-extldflags '-Wl,-dynamic-linker,$dynamic_linker -Wl,-rpath,/run/host$libc_dir_canonical_dirname' -linkmode external -X github.com/containers/toolbox/pkg/version.currentVersion=$3" \ ++ -ldflags "${LDFLAGS:-} -B 0x$(head -c20 /dev/urandom|od -An -tx1|tr -d ' \n') -compressdwarf=false -extldflags '-Wl,-z,relro -Wl,--as-needed -Wl,-z,now -specs=/usr/lib/rpm/redhat/redhat-hardened-ld -Wl,-dynamic-linker,$dynamic_linker -Wl,-rpath,/run/host$libc_dir_canonical_dirname' -linkmode external -X github.com/containers/toolbox/pkg/version.currentVersion=$3" \ ++ -a \ ++ -v \ ++ -x \ + -o "$2/toolbox" + exit "$?" -- -2.29.2 +2.31.1 diff --git a/toolbox-Make-the-build-flags-match-Fedora-s-gobuild.patch b/toolbox-Make-the-build-flags-match-Fedora-s-gobuild.patch index 16c844d..2e4cbfd 100644 --- a/toolbox-Make-the-build-flags-match-Fedora-s-gobuild.patch +++ b/toolbox-Make-the-build-flags-match-Fedora-s-gobuild.patch @@ -1,4 +1,4 @@ -From d204528ce3b3c70727c12e1911d1c5562b56d474 Mon Sep 17 00:00:00 2001 +From 6d913f1fbd6e609957bb01273504b2f479e1b546 Mon Sep 17 00:00:00 2001 From: Debarshi Ray Date: Mon, 29 Jun 2020 17:57:47 +0200 Subject: [PATCH] build: Make the build flags match Fedora's %{gobuild} @@ -19,21 +19,45 @@ Note that these flags are meant for every CPU architecture other than PPC64, and should be kept updated to match Fedora's Go guidelines. Use 'rpm --eval "%{gobuild}"' to expand the %{gobuild} macro. --- - src/go-build-wrapper | 3 ++- - 1 file changed, 2 insertions(+), 1 deletion(-) + src/go-build-wrapper | 14 ++++++++++---- + 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/src/go-build-wrapper b/src/go-build-wrapper -index 515e1d8a0670..013a35e52a1a 100755 +index ef4aafc8b024..4354beceb215 100755 --- a/src/go-build-wrapper +++ b/src/go-build-wrapper -@@ -27,5 +27,6 @@ if ! cd "$1"; then +@@ -32,9 +32,9 @@ if ! cd "$1"; then exit 1 fi --go build -trimpath -ldflags "-extldflags '-Wl,--wrap,pthread_sigmask $4' -linkmode external -X github.com/containers/toolbox/pkg/version.currentVersion=$3" -o "$2/toolbox" +-tags="" ++tags="-tags rpm_crashtraceback,${BUILDTAGS:-}" + if $6; then +- tags="-tags migration_path_for_coreos_toolbox" ++ tags="$tags,migration_path_for_coreos_toolbox" + fi + + if ! libc_dir=$("$4" --print-file-name=libc.so); then +@@ -69,11 +69,17 @@ fi + + dynamic_linker="/run/host$dynamic_linker_canonical_dirname/$dynamic_linker_basename" + +unset LDFLAGS -+go build -buildmode pie -compiler gc -tags="rpm_crashtraceback ${BUILDTAGS:-}" -ldflags "${LDFLAGS:-} -B 0x$(head -c20 /dev/urandom|od -An -tx1|tr -d ' \n') -extldflags '-Wl,-z,relro -Wl,--as-needed -Wl,-z,now -specs=/usr/lib/rpm/redhat/redhat-hardened-ld -Wl,--wrap,pthread_sigmask $4' -linkmode external -X github.com/containers/toolbox/pkg/version.currentVersion=$3" -a -v -x -o "$2/toolbox" ++ + # shellcheck disable=SC2086 + go build \ ++ -buildmode pie \ ++ -compiler gc \ + $tags \ +- -trimpath \ +- -ldflags "-extldflags '-Wl,-dynamic-linker,$dynamic_linker -Wl,-rpath,/run/host$libc_dir_canonical_dirname' -linkmode external -X github.com/containers/toolbox/pkg/version.currentVersion=$3" \ ++ -ldflags "${LDFLAGS:-} -B 0x$(head -c20 /dev/urandom|od -An -tx1|tr -d ' \n') -compressdwarf=false -extldflags '-Wl,-z,relro -Wl,--as-needed -Wl,-z,now -specs=/usr/lib/rpm/redhat/redhat-hardened-ld -Wl,-dynamic-linker,$dynamic_linker -Wl,-rpath,/run/host$libc_dir_canonical_dirname' -linkmode external -X github.com/containers/toolbox/pkg/version.currentVersion=$3" \ ++ -a \ ++ -v \ ++ -x \ + -o "$2/toolbox" + exit "$?" -- -2.29.2 +2.31.1 diff --git a/toolbox-Test-fixes-for-gating.patch b/toolbox-Test-fixes-for-gating.patch deleted file mode 100644 index 160c1ee..0000000 --- a/toolbox-Test-fixes-for-gating.patch +++ /dev/null @@ -1,124 +0,0 @@ -From a0ff01b52ffc8980cba501149a4e3606481cbefb Mon Sep 17 00:00:00 2001 -From: Oliver Gutierrez -Date: Thu, 2 Sep 2021 13:41:14 +0100 -Subject: [PATCH] Fixes in tests for fedora gating - - -diff --git a/test/system/002-help.bats b/test/system/002-help.bats -index 8a057dd..bf863ef 100644 ---- a/test/system/002-help.bats -+++ b/test/system/002-help.bats -@@ -4,6 +4,10 @@ load 'libs/bats-support/load' - load 'libs/bats-assert/load' - load 'libs/helpers.bash' - -+setup() { -+ check_xdg_runtime_dir -+} -+ - @test "help: Try to run toolbox with no command (shows usage screen)" { - run $TOOLBOX - -diff --git a/test/system/101-create.bats b/test/system/101-create.bats -index dfb4d89..63d4fcb 100644 ---- a/test/system/101-create.bats -+++ b/test/system/101-create.bats -@@ -5,6 +5,7 @@ load 'libs/bats-assert/load' - load 'libs/helpers' - - setup() { -+ check_xdg_runtime_dir - cleanup_containers - } - -diff --git a/test/system/102-list.bats b/test/system/102-list.bats -index ea74645..42000c7 100644 ---- a/test/system/102-list.bats -+++ b/test/system/102-list.bats -@@ -5,6 +5,7 @@ load 'libs/bats-assert/load' - load 'libs/helpers' - - setup() { -+ check_xdg_runtime_dir - cleanup_all - } - -@@ -89,9 +90,9 @@ teardown() { - run $PODMAN build "$BATS_TMPDIR" - - assert_success -- assert_line --index 0 "STEP 1: FROM scratch" -- assert_line --index 1 "STEP 2: LABEL com.github.containers.toolbox=\"true\"" -- assert_line --index 2 "STEP 3: COMMIT" -+ assert_line --index 0 "STEP 1/2: FROM scratch" -+ assert_line --index 1 "STEP 2/2: LABEL com.github.containers.toolbox=\"true\"" -+ assert_line --index 2 "COMMIT" - assert_line --index 3 --regexp "^--> [a-z0-9]*$" - - run $TOOLBOX list -diff --git a/test/system/103-run.bats b/test/system/103-run.bats -index 8b58e42..6fc840e 100644 ---- a/test/system/103-run.bats -+++ b/test/system/103-run.bats -@@ -10,7 +10,7 @@ load 'libs/helpers' - readonly CURDIR=$PWD - - setup() { -- cd "$HOME" || return 1 -+ check_xdg_runtime_dir - cleanup_containers - } - -diff --git a/test/system/104-rm.bats b/test/system/104-rm.bats -index 9f1435b..68e3c03 100644 ---- a/test/system/104-rm.bats -+++ b/test/system/104-rm.bats -@@ -5,6 +5,7 @@ load 'libs/bats-assert/load' - load 'libs/helpers' - - setup() { -+ check_xdg_runtime_dir - cleanup_containers - } - -diff --git a/test/system/105-rmi.bats b/test/system/105-rmi.bats -index 0ef0ebe..b48f802 100644 ---- a/test/system/105-rmi.bats -+++ b/test/system/105-rmi.bats -@@ -5,6 +5,7 @@ load 'libs/bats-assert/load' - load 'libs/helpers' - - setup() { -+ check_xdg_runtime_dir - cleanup_all - } - -diff --git a/test/system/libs/helpers.bash b/test/system/libs/helpers.bash -index d59d661..5d48957 100644 ---- a/test/system/libs/helpers.bash -+++ b/test/system/libs/helpers.bash -@@ -8,8 +8,7 @@ readonly TOOLBOX=${TOOLBOX:-toolbox} - readonly SKOPEO=$(command -v skopeo) - - # Helpful globals --readonly PROJECT_DIR=${PWD} --readonly IMAGE_CACHE_DIR="${PROJECT_DIR}/image-cache" -+readonly IMAGE_CACHE_DIR="${BATS_RUN_TMPDIR}/image-cache" - - # Images - declare -Ag IMAGES=([busybox]="docker.io/library/busybox" \ -@@ -271,3 +270,11 @@ function get_system_version() { - - echo $(awk -F= '/VERSION_ID/ {print $2}' $os_release | head -n 1) - } -+ -+ -+# Setup the XDG_RUNTIME_DIR variable if not set -+function check_xdg_runtime_dir() { -+ if [[ -z "${XDG_RUNTIME_DIR}" ]]; then -+ export XDG_RUNTIME_DIR="/run/user/${UID}" -+ fi -+} --- -2.31.1 - diff --git a/toolbox.spec b/toolbox.spec index 24827ca..1c4f29c 100644 --- a/toolbox.spec +++ b/toolbox.spec @@ -1,24 +1,22 @@ +%global __brp_check_rpaths %{nil} + Name: toolbox -Version: 0.0.99.2 +Version: 0.0.99.3 %global goipath github.com/containers/%{name} %gometa -Release: 7%{?dist} +Release: 1%{?dist} Summary: Tool for containerized command line environments on Linux License: ASL 2.0 -URL: https://github.com/containers/%{name} -# Source0: https://github.com/containers/%%{name}/releases/download/%%{version}/%%{name}-%%{version}.tar.xz - -# Sources were vendored to include needed bats modules for gating tests -Source0: %{name}-%{version}-vendored.tar.xz +URL: https://containertoolbx.org/ +Source0: https://github.com/containers/%{name}/releases/download/%{version}/%{name}-%{version}.tar.xz # Fedora specific Patch100: toolbox-Don-t-use-Go-s-semantic-import-versioning.patch Patch101: toolbox-Make-the-build-flags-match-Fedora-s-gobuild.patch Patch102: toolbox-Make-the-build-flags-match-Fedora-s-gobuild-for-PPC64.patch -Patch103: toolbox-Test-fixes-for-gating.patch BuildRequires: ShellCheck BuildRequires: golang >= 1.13 @@ -34,10 +32,11 @@ BuildRequires: golang(github.com/sirupsen/logrus) >= 1.4.2 # BuildRequires: golang(github.com/stretchr/testify) >= 1.7.0 BuildRequires: golang(github.com/spf13/cobra) >= 0.0.5 BuildRequires: golang(golang.org/x/sys/unix) -BuildRequires: meson +BuildRequires: meson >= 0.58.0 BuildRequires: pkgconfig(bash-completion) BuildRequires: systemd +Requires: containers-common Requires: flatpak-session-helper Requires: podman >= 1.4.0 @@ -55,6 +54,7 @@ Summary: Required packages for the container image to support %{name} # These are really required to make the image work with toolbox Requires: passwd Requires: shadow-utils +Requires: util-linux Requires: vte-profile %description support @@ -91,7 +91,6 @@ Requires: less Requires: lsof Requires: man-db Requires: man-pages -Requires: mlocate Requires: mtr Requires: nano-default-editor Requires: nss-mdns @@ -126,6 +125,9 @@ Summary: Tests for %{name} Requires: %{name}%{?_isa} = %{version}-%{release} Requires: bats +Requires: coreutils +Requires: gawk +Requires: grep Requires: skopeo %description tests @@ -142,8 +144,6 @@ The %{name}-tests package contains system tests for %{name}. %patch102 -p1 %endif -%patch103 -p1 - %gomkdir @@ -172,6 +172,7 @@ ln -s src/pkg pkg %{_datadir}/bash-completion %{_mandir}/man1/%{name}.1* %{_mandir}/man1/%{name}-*.1* +%config(noreplace) %{_sysconfdir}/containers/%{name}.conf %{_sysconfdir}/profile.d/%{name}.sh %{_tmpfilesdir}/%{name}.conf @@ -184,6 +185,10 @@ ln -s src/pkg pkg %changelog +* Fri Dec 10 2021 Debarshi Ray - 0.0.99.3-1 +- Update to 0.0.99.3 +- Update the URL to point to the website + * Thu Sep 02 2021 Oliver Gutiérrez - 0.0.99.2-7 - Updated vendored sources From 1839cc68e1a02e891f3c92c36ad2fc38975c6eae Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ond=C5=99ej=20M=C3=ADchal?= Date: Sun, 9 Jan 2022 20:36:32 +0200 Subject: [PATCH 18/18] Add upstream patch fixing doubled error messages --- ...ound-Cobra-1.1.2-s-handling-of-usage.patch | 95 +++++++++++++++++++ toolbox.spec | 8 +- 2 files changed, 102 insertions(+), 1 deletion(-) create mode 100644 toolbox-cmd-root-Work-around-Cobra-1.1.2-s-handling-of-usage.patch diff --git a/toolbox-cmd-root-Work-around-Cobra-1.1.2-s-handling-of-usage.patch b/toolbox-cmd-root-Work-around-Cobra-1.1.2-s-handling-of-usage.patch new file mode 100644 index 0000000..a618021 --- /dev/null +++ b/toolbox-cmd-root-Work-around-Cobra-1.1.2-s-handling-of-usage.patch @@ -0,0 +1,95 @@ +From e598e2160323b63310ad7b6def723eb1f8767f90 Mon Sep 17 00:00:00 2001 +From: =?UTF-8?q?Ond=C5=99ej=20M=C3=ADchal?= +Date: Thu, 11 Nov 2021 18:18:52 +0200 +Subject: [PATCH 02/13] cmd/root: Work around Cobra 1.1.2's handling of usage + functions + +In version 1.1.2 of Cobra has been included a change[0] that changes +how custom usage functions are handled. + +Example of the wrong behaviour: +$ toolbox --foo +Error: unknown flag: --foo +Run 'toolbox --help' for usage.Error: Run 'toolbox --help' for usage. + +Desired behaviour: +$ toolbox --foo +Error: unknown flag: --foo +Run 'toolbox --help' for usage. + +A workaround is to define a template string for the usage instead. The +template uses the templating language of Go[1]. See the default +template string in version 1.2.1[2]. + +Because the template is set only once, the executableBase needs to be +set before the template is applied. That required the move of +setUpGlobals() into init() of the cmd package. This is a better place +for the function call as init() is called earlier than Execute()[3]. + +Upstream issue: https://github.com/spf13/cobra/issues/1532 + +[0] https://github.com/spf13/cobra/pull/1044 +[1] https://pkg.go.dev/text/template +[2] https://github.com/spf13/cobra/blob/v1.2.1/command.go#L491 +[3] https://golang.org/doc/effective_go#init + +https://github.com/containers/toolbox/pull/917 +--- + src/cmd/root.go | 20 ++++++++------------ + 1 file changed, 8 insertions(+), 12 deletions(-) + +diff --git a/src/cmd/root.go b/src/cmd/root.go +index eb0622f..ad0753b 100644 +--- a/src/cmd/root.go ++++ b/src/cmd/root.go +@@ -62,11 +62,6 @@ var ( + ) + + func Execute() { +- if err := setUpGlobals(); err != nil { +- fmt.Fprintf(os.Stderr, "Error: %s\n", err) +- os.Exit(1) +- } +- + if err := rootCmd.Execute(); err != nil { + os.Exit(1) + } +@@ -75,6 +70,11 @@ func Execute() { + } + + func init() { ++ if err := setUpGlobals(); err != nil { ++ fmt.Fprintf(os.Stderr, "Error: %s\n", err) ++ os.Exit(1) ++ } ++ + persistentFlags := rootCmd.PersistentFlags() + + persistentFlags.BoolVarP(&rootFlags.assumeYes, +@@ -96,7 +96,9 @@ func init() { + persistentFlags.CountVarP(&rootFlags.verbose, "verbose", "v", "Set log-level to 'debug'") + + rootCmd.SetHelpFunc(rootHelp) +- rootCmd.SetUsageFunc(rootUsage) ++ ++ usageTemplate := fmt.Sprintf("Run '%s --help' for usage.", executableBase) ++ rootCmd.SetUsageTemplate(usageTemplate) + } + + func preRun(cmd *cobra.Command, args []string) error { +@@ -188,12 +190,6 @@ func rootRun(cmd *cobra.Command, args []string) error { + return rootRunImpl(cmd, args) + } + +-func rootUsage(cmd *cobra.Command) error { +- err := fmt.Errorf("Run '%s --help' for usage.", executableBase) +- fmt.Fprintf(os.Stderr, "%s", err) +- return err +-} +- + func migrate() error { + logrus.Debug("Migrating to newer Podman") + +-- +2.34.1 + diff --git a/toolbox.spec b/toolbox.spec index 1c4f29c..11f71c3 100644 --- a/toolbox.spec +++ b/toolbox.spec @@ -6,7 +6,7 @@ Version: 0.0.99.3 %global goipath github.com/containers/%{name} %gometa -Release: 1%{?dist} +Release: 2%{?dist} Summary: Tool for containerized command line environments on Linux License: ASL 2.0 @@ -17,6 +17,7 @@ Source0: https://github.com/containers/%{name}/releases/download/%{version Patch100: toolbox-Don-t-use-Go-s-semantic-import-versioning.patch Patch101: toolbox-Make-the-build-flags-match-Fedora-s-gobuild.patch Patch102: toolbox-Make-the-build-flags-match-Fedora-s-gobuild-for-PPC64.patch +Patch103: toolbox-cmd-root-Work-around-Cobra-1.1.2-s-handling-of-usage.patch BuildRequires: ShellCheck BuildRequires: golang >= 1.13 @@ -144,6 +145,8 @@ The %{name}-tests package contains system tests for %{name}. %patch102 -p1 %endif +%patch103 -p1 + %gomkdir @@ -185,6 +188,9 @@ ln -s src/pkg pkg %changelog +* Sun Jan 09 2022 Ondřej Míchal - 0.0.99.3-2 +- Add upstream patch fixing doubled error messages + * Fri Dec 10 2021 Debarshi Ray - 0.0.99.3-1 - Update to 0.0.99.3 - Update the URL to point to the website