Files
odo/rpms/openshift-odo.spec
Mohammed Ahmed 4305079156 Cleaning up odo rpm spec and scripts (#3904)
* Fixing rpm spec Provides and Obsoletes to be more specific

Signed-off-by: Mohammed Zeeshan Ahmed <mohammed.zee1000@gmail.com>

* Fixing local build script to use dist/rpmbuild and topdir for build

 - This prevents polluting users main rpmbuild

Signed-off-by: Mohammed Zeeshan Ahmed <mohammed.zee1000@gmail.com>

* Setting goflags during `make test` and turning off missing buildid

 - without goflags, unit tests take a while as they dont use vendor
 - providing -mod=vendor does not seem to help
 - missing gnu build ids in go binaries can cause warnings

Signed-off-by: Mohammed Zeeshan Ahmed <mohammed.zee1000@gmail.com>

* Removing GOFLAGS from spec and adding build_flags to test target

Signed-off-by: Mohammed Zeeshan Ahmed <mohammed.zee1000@gmail.com>

* Unsetting any goflags for make test in openshift ci

Signed-off-by: Mohammed Zeeshan Ahmed <mohammed.zee1000@gmail.com>

* Removing the set +x from local build script

Signed-off-by: Mohammed Zeeshan Ahmed <mohammed.zee1000@gmail.com>

* Adding rpm tests

Signed-off-by: Mohammed Zeeshan Ahmed <mohammed.zee1000@gmail.com>

* Removing last rm -rf

Signed-off-by: Mohammed Zeeshan Ahmed <mohammed.zee1000@gmail.com>

* Reverting to explicitly setting GOFLAGS for make test

 - It appears that while `-mod=vendor` flag is available for `go test`
   it is sometimes not respected
 - It is therefore, better to just set GOFLAGS only for make test
 - More investigation is needed to find better solution, but we should
   not break stuff relation to testing and release, where we should not
   be pulling from outside world

Signed-off-by: Mohammed Zeeshan Ahmed <mohammed.zee1000@gmail.com>

* Cleaning up rpm-prepare

Signed-off-by: Mohammed Zeeshan Ahmed <mohammed.zee1000@gmail.com>

* Removing unnessasary newline

Signed-off-by: Mohammed Zeeshan Ahmed <mohammed.zee1000@gmail.com>

* Adding version file to spec for any future automation to have easier time

Signed-off-by: Mohammed Zeeshan Ahmed <mohammed.zee1000@gmail.com>
2020-09-10 11:55:19 -04:00

96 lines
4.0 KiB
RPMSpec

#this is a template spec and actual spec will be generated
#debuginfo not supported with Go
%global debug_package %{nil}
%global package_name odo
%global product_name odo
%global golang_version ${GOLANG_VERSION}
%global golang_version_nodot ${GOLANG_VERSION_NODOT}
%global odo_version ${ODO_RPM_VERSION}
%global odo_release ${ODO_RELEASE}
%global git_commit ${GIT_COMMIT}
%global odo_cli_version v%{odo_version}
%global source_dir openshift-odo-%{odo_version}-%{odo_release}
%global source_tar %{source_dir}.tar.gz
%global gopath %{_builddir}/gocode
%global _missing_build_ids_terminate_build 0
Name: %{package_name}
Version: %{odo_version}
Release: %{odo_release}%{?dist}
Summary: %{product_name} client odo CLI binary
License: ASL 2.0
URL: https://github.com/openshift/odo/tree/%{odo_cli_version}
Source0: %{source_tar}
BuildRequires: gcc
BuildRequires: golang >= %{golang_version}
Provides: %{package_name} = %{odo_version}
Obsoletes: %{package_name} <= %{odo_version}
%description
odo is a fast, iterative, and straightforward CLI tool for developers who write, build, and deploy applications on OpenShift.
%prep
%setup -q -n %{source_dir}
%build
export GITCOMMIT="%{git_commit}"
mkdir -p %{gopath}/src/github.com/openshift
ln -s "$(pwd)" %{gopath}/src/github.com/openshift/odo
export GOPATH=%{gopath}
cd %{gopath}/src/github.com/openshift/odo
%ifarch x86_64
# go test -race is not supported on all arches
GOFLAGS='-mod=vendor' make test
%endif
make prepare-release
echo "%{odo_version}" > dist/release/VERSION
unlink %{gopath}/src/github.com/openshift/odo
%install
mkdir -p %{buildroot}/%{_bindir}
install -m 0755 dist/bin/linux-`go env GOARCH`/odo %{buildroot}%{_bindir}/odo
mkdir -p %{buildroot}%{_datadir}
install -d %{buildroot}%{_datadir}/%{name}-redistributable
install -p -m 755 dist/release/odo-linux-amd64 %{buildroot}%{_datadir}/%{name}-redistributable/odo-linux-amd64
install -p -m 755 dist/release/odo-linux-arm64 %{buildroot}%{_datadir}/%{name}-redistributable/odo-linux-arm64
install -p -m 755 dist/release/odo-linux-ppc64le %{buildroot}%{_datadir}/%{name}-redistributable/odo-linux-ppc64le
install -p -m 755 dist/release/odo-linux-s390x %{buildroot}%{_datadir}/%{name}-redistributable/odo-linux-s390x
install -p -m 755 dist/release/odo-darwin-amd64 %{buildroot}%{_datadir}/%{name}-redistributable/odo-darwin-amd64
install -p -m 755 dist/release/odo-windows-amd64.exe %{buildroot}%{_datadir}/%{name}-redistributable/odo-windows-amd64.exe
cp -avrf dist/release/odo*.tar.gz %{buildroot}%{_datadir}/%{name}-redistributable
cp -avrf dist/release/SHA256_SUM %{buildroot}%{_datadir}/%{name}-redistributable
cp -avrf dist/release/VERSION %{buildroot}%{_datadir}/%{name}-redistributable
%files
%license LICENSE
%{_bindir}/odo
%package redistributable
Summary: %{product_name} client CLI binaries for Linux, macOS and Windows
BuildRequires: gcc
BuildRequires: golang >= %{golang_version}
Provides: %{package_name}-redistributable = %{odo_version}
Obsoletes: %{package_name}-redistributable <= %{odo_version}
%description redistributable
%{product_name} client odo cross platform binaries for Linux, macOS and Windows.
%files redistributable
%license LICENSE
%dir %{_datadir}/%{name}-redistributable
%{_datadir}/%{name}-redistributable/odo-linux-amd64
%{_datadir}/%{name}-redistributable/odo-linux-amd64.tar.gz
%{_datadir}/%{name}-redistributable/odo-linux-arm64
%{_datadir}/%{name}-redistributable/odo-linux-arm64.tar.gz
%{_datadir}/%{name}-redistributable/odo-linux-ppc64le
%{_datadir}/%{name}-redistributable/odo-linux-ppc64le.tar.gz
%{_datadir}/%{name}-redistributable/odo-linux-s390x
%{_datadir}/%{name}-redistributable/odo-linux-s390x.tar.gz
%{_datadir}/%{name}-redistributable/odo-darwin-amd64
%{_datadir}/%{name}-redistributable/odo-darwin-amd64.tar.gz
%{_datadir}/%{name}-redistributable/odo-windows-amd64.exe
%{_datadir}/%{name}-redistributable/odo-windows-amd64.exe.tar.gz
%{_datadir}/%{name}-redistributable/SHA256_SUM
%{_datadir}/%{name}-redistributable/VERSION