build deb packages using debbuild

Signed-off-by: Lokesh Mandvekar <lsm5@fedoraproject.org>
This commit is contained in:
Lokesh Mandvekar 2022-05-18 15:16:30 -04:00
parent 8d5f758a1d
commit b98b56cfd4

View File

@ -1,3 +1,7 @@
%if "%{_vendor}" == "debbuild"
%define gobuild(o:) GO111MODULE=off go build -buildmode pie -tags=" ${BUILDTAGS:-}" -a -v -x %{?**};
%endif
%global with_debug 1 %global with_debug 1
%if 0%{?with_debug} %if 0%{?with_debug}
@ -21,7 +25,6 @@
%global import_path_plugins %{provider}.%{provider_tld}/%{project}/%{repo_plugins} %global import_path_plugins %{provider}.%{provider_tld}/%{project}/%{repo_plugins}
%global git_plugins https://%{import_path_plugins} %global git_plugins https://%{import_path_plugins}
%global commit_plugins 18822f9a4fb35d1349eb256f4cd2bfd372474d84 %global commit_plugins 18822f9a4fb35d1349eb256f4cd2bfd372474d84
%global shortcommit_plugins %(c=%{commit_plugins}; echo ${c:0:7})
# gvproxy # gvproxy
%global repo_gvproxy gvisor-tap-vsock %global repo_gvproxy gvisor-tap-vsock
@ -29,34 +32,53 @@
%global import_path_gvproxy %%{provider}.%{provider_tld}/%{project}/%{repo_gvproxy} %global import_path_gvproxy %%{provider}.%{provider_tld}/%{project}/%{repo_gvproxy}
%global git_gvproxy https://%{import_path_gvproxy} %global git_gvproxy https://%{import_path_gvproxy}
%global commit_gvproxy 4ee84d66bd86668f011733d8873989b5862bcd07 %global commit_gvproxy 4ee84d66bd86668f011733d8873989b5862bcd07
%global shortcommit_gvproxy %(c=%{commit_gvproxy}; echo ${c:0:7})
%global built_tag v4.1.0 %global built_tag v4.1.0
%global built_tag_strip %(b=%{built_tag}; echo ${b:1})
%global gen_version %(b=%{built_tag_strip}; echo ${b/-/"~"})
Name: podman Name: podman
Epoch: 3 Epoch: 3
Version: %{gen_version} Version: 4.1.0
Release: %autorelease %if "%{_vendor}" == "debbuild"
Summary: Manage Pods, Containers and Container Images Maintainer: Lokesh Mandvekar <lsm5@fedoraproject.org>
License: ASL-2.0+
Release: 0%{?dist}
%else
License: ASL 2.0 and BSD and ISC and MIT and MPLv2.0 License: ASL 2.0 and BSD and ISC and MIT and MPLv2.0
URL: https://%{name}.io/ Release: %autorelease
ExclusiveArch: %{golang_arches} ExclusiveArch: %{golang_arches}
%endif
Summary: Manage Pods, Containers and Container Images
URL: https://%{name}.io/
Source0: %{git0}/archive/%{built_tag}.tar.gz Source0: %{git0}/archive/%{built_tag}.tar.gz
Source1: %{git_plugins}/archive/%{commit_plugins}/%{repo_plugins}-%{shortcommit_plugins}.tar.gz Source1: %{git_plugins}/archive/%{commit_plugins}/%{repo_plugins}-%{commit_plugins}.tar.gz
Source2: %{git_gvproxy}/archive/%{commit_gvproxy}/%{repo_gvproxy}-%{shortcommit_gvproxy}.tar.gz Source2: %{git_gvproxy}/archive/%{commit_gvproxy}/%{repo_gvproxy}-%{commit_gvproxy}.tar.gz
Provides: %{name}-manpages = %{epoch}:%{version}-%{release} Provides: %{name}-manpages = %{epoch}:%{version}-%{release}
BuildRequires: go-md2man
BuildRequires: golang
Requires: iptables
Requires: nftables
Recommends: catatonit
%if "%{_vendor}" == "debbuild"
BuildRequires: git
BuildRequires: libassuan-dev
BuildRequires: libglib2.0-dev
BuildRequires: libgpg-error-dev
BuildRequires: libgpgme-dev
BuildRequires: libseccomp-dev
BuildRequires: libsystemd-dev
BuildRequires: pkg-config
Requires: conmon >= 2:2.0.30
Requires: containers-common >= 4:1
Requires: uidmap
%else
%if ! 0%{?centos} %if ! 0%{?centos}
BuildRequires: btrfs-progs-devel BuildRequires: btrfs-progs-devel
%endif %endif
BuildRequires: gcc BuildRequires: gcc
BuildRequires: golang >= 1.16.6
BuildRequires: glib2-devel BuildRequires: glib2-devel
BuildRequires: glibc-devel BuildRequires: glibc-devel
BuildRequires: glibc-static BuildRequires: glibc-static
BuildRequires: git-core BuildRequires: git-core
BuildRequires: go-md2man
%if 0%{?fedora} || 0%{?rhel} >= 9 %if 0%{?fedora} || 0%{?rhel} >= 9
BuildRequires: go-rpm-macros BuildRequires: go-rpm-macros
%endif %endif
@ -73,11 +95,8 @@ BuildRequires: systemd
BuildRequires: systemd-devel BuildRequires: systemd-devel
Requires: conmon >= 2:2.0.30-2 Requires: conmon >= 2:2.0.30-2
Requires: containers-common >= 4:1-46 Requires: containers-common >= 4:1-46
Suggests: containernetworking-plugins >= 0.9.1-1
Requires: netavark >= 1.0.3-1 Requires: netavark >= 1.0.3-1
Requires: iptables Suggests: containernetworking-plugins >= 0.9.1-1
Requires: nftables
Recommends: catatonit
Suggests: qemu-user-static Suggests: qemu-user-static
# vendored libraries # vendored libraries
# awk '{print "Provides: bundled(golang("$1")) = "$2}' go.mod | sort | uniq | sed -e 's/-/_/g' -e '/bundled(golang())/d' -e '/bundled(golang(go\|module\|replace\|require))/d' # awk '{print "Provides: bundled(golang("$1")) = "$2}' go.mod | sort | uniq | sed -e 's/-/_/g' -e '/bundled(golang())/d' -e '/bundled(golang(go\|module\|replace\|require))/d'
@ -141,6 +160,7 @@ Provides: bundled(golang(github.com/uber/jaeger_client_go)) = v2.30.0+incompatib
Provides: bundled(golang(github.com/ulikunitz/xz)) = v0.5.10 Provides: bundled(golang(github.com/ulikunitz/xz)) = v0.5.10
Provides: bundled(golang(github.com/vbauerster/mpb/v7)) = v7.4.1 Provides: bundled(golang(github.com/vbauerster/mpb/v7)) = v7.4.1
Provides: bundled(golang(github.com/vishvananda/netlink)) = v1.1.1_0.20220115184804_dd687eb2f2d4 Provides: bundled(golang(github.com/vishvananda/netlink)) = v1.1.1_0.20220115184804_dd687eb2f2d4
%endif
%description %description
%{name} (Pod Manager) is a fully featured container engine that is a simple %{name} (Pod Manager) is a fully featured container engine that is a simple
@ -227,7 +247,7 @@ gvisor-tap-vsock brings a configurable DNS server and
dynamic port forwarding. dynamic port forwarding.
%prep %prep
%autosetup -Sgit -n %{name}-%{built_tag_strip} %autosetup -Sgit
sed -i 's;@@PODMAN@@\;$(BINDIR);@@PODMAN@@\;%{_bindir};' Makefile sed -i 's;@@PODMAN@@\;$(BINDIR);@@PODMAN@@\;%{_bindir};' Makefile
# untar dnsname # untar dnsname
@ -237,9 +257,8 @@ tar zxf %{SOURCE1}
tar zxf %{SOURCE2} tar zxf %{SOURCE2}
%build %build
%if "%{_vendor}" != "debbuild"
%set_build_flags %set_build_flags
export GO111MODULE=off
export GOPATH=$(pwd)/_build:$(pwd)
export CGO_CFLAGS=$CFLAGS export CGO_CFLAGS=$CFLAGS
# These extra flags present in $CFLAGS have been skipped for now as they break the build # These extra flags present in $CFLAGS have been skipped for now as they break the build
CGO_CFLAGS=$(echo $CGO_CFLAGS | sed 's/-flto=auto//g') CGO_CFLAGS=$(echo $CGO_CFLAGS | sed 's/-flto=auto//g')
@ -249,12 +268,16 @@ CGO_CFLAGS=$(echo $CGO_CFLAGS | sed 's/-specs=\/usr\/lib\/rpm\/redhat\/redhat-an
%ifarch x86_64 %ifarch x86_64
export CGO_CFLAGS+=" -m64 -mtune=generic -fcf-protection=full" export CGO_CFLAGS+=" -m64 -mtune=generic -fcf-protection=full"
%endif %endif
%endif
export GO111MODULE=off
export GOPATH=$(pwd)/_build:$(pwd)
mkdir _build mkdir _build
pushd _build cd _build
mkdir -p src/%{provider}.%{provider_tld}/%{project} mkdir -p src/%{provider}.%{provider_tld}/%{project}
ln -s ../../../../ src/%{import_path} ln -s ../../../../ src/%{import_path}
popd cd ..
ln -s vendor src ln -s vendor src
# build date. FIXME: Makefile uses '/v2/libpod', that doesn't work here? # build date. FIXME: Makefile uses '/v2/libpod', that doesn't work here?
@ -269,30 +292,30 @@ export BUILDTAGS="seccomp exclude_graphdriver_devicemapper $(hack/btrfs_installe
%gobuild -o bin/%{name} %{import_path}/cmd/%{name} %gobuild -o bin/%{name} %{import_path}/cmd/%{name}
# build %%{name}-remote # build %%{name}-remote
export BUILDTAGS+=" exclude_graphdriver_btrfs btrfs_noversion remote" export BUILDTAGS="seccomp exclude_graphdriver_devicemapper exclude_graphdriver_btrfs btrfs_noversion $(hack/selinux_tag.sh) $(hack/systemd_tag.sh) $(hack/libsubid_tag.sh) remote"
%gobuild -o bin/%{name}-remote %{import_path}/cmd/%{name} %gobuild -o bin/%{name}-remote %{import_path}/cmd/%{name}
pushd %{repo_plugins}-%{commit_plugins} cd %{repo_plugins}-%{commit_plugins}
mkdir _build mkdir _build
pushd _build cd _build
mkdir -p src/%{provider}.%{provider_tld}/%{project} mkdir -p src/%{provider}.%{provider_tld}/%{project}
ln -s ../../../../ src/%{import_path_plugins} ln -s ../../../../ src/%{import_path_plugins}
popd cd ..
ln -s vendor src ln -s vendor src
export GOPATH=$(pwd)/_build:$(pwd) export GOPATH=$(pwd)/_build:$(pwd)
%gobuild -o bin/dnsname %{import_path_plugins}/plugins/meta/dnsname %gobuild -o bin/dnsname %{import_path_plugins}/plugins/meta/dnsname
popd cd ..
pushd %{repo_gvproxy}-%{commit_gvproxy} cd %{repo_gvproxy}-%{commit_gvproxy}
mkdir _build mkdir _build
pushd _build cd _build
mkdir -p src/%{provider}.%{provider_tld}/%{project} mkdir -p src/%{provider}.%{provider_tld}/%{project}
ln -s ../../../../ src/%{import_path_gvproxy} ln -s ../../../../ src/%{import_path_gvproxy}
popd cd ..
ln -s vendor src ln -s vendor src
export GOPATH=$(pwd)/_build:$(pwd) export GOPATH=$(pwd)/_build:$(pwd)
%gobuild -o bin/gvproxy %{import_path_gvproxy}/cmd/gvproxy %gobuild -o bin/gvproxy %{import_path_gvproxy}/cmd/gvproxy
popd cd ..
%{__make} docs docker-docs %{__make} docs docker-docs
@ -313,15 +336,15 @@ PODMAN_VERSION=%{version} %{__make} PREFIX=%{buildroot}%{_prefix} ETCDIR=%{build
mv pkg/hooks/README.md pkg/hooks/README-hooks.md mv pkg/hooks/README.md pkg/hooks/README-hooks.md
# install dnsname plugin # install dnsname plugin
pushd %{repo_plugins}-%{commit_plugins} cd %{repo_plugins}-%{commit_plugins}
%{__make} PREFIX=%{_prefix} DESTDIR=%{buildroot} install %{__make} PREFIX=%{_prefix} DESTDIR=%{buildroot} install
popd cd ..
# install gvproxy # install gvproxy
pushd %{repo_gvproxy}-%{commit_gvproxy} cd %{repo_gvproxy}-%{commit_gvproxy}
install -dp %{buildroot}%{_libexecdir}/%{name} install -dp %{buildroot}%{_libexecdir}/%{name}
install -p -m0755 bin/gvproxy %{buildroot}%{_libexecdir}/%{name} install -p -m0755 bin/gvproxy %{buildroot}%{_libexecdir}/%{name}
popd cd ..
# do not include docker and podman-remote man pages in main package # do not include docker and podman-remote man pages in main package
for file in `find %{buildroot}%{_mandir}/man[15] -type f | sed "s,%{buildroot},," | grep -v -e remote -e docker`; do for file in `find %{buildroot}%{_mandir}/man[15] -type f | sed "s,%{buildroot},," | grep -v -e remote -e docker`; do