diff --git a/toolbox-0.0.99-vendored.tar.xz b/toolbox-0.0.99-vendored.tar.xz deleted file mode 100644 index 95f814360bdc793ba72d82bc0041396f4535095c..0000000000000000000000000000000000000000 Binary files a/toolbox-0.0.99-vendored.tar.xz and /dev/null differ diff --git a/toolbox-0.0.99.3.tar.xz b/toolbox-0.0.99.3.tar.xz new file mode 100644 index 0000000000000000000000000000000000000000..ea5f20ffd4a320a86f904d1f538919a02131ca20 Binary files /dev/null and b/toolbox-0.0.99.3.tar.xz differ diff --git a/toolbox-Don-t-use-Go-s-semantic-import-versioning.patch b/toolbox-Don-t-use-Go-s-semantic-import-versioning.patch new file mode 100644 index 0000000000000000000000000000000000000000..8cdae9c04b31c2ecf6b6b24eb2cefcecea10828f --- /dev/null +++ b/toolbox-Don-t-use-Go-s-semantic-import-versioning.patch @@ -0,0 +1,72 @@ +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-Make-the-build-flags-match-Fedora-s-gobuild-for-PPC64.patch b/toolbox-Make-the-build-flags-match-Fedora-s-gobuild-for-PPC64.patch new file mode 100644 index 0000000000000000000000000000000000000000..a1d92a5790bbdf91ad77bb461611f5560bd5b6e3 --- /dev/null +++ b/toolbox-Make-the-build-flags-match-Fedora-s-gobuild-for-PPC64.patch @@ -0,0 +1,63 @@ +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 + PPC64 + +The Go toolchain doesn't play well with passing compiler and linker +flags via environment variables. The linker flags require a second +level of quoting, which leaves the build system without a quote level +to assign the flags to an environment variable like GOFLAGS. + +This is one reason why Fedora doesn't have a RPM macro with only the +flags. The %{gobuild} RPM macro includes the entire 'go build ...' +invocation. + +The Go toolchain also doesn't like the LDFLAGS environment variable as +exported by Fedora's %{meson} RPM macro. + +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 | 13 +++++++++---- + 1 file changed, 9 insertions(+), 4 deletions(-) + +diff --git a/src/go-build-wrapper b/src/go-build-wrapper +index ef4aafc8b024..f8ea8370792c 100755 +--- a/src/go-build-wrapper ++++ b/src/go-build-wrapper +@@ -32,9 +32,9 @@ if ! cd "$1"; then + exit 1 + fi + +-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 ++ + # 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.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 new file mode 100644 index 0000000000000000000000000000000000000000..2e4cbfd7c6f4ea0525c9d98b2f7526b8088d7cb3 --- /dev/null +++ b/toolbox-Make-the-build-flags-match-Fedora-s-gobuild.patch @@ -0,0 +1,63 @@ +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} + +The Go toolchain doesn't play well with passing compiler and linker +flags via environment variables. The linker flags require a second +level of quoting, which leaves the build system without a quote level +to assign the flags to an environment variable like GOFLAGS. + +This is one reason why Fedora doesn't have a RPM macro with only the +flags. The %{gobuild} RPM macro includes the entire 'go build ...' +invocation. + +The Go toolchain also doesn't like the LDFLAGS environment variable as +exported by Fedora's %{meson} RPM macro. + +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 | 14 ++++++++++---- + 1 file changed, 10 insertions(+), 4 deletions(-) + +diff --git a/src/go-build-wrapper b/src/go-build-wrapper +index ef4aafc8b024..4354beceb215 100755 +--- a/src/go-build-wrapper ++++ b/src/go-build-wrapper +@@ -32,9 +32,9 @@ if ! cd "$1"; then + exit 1 + fi + +-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 ++ + # 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.31.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 new file mode 100644 index 0000000000000000000000000000000000000000..a618021538697e753eb23e0025768398c5928506 --- /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 31b53c3ca50425d7f404d291143dd87a8c0eac85..580c3a0d16e607af9ae2d9ad1de7e43b7acab14f 100644 --- a/toolbox.spec +++ b/toolbox.spec @@ -1,17 +1,22 @@ Name: toolbox -Version: 0.0.99 +Version: 0.0.99.3 %global goipath github.com/containers/%{name} -Release: 1 +Release: 2 Summary: Unprivileged development environment License: ASL 2.0 URL: https://github.com/containers/toolbox -Source0: toolbox-0.0.99-vendored.tar.xz +Source0: https://github.com/containers/%{name}/releases/download/%{version}/%{name}-%{version}.tar.xz Source1: https://github.com/cpuguy83/go-md2man/archive/v1.0.10.tar.gz +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: golang >= 1.13 meson BuildRequires: pkgconfig(bash-completion) systemd @@ -36,6 +41,16 @@ The toolbox-tests package contains system tests for toolbox. %prep %setup -q +%patch100 -p1 + +%ifnarch ppc64 +%patch101 -p1 +%else +%patch102 -p1 +%endif + +%patch103 -p1 + GOBUILDDIR="$(pwd)/_build" GOSOURCEDIR="$(pwd)" if [[ ! -e "$GOBUILDDIR/bin" ]] ; then @@ -87,5 +102,8 @@ ln -s src/vendor vendor %{_datadir}/%{name} %changelog -* Thu Feb 10 2022 duyiwei - 0.0.99-1 +* Tue Jun 07 2022 fushanqing - 0.0.99.3-2 +- Add upstream patch + +* Thu Feb 10 2022 duyiwei - 0.0.99.3-1 - Package init \ No newline at end of file diff --git a/toolbox.yaml b/toolbox.yaml new file mode 100644 index 0000000000000000000000000000000000000000..3c9c4b5447e60ae41bec1140a3e3ca136cf4e706 --- /dev/null +++ b/toolbox.yaml @@ -0,0 +1,4 @@ +version_control: github +src_repo: containers/toolbox +tag_prefix: "" +separator: . \ No newline at end of file