diff --git a/.gitignore b/.gitignore index 8282a1a..e0a04d0 100644 --- a/.gitignore +++ b/.gitignore @@ -1 +1,60 @@ /podman-tui-0.2.0.tar.gz +/podman-tui-0.3.0.tar.gz +/podman-tui-0.3.1.tar.gz +/podman-tui-0.4.0.tar.gz +/podman-tui-0.5.0.tar.gz +/podman-tui-0.6.0.tar.gz +/podman-tui-0.7.0.tar.gz +/podman-tui-0.9.0.tar.gz +/podman-tui-0.9.1.tar.gz +/podman-tui-0.11.0.tar.gz +/podman-tui-0.12.0.tar.gz +/vendor-0.12.0.tar.gz +/podman-tui-0.13.0.tar.gz +/vendor-0.13.0.tar.gz +/podman-tui-0.14.0.tar.gz +/vendor-0.14.0.tar.gz +/podman-tui-0.15.0.tar.gz +/vendor-0.15.0.tar.gz +/podman-tui-0.16.0.tar.gz +/vendor-0.16.0.tar.gz +/podman-tui-0.17.0.tar.gz +/vendor-0.17.0.tar.gz +/podman-tui-0.18.0.tar.gz +/vendor-0.18.0.tar.gz +/podman-tui-1.0.0.tar.gz +/vendor-1.0.0.tar.gz +/podman-tui-1.0.1.tar.gz +/vendor-1.0.1.tar.gz +/podman-tui-1.1.0.tar.gz +/vendor-1.1.0.tar.gz +/podman-tui-1.2.0.tar.gz +/vendor-1.2.0.tar.gz +/podman-tui-1.2.1.tar.gz +/vendor-1.2.1.tar.gz +/podman-tui-1.2.2.tar.gz +/vendor-1.2.2.tar.gz +/podman-tui-1.2.3.tar.gz +/vendor-1.2.3.tar.gz +/podman-tui-1.3.0.tar.gz +/vendor-1.3.0.tar.gz +/podman-tui-1.3.1.tar.gz +/vendor-1.3.1.tar.gz +/podman-tui-1.4.0.tar.gz +/vendor-1.4.0.tar.gz +/podman-tui-1.5.0.tar.gz +/vendor-1.5.0.tar.gz +/podman-tui-1.6.0.tar.gz +/vendor-1.6.0.tar.gz +/podman-tui-1.6.1.tar.gz +/vendor-1.6.1.tar.gz +/podman-tui-1.7.0.tar.gz +/vendor-1.7.0.tar.gz +/podman-tui-1.8.0.tar.gz +/vendor-1.8.0.tar.gz +/podman-tui-1.8.1.tar.gz +/vendor-1.8.1.tar.gz +/podman-tui-1.9.0.tar.gz +/vendor-1.9.0.tar.gz +/podman-tui-1.10.0.tar.gz +/vendor-1.10.0.tar.gz diff --git a/bundle_go_deps_for_rpm.sh b/bundle_go_deps_for_rpm.sh new file mode 100644 index 0000000..358556d --- /dev/null +++ b/bundle_go_deps_for_rpm.sh @@ -0,0 +1,116 @@ +#!/bin/bash + +# Description: +# This script creates an archive with vendored dependencies from a Go SPEC file. + +# License: +# MIT License +# +# Copyright (c) 2023 Robert-André Mauchin +# +# Permission is hereby granted, free of charge, to any person obtaining a copy +# of this software and associated documentation files (the "Software"), to deal +# in the Software without restriction, including without limitation the rights +# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +# copies of the Software, and to permit persons to whom the Software is +# furnished to do so, subject to the following conditions: +# +# The above copyright notice and this permission notice shall be included in all +# copies or substantial portions of the Software. +# +# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +# SOFTWARE. + +# Check if the RPM SPEC file is given as an argument +if [[ $# -ne 1 ]]; then + echo "Usage: $0 " + exit 1 +fi + +RPM_SPEC_FILE=$1 + +# Extract the directory from the RPM SPEC file path +SPEC_DIR=$(dirname $(realpath "$RPM_SPEC_FILE")) + +# Extract the URL, commit, tag, and version from the RPM SPEC file +FORGEURL=$(awk '/^%global forgeurl/ {print $NF}' "$RPM_SPEC_FILE") +GOIPATH=$(awk '/^%global goipath/ {print $NF}' "$RPM_SPEC_FILE") +COMMIT=$(awk '/^%global commit/ {print $NF}' "$RPM_SPEC_FILE") +TAG=$(awk '/^%global tag/ {print $NF}' "$RPM_SPEC_FILE") +VERSION=$(awk '/^Version:/ {print $NF}' "$RPM_SPEC_FILE") + +# Decide which URL to use +if [[ -n "$FORGEURL" ]]; then + REPO_URL="$FORGEURL" +elif [[ -n "$GOIPATH" ]]; then + REPO_URL="https://$GOIPATH" +else + echo "No repository URL found in the RPM SPEC file." + exit 2 +fi + +# Create a temporary directory and clone the repository +TMP_DIR=$(mktemp -d) +trap "rm -rf $TMP_DIR" EXIT +git clone "$REPO_URL" "$TMP_DIR" +if [[ $? -ne 0 ]]; then + echo "Failed to clone repository." + exit 3 +fi + +# Change to the directory +pushd "$TMP_DIR" > /dev/null + +# Checkout based on priority: commit > tag > Version +CHECKOUT_SUCCESS=0 +if [[ -n "$COMMIT" ]]; then + CHECKOUT_IDENTIFIER="$COMMIT" + git checkout "$CHECKOUT_IDENTIFIER" && CHECKOUT_SUCCESS=1 +elif [[ -n "$TAG" ]]; then + CHECKOUT_IDENTIFIER="$TAG" + git checkout "$CHECKOUT_IDENTIFIER" && CHECKOUT_SUCCESS=1 +elif [[ -n "$VERSION" ]]; then + CHECKOUT_IDENTIFIER="$VERSION" + git checkout "$VERSION" || git checkout "v$VERSION" + if [ $? -eq 0 ]; then + CHECKOUT_SUCCESS=1 + fi +else + echo "No commit, tag, or version found in the RPM SPEC file." + exit 4 +fi + +if [ $CHECKOUT_SUCCESS -eq 0 ]; then + echo "Failed to checkout using commit, tag, or version." + exit 5 +fi + +# Run go mod vendor +go mod vendor +if [[ $? -ne 0 ]]; then + echo "Failed to run 'go mod vendor'." + exit 6s +fi + +# Create a tar.gz of the vendor directory +tar czf "vendor-$CHECKOUT_IDENTIFIER.tar.gz" vendor/ +if [[ $? -ne 0 ]]; then + echo "Failed to create tar.gz of the vendor directory." + exit 7 +fi + +# Move the tar.gz to the SPEC directory +mv "vendor-$CHECKOUT_IDENTIFIER.tar.gz" "$SPEC_DIR/" + +# Go back to the original directory +popd > /dev/null + +# Clean up +rm -rf "$TMP_DIR" + +echo "Created vendor-$CHECKOUT_IDENTIFIER.tar.gz successfully." diff --git a/podman-tui.spec b/podman-tui.spec index bb5de58..ac2acde 100644 --- a/podman-tui.spec +++ b/podman-tui.spec @@ -1,23 +1,28 @@ -%global with_check 0 -%global with_debug 1 - -%if 0%{?with_debug} -%global _find_debuginfo_dwz_opts %{nil} -%global _dwz_low_mem_die_limit 0 -%else -%global debug_package %{nil} +%bcond_without check +%bcond_without bundled +%if 0%{?rhel} +%bcond_without bundled %endif +%if %{defined rhel} && 0%{?rhel} < 10 +%define gobuild(o:) go build -buildmode pie -compiler gc -tags="rpm_crashtraceback ${BUILDTAGS:-}" -ldflags "-linkmode=external -compressdwarf=false ${LDFLAGS:-} -B 0x$(head -c20 /dev/urandom|od -An -tx1|tr -d ' \\n') -extldflags '%__global_ldflags'" -a -v -x %{?**}; +%endif + +%if %{with bundled} +%global gomodulesmode GO111MODULE=on +%endif + +# https://github.com/containers/podman-tui %global goipath github.com/containers/podman-tui -Version: 0.2.0 -%global tag v0.2.0 +Version: 1.10.0 %gometa %global goname podman-tui %global common_description %{expand: -%{goname} is a terminal user interface for Podman v3 (>= 3.1). -it is using podman.socket service to communicate with podman machine. +%{goname} is a terminal user interface for Podman v4 and v5. +%{goname} is using podman.socket service to communicate with podman environment +and SSH to connect to remote podman machines. } %global golicenses LICENSE @@ -30,195 +35,59 @@ Requires: %{name} = %{version}-%{release} Name: %{goname} Release: %autorelease Summary: Podman Terminal User Interface -License: ASL 2.0 and BSD and ISC and MIT and MPLv2.0 + +License: Apache-2.0 AND BSD-2-Clause AND BSD-3-Clause AND ISC AND MIT AND MPL-2.0 URL: %{gourl} -Source0: %{gosource} +Source: %{gosource} +Source: vendor-%{version}.tar.gz +Source: bundle_go_deps_for_rpm.sh BuildRequires: gcc -BuildRequires: golang >= 1.16.6 +BuildRequires: golang BuildRequires: glib2-devel BuildRequires: glibc-devel BuildRequires: glibc-static BuildRequires: git-core BuildRequires: go-rpm-macros BuildRequires: make -BuildRequires: gpgme-devel -BuildRequires: device-mapper-devel -BuildRequires: libassuan-devel -%if ! 0%{?centos} -BuildRequires: btrfs-progs-devel -%endif + %if 0%{?fedora} >= 35 BuildRequires: shadow-utils-subid-devel %endif -BuildRequires: golang-github-docker-distribution-devel -BuildRequires: golang-github-docker-devel -BuildRequires: golang-github-docker-units-devel -BuildRequires: golang-github-pkg-errors-devel -BuildRequires: golang-github-rs-zerolog-devel -BuildRequires: golang-github-sirupsen-logrus-devel -BuildRequires: golang-github-spf13-cobra-devel -# indirect requirements -BuildRequires: golang-github-moby-term-devel -BuildRequires: golang-github-burntsushi-toml-devel -BuildRequires: golang-github-rivo-uniseg-devel -BuildRequires: golang-github-protobuf-devel -BuildRequires: golang-github-gorilla-mux-devel -BuildRequires: golang-github-gorilla-schema-devel -BuildRequires: golang-github-gdamore-encoding-devel -BuildRequires: golang-github-klauspost-compress-devel -BuildRequires: golang-github-xeipuuv-gojsonschema-devel -BuildRequires: golang-github-xeipuuv-gojsonreference-devel -BuildRequires: golang-github-xeipuuv-gojsonpointer-devel -BuildRequires: golang-github-vishvananda-netlink-devel -BuildRequires: golang-github-vishvananda-netns-devel -BuildRequires: golang-github-ulikunitz-xz-devel -BuildRequires: golang-github-syndtr-gocapability-devel -BuildRequires: golang-github-miekg-pkcs11-devel -BuildRequires: golang-github-modern-reflect2-devel -BuildRequires: golang-github-lucasb-eyer-colorful-devel -BuildRequires: golang-github-klauspost-pgzip-devel -BuildRequires: golang-github-mattn-shellwords-devel -BuildRequires: golang-github-manifoldco-promptui-devel -BuildRequires: golang-github-inconshreveable-mousetrap-devel -BuildRequires: golang-github-imdario-mergo-devel -BuildRequires: golang-github-hpcloud-tail-devel -BuildRequires: golang-github-hashicorp-multierror-devel -BuildRequires: golang-github-hashicorp-errwrap-devel -BuildRequires: golang-github-google-uuid-devel -BuildRequires: golang-github-groupcache-devel -BuildRequires: golang-github-gogo-protobuf-devel -BuildRequires: compat-golang-github-godbus-dbus-5-devel -BuildRequires: golang-github-ghodss-yaml-devel -BuildRequires: golang-gopkg-yaml-2-devel -BuildRequires: golang-github-fsnotify-devel -BuildRequires: golang-github-docker-metrics-devel -BuildRequires: golang-github-docker-connections-devel -BuildRequires: golang-github-cyphar-filepath-securejoin-devel -BuildRequires: golang-github-beorn7-perks-devel -BuildRequires: golang-github-acarl005-stripansi-devel -BuildRequires: golang-github-containerd-cgroups-devel -BuildRequires: golang-github-containernetworking-plugins-devel -BuildRequires: golang-github-containernetworking-cni-devel -BuildRequires: golang-gopkg-square-jose-2-devel -BuildRequires: golang-github-vbatts-tar-split -BuildRequires: golang-github-tchap-patricia-devel -BuildRequires: golang-github-stefanberger-pkcs11uri-devel -BuildRequires: golang-github-opencontainers-selinux-devel -BuildRequires: golang-github-modern-concurrent-devel -BuildRequires: golang-github-blang-semver-devel -BuildRequires: golang-github-json-iterator-devel -BuildRequires: golang-github-prometheus-common-devel -BuildRequires: golang-github-prometheus-client-devel -BuildRequires: golang-github-prometheus-client-model-devel -BuildRequires: golang-github-prometheus-procfs-devel -BuildRequires: golang-github-moby-sys-devel -BuildRequires: golang-github-docker-credential-helpers-devel -BuildRequires: compat-golang-github-chzyer-readline-devel -BuildRequires: golang-github-cespare-xxhash-devel -BuildRequires: golang-github-matttproud-protobuf-extensions-devel -BuildRequires: golang-github-mistifyio-zfs-devel -BuildRequires: golang-github-opencontainers-digest-devel -BuildRequires: golang-github-opencontainers-image-spec-devel -BuildRequires: golang-github-opencontainers-runc-devel -BuildRequires: golang-github-opencontainers-runtime-spec-devel -BuildRequires: golang-github-opencontainers-runtime-tools-devel -BuildRequires: golang-github-containerd-stargz-snapshotter-estargz-devel - -# bundled libraries - not available in fedora packages -Provides: bundled(golang(github.com/containerd/containerd)) = v1.5.7 -Provides: bundled(golang(github.com/containers/buildah)) = v1.23.1 -Provides: bundled(golang(github.com/containers/common)) = v0.44.4 -Provides: bundled(golang(github.com/containers/image/v5)) = v5.17.0 -Provides: bundled(golang(github.com/containers/libtrust)) = v0.0.0_20190913040956_14b96171aa3b -Provides: bundled(golang(github.com/containers/ocicrypt)) = v1.1.2 -Provides: bundled(golang(github.com/containers/podman/v3)) = v3.4.4 -Provides: bundled(golang(github.com/containers/psgo)) = v1.7.1 -Provides: bundled(golang(github.com/containers/storage)) = v1.37.0 -Provides: bundled(golang(github.com/cri_o/ocicni)) = v0.2.1_0.20210621164014_d0acc7862283 -Provides: bundled(golang(github.com/disiqueira/gotree/v3)) = v3.0.2 -Provides: bundled(golang(github.com/gdamore/tcell/v2)) = v2.4.1_0.20210905002822_f057f0a857a1 -Provides: bundled(golang(github.com/google/go_intervals)) = v0.0.2 -Provides: bundled(golang(github.com/jinzhu/copier)) = v0.3.2 -Provides: bundled(golang(github.com/mattn/go_runewidth)) = v0.0.13 -Provides: bundled(golang(github.com/Microsoft/hcsshim)) = v0.8.22 -Provides: bundled(golang(github.com/mtrmac/gpgme)) = v0.1.2 -Provides: bundled(golang(github.com/navidys/tvxwidgets)) = v0.1.0 -Provides: bundled(golang(github.com/navidys/vtterm)) = v0.1.0 -Provides: bundled(golang(github.com/ostreedev/ostree_go)) = v0.0.0_20190702140239_759a8c1ac913 -Provides: bundled(golang(github.com/rivo/tview)) = v0.0.0_20220106183741_90d72bc664f5 -Provides: bundled(golang(github.com/vbauerster/mpb/v7)) = v7.1.5 -Provides: bundled(golang(github.com/VividCortex/ewma)) = v1.2.0 -Provides: bundled(golang(github.com/beorn7/perks)) = v1.0.1 %description %{common_description} %prep -%goprep +%goprep %{?with_bundledc:-k} +%if %{with bundled} +%setup -q -T -D -a 1 -n %{name}-%{version} +%endif -mkdir _depbundle -pushd _depbundle -/usr/bin/gzip -dc %{SOURCE0} | /usr/bin/tar -xof - -/usr/bin/chmod -Rf a+rX,u+w,g-w,o-w . -%{__install} -m 0755 -vd %{gobuilddir}/src/github.com/ -%{__install} -m 0755 -vd %{gobuilddir}/src/github.com/vbauerster/mpb/ -%{__install} -m 0755 -vd %{gobuilddir}/src/github.com/rivo -%{__install} -m 0755 -vd %{gobuilddir}/src/github.com/ostreedev -%{__install} -m 0755 -vd %{gobuilddir}/src/github.com/disiqueira/gotree -%{__install} -m 0755 -vd %{gobuilddir}/src/github.com/navidys -%{__install} -m 0755 -vd %{gobuilddir}/src/github.com/mtrmac -%{__install} -m 0755 -vd %{gobuilddir}/src/github.com/Microsoft -%{__install} -m 0755 -vd %{gobuilddir}/src/github.com/mattn -%{__install} -m 0755 -vd %{gobuilddir}/src/github.com/jinzhu -%{__install} -m 0755 -vd %{gobuilddir}/src/github.com/disiqueira/gotree -%{__install} -m 0755 -vd %{gobuilddir}/src/github.com/containers -%{__install} -m 0755 -vd %{gobuilddir}/src/github.com/cri-o -%{__install} -m 0755 -vd %{gobuilddir}/src/github.com/containerd/stargz-snapshotter -%{__install} -m 0755 -vd %{gobuilddir}/src/github.com/google -%{__install} -m 0755 -vd %{gobuilddir}/src/github.com/gdamore -%{__install} -m 0755 -vd %{gobuilddir}/src/github.com/beorn7 - -# copy required bundled libraries -%{__cp} -rp %{goname}-%{version}/vendor/github.com/VividCortex %{gobuilddir}/src/github.com/ -%{__cp} -rp %{goname}-%{version}/vendor/github.com/vbauerster/mpb/v7 %{gobuilddir}/src/github.com/vbauerster/mpb/ -%{__cp} -rp %{goname}-%{version}/vendor/github.com/rivo/tview %{gobuilddir}/src/github.com/rivo/ -%{__cp} -rp %{goname}-%{version}/vendor/github.com/ostreedev/ostree-go %{gobuilddir}/src/github.com/ostreedev/ -%{__cp} -rp %{goname}-%{version}/vendor/github.com/navidys/tvxwidgets %{gobuilddir}/src/github.com/navidys/ -%{__cp} -rp %{goname}-%{version}/vendor/github.com/navidys/vtterm %{gobuilddir}/src/github.com/navidys/ -%{__cp} -rp %{goname}-%{version}/vendor/github.com/mtrmac/gpgme %{gobuilddir}/src/github.com/mtrmac/ -%{__cp} -rp %{goname}-%{version}/vendor/github.com/Microsoft/hcsshim %{gobuilddir}/src/github.com/Microsoft/ -%{__cp} -rp %{goname}-%{version}/vendor/github.com/Microsoft/go-winio %{gobuilddir}/src/github.com/Microsoft/ -%{__cp} -rp %{goname}-%{version}/vendor/github.com/mattn/go-runewidth %{gobuilddir}/src/github.com/mattn/ -%{__cp} -rp %{goname}-%{version}/vendor/github.com/jinzhu/copier %{gobuilddir}/src/github.com/jinzhu/ -%{__cp} -rp %{goname}-%{version}/vendor/github.com/google/go-intervals %{gobuilddir}/src/github.com/google/ -%{__cp} -rp %{goname}-%{version}/vendor/github.com/gdamore/tcell %{gobuilddir}/src/github.com/gdamore/ -%{__cp} -rp %{goname}-%{version}/vendor/github.com/disiqueira/gotree/v3 %{gobuilddir}/src/github.com/disiqueira/gotree/ -%{__cp} -rp %{goname}-%{version}/vendor/github.com/containers/storage %{gobuilddir}/src/github.com/containers/ -%{__cp} -rp %{goname}-%{version}/vendor/github.com/containers/psgo %{gobuilddir}/src/github.com/containers/ -%{__cp} -rp %{goname}-%{version}/vendor/github.com/containers/ocicrypt %{gobuilddir}/src/github.com/containers/ -%{__cp} -rp %{goname}-%{version}/vendor/github.com/containers/libtrust %{gobuilddir}/src/github.com/containers/ -%{__cp} -rp %{goname}-%{version}/vendor/github.com/containers/image %{gobuilddir}/src/github.com/containers/ -%{__cp} -rp %{goname}-%{version}/vendor/github.com/containers/common %{gobuilddir}/src/github.com/containers/ -%{__cp} -rp %{goname}-%{version}/vendor/github.com/containers/buildah %{gobuilddir}/src/github.com/containers/ -%{__cp} -rp %{goname}-%{version}/vendor/github.com/containers/podman %{gobuilddir}/src/github.com/containers/ -%{__cp} -rp %{goname}-%{version}/vendor/github.com/cri-o/ocicni %{gobuilddir}/src/github.com/cri-o/ -%{__cp} -rp %{goname}-%{version}/vendor/github.com/containerd/containerd %{gobuilddir}/src/github.com/containerd/ -%{__cp} -rp %{goname}-%{version}/vendor/github.com/beorn7/perks %{gobuilddir}/src/github.com/beorn7/ - -popd -%{_bindir}/rm -rf _depbundle +%if %{without bundled} +%generate_buildrequires +%go_generate_buildrequires +%endif %build -%gobuild -o %{gobuilddir}/bin/%{goname} %{goipath}/ +%if %{with bundled} +export GOFLAGS="-mod=vendor" +%endif + +export BUILDTAGS="exclude_graphdriver_devicemapper exclude_graphdriver_btrfs btrfs_noversion containers_image_openpgp remote" +%if 0%{?rhel} +export BUILDTAGS="$BUILDTAGS libtrust_openssl" +%endif + +export CGO_LDFLAGS="${CGO_LDFLAGS} -Wl,--allow-multiple-definition" +%gobuild -o %{gobuilddir}/bin/%{goname} %{goipath} %install %{__install} -m 0755 -vd %{buildroot}%{_bindir} %{__install} -m 0755 -vp %{gobuilddir}/bin/* %{buildroot}%{_bindir}/ -%if 0%{?with_check} +%if %{with check} %check -%gocheck %endif %files @@ -227,4 +96,4 @@ popd %{_bindir}/* %changelog -%autochangelog \ No newline at end of file +%autochangelog diff --git a/sources b/sources index 6639838..94f983f 100644 --- a/sources +++ b/sources @@ -1 +1,2 @@ -SHA512 (podman-tui-0.2.0.tar.gz) = ce3d49a7c648dfd7d64b1f5ed6a9517befd9910d02f33f5cf72eb86319a4ed5c579ac1b13d13e3122b9e7ba1948d5f0e33b97e55fc2204f5ba6c2acce3f6e2f8 +SHA512 (podman-tui-1.10.0.tar.gz) = 55604933d2f4f285b24473eca3738f89f943424da1e5d9161a6cef3f4a9aa9c316467f2eb982866b47132eff7ed6abf06a0e34fed2f04c4bf345507e4d040390 +SHA512 (vendor-1.10.0.tar.gz) = 2c30cb295c0f69ea1717646ce9bbfc7fb782006caf48f710da9448daf4f86276a972fae3a5152579582d4328b4dd84eed58292a64a47c17ba5069a4b289045f8