From f24f9e1c6a96bc6e893411cd27806a62590d0d3a Mon Sep 17 00:00:00 2001 From: Yaakov Selkowitz Date: Wed, 21 Dec 2022 00:22:14 -0500 Subject: [PATCH 01/13] Use vendored dependencies for RHEL --- .gitignore | 1 + gen-vendor-tarball.sh | 27 +++++++++++++++++++++++++++ sources | 1 + toolbox.spec | 22 +++++++++++++++++++--- 4 files changed, 48 insertions(+), 3 deletions(-) create mode 100755 gen-vendor-tarball.sh diff --git a/.gitignore b/.gitignore index 66d6df6..3443637 100644 --- a/.gitignore +++ b/.gitignore @@ -28,3 +28,4 @@ /toolbox-0.0.99.2^2.git40fbd377ed0b.tar.xz /toolbox-0.0.99.2^3.git075b9a8d2779.tar.xz /toolbox-0.0.99.3.tar.xz +/toolbox-0.0.99.3-vendor.tar.xz diff --git a/gen-vendor-tarball.sh b/gen-vendor-tarball.sh new file mode 100755 index 0000000..f704f1a --- /dev/null +++ b/gen-vendor-tarball.sh @@ -0,0 +1,27 @@ +#!/bin/sh + +# Process a toolbox tarball to get vendored dependencies for the RHEL build. +# +# Yaakov Selkowitz - 2022 + +SOURCE="$1" +DIRECTORY=`echo $SOURCE | sed 's/\.tar\.xz//'` +VENDOR_SOURCE="${DIRECTORY}-vendor.tar.xz" + +error() +{ + MESSAGE=$1 + echo $MESSAGE + exit 1 +} + +rm -rf $DIRECTORY +tar xJf $SOURCE || error "Cannot unpack $SOURCE" +pushd $DIRECTORY/src > /dev/null || error "Cannot open directory \"$DIRECTORY\"" + +echo "Vendoring dependencies" +go mod vendor || error "Vendoring failed" +popd > /dev/null + +tar cJf $VENDOR_SOURCE -C $DIRECTORY src/vendor || error "Unable to create $VENDOR_SOURCE" +echo "$VENDOR_SOURCE is ready to use" diff --git a/sources b/sources index 64d6d65..2bf14ad 100644 --- a/sources +++ b/sources @@ -1 +1,2 @@ SHA512 (toolbox-0.0.99.3.tar.xz) = d9e4bd1cc7667b6ecdcf25a2c3ad7d7d67cc997168a41e668c936d2de24db774331a78a1b4a06b63e7cef8e0dc4ac5651591b6d9cec0d8e81be2b2dd64854dca +SHA512 (toolbox-0.0.99.3-vendor.tar.xz) = 51ce5a16276ccc75d2b6fb9cae1c4371ad028f6a820cd176a4a0ee85fab447a6b37b5ec2e969b882c4f04cfe58bd78f92975606297a0db22e72457f012102ec2 diff --git a/toolbox.spec b/toolbox.spec index 8f5417d..92f43aa 100644 --- a/toolbox.spec +++ b/toolbox.spec @@ -6,12 +6,16 @@ Version: 0.0.99.3 %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://containertoolbx.org/ Source0: https://github.com/containers/%{name}/releases/download/%{version}/%{name}-%{version}.tar.xz +# RHEL package is built with vendored dependencies +# created with gen-vendor-tarball.sh from SOURCE2 +Source1: %{name}-%{version}-vendor.tar.xz +Source2: gen-vendor-tarball.sh # Fedora specific Patch100: toolbox-Don-t-use-Go-s-semantic-import-versioning.patch @@ -22,6 +26,7 @@ Patch103: toolbox-cmd-root-Work-around-Cobra-1.1.2-s-handling-of-usage.patc BuildRequires: ShellCheck BuildRequires: go-md2man BuildRequires: golang >= 1.13 +%if ! 0%{?rhel} BuildRequires: golang(github.com/HarryMichal/go-version) BuildRequires: golang(github.com/acobaugh/osrelease) BuildRequires: golang(github.com/briandowns/spinner) >= 1.10.0 @@ -35,6 +40,7 @@ BuildRequires: golang(github.com/spf13/cobra) >= 0.0.5 BuildRequires: golang(github.com/spf13/viper) >= 1.3.2 BuildRequires: golang(golang.org/x/crypto/ssh/terminal) BuildRequires: golang(golang.org/x/sys/unix) +%endif BuildRequires: meson >= 0.58.0 BuildRequires: pkgconfig(bash-completion) BuildRequires: systemd-rpm-macros @@ -138,8 +144,10 @@ The %{name}-tests package contains system tests for %{name}. %prep -%setup -q +%setup -q %{?rhel:-a 1} +%if ! 0%{?rhel} %patch100 -p1 +%endif %ifnarch ppc64 %patch101 -p1 @@ -147,7 +155,9 @@ The %{name}-tests package contains system tests for %{name}. %patch102 -p1 %endif +%if ! 0%{?rhel} %patch103 -p1 +%endif %gomkdir @@ -158,6 +168,9 @@ export GOPATH=%{gobuilddir}:%{gopath} export CGO_CFLAGS="%{optflags} -D_GNU_SOURCE -D_LARGEFILE_SOURCE -D_LARGEFILE64_SOURCE -D_FILE_OFFSET_BITS=64" ln -s src/cmd cmd ln -s src/pkg pkg +%if 0%{?rhel} +ln -s src/vendor vendor +%endif %meson --buildtype=plain -Dprofile_dir=%{_sysconfdir}/profile.d -Dtmpfiles_dir=%{_tmpfilesdir} %meson_build @@ -172,7 +185,7 @@ ln -s src/pkg pkg %files %doc CODE-OF-CONDUCT.md NEWS README.md SECURITY.md -%license COPYING +%license COPYING %{?rhel:src/vendor/modules.txt} %{_bindir}/%{name} %{_datadir}/bash-completion %{_mandir}/man1/%{name}.1* @@ -190,6 +203,9 @@ ln -s src/pkg pkg %changelog +* Thu Dec 22 2022 Yaakov Selkowitz - 0.0.99.3-7 +- Use vendored dependencies for RHEL/ELN builds + * Tue Jul 19 2022 Maxwell G - 0.0.99.3-6 - Rebuild for CVE-2022-{1705,32148,30631,30633,28131,30635,30632,30630,1962} in golang From 84e5619113010ec7e96578f87d4b0576b8ab0a38 Mon Sep 17 00:00:00 2001 From: Fedora Release Engineering Date: Sat, 21 Jan 2023 05:16:24 +0000 Subject: [PATCH 02/13] Sync packaging changes from CentOS Stream --- toolbox.spec | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/toolbox.spec b/toolbox.spec index 92f43aa..62431d6 100644 --- a/toolbox.spec +++ b/toolbox.spec @@ -6,7 +6,7 @@ Version: 0.0.99.3 %global goipath github.com/containers/%{name} %gometa -Release: 7%{?dist} +Release: 8%{?dist} Summary: Tool for containerized command line environments on Linux License: ASL 2.0 @@ -23,7 +23,6 @@ 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: go-md2man BuildRequires: golang >= 1.13 %if ! 0%{?rhel} @@ -40,6 +39,8 @@ BuildRequires: golang(github.com/spf13/cobra) >= 0.0.5 BuildRequires: golang(github.com/spf13/viper) >= 1.3.2 BuildRequires: golang(golang.org/x/crypto/ssh/terminal) BuildRequires: golang(golang.org/x/sys/unix) +# for tests +BuildRequires: ShellCheck %endif BuildRequires: meson >= 0.58.0 BuildRequires: pkgconfig(bash-completion) @@ -55,6 +56,8 @@ Toolbox is a tool for Linux operating systems, which allows the use of containerized command line environments. It is built on top of Podman and other standard container technologies from OCI. +%if ! 0%{?rhel} + # The list of requires packages for -support and -experience should be in sync with: # https://github.com/containers/toolbox/blob/master/images/fedora/f33/extra-packages %package support @@ -128,6 +131,7 @@ on the host. The %{name}-experience package should be typically installed from the Dockerfile if the image isn't based on the fedora-toolbox image. +%endif %package tests Summary: Tests for %{name} @@ -194,15 +198,22 @@ ln -s src/vendor vendor %{_sysconfdir}/profile.d/%{name}.sh %{_tmpfilesdir}/%{name}.conf +%if ! 0%{?rhel} + %files support %files experience +%endif + %files tests %{_datadir}/%{name} %changelog +* Thu Feb 02 2023 Yaakov Selkowitz - 0.0.99.3-8 +- Sync packaging changes from CentOS Stream + * Thu Dec 22 2022 Yaakov Selkowitz - 0.0.99.3-7 - Use vendored dependencies for RHEL/ELN builds From 20d35238776181078d2b62ecb057bbb2784c2931 Mon Sep 17 00:00:00 2001 From: Debarshi Ray Date: Tue, 21 Feb 2023 16:43:49 +0100 Subject: [PATCH 03/13] Drop redundant option from %meson There's no need to pass the --buildtype=plain option to the %meson RPM macro, because it's one of the default options used by the macro. There's no need to do a build just for this. Fallout from 33bd39b0f97b72a788c9ee564ce2b0e2a8a3c23e --- toolbox.spec | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/toolbox.spec b/toolbox.spec index 62431d6..034a44f 100644 --- a/toolbox.spec +++ b/toolbox.spec @@ -175,7 +175,7 @@ ln -s src/pkg pkg %if 0%{?rhel} ln -s src/vendor vendor %endif -%meson --buildtype=plain -Dprofile_dir=%{_sysconfdir}/profile.d -Dtmpfiles_dir=%{_tmpfilesdir} +%meson -Dprofile_dir=%{_sysconfdir}/profile.d -Dtmpfiles_dir=%{_tmpfilesdir} %meson_build From 7cae6d8371c58c2e37ca432852597a8f18f26984 Mon Sep 17 00:00:00 2001 From: Debarshi Ray Date: Tue, 21 Feb 2023 16:48:16 +0100 Subject: [PATCH 04/13] Add missing 'BuildRequires: gcc' A C compiler is necessary to build Toolbx [1]. GCC is being pulled in by the other BuildRequires, but it's good to explicitly list it since GCC isn't part of the default buildroot since Fedora 29 [2] and will prevent the compiler from unexpectedly changing to Clang. There's no need to do a build just for this. [1] Upstream commit c8aaed52c547e24e https://github.com/containers/toolbox/commit/c8aaed52c547e24e https://github.com/containers/toolbox/pull/923 [2] https://fedoraproject.org/wiki/Changes/Remove_GCC_from_BuildRoot --- toolbox.spec | 1 + 1 file changed, 1 insertion(+) diff --git a/toolbox.spec b/toolbox.spec index 034a44f..e7af8e2 100644 --- a/toolbox.spec +++ b/toolbox.spec @@ -23,6 +23,7 @@ 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: gcc BuildRequires: go-md2man BuildRequires: golang >= 1.13 %if ! 0%{?rhel} From 1cbafd315caf584909c58c99e563abf1fd12d60b Mon Sep 17 00:00:00 2001 From: Debarshi Ray Date: Tue, 21 Feb 2023 17:01:39 +0100 Subject: [PATCH 05/13] Mark and comment out the unused BuildRequires for %check Fallout from 84e5619113010ec7e96578f87d4b0576b8ab0a38 and 12df1ef16a673d90a85d3b8fc631adcd1ae27ba5 There's no need to do a build just for this. --- toolbox.spec | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/toolbox.spec b/toolbox.spec index e7af8e2..d784a34 100644 --- a/toolbox.spec +++ b/toolbox.spec @@ -35,13 +35,13 @@ 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(github.com/spf13/viper) >= 1.3.2 BuildRequires: golang(golang.org/x/crypto/ssh/terminal) BuildRequires: golang(golang.org/x/sys/unix) # for tests -BuildRequires: ShellCheck +# BuildRequires: golang(github.com/stretchr/testify) >= 1.7.0 +# BuildRequires: ShellCheck %endif BuildRequires: meson >= 0.58.0 BuildRequires: pkgconfig(bash-completion) From fb48d51300573b73f80d7c50b3edaeca0ca01afd Mon Sep 17 00:00:00 2001 From: Debarshi Ray Date: Tue, 21 Feb 2023 17:15:21 +0100 Subject: [PATCH 06/13] Use %gomodulesmode introduced in go-rpm-macros-3.0.10 There's no need to do a build just for this. --- toolbox.spec | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/toolbox.spec b/toolbox.spec index d784a34..77d0e87 100644 --- a/toolbox.spec +++ b/toolbox.spec @@ -168,7 +168,7 @@ The %{name}-tests package contains system tests for %{name}. %build -export GO111MODULE=off +export %{gomodulesmode} export GOPATH=%{gobuilddir}:%{gopath} export CGO_CFLAGS="%{optflags} -D_GNU_SOURCE -D_LARGEFILE_SOURCE -D_LARGEFILE64_SOURCE -D_FILE_OFFSET_BITS=64" ln -s src/cmd cmd From ca45ccdce738113a67a8a110b4f099d12095aa47 Mon Sep 17 00:00:00 2001 From: Debarshi Ray Date: Tue, 21 Feb 2023 17:32:58 +0100 Subject: [PATCH 07/13] Add ExclusiveArch to match Podman There's no golang on %ix86 from RHEL 9 onwards [1], and hence no podman either [2]. Recently, with Podman 4.4.1, there are also no new podman builds for %ix86 for Fedora 36 onwards [3]. Arguably, the podman change should have been limited to Fedora Rawhide, but it's probably not a big problem because there's no %ix86 install media for Fedora CoreOS, Silverblue or Workstation. Note that while %golang_arches on RHEL 9 doesn't include %arm, it's included in both %golang_arches and %golang_arches_future on Fedora. [1] go-rpm-macros commit b1500ff47ee8cdd1 https://src.fedoraproject.org/rpms/go-rpm-macros/c/b1500ff47ee8cdd1 [2] podman commit 555a5a504dd538d5 https://src.fedoraproject.org/rpms/podman/c/555a5a504dd538d5 [3] podman commit 313c3e86a81c69eb https://src.fedoraproject.org/rpms/podman/c/313c3e86a81c69eb --- toolbox.spec | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/toolbox.spec b/toolbox.spec index 77d0e87..173f75d 100644 --- a/toolbox.spec +++ b/toolbox.spec @@ -6,7 +6,7 @@ Version: 0.0.99.3 %global goipath github.com/containers/%{name} %gometa -Release: 8%{?dist} +Release: 9%{?dist} Summary: Tool for containerized command line environments on Linux License: ASL 2.0 @@ -23,6 +23,12 @@ 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 +%if 0%{?rhel} == 9 +ExclusiveArch: %{golang_arches} +%else +ExclusiveArch: %{golang_arches_future} +%endif + BuildRequires: gcc BuildRequires: go-md2man BuildRequires: golang >= 1.13 @@ -212,6 +218,9 @@ ln -s src/vendor vendor %changelog +* Tue Feb 21 2023 Debarshi Ray - 0.0.99.3-9 +- Add ExclusiveArch to match Podman + * Thu Feb 02 2023 Yaakov Selkowitz - 0.0.99.3-8 - Sync packaging changes from CentOS Stream From a5de73782ead309457d5126aa87eccf5ba7e008d Mon Sep 17 00:00:00 2001 From: Martin Jackson Date: Wed, 22 Feb 2023 08:48:32 -0600 Subject: [PATCH 08/13] Fix the ExclusiveArch The %gometa RPM macro also generates a ExclusiveArch on %golang_arches or %golang_arches_future depending on whether the -f flag is present or not. This was overriding the separately specified ExclusiveArch. Fallout from ca45ccdce738113a67a8a110b4f099d12095aa47 https://src.fedoraproject.org/rpms/toolbox/pull-request/12 --- toolbox.spec | 18 ++++++++++-------- 1 file changed, 10 insertions(+), 8 deletions(-) diff --git a/toolbox.spec b/toolbox.spec index 173f75d..121b8b3 100644 --- a/toolbox.spec +++ b/toolbox.spec @@ -4,9 +4,14 @@ Name: toolbox Version: 0.0.99.3 %global goipath github.com/containers/%{name} -%gometa -Release: 9%{?dist} +%if 0%{?rhel} == 9 +%gometa +%else +%gometa -f +%endif + +Release: 10%{?dist} Summary: Tool for containerized command line environments on Linux License: ASL 2.0 @@ -23,12 +28,6 @@ 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 -%if 0%{?rhel} == 9 -ExclusiveArch: %{golang_arches} -%else -ExclusiveArch: %{golang_arches_future} -%endif - BuildRequires: gcc BuildRequires: go-md2man BuildRequires: golang >= 1.13 @@ -218,6 +217,9 @@ ln -s src/vendor vendor %changelog +* Wed Feb 22 2023 Martin Jackson - 0.0.99.3-10 +- Fix the ExclusiveArch + * Tue Feb 21 2023 Debarshi Ray - 0.0.99.3-9 - Add ExclusiveArch to match Podman From b9c4200fe66875b5c38077c37a7c3968f53dbc6e Mon Sep 17 00:00:00 2001 From: Debarshi Ray Date: Wed, 22 Feb 2023 20:29:43 +0100 Subject: [PATCH 09/13] Bump the golang requirement to ensure recent CVE fixes 'BuildRequires: golang >= 1.18.9' will ensure that recent CVEs like CVE-2022-41717 remain fixed. There's no need to do a build just for this, because the toolbox package has either already been built with a sufficiently recent golang or will soon be. https://bugzilla.redhat.com/show_bug.cgi?id=2161274 --- toolbox.spec | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/toolbox.spec b/toolbox.spec index 121b8b3..ad131e6 100644 --- a/toolbox.spec +++ b/toolbox.spec @@ -30,7 +30,7 @@ Patch103: toolbox-cmd-root-Work-around-Cobra-1.1.2-s-handling-of-usage.patc BuildRequires: gcc BuildRequires: go-md2man -BuildRequires: golang >= 1.13 +BuildRequires: golang >= 1.18.9 %if ! 0%{?rhel} BuildRequires: golang(github.com/HarryMichal/go-version) BuildRequires: golang(github.com/acobaugh/osrelease) From 4daed5535f68dfcfe15560402822250f345cc953 Mon Sep 17 00:00:00 2001 From: Debarshi Ray Date: Thu, 23 Feb 2023 15:22:14 +0100 Subject: [PATCH 10/13] Simplify and unify the build with RHEL There's no need to do a build just for this. --- toolbox.spec | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-) diff --git a/toolbox.spec b/toolbox.spec index ad131e6..f050d29 100644 --- a/toolbox.spec +++ b/toolbox.spec @@ -169,18 +169,14 @@ The %{name}-tests package contains system tests for %{name}. %patch103 -p1 %endif -%gomkdir +%gomkdir -s %{_builddir}/%{extractdir}/src %{?rhel:-k} %build export %{gomodulesmode} export GOPATH=%{gobuilddir}:%{gopath} export CGO_CFLAGS="%{optflags} -D_GNU_SOURCE -D_LARGEFILE_SOURCE -D_LARGEFILE64_SOURCE -D_FILE_OFFSET_BITS=64" -ln -s src/cmd cmd -ln -s src/pkg pkg -%if 0%{?rhel} -ln -s src/vendor vendor -%endif + %meson -Dprofile_dir=%{_sysconfdir}/profile.d -Dtmpfiles_dir=%{_tmpfilesdir} %meson_build From cf648e5aa4992933d0337dea0cb32554415155c2 Mon Sep 17 00:00:00 2001 From: Debarshi Ray Date: Thu, 23 Feb 2023 17:15:40 +0100 Subject: [PATCH 11/13] Remove a patch specific to Fedora that doesn't seem necessary anymore There's no need to do a build just for this. --- ...-use-Go-s-semantic-import-versioning.patch | 72 ------------------- toolbox.spec | 16 ++--- 2 files changed, 6 insertions(+), 82 deletions(-) delete mode 100644 toolbox-Don-t-use-Go-s-semantic-import-versioning.patch diff --git a/toolbox-Don-t-use-Go-s-semantic-import-versioning.patch b/toolbox-Don-t-use-Go-s-semantic-import-versioning.patch deleted file mode 100644 index 8cdae9c..0000000 --- a/toolbox-Don-t-use-Go-s-semantic-import-versioning.patch +++ /dev/null @@ -1,72 +0,0 @@ -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. - ---- - src/cmd/create.go | 2 +- - src/go.mod | 2 +- - src/go.sum | 4 ++-- - src/pkg/utils/utils.go | 2 +- - 4 files changed, 5 insertions(+), 5 deletions(-) - -diff --git a/src/cmd/create.go b/src/cmd/create.go -index 8b31365..502f691 100644 ---- a/src/cmd/create.go -+++ b/src/cmd/create.go -@@ -28,7 +28,7 @@ import ( - "github.com/containers/toolbox/pkg/podman" - "github.com/containers/toolbox/pkg/shell" - "github.com/containers/toolbox/pkg/utils" -- "github.com/godbus/dbus/v5" -+ "github.com/godbus/dbus" - "github.com/sirupsen/logrus" - "github.com/spf13/cobra" - "golang.org/x/crypto/ssh/terminal" -diff --git a/src/go.mod b/src/go.mod -index cce3e5a..eb7f70c 100644 ---- a/src/go.mod -+++ b/src/go.mod -@@ -8,7 +8,7 @@ require ( - github.com/briandowns/spinner v1.10.0 - github.com/docker/go-units v0.4.0 - github.com/fsnotify/fsnotify v1.4.7 -- github.com/godbus/dbus/v5 v5.0.3 -+ github.com/godbus/dbus v4.1.0+incompatible - github.com/mattn/go-isatty v0.0.8 - 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 fbad155..737f058 100644 ---- a/src/go.sum -+++ b/src/go.sum -@@ -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= --github.com/godbus/dbus/v5 v5.0.3 h1:ZqHaoEF7TBzh4jzPmqVhE/5A1z9of6orkAe5uHoAeME= --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= -diff --git a/src/pkg/utils/utils.go b/src/pkg/utils/utils.go -index ae7c596..4d1556a 100644 ---- a/src/pkg/utils/utils.go -+++ b/src/pkg/utils/utils.go -@@ -33,7 +33,7 @@ import ( - "github.com/acobaugh/osrelease" - "github.com/containers/toolbox/pkg/shell" - "github.com/docker/go-units" -- "github.com/godbus/dbus/v5" -+ "github.com/godbus/dbus" - "github.com/sirupsen/logrus" - "github.com/spf13/viper" - "golang.org/x/sys/unix" --- -2.31.1 - diff --git a/toolbox.spec b/toolbox.spec index f050d29..44ca80b 100644 --- a/toolbox.spec +++ b/toolbox.spec @@ -23,10 +23,9 @@ Source1: %{name}-%{version}-vendor.tar.xz Source2: gen-vendor-tarball.sh # 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-cmd-root-Work-around-Cobra-1.1.2-s-handling-of-usage.patch +Patch100: toolbox-Make-the-build-flags-match-Fedora-s-gobuild.patch +Patch101: toolbox-Make-the-build-flags-match-Fedora-s-gobuild-for-PPC64.patch +Patch102: toolbox-cmd-root-Work-around-Cobra-1.1.2-s-handling-of-usage.patch BuildRequires: gcc BuildRequires: go-md2man @@ -155,18 +154,15 @@ The %{name}-tests package contains system tests for %{name}. %prep %setup -q %{?rhel:-a 1} -%if ! 0%{?rhel} -%patch100 -p1 -%endif %ifnarch ppc64 -%patch101 -p1 +%patch100 -p1 %else -%patch102 -p1 +%patch101 -p1 %endif %if ! 0%{?rhel} -%patch103 -p1 +%patch102 -p1 %endif %gomkdir -s %{_builddir}/%{extractdir}/src %{?rhel:-k} From 008f2fd173ad5a87fca4995e7f7ff9a1aa314e9d Mon Sep 17 00:00:00 2001 From: Debarshi Ray Date: Tue, 21 Feb 2023 16:42:39 +0100 Subject: [PATCH 12/13] Update to 0.0.99.4 https://bugzilla.redhat.com/show_bug.cgi?id=2171961 --- .gitignore | 1 + gen-vendor-tarball.sh | 27 ------ sources | 3 +- ...ags-match-Fedora-s-gobuild-for-PPC64.patch | 20 ++-- ...e-build-flags-match-Fedora-s-gobuild.patch | 20 ++-- ...ound-Cobra-1.1.2-s-handling-of-usage.patch | 95 ------------------- toolbox.spec | 52 +++++----- 7 files changed, 50 insertions(+), 168 deletions(-) delete mode 100755 gen-vendor-tarball.sh delete mode 100644 toolbox-cmd-root-Work-around-Cobra-1.1.2-s-handling-of-usage.patch diff --git a/.gitignore b/.gitignore index 3443637..3db2fe9 100644 --- a/.gitignore +++ b/.gitignore @@ -29,3 +29,4 @@ /toolbox-0.0.99.2^3.git075b9a8d2779.tar.xz /toolbox-0.0.99.3.tar.xz /toolbox-0.0.99.3-vendor.tar.xz +/toolbox-0.0.99.4-vendored.tar.xz diff --git a/gen-vendor-tarball.sh b/gen-vendor-tarball.sh deleted file mode 100755 index f704f1a..0000000 --- a/gen-vendor-tarball.sh +++ /dev/null @@ -1,27 +0,0 @@ -#!/bin/sh - -# Process a toolbox tarball to get vendored dependencies for the RHEL build. -# -# Yaakov Selkowitz - 2022 - -SOURCE="$1" -DIRECTORY=`echo $SOURCE | sed 's/\.tar\.xz//'` -VENDOR_SOURCE="${DIRECTORY}-vendor.tar.xz" - -error() -{ - MESSAGE=$1 - echo $MESSAGE - exit 1 -} - -rm -rf $DIRECTORY -tar xJf $SOURCE || error "Cannot unpack $SOURCE" -pushd $DIRECTORY/src > /dev/null || error "Cannot open directory \"$DIRECTORY\"" - -echo "Vendoring dependencies" -go mod vendor || error "Vendoring failed" -popd > /dev/null - -tar cJf $VENDOR_SOURCE -C $DIRECTORY src/vendor || error "Unable to create $VENDOR_SOURCE" -echo "$VENDOR_SOURCE is ready to use" diff --git a/sources b/sources index 2bf14ad..a8351c5 100644 --- a/sources +++ b/sources @@ -1,2 +1 @@ -SHA512 (toolbox-0.0.99.3.tar.xz) = d9e4bd1cc7667b6ecdcf25a2c3ad7d7d67cc997168a41e668c936d2de24db774331a78a1b4a06b63e7cef8e0dc4ac5651591b6d9cec0d8e81be2b2dd64854dca -SHA512 (toolbox-0.0.99.3-vendor.tar.xz) = 51ce5a16276ccc75d2b6fb9cae1c4371ad028f6a820cd176a4a0ee85fab447a6b37b5ec2e969b882c4f04cfe58bd78f92975606297a0db22e72457f012102ec2 +SHA512 (toolbox-0.0.99.4-vendored.tar.xz) = 882cd6ec1c1a193af8774dfdfd0aff72d376c4fec3e0cc702e2d524353c051e408eab2ac3fb43ec00fe622b46ac89fdbe97aca2f7cfbe3822e5d3ff1743f2fd0 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 a1d92a5..f658031 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 32aa30a17358598f568991a5375f6182e4135648 Mon Sep 17 00:00:00 2001 +From 17a0e519fd9b1e721b35a823bd244a28e3f87a4a 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 @@ -24,22 +24,22 @@ and should be kept updated to match Fedora's Go guidelines. Use 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/src/go-build-wrapper b/src/go-build-wrapper -index ef4aafc8b024..f8ea8370792c 100755 +index c572d6dfb02b..cae2de426a96 100755 --- a/src/go-build-wrapper +++ b/src/go-build-wrapper -@@ -32,9 +32,9 @@ if ! cd "$1"; then +@@ -33,9 +33,9 @@ if ! cd "$1"; then exit 1 fi -tags="" +tags="-tags rpm_crashtraceback,${BUILDTAGS:-}" - if $6; then + if $7; 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 + if ! libc_dir=$("$5" --print-file-name=libc.so); then +@@ -70,11 +70,16 @@ fi dynamic_linker="/run/host$dynamic_linker_canonical_dirname/$dynamic_linker_basename" @@ -50,14 +50,14 @@ index ef4aafc8b024..f8ea8370792c 100755 + -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" \ +- -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=$4" \ ++ -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 -specs=/usr/lib/rpm/redhat/redhat-annobin-cc1 -Wl,--build-id=sha1 -Wl,-dynamic-linker,$dynamic_linker -Wl,-rpath,/run/host$libc_dir_canonical_dirname' -linkmode external -X github.com/containers/toolbox/pkg/version.currentVersion=$4" \ + -a \ + -v \ + -x \ - -o "$2/toolbox" + -o "$2/$3" exit "$?" -- -2.31.1 +2.39.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 2e4cbfd..7105cb5 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 6d913f1fbd6e609957bb01273504b2f479e1b546 Mon Sep 17 00:00:00 2001 +From fd03e31c7d789413700db84af02894d5be70b5ee 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} @@ -23,22 +23,22 @@ PPC64, and should be kept updated to match Fedora's Go guidelines. Use 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/src/go-build-wrapper b/src/go-build-wrapper -index ef4aafc8b024..4354beceb215 100755 +index c572d6dfb02b..0e6a2efa6853 100755 --- a/src/go-build-wrapper +++ b/src/go-build-wrapper -@@ -32,9 +32,9 @@ if ! cd "$1"; then +@@ -33,9 +33,9 @@ if ! cd "$1"; then exit 1 fi -tags="" +tags="-tags rpm_crashtraceback,${BUILDTAGS:-}" - if $6; then + if $7; 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 + if ! libc_dir=$("$5" --print-file-name=libc.so); then +@@ -70,11 +70,17 @@ fi dynamic_linker="/run/host$dynamic_linker_canonical_dirname/$dynamic_linker_basename" @@ -50,14 +50,14 @@ index ef4aafc8b024..4354beceb215 100755 + -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" \ +- -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=$4" \ ++ -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 -specs=/usr/lib/rpm/redhat/redhat-annobin-cc1 -Wl,--build-id=sha1 -Wl,-dynamic-linker,$dynamic_linker -Wl,-rpath,/run/host$libc_dir_canonical_dirname' -linkmode external -X github.com/containers/toolbox/pkg/version.currentVersion=$4" \ + -a \ + -v \ + -x \ - -o "$2/toolbox" + -o "$2/$3" exit "$?" -- -2.31.1 +2.39.1 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 deleted file mode 100644 index a618021..0000000 --- a/toolbox-cmd-root-Work-around-Cobra-1.1.2-s-handling-of-usage.patch +++ /dev/null @@ -1,95 +0,0 @@ -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 44ca80b..be9a965 100644 --- a/toolbox.spec +++ b/toolbox.spec @@ -1,7 +1,7 @@ %global __brp_check_rpaths %{nil} Name: toolbox -Version: 0.0.99.3 +Version: 0.0.99.4 %global goipath github.com/containers/%{name} @@ -11,44 +11,43 @@ Version: 0.0.99.3 %gometa -f %endif -Release: 10%{?dist} +Release: 1%{?dist} Summary: Tool for containerized command line environments on Linux License: ASL 2.0 URL: https://containertoolbx.org/ -Source0: https://github.com/containers/%{name}/releases/download/%{version}/%{name}-%{version}.tar.xz -# RHEL package is built with vendored dependencies -# created with gen-vendor-tarball.sh from SOURCE2 -Source1: %{name}-%{version}-vendor.tar.xz -Source2: gen-vendor-tarball.sh +Source0: https://github.com/containers/%{name}/releases/download/%{version}/%{name}-%{version}-vendored.tar.xz # Fedora specific Patch100: toolbox-Make-the-build-flags-match-Fedora-s-gobuild.patch Patch101: toolbox-Make-the-build-flags-match-Fedora-s-gobuild-for-PPC64.patch -Patch102: toolbox-cmd-root-Work-around-Cobra-1.1.2-s-handling-of-usage.patch BuildRequires: gcc BuildRequires: go-md2man BuildRequires: golang >= 1.18.9 %if ! 0%{?rhel} -BuildRequires: golang(github.com/HarryMichal/go-version) -BuildRequires: golang(github.com/acobaugh/osrelease) -BuildRequires: golang(github.com/briandowns/spinner) >= 1.10.0 +BuildRequires: golang(github.com/HarryMichal/go-version) >= 1.0.1 +BuildRequires: golang(github.com/acobaugh/osrelease) >= 0.1.0 +BuildRequires: golang(github.com/briandowns/spinner) >= 1.17.0 BuildRequires: golang(github.com/docker/go-units) >= 0.4.0 -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/spf13/cobra) >= 0.0.5 -BuildRequires: golang(github.com/spf13/viper) >= 1.3.2 -BuildRequires: golang(golang.org/x/crypto/ssh/terminal) +BuildRequires: golang(github.com/fsnotify/fsnotify) >= 1.5.1 +BuildRequires: golang(github.com/godbus/dbus) >= 5.0.6 +BuildRequires: golang(github.com/sirupsen/logrus) >= 1.8.1 +BuildRequires: golang(github.com/spf13/cobra) >= 1.3.0 +BuildRequires: golang(github.com/spf13/viper) >= 1.10.1 BuildRequires: golang(golang.org/x/sys/unix) +BuildRequires: golang(golang.org/x/term) # for tests +# BuildRequires: codespell # BuildRequires: golang(github.com/stretchr/testify) >= 1.7.0 # BuildRequires: ShellCheck %endif BuildRequires: meson >= 0.58.0 BuildRequires: pkgconfig(bash-completion) +BuildRequires: pkgconfig(fish) +BuildRequires: podman +BuildRequires: shadow-utils-subid-devel +BuildRequires: systemd BuildRequires: systemd-rpm-macros Requires: containers-common @@ -153,7 +152,7 @@ The %{name}-tests package contains system tests for %{name}. %prep -%setup -q %{?rhel:-a 1} +%setup -q %ifnarch ppc64 %patch100 -p1 @@ -161,10 +160,6 @@ The %{name}-tests package contains system tests for %{name}. %patch101 -p1 %endif -%if ! 0%{?rhel} -%patch102 -p1 -%endif - %gomkdir -s %{_builddir}/%{extractdir}/src %{?rhel:-k} @@ -173,7 +168,10 @@ export %{gomodulesmode} export GOPATH=%{gobuilddir}:%{gopath} export CGO_CFLAGS="%{optflags} -D_GNU_SOURCE -D_LARGEFILE_SOURCE -D_LARGEFILE64_SOURCE -D_FILE_OFFSET_BITS=64" -%meson -Dprofile_dir=%{_sysconfdir}/profile.d -Dtmpfiles_dir=%{_tmpfilesdir} +%meson \ + -Dprofile_dir=%{_sysconfdir}/profile.d \ + -Dtmpfiles_dir=%{_tmpfilesdir} \ + -Dzsh_completions_dir=%{_datadir}/zsh/site-functions %meson_build @@ -190,8 +188,11 @@ export CGO_CFLAGS="%{optflags} -D_GNU_SOURCE -D_LARGEFILE_SOURCE -D_LARGEFILE64_ %license COPYING %{?rhel:src/vendor/modules.txt} %{_bindir}/%{name} %{_datadir}/bash-completion +%{_datadir}/fish +%{_datadir}/zsh %{_mandir}/man1/%{name}.1* %{_mandir}/man1/%{name}-*.1* +%{_mandir}/man5/%{name}.conf.5* %config(noreplace) %{_sysconfdir}/containers/%{name}.conf %{_sysconfdir}/profile.d/%{name}.sh %{_tmpfilesdir}/%{name}.conf @@ -209,6 +210,9 @@ export CGO_CFLAGS="%{optflags} -D_GNU_SOURCE -D_LARGEFILE_SOURCE -D_LARGEFILE64_ %changelog +* Wed Feb 22 2023 Debarshi Ray - 0.0.99.4-1 +- Update to 0.0.99.4 + * Wed Feb 22 2023 Martin Jackson - 0.0.99.3-10 - Fix the ExclusiveArch From 6d34184727d10be643ff6a3686a34564faa428d8 Mon Sep 17 00:00:00 2001 From: Debarshi Ray Date: Mon, 27 Feb 2023 17:49:45 +0100 Subject: [PATCH 13/13] Don't use podman(1) when generating the completions This is actually needed for Fedoras 36 and 37, but, at least currently, not necessary for Fedoras 38 and 39. https://github.com/containers/podman/issues/17657 --- ...se-podman-1-when-generating-the-comp.patch | 89 +++++++++++++++++++ toolbox.spec | 5 +- 2 files changed, 93 insertions(+), 1 deletion(-) create mode 100644 toolbox-Don-t-use-podman-1-when-generating-the-comp.patch diff --git a/toolbox-Don-t-use-podman-1-when-generating-the-comp.patch b/toolbox-Don-t-use-podman-1-when-generating-the-comp.patch new file mode 100644 index 0000000..85c7289 --- /dev/null +++ b/toolbox-Don-t-use-podman-1-when-generating-the-comp.patch @@ -0,0 +1,89 @@ +From fc5f568c5d82f4a16982268fa67092e52be91fbe Mon Sep 17 00:00:00 2001 +From: Debarshi Ray +Date: Tue, 28 Feb 2023 17:12:04 +0100 +Subject: [PATCH] cmd/root: Don't use podman(1) when generating the completions + +Ever since commit bafbbe81c9220cb3, the shell completions are generated +while building Toolbx using the 'completion' command. This involves +running toolbox(1) itself, and hence invoking 'podman version' to decide +if 'podman system migrate' is needed or not. + +Unfortunately, some build environments, like Fedora's, are set up inside +a chroot(2) or systemd-nspawn(1) or similar, where 'podman version' may +not work because it does various things with namespaces(7) and clone(2) +that can, under certain circumstances, encounter an EPERM. + +Therefore, it's better to avoid using podman(1) when generating the +shell completions, especially, since they are generated by Cobra itself +and podman(1) is not involved at all. + +Note that podman(1) is needed when the generated shell completions are +actually used in interactive command line environments. The shell +completions invoke the hidden '__complete' command to get the results +that are presented to the user, and, if needed, 'podman system migrate' +will continue to be run as part of that. + +This partially reverts commit f3e005d0142d7ec76d5ac8f0a2f331a52fd46011 +because podman(1) is now only an optional runtime dependency for the +system tests. + +https://github.com/containers/podman/issues/17657 +--- + meson.build | 2 +- + src/cmd/root.go | 9 +++++++-- + 2 files changed, 8 insertions(+), 3 deletions(-) + +diff --git a/meson.build b/meson.build +index 6f044bb204e3..653a3d3ac588 100644 +--- a/meson.build ++++ b/meson.build +@@ -18,12 +18,12 @@ subid_dep = cc.find_library('subid', has_headers: ['shadow/subid.h']) + + go = find_program('go') + go_md2man = find_program('go-md2man') +-podman = find_program('podman') + + bats = find_program('bats', required: false) + codespell = find_program('codespell', required: false) + htpasswd = find_program('htpasswd', required: false) + openssl = find_program('openssl', required: false) ++podman = find_program('podman', required: false) + shellcheck = find_program('shellcheck', required: false) + skopeo = find_program('skopeo', required: false) + +diff --git a/src/cmd/root.go b/src/cmd/root.go +index 304b03dcd889..9975ccc7a4c8 100644 +--- a/src/cmd/root.go ++++ b/src/cmd/root.go +@@ -166,7 +166,7 @@ func preRun(cmd *cobra.Command, args []string) error { + + logrus.Debugf("TOOLBOX_PATH is %s", toolboxPath) + +- if err := migrate(); err != nil { ++ if err := migrate(cmd, args); err != nil { + return err + } + +@@ -211,13 +211,18 @@ func rootRun(cmd *cobra.Command, args []string) error { + return rootRunImpl(cmd, args) + } + +-func migrate() error { ++func migrate(cmd *cobra.Command, args []string) error { + logrus.Debug("Migrating to newer Podman") + + if utils.IsInsideContainer() { + return nil + } + ++ if cmdName, completionCmdName := cmd.Name(), completionCmd.Name(); cmdName == completionCmdName { ++ logrus.Debugf("Migration not needed: command %s doesn't need it", cmdName) ++ return nil ++ } ++ + configDir, err := os.UserConfigDir() + if err != nil { + logrus.Debugf("Migrating to newer Podman: failed to get the user config directory: %s", err) +-- +2.39.1 + diff --git a/toolbox.spec b/toolbox.spec index be9a965..b27a7a5 100644 --- a/toolbox.spec +++ b/toolbox.spec @@ -18,6 +18,9 @@ License: ASL 2.0 URL: https://containertoolbx.org/ Source0: https://github.com/containers/%{name}/releases/download/%{version}/%{name}-%{version}-vendored.tar.xz +# Upstream +Patch0: toolbox-Don-t-use-podman-1-when-generating-the-comp.patch + # Fedora specific Patch100: toolbox-Make-the-build-flags-match-Fedora-s-gobuild.patch Patch101: toolbox-Make-the-build-flags-match-Fedora-s-gobuild-for-PPC64.patch @@ -45,7 +48,6 @@ BuildRequires: golang(golang.org/x/term) BuildRequires: meson >= 0.58.0 BuildRequires: pkgconfig(bash-completion) BuildRequires: pkgconfig(fish) -BuildRequires: podman BuildRequires: shadow-utils-subid-devel BuildRequires: systemd BuildRequires: systemd-rpm-macros @@ -153,6 +155,7 @@ The %{name}-tests package contains system tests for %{name}. %prep %setup -q +%patch0 -p1 %ifnarch ppc64 %patch100 -p1