| 1 | %global with_debug 1 |
| 2 | |
| 3 | %if 0%{?with_debug} |
| 4 | %global _find_debuginfo_dwz_opts %{nil} |
| 5 | %global _dwz_low_mem_die_limit 0 |
| 6 | %else |
| 7 | %global debug_package %{nil} |
| 8 | %endif |
| 9 | |
| 10 | %global gomodulesmode GO111MODULE=on |
| 11 | |
| 12 | %global _gvisor_installdir %{_libexecdir}/podman |
| 13 | |
| 14 | %global desc_gvforwarder Forward traffic from a tap interface over vsock |
| 15 | |
| 16 | Name: gvisor-tap-vsock |
| 17 | %if %{defined copr_username} |
| 18 | Epoch: 103 |
| 19 | %else |
| 20 | Epoch: 6 |
| 21 | %endif |
| 22 | # DO NOT TOUCH the Version string! |
| 23 | # The TRUE source of this specfile is: |
| 24 | # https://github.com/containers/podman/blob/main/rpm/podman.spec |
| 25 | # If that's what you're reading, Version must be 0, and will be updated by Packit for |
| 26 | # copr and koji builds. |
| 27 | # If you're reading this on dist-git, the version is automatically filled in by Packit. |
| 28 | Version: 0 |
| 29 | License: Apache-2.0 AND BSD-2-Clause AND BSD-3-Clause AND MIT |
| 30 | %if %{defined autorelease} |
| 31 | Release: %autorelease |
| 32 | %else |
| 33 | Release: 1 |
| 34 | %endif |
| 35 | %if %{defined golang_arches_future} |
| 36 | ExclusiveArch: %{golang_arches_future} |
| 37 | %else |
| 38 | ExclusiveArch: aarch64 ppc64le s390x x86_64 |
| 39 | %endif |
| 40 | Summary: Go replacement for libslirp and VPNKit |
| 41 | URL: https://github.com/containers/%{name} |
| 42 | # All SourceN files fetched from upstream |
| 43 | Source0: %{url}/archive/refs/tags/v%{version}.tar.gz |
| 44 | BuildRequires: gcc |
| 45 | BuildRequires: glib2-devel |
| 46 | BuildRequires: glibc-devel |
| 47 | BuildRequires: glibc-static |
| 48 | BuildRequires: golang |
| 49 | BuildRequires: git-core |
| 50 | %if %{defined rhel} && 0%{?rhel} == 8 |
| 51 | BuildRequires: go-srpm-macros |
| 52 | %else |
| 53 | BuildRequires: go-rpm-macros |
| 54 | %endif |
| 55 | BuildRequires: make |
| 56 | %if %{defined copr_username} |
| 57 | Obsoletes: podman-gvproxy < 102:4.7.0-1 |
| 58 | %else |
| 59 | Obsoletes: podman-gvproxy < 5:4.7.0-1 |
| 60 | %endif |
| 61 | Provides: podman-gvproxy = %{epoch}:%{version}-%{release} |
| 62 | Requires: %{name}-gvforwarder = %{epoch}:%{version}-%{release} |
| 63 | |
| 64 | %description |
| 65 | A replacement for libslirp and VPNKit, written in pure Go. |
| 66 | It is based on the network stack of gVisor. Compared to libslirp, |
| 67 | gvisor-tap-vsock brings a configurable DNS server and |
| 68 | dynamic port forwarding. |
| 69 | |
| 70 | %package gvforwarder |
| 71 | Summary: %{desc_gvforwarder} |
| 72 | Provides: gvforwarder = %{epoch}:%{version}-%{release} |
| 73 | Obsoletes: %{name} < 6:0.7.0-6 |
| 74 | Recommends: %{name} = %{epoch}:%{version}-%{release} |
| 75 | |
| 76 | %description gvforwarder |
| 77 | %{desc_gvforwarder} |
| 78 | |
| 79 | %prep |
| 80 | %autosetup -Sgit -n %{name}-%{version} |
| 81 | |
| 82 | %build |
| 83 | %set_build_flags |
| 84 | export CGO_CFLAGS=$CFLAGS |
| 85 | |
| 86 | # These extra flags present in $CFLAGS have been skipped for now as they break the build |
| 87 | CGO_CFLAGS=$(echo $CGO_CFLAGS | sed 's/-flto=auto//g') |
| 88 | CGO_CFLAGS=$(echo $CGO_CFLAGS | sed 's/-Wp,D_GLIBCXX_ASSERTIONS//g') |
| 89 | CGO_CFLAGS=$(echo $CGO_CFLAGS | sed 's/-specs=\/usr\/lib\/rpm\/redhat\/redhat-annobin-cc1//g') |
| 90 | |
| 91 | %ifarch x86_64 |
| 92 | export CGO_CFLAGS+=" -m64 -mtune=generic -fcf-protection=full" |
| 93 | %endif |
| 94 | |
| 95 | # reset LDFLAGS for plugins and gvisor binaries |
| 96 | LDFLAGS='' |
| 97 | |
| 98 | # build gvisor-tap-vsock binaries |
| 99 | %gobuild -o bin/gvproxy ./cmd/gvproxy |
| 100 | %gobuild -o bin/gvforwarder ./cmd/vm |
| 101 | |
| 102 | %install |
| 103 | # install gvproxy |
| 104 | install -dp %{buildroot}%{_gvisor_installdir} |
| 105 | install -p -m0755 bin/gvproxy %{buildroot}%{_gvisor_installdir} |
| 106 | install -p -m0755 bin/gvforwarder %{buildroot}%{_gvisor_installdir} |
| 107 | |
| 108 | #define license tag if not already defined |
| 109 | %{!?_licensedir:%global license %doc} |
| 110 | |
| 111 | %files |
| 112 | %license LICENSE |
| 113 | %doc README.md |
| 114 | %dir %{_gvisor_installdir} |
| 115 | %{_gvisor_installdir}/gvproxy |
| 116 | |
| 117 | %files gvforwarder |
| 118 | %dir %{_gvisor_installdir} |
| 119 | %{_gvisor_installdir}/gvforwarder |
| 120 | |
| 121 | %changelog |
| 122 | %if %{defined autochangelog} |
| 123 | %autochangelog |
| 124 | %else |
| 125 | * Mon Jul 24 2023 RH Container Bot <[email protected]> |
| 126 | - Placeholder changelog for envs that are not autochangelog-ready |
| 127 | %endif |