-
Notifications
You must be signed in to change notification settings - Fork 381
/
oc.spec
163 lines (137 loc) · 4.67 KB
/
oc.spec
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
#debuginfo not supported with Go
%global debug_package %{nil}
# modifying the Go binaries breaks the DWARF debugging
%global __os_install_post %{_rpmconfigdir}/brp-compress
%global gopath %{_datadir}/gocode
%global import_path github.com/openshift/oc
%global golang_version 1.13
%{!?version: %global version 0.0.1}
%{!?release: %global release 1}
%{!?commit:
# DO NOT MODIFY: the value on the line below is sed-like replaced by openshift/doozer
%global commit e0a5699f2049372633b18c43a98a522999b1f297
}
%if ! 0%{?os_git_vars:1}
# DO NOT MODIFY: the value on the line below is sed-like replaced by openshift/doozer
%global os_git_vars OS_GIT_VERSION='' OS_GIT_COMMIT='' OS_GIT_MAJOR='' OS_GIT_MINOR='' OS_GIT_TREE_STATE=''
%endif
%if "%{os_git_vars}" == "ignore"
%global make make
%else
%global make %{os_git_vars} && make SOURCE_GIT_TAG:="${OS_GIT_VERSION}" SOURCE_GIT_COMMIT:="${OS_GIT_COMMIT}" SOURCE_GIT_MAJOR:="${OS_GIT_MAJOR}" SOURCE_GIT_MINOR:="${OS_GIT_MINOR}" SOURCE_GIT_TREE_STATE:="${OS_GIT_TREE_STATE}"
%endif
Name: openshift-clients
Version: %{version}
Release: %{release}%{dist}
Summary: OpenShift client binaries
License: ASL 2.0
URL: https://%{import_path}
%if ! 0%{?local_build:1}
Source0: https://%{import_path}/archive/%{commit}/%{name}-%{version}.tar.gz
%endif
# If go_arches not defined fall through to implicit golang archs
%if 0%{?go_arches:1}
ExclusiveArch: %{go_arches}
%else
ExclusiveArch: x86_64 aarch64 ppc64le s390x
%endif
BuildRequires: golang >= %{golang_version}
BuildRequires: goversioninfo
BuildRequires: krb5-devel
BuildRequires: rsync
Provides: atomic-openshift-clients = %{version}
Obsoletes: atomic-openshift-clients <= %{version}
Requires: bash-completion
%description
%{summary}
%package redistributable
Summary: OpenShift Client binaries for Linux, Mac OSX, and Windows
Provides: atomic-openshift-clients-redistributable = %{version}
Obsoletes: atomic-openshift-clients-redistributable <= %{version}
%description redistributable
%{summary}
%prep
%if ! 0%{?local_build:1}
%setup -q
%endif
%build
%if ! 0%{?local_build:1}
mkdir -p "$(dirname __gopath/src/%{import_path})"
mkdir -p "$(dirname __gopath/src/%{import_path})"
ln -s "$(pwd)" "__gopath/src/%{import_path}"
export GOPATH=$(pwd)/__gopath:%{gopath}
cd "__gopath/src/%{import_path}"
%endif
%ifarch %{ix86}
GOOS=linux
GOARCH=386
%endif
%ifarch ppc64le
GOOS=linux
GOARCH=ppc64le
%endif
%ifarch %{arm} aarch64
GOOS=linux
GOARCH=arm64
%endif
%ifarch s390x
GOOS=linux
GOARCH=s390x
%endif
%{make} build GO_BUILD_PACKAGES:='./cmd/oc ./tools/genman'
%ifarch x86_64
# Create Binaries for all supported arches
%{make} cross-build-darwin-amd64 cross-build-windows-amd64 GO_BUILD_PACKAGES:='./cmd/oc'
%endif
%install
install -d %{buildroot}%{_bindir}
# Install for the local platform
install -p -m 755 ./oc %{buildroot}%{_bindir}/oc
ln -s ./oc %{buildroot}%{_bindir}/kubectl
[[ -e %{buildroot}%{_bindir}/kubectl ]]
%ifarch x86_64
# Install client executable for windows and mac
install -d %{buildroot}%{_datadir}/%{name}/{linux,macosx,windows}
install -p -m 755 ./oc %{buildroot}%{_datadir}/%{name}/linux/oc
ln -s ./oc %{buildroot}%{_datadir}/%{name}/linux/kubectl
[[ -e %{buildroot}%{_datadir}/%{name}/linux/kubectl ]]
install -p -m 755 ./_output/bin/darwin_amd64/oc %{buildroot}/%{_datadir}/%{name}/macosx/oc
ln -s ./oc %{buildroot}/%{_datadir}/%{name}/macosx/kubectl
[[ -e %{buildroot}/%{_datadir}/%{name}/macosx/kubectl ]]
install -p -m 755 ./_output/bin/windows_amd64/oc.exe %{buildroot}/%{_datadir}/%{name}/windows/oc.exe
ln -s ./oc.exe %{buildroot}/%{_datadir}/%{name}/windows/kubectl.exe
[[ -e %{buildroot}/%{_datadir}/%{name}/windows/kubectl.exe ]]
%endif
# Install man1 man pages
install -d -m 0755 %{buildroot}%{_mandir}/man1
./genman %{buildroot}%{_mandir}/man1 oc
# Install bash completions
install -d -m 755 %{buildroot}%{_sysconfdir}/bash_completion.d/
for bin in oc kubectl
do
echo "+++ INSTALLING BASH COMPLETIONS FOR ${bin} "
%{buildroot}%{_bindir}/${bin} completion bash > %{buildroot}%{_sysconfdir}/bash_completion.d/${bin}
chmod 644 %{buildroot}%{_sysconfdir}/bash_completion.d/${bin}
done
%files
%license LICENSE
%{_bindir}/oc
%{_bindir}/kubectl
%{_sysconfdir}/bash_completion.d/oc
%{_sysconfdir}/bash_completion.d/kubectl
%dir %{_mandir}/man1/
%{_mandir}/man1/oc*
%ifarch x86_64
%files redistributable
%license LICENSE
%dir %{_datadir}/%{name}/linux/
%dir %{_datadir}/%{name}/macosx/
%dir %{_datadir}/%{name}/windows/
%{_datadir}/%{name}/linux/oc
%{_datadir}/%{name}/linux/kubectl
%{_datadir}/%{name}/macosx/oc
%{_datadir}/%{name}/macosx/kubectl
%{_datadir}/%{name}/windows/oc.exe
%{_datadir}/%{name}/windows/kubectl.exe
%endif
%changelog