From 46d2ca508e5b7bab639d692c5d0fda6de05ce178 Mon Sep 17 00:00:00 2001 From: Yaakov Selkowitz Date: Wed, 21 Dec 2022 00:22:14 -0500 Subject: [PATCH] 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 074d515..9063708 100644 --- a/toolbox.spec +++ b/toolbox.spec @@ -6,12 +6,16 @@ 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 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-8 +- Use vendored dependencies for RHEL/ELN builds + * Sat Jul 23 2022 Fedora Release Engineering - 0.0.99.3-7 - Rebuilt for https://fedoraproject.org/wiki/Fedora_37_Mass_Rebuild