%if 0%{?fedora} || 0%{?rhel} == 6 %global with_devel 1 %global with_bundled 1 %global with_debug 1 %global with_check 1 %global with_unit_test 1 %else %global with_devel 0 %global with_bundled 1 %global with_debug 0 %global with_check 0 %global with_unit_test 0 %endif %if 0%{?with_debug} %global _dwz_low_mem_die_limit 0 %else %global debug_package %{nil} %endif %if ! 0%{?gobuild:1} %define gobuild(o:) go build -ldflags "${LDFLAGS:-} -B 0x$(head -c20 /dev/urandom|od -An -tx1|tr -d ' \\n')" -a -v -x %{?**}; %endif %global provider github %global provider_tld com %global project openshift %global repo source-to-image # https://github.com/openshift/source-to-image %global provider_prefix %{provider}.%{provider_tld}/%{project}/%{repo} %global import_path %{provider_prefix} %global commit 00d1cb3cb9224bb59c0a37bb2bdd0100e20e1982 %global shortcommit %(c=%{commit}; echo ${c:0:7}) %global majorFromGit 1 %global minorFromGit 0+ %global versionFromGit v1.0.2 %global commitFromGit %{commit} Name: %{repo} Version: 1.0.2 Release: 4%{?dist} Summary: A tool for building artifacts from source and injecting into docker images License: ASL 2.0 URL: https://%{provider_prefix} Source0: https://%{provider_prefix}/archive/v%{version}.tar.gz # e.g. el6 has ppc64 arch without gcc-go, so EA tag is required ExclusiveArch: %{?go_arches:%{go_arches}}%{!?go_arches:%{ix86} x86_64 %{arm}} # If go_compiler is not set to 1, there is no virtual provide. Use golang instead. BuildRequires: %{?go_compiler:compiler(go-compiler)}%{!?go_compiler:golang} %if ! 0%{?with_bundled} BuildRequires: golang(github.com/docker/docker/builder/parser) BuildRequires: golang(github.com/fsouza/go-dockerclient) BuildRequires: golang(github.com/golang/glog) BuildRequires: golang(github.com/spf13/cobra) BuildRequires: golang(github.com/spf13/pflag) %endif Requires: docker Requires: git Requires: tar %description %{summary} %if 0%{?with_devel} %package devel Summary: %{summary} BuildArch: noarch %if 0%{?with_check} BuildRequires: golang(github.com/docker/docker/builder/parser) BuildRequires: golang(github.com/fsouza/go-dockerclient) BuildRequires: golang(github.com/golang/glog) BuildRequires: golang(github.com/spf13/cobra) BuildRequires: golang(github.com/spf13/pflag) %endif Requires: golang(github.com/docker/docker/builder/parser) Requires: golang(github.com/fsouza/go-dockerclient) Requires: golang(github.com/golang/glog) Requires: golang(github.com/spf13/cobra) Requires: golang(github.com/spf13/pflag) Provides: golang(%{import_path}) = %{version}-%{release} Provides: golang(%{import_path}/pkg/api) = %{version}-%{release} Provides: golang(%{import_path}/pkg/api/describe) = %{version}-%{release} Provides: golang(%{import_path}/pkg/api/validation) = %{version}-%{release} Provides: golang(%{import_path}/pkg/build) = %{version}-%{release} Provides: golang(%{import_path}/pkg/build/ignore) = %{version}-%{release} Provides: golang(%{import_path}/pkg/build/strategies) = %{version}-%{release} Provides: golang(%{import_path}/pkg/build/strategies/layered) = %{version}-%{release} Provides: golang(%{import_path}/pkg/build/strategies/onbuild) = %{version}-%{release} Provides: golang(%{import_path}/pkg/build/strategies/sti) = %{version}-%{release} Provides: golang(%{import_path}/pkg/config) = %{version}-%{release} Provides: golang(%{import_path}/pkg/create) = %{version}-%{release} Provides: golang(%{import_path}/pkg/create/templates) = %{version}-%{release} Provides: golang(%{import_path}/pkg/docker) = %{version}-%{release} Provides: golang(%{import_path}/pkg/docker/test) = %{version}-%{release} Provides: golang(%{import_path}/pkg/errors) = %{version}-%{release} Provides: golang(%{import_path}/pkg/git) = %{version}-%{release} Provides: golang(%{import_path}/pkg/ignore) = %{version}-%{release} Provides: golang(%{import_path}/pkg/run) = %{version}-%{release} Provides: golang(%{import_path}/pkg/scripts) = %{version}-%{release} Provides: golang(%{import_path}/pkg/tar) = %{version}-%{release} Provides: golang(%{import_path}/pkg/test) = %{version}-%{release} Provides: golang(%{import_path}/pkg/util) = %{version}-%{release} Provides: golang(%{import_path}/pkg/util/user) = %{version}-%{release} Provides: golang(%{import_path}/pkg/version) = %{version}-%{release} Provides: golang(%{import_path}/test/integration) = %{version}-%{release} %description devel %{summary} This package contains library source intended for building other packages which use import path with %{import_path} prefix. %endif %if 0%{?with_unit_test} && 0%{?with_devel} %package unit-test Summary: Unit tests for %{name} package # If go_compiler is not set to 1, there is no virtual provide. Use golang instead. BuildRequires: %{?go_compiler:compiler(go-compiler)}%{!?go_compiler:golang} %if 0%{?with_check} #Here comes all BuildRequires: PACKAGE the unit tests #in %%check section need for running %endif # test subpackage tests code from devel subpackage Requires: %{name}-devel = %{version}-%{release} %description unit-test %{summary} This package contains unit tests for project providing packages with %{import_path} prefix. %endif %prep %setup -q -n source-to-image-%{version} %build mkdir -p src/github.com/openshift ln -s ../../../ src/github.com/openshift/source-to-image %if ! 0%{?with_bundled} export GOPATH=$(pwd):%{gopath} %else export GOPATH=$(pwd):$(pwd)/Godeps/_workspace:%{gopath} %endif export STI_GIT_MAJOR=1.0 export STI_GIT_MINOR=2 export STI_GIT_VERSION=%{commit} export LDFLAGS="-X majorFromGit=%{majorFromGit} -X minorFromGit=%{minorFromGit} -X versionFromGit=%{versionFromGit} -X commitFromGit=%{commitFromGit}" go build -a -v -x -o bin/s2i %{import_path}/cmd/s2i %install install -d -p %{buildroot}%{_bindir} install -p -m 0755 bin/s2i %{buildroot}%{_bindir} # source codes for building projects %if 0%{?with_devel} install -d -p %{buildroot}/%{gopath}/src/%{import_path}/ echo "%%dir %%{gopath}/src/%%{import_path}/." >> devel.file-list # find all *.go but no *_test.go files and generate devel.file-list for file in $(find . -iname "*.go" \! -iname "*_test.go" | grep -v "./Godeps") ; do echo "%%dir %%{gopath}/src/%%{import_path}/$(dirname $file)" >> devel.file-list install -d -p %{buildroot}/%{gopath}/src/%{import_path}/$(dirname $file) cp -pav $file %{buildroot}/%{gopath}/src/%{import_path}/$file echo "%%{gopath}/src/%%{import_path}/$file" >> devel.file-list done %endif # testing files for this project %if 0%{?with_unit_test} && 0%{?with_devel} install -d -p %{buildroot}/%{gopath}/src/%{import_path}/ # find all *_test.go files and generate unit-test.file-list for file in $(find . -iname "*_test.go" | grep -v "./Godeps"); do echo "%%dir %%{gopath}/src/%%{import_path}/$(dirname $file)" >> devel.file-list install -d -p %{buildroot}/%{gopath}/src/%{import_path}/$(dirname $file) cp -pav $file %{buildroot}/%{gopath}/src/%{import_path}/$file echo "%%{gopath}/src/%%{import_path}/$file" >> unit-test.file-list done %endif %if 0%{?with_devel} sort -u -o devel.file-list devel.file-list %endif %check %if 0%{?with_check} && 0%{?with_unit_test} && 0%{?with_devel} %if ! 0%{?with_bundled} export GOPATH=%{buildroot}/%{gopath}:%{gopath} %else export GOPATH=%{buildroot}/%{gopath}:$(pwd)/Godeps/_workspace:%{gopath} %endif %if ! 0%{?gotest:1} %global gotest go test %endif %gotest %{import_path}/pkg/build/strategies %gotest %{import_path}/pkg/build/strategies/layered %gotest %{import_path}/pkg/build/strategies/onbuild %gotest %{import_path}/pkg/build/strategies/sti %gotest %{import_path}/pkg/docker %gotest %{import_path}/pkg/git %gotest %{import_path}/pkg/ignore %gotest %{import_path}/pkg/scripts %gotest %{import_path}/pkg/tar %gotest %{import_path}/pkg/util %gotest %{import_path}/pkg/util/user %gotest %{import_path}/test/integration %endif #define license tag if not already defined %{!?_licensedir:%global license %doc} %files %license LICENSE %doc README.md CONTRIBUTING.md AUTHORS %{_bindir}/s2i %if 0%{?with_devel} %files devel -f devel.file-list %license LICENSE %doc README.md CONTRIBUTING.md AUTHORS %dir %{gopath}/src/%{provider}.%{provider_tld}/%{project} %endif %if 0%{?with_unit_test} && 0%{?with_devel} %files unit-test -f unit-test.file-list %license LICENSE %doc README.md CONTRIBUTING.md AUTHORS %endif %changelog * Thu Sep 17 2015 Tomas Hrcka - 1.0.2-4 - Fix dependencies - Remove -devel sub package * Tue Sep 15 2015 Tomas Hrcka - 1.0.2-2 - Build the right directory * Mon Sep 14 2015 jchaloup - 0-0.1.git00d1cb3 - First package for Fedora