This repository has been archived by the owner on Apr 17, 2023. It is now read-only.
/
portus.spec.in
184 lines (152 loc) · 5.6 KB
/
portus.spec.in
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
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
#
# spec file for package portus
#
# Copyright (c) __CURRENT_YEAR__ SUSE LINUX Products GmbH, Nuernberg, Germany.
#
# All modifications and additions to the file contributed by third parties
# remain the property of their copyright owners, unless otherwise agreed
# upon. The license for this file, and modifications and additions to the
# file, is the same license as for the pristine package itself (unless the
# license for the pristine package is not an Open Source License, in which
# case the license is the MIT License). An "Open Source License" is a
# license that conforms to the Open Source Definition (Version 1.9)
# published by the Open Source Initiative.
# Please submit bugfixes or comments via http://bugs.opensuse.org/
#
%define branch __BRANCH__
%define portusdir /srv/Portus
Name: portus
Version: __VERSION__
Release: 0.0.1
License: Apache-2.0
Summary: Authorization service and fronted for Docker registry (v2)
Url: https://github.com/SUSE/Portus
Group: System/Management
Source0: %{branch}.tar.gz
# Generated with `yarn install` which produces a reproduceable `node_modules`
# directory thanks to the yarn.lock file defined in the Portus repo.
Source1: node_modules.tar.gz
__PATCHSOURCES__
Requires: rubygem(%{rb_default_ruby_abi}:gem2rpm)
Requires: timezone
Requires: net-tools
%if 0%{?suse_version} >= 1210
BuildRequires: systemd-rpm-macros
%endif
BuildRequires: fdupes
BuildRequires: ruby-macros >= 5
%{?systemd_requires}
Provides: Portus = %{version}
Obsoletes: Portus < %{version}
# Portus-20151120162040 was accidentaly released when it should have been Portus-2.0
# This is the reason why we are obsoleting it
Obsoletes: Portus = 20151120162040
# Javascript engine to build assets
BuildRequires: nodejs6
BuildRequires: yarn
# Base ruby engine.
%define rb_build_versions ruby24
%define rb_build_abi ruby:2.4.0
%define rb_suffix ruby2.4
%define rb_ver 2.4.0
BuildRequires: %{rubydevel}
BuildRequires: %{rubygem gem2rpm}
Requires: config(%{rb_suffix}) >= %{rb_default_ruby_abi}
__RUBYGEMS_BUILD_REQUIRES__
__NODEJS_BUILD_PROVIDES__
BuildRoot: %{_tmppath}/%{name}-%{version}-build
%description
Portus targets version 2 of the Docker registry API. It aims to act both as an
authoritzation server and as a user interface for the next generation of the
Docker registry.
This package has been built with commit __COMMIT__ from branch __BRANCH__ on
date __DATE__
%prep
%setup -q -n Portus-%{branch}
__PATCHEXECS__
%build
# Untar Javascript dependencies
cp %{SOURCE1} .
tar xzvf node_modules.tar.gz
# Deal with Ruby gems.
install -d vendor/cache
cp %{_libdir}/ruby/gems/%{rb_ver}/cache/*.gem vendor/cache
# Deploy gems
bundle config build.nokogiri --use-system-libraries
bundle install --retry=3 --local --deployment --without assets test development
# Install bundler
gem.ruby2.4 install --no-rdoc --no-ri --install-dir vendor/bundle/ruby/%{rb_ver}/ vendor/cache/bundler-*.gem
# Compile assets
PORTUS_SECRET_KEY_BASE="ap" PORTUS_KEY_PATH="ap" PORTUS_PASSWORD="ap" \
RAILS_ENV=production NODE_ENV=production \
bundle exec rake portus:assets:compile
# Patch landing_page
APPLICATION_CSS=$(find . -name application-*.css 2>/dev/null)
cp $APPLICATION_CSS public/landing.css
# Save the commit so it can later be used by Portus.
echo "__COMMIT__" >> .gitcommit
# Remove unneeded directories/files
rm -rf \
vendor/cache \
node_modules \
public/assets/application-*.js* \
vendor/assets \
examples \
*.orig
# Removing irrelevant files for production.
declare -a ary=(
".gitignore" ".travis.yml" ".pelusa.yml" ".keep" ".rspec" ".codeclimate.yml"
".yardopts" ".ruby-gemset" ".rubocop.yml" ".document" ".eslintrc"
".eslintignore" ".env" ".dockerignore" ".editorconfig" ".erdconfig"
"*.pem" ".rubocop_todo.yml" ".concourse.yml" "Dockerfile" "Vagrantfile"
"node_modules.tar.gz"
)
for i in "${ary[@]}"; do
find . -name "$i" -type f -delete
done
# Remove directories.
find . -name "spec" -type d -exec rm -rv {} +
find . -name ".github" -type d -exec rm -rv {} +
find . -name ".empty_directory" -type d -delete
# Remove empty files which are not important.
find . -size 0 ! -path "*gem.build_complete" -delete
%install
install -d %{buildroot}/%{portusdir}
cp -av . %{buildroot}/%{portusdir}
rm -rf %{buildroot}/%{portusdir}/log
mkdir %{buildroot}/%{portusdir}/log
rm -rf %{buildroot}/%{portusdir}/tmp
mkdir %{buildroot}/%{portusdir}/tmp
install -d %{buildroot}/%{_sbindir}
cp packaging/suse/bin/portusctl %{buildroot}/%{_sbindir}/
# Man pages
install -d %{buildroot}%{_mandir}/man1
install -p -m 644 packaging/suse/portusctl/man/man1/*.1 %{buildroot}%{_mandir}/man1
%fdupes %{buildroot}/%{portusdir}
%files
%defattr(-,root,root)
%{portusdir}
%exclude %{portusdir}/lib/man_pages.rb
%exclude %{portusdir}/lib/tasks/man.rake
%exclude %{portusdir}/packaging/suse/.gitignore
%exclude %{portusdir}/packaging/suse/package_and_push_to_obs.sh
%exclude %{portusdir}/packaging/suse/portus.spec.in
%exclude %{portusdir}/packaging/suse/README.md
%exclude %{portusdir}/packaging/suse/conf
%exclude %{portusdir}/packaging/suse/make_spec.sh
%exclude %{portusdir}/packaging/suse/patches
%exclude %{portusdir}/packaging/suse/portus.spec.in
%exclude %{portusdir}/packaging/suse/release
%doc %{portusdir}/README.md
%doc %{portusdir}/CONTRIBUTING.md
%doc %{portusdir}/LICENSE
%defattr(0640, root, www)
%config(noreplace) %{portusdir}/config/environment.rb
%defattr(-, root, www, 1770)
%{portusdir}/log/
%{portusdir}/tmp/
%{portusdir}/db/
%{_sbindir}/portusctl
%{_mandir}/man1/portusctl-*.1.gz
%{_mandir}/man1/portusctl.1.gz
%changelog