Skip to content

Commit

Permalink
Merge pull request virtuozzo#1 from kolyshkin/spec
Browse files Browse the repository at this point in the history
Add rpm build
  • Loading branch information
avagin authored Mar 21, 2017
2 parents 83f0826 + 8afe47a commit 69ca573
Show file tree
Hide file tree
Showing 48 changed files with 251 additions and 16 deletions.
13 changes: 0 additions & 13 deletions virtuozzo-storage/Dockerfile

This file was deleted.

2 changes: 0 additions & 2 deletions virtuozzo-storage/Makefile

This file was deleted.

2 changes: 2 additions & 0 deletions vzstorage-pd/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
vzstorage-pd
vzstorage-pd-*.tar.bz2
8 changes: 8 additions & 0 deletions vzstorage-pd/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
FROM centos:7
ENTRYPOINT ["vzstorage-pd"]
CMD -master=http://127.0.0.1:8080 -kubeconfig=/kube/config

ADD virtuozzo.repo /etc/yum.repos.d/
RUN printf "upgrade \n install ploop gdisk \n run" | yum shell -y

ADD vzstorage-pd /usr/bin/
37 changes: 37 additions & 0 deletions vzstorage-pd/Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
NAME := vzstorage-pd
BINS := vzstorage-pd
BINDIR := /usr/bin
GITID ?= $(shell git describe --always HEAD || true)
TARNAME := $(NAME)-$(GITID)

all:
go build .
.PHONY: all

tar: $(TARNAME).tar.bz2
.PHONY: tar

dist: tar
.PHONY: dist

rpm: tar
sed -i "s/\(%global commit[[:space:]]*\).*$$/\1 $(GITID)/" $(NAME).spec
rpmbuild -ba --define "_sourcedir $$PWD" $(NAME).spec
.PHONY: rpm

$(TARNAME).tar.bz2:
(cd .. && git archive --format tar --prefix "$(TARNAME)/" $(GITID)) \
| bzip2 -9 > $@

install-bin:
install -d $(DESTDIR)$(BINDIR)
install $(BINS) $(DESTDIR)$(BINDIR)/
.PHONY: install-bin

install: install-bin
.PHONY: install

clean:
rm -f $(BINS)
rm -f $(TARNAME).tar.bz2
.PHONY: clean
2 changes: 1 addition & 1 deletion virtuozzo-storage/README.md → vzstorage-pd/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ docker build -t virtuozzo-storage .
Assume kubeconfig is at `/root/.kube` and vstorage mounted on all cluster nodes in /mnt/vstorage:

```bash
docker run -tid -v /mnt/vstorage/kube/:/mnt/vstorage/kube/ -v /root/.kube:/kube --privileged --net=host virtuozzo-storage /usr/local/bin/virtuozzo-storage -master=http://127.0.0.1:8080 -kubeconfig=/kube/config
docker run -tid -v /mnt/vstorage/kube/:/mnt/vstorage/kube/ -v /root/.kube:/kube --privileged --net=host virtuozzo-storage
```

* Create a Virtuozzo Storage Class
Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
203 changes: 203 additions & 0 deletions vzstorage-pd/vzstorage-pd.spec
Original file line number Diff line number Diff line change
@@ -0,0 +1,203 @@
# If any of the following macros should be set otherwise,
# you can wrap any of them with the following conditions:
# - %%if 0%%{centos} == 7
# - %%if 0%%{?rhel} == 7
# - %%if 0%%{?fedora} == 23
# Or just test for particular distribution:
# - %%if 0%%{centos}
# - %%if 0%%{?rhel}
# - %%if 0%%{?fedora}
#
# Be aware, on centos, both %%rhel and %%centos are set. If you want to test
# rhel specific macros, you can use %%if 0%%{?rhel} && 0%%{?centos} == 0 condition.
# (Don't forget to replace double percentage symbol with single one in order to apply a condition)

# Generate devel rpm
%global with_devel 0
# Build project from bundled dependencies
%global with_bundled 0
# Build with debug info rpm
%global with_debug 0
# Run tests in check section
%global with_check 1
# Generate unit-test rpm
%global with_unit_test 0

%if 0%{?with_debug}
%global _dwz_low_mem_die_limit 0
%else
%global debug_package %{nil}
%endif


%global provider github
%global provider_tld com
%global project kolyshkin
%global repo external-storage
# https://github.com/kolyshkin/external-storage
%global provider_prefix %{provider}.%{provider_tld}/%{project}/%{repo}
%global import_path %{provider_prefix}
%global commit 4655a1f
%global shortcommit %(c=%{commit}; echo ${c:0:7})

Name: vzstorage-pd
Version: 0.1.1
Release: 0.1.git%{shortcommit}%{?dist}
Summary: Kubetnetes provisioner for Virtuozzo Storage
License: ASL 2.0
URL: https://%{provider_prefix}
Source0: %{name}-%{shortcommit}.tar.bz2

# e.g. el6 has ppc64 arch without gcc-go, so EA tag is required
ExclusiveArch: %{?go_arches:%{go_arches}}%{!?go_arches:%{ix86} x86_64 aarch64 %{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}

Requires: ploop
# Remove gdisk req once PSBM-62550 is fixed
Requires: gdisk


%description
%{summary}

%if 0%{?with_devel}
%package devel
Summary: %{summary}
BuildArch: noarch

%if 0%{?with_check} && ! 0%{?with_bundled}
%endif



%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-devel
Summary: Unit tests for %{name} package
%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}

%if 0%{?with_check} && ! 0%{?with_bundled}
%endif


%description unit-test-devel
%{summary}

This package contains unit tests for project
providing packages with %{import_path} prefix.
%endif

%prep
#%setup -q -n %{repo}-%{commit}
%setup -q -n %{name}-%{shortcommit}

%build
mkdir src
DIR=src/github.com/kubernetes-incubator/external-storage
mkdir -p $(dirname $DIR)
ln -s ../../../ $DIR
GOPATH=`pwd`
cd $GOPATH/$DIR/%{name}
make


%install
cd %{name}
make DESTDIR="%{buildroot}" install
# 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" -or -iname "*.s" \) \! -iname "*_test.go" | grep -v "vendor") ; do
dirprefix=$(dirname $file)
install -d -p %{buildroot}/%{gopath}/src/%{import_path}/$dirprefix
cp -pav $file %{buildroot}/%{gopath}/src/%{import_path}/$file
echo "%%{gopath}/src/%%{import_path}/$file" >> devel.file-list

while [ "$dirprefix" != "." ]; do
echo "%%dir %%{gopath}/src/%%{import_path}/$dirprefix" >> devel.file-list
dirprefix=$(dirname $dirprefix)
done
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-devel.file-list
for file in $(find . -iname "*_test.go" | grep -v "vendor") ; do
dirprefix=$(dirname $file)
install -d -p %{buildroot}/%{gopath}/src/%{import_path}/$dirprefix
cp -pav $file %{buildroot}/%{gopath}/src/%{import_path}/$file
echo "%%{gopath}/src/%%{import_path}/$file" >> unit-test-devel.file-list

while [ "$dirprefix" != "." ]; do
echo "%%dir %%{gopath}/src/%%{import_path}/$dirprefix" >> devel.file-list
dirprefix=$(dirname $dirprefix)
done
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
# Since we aren't packaging up the vendor directory we need to link
# back to it somehow. Hack it up so that we can add the vendor
# directory from BUILD dir as a gopath to be searched when executing
# tests from the BUILDROOT dir.
ln -s ./ ./vendor/src # ./vendor/src -> ./vendor

export GOPATH=%{buildroot}/%{gopath}:$(pwd)/vendor:%{gopath}
%endif

%if ! 0%{?gotest:1}
%global gotest go test
%endif

%endif

#define license tag if not already defined
%{!?_licensedir:%global license %doc}


%if 0%{?with_devel}
%files devel -f devel.file-list
%dir %{gopath}/src/%{provider}.%{provider_tld}/%{project}
%endif

%if 0%{?with_unit_test} && 0%{?with_devel}
%files unit-test-devel -f unit-test-devel.file-list
%endif

%files
%_bindir/%{name}
%doc %{name}/README.md
# examples
%doc %{name}/claim.yaml
%doc %{name}/class.yaml
%doc %{name}/test-pod.yaml

%changelog
* Mon Mar 20 2017 Kir Kolyshkin <[email protected]> 0.1.1-1
- Initial packaging

0 comments on commit 69ca573

Please sign in to comment.