Skip to content

Commit f95dc3b

Browse files
author
Matt Rogers
committed
Revise build spec for CD
1 parent 86f2c80 commit f95dc3b

File tree

1 file changed

+39
-23
lines changed

1 file changed

+39
-23
lines changed

oauth-proxy.spec

+39-23
Original file line numberDiff line numberDiff line change
@@ -1,47 +1,63 @@
1-
%global debug_package %{nil}
1+
# /!\ This file is maintained at https://github.com/openshift/oauth-proxy
2+
%global debug_package %{nil}
23
%global snapshot 1
34

45
%if ! 0%{?gobuild:1}
56
%define gobuild(o:) go build -ldflags "${LDFLAGS:-} -B 0x$(head -c20 /dev/urandom|od -An -tx1|tr -d ' \\n')" -a -v -x %{?**};
67
%endif
78

8-
%global provider github
9-
%global provider_tld com
10-
%global project openshift
11-
%global repo oauth-proxy
12-
# github.com/openshift/oauth-proxy
13-
%global provider_prefix %{provider}.%{provider_tld}/%{project}/%{repo}
14-
%global import_path %{provider_prefix}
15-
%global build_gopath %{_builddir}/%{repo}-gopath
16-
%global source https://%{provider_prefix}/archive/%{repo}
17-
18-
Name: golang-%{provider}-%{project}-%{repo}
19-
Version: 2.3
20-
Release: 1.%{?dist}
9+
%global provider github
10+
%global provider_tld com
11+
%global project openshift
12+
%global repo oauth-proxy
13+
# https://github.com/openshift/oauth-proxy
14+
%global provider_prefix %{provider}.%{provider_tld}/%{project}/%{repo}
15+
%global import_path %{provider_prefix}
16+
# %commit is intended to be set by tito. The values in this spec file will not be kept up to date.
17+
%{!?commit:
18+
%global commit 57b6863264c89307830fccadf2f122e5cea3d2a0
19+
}
20+
%global shortcommit %(c=%{commit}; echo ${c:0:7})
21+
%global gopathdir %{_sourcedir}/go
22+
%global upstream_ver 2.3
23+
%global rpm_ver %(v=%{upstream_ver}; echo ${v//-/_})
24+
%global download_prefix %{provider}.%{provider_tld}/openshift/%{repo}
25+
26+
Name: golang-%{provider}-%{project}-%{repo}
27+
# Version and release information will be automatically managed by CD
28+
# It will be kept in sync with OCP builds.
29+
Version: %{rpm_ver}
30+
Release: 1.git%{shortcommit}%{?dist}
2131
Summary: A reverse proxy that provides authentication with OpenShift and other OAuth providers
2232
License: MIT
23-
URL: https://%{provider}.%{provider_tld}/%{project}/%{repo}
24-
Source0: ${source}.tar.gz
33+
URL: https://%{provider}.%{provider_tld}/%{project}/%{repo}
34+
Source0: https://%{download_prefix}/archive/%{commit}/%{repo}-%{commit}.tar.gz
2535

2636
# e.g. el6 has ppc64 arch without gcc-go, so EA tag is required
2737
ExclusiveArch: %{?go_arches:%{go_arches}}%{!?go_arches:%{ix86} x86_64 aarch64 %{arm} ppc64le s390x}
28-
BuildRequires: %{?go_compiler:compiler(go-compiler)}%{!?go_compiler:golang}
38+
# If go_compiler is not set to 1, there is no virtual provide. Use golang instead.
39+
BuildRequires: %{?go_compiler:compiler(go-compiler)}%{!?go_compiler:golang}
2940

30-
Provides: %{repo} = %{version}-%{release}
41+
Provides: %{repo} = %{version}-%{release}
3142

3243
%description
3344
%{summary}
3445

3546
%prep
36-
%setup -q -n %{source}
47+
%setup -q -n %{repo}-%{commit}
3748

3849
%build
39-
mkdir -p %{build_gopath}/src/%{provider}.%{provider_tld}/%{project}
40-
ln -s %{_builddir}/%{source} %{build_gopath}/src/%{import_path}
50+
# Go expects a full path to the sources which is not included in the source
51+
# tarball so create a link with the expected path
52+
mkdir -p %{gopathdir}/src/%{provider}.%{provider_tld}/%{project}
53+
GOSRCDIR=%{gopathdir}/src/%{import_path}
54+
if [ ! -e "$GOSRCDIR" ]; then
55+
ln -s `pwd` "$GOSRCDIR"
56+
fi
57+
export GOPATH=%{gopathdir}
4158

4259
# Ensure the default GOBIN is used ${GOPATH}/bin
43-
unset GOBIN
44-
export GOPATH=%{build_gopath}
60+
# unset GOBIN // needed?
4561
export LDFLAGS='-s -w'
4662
%gobuild %{import_path}
4763

0 commit comments

Comments
 (0)