Permalink
Cannot retrieve contributors at this time
# | |
# 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 | |
# Base ruby engine. | |
%define portus_ruby_abi 2.6.0 | |
%define rb_build_versions ruby26 | |
%define rb_build_abi ruby:%{portus_ruby_abi} | |
%define rb_suffix ruby2.6 | |
%define rb_ver 2.6.2 | |
%define fix_sheb() ( \ | |
for i in $(grep '^#!/usr/bin/env ruby$' * -r | cut -d: -f1 | uniq);do\ | |
sed -e 's|^#!/usr/bin/env ruby$|#!/usr/bin/ruby.%{rb_suffix}|g' -i $i;\ | |
done;\ | |
for i in $(grep '^#!/usr/bin/ruby$' * -r | cut -d: -f1 | uniq);do\ | |
sed -e 's|^#!/usr/bin/ruby$|#!/usr/bin/ruby.%{rb_suffix}|g' -i $i;\ | |
done;\ | |
) | |
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: Portus-%{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 | |
Source2: yarn.lock | |
__PATCHSOURCES__ | |
# We need to add bundler cause https://github.com/openSUSE/obs-service-bundle_gems | |
# does not add it by default | |
Source100: bundler-1.16.4.gem | |
Requires: timezone | |
Requires: net-tools | |
Requires: portusctl | |
%if 0%{?suse_version} >= 1210 | |
BuildRequires: systemd-rpm-macros | |
%endif | |
BuildRequires: fdupes | |
BuildRequires: gcc-c++ | |
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. Note that yarn-packaging will automatically | |
# create the provides for the JS libs | |
BuildRequires: nodejs6 | |
BuildRequires: yarn | |
BuildRequires: yarn-packaging | |
BuildRequires: libcurl-devel | |
Requires: libcurl4 | |
BuildRequires: libffi-devel | |
BuildRequires: libxml2-devel libxslt-devel | |
# DB-related libraries. | |
BuildRequires: mysql-devel | |
BuildRequires: postgresql-devel | |
Requires: config(%{rb_suffix}) >= %{rb_default_ruby_abi} | |
Requires: %rb_default_ruby_suffix | |
BuildRequires: %rb_default_ruby_suffix %{rb_default_ruby_suffix}-rubygem-gem2rpm | |
BuildRequires: %{rb_suffix}-devel | |
__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 xzf node_modules.tar.gz | |
# Deal with Ruby gems. | |
install -d vendor/cache | |
# obs-service-bundle_gems will install gems in SOURCE/vendor/cache when using the cpio strategy | |
# https://github.com/openSUSE/obs-service-bundle_gems/ | |
cp %{_sourcedir}/vendor/cache/*.gem vendor/cache | |
# copy bundler gem | |
cp %{S:100} vendor/cache | |
# Deploy gems for compiling the assets. | |
export GEM_HOME=$PWD/vendor GEM_PATH=$PWD/vendor PATH=$PWD/vendor/bin:$PWD/bin:$PATH | |
# Install bundler in the build system | |
%fix_sheb | |
gem.%{rb_suffix} install --no-document vendor/cache/bundler-*.gem | |
bundle config build.nokogiri --use-system-libraries | |
bundle install --retry=3 --local --deployment --without test development | |
gem.%{rb_suffix} install --no-document --install-dir vendor/bundle/ruby/%{portus_ruby_abi}/ vendor/cache/bundler-*.gem | |
%fix_sheb | |
# Compile assets | |
PORTUS_SECRET_KEY_BASE="ap" PORTUS_KEY_PATH="ap" PORTUS_PASSWORD="ap" \ | |
INCLUDE_ASSETS_GROUP=yes RAILS_ENV=production NODE_ENV=production \ | |
./bin/bundle exec rake portus:assets:compile | |
# Install the final gems (i.e. exclude the `assets` group from the final | |
# bundle). Unfortunately, bundler does not have a way to remove gems from a | |
# given group. So, we have to remove all of them, and then install the ones we | |
# want... | |
rm -r vendor/bundle/ruby | |
gem.%{rb_suffix} install --no-document --install-dir vendor/bundle/ruby/%{portus_ruby_abi}/ vendor/cache/bundler-*.gem | |
bundle install --retry=3 --local --deployment --without test development assets | |
rm -r vendor/bundle/ruby/%{portus_ruby_abi}/cache/* | |
%fix_sheb | |
# Patch landing_page | |
APPLICATION_CSS=$(find . -name application-*.css 2>/dev/null) | |
cp $APPLICATION_CSS public/landing.css | |
# Fix schema.rb softlink to its final destination | |
rm db/schema.rb | |
ln -s %{portusdir}/db/schema.mysql.rb db/schema.rb | |
# 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 \ | |
packaging \ | |
tmp \ | |
log \ | |
docker \ | |
doc \ | |
*.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" ".babelrc" "docker-compose.yml" | |
) | |
for i in "${ary[@]}"; do | |
find . -name "$i" -type f -delete | |
done | |
# Remove directories. | |
find . -name "spec" -type d -exec rm -rfv {} + | |
find vendor/bundle -name "test" -type d ! -path "*rack*/test" -exec rm -rfv {} + | |
find . -name ".github" -type d -exec rm -rfv {} + | |
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} | |
mkdir %{buildroot}%{portusdir}/log | |
mkdir %{buildroot}%{portusdir}/tmp | |
%fdupes %{buildroot}%{portusdir} | |
%files | |
%defattr(-,root,root) | |
%dir %{portusdir} | |
%{portusdir}/.bundle | |
%{portusdir}/.gitcommit | |
%{portusdir}/.ruby-version | |
%{portusdir}/Gemfile | |
%{portusdir}/Gemfile.lock | |
%{portusdir}/Guardfile | |
%{portusdir}/Rakefile | |
%{portusdir}/VERSION | |
%{portusdir}/app | |
%{portusdir}/bin | |
%{portusdir}/config.ru | |
%{portusdir}/db | |
%{portusdir}/lib | |
%{portusdir}/log | |
%{portusdir}/package.json | |
%{portusdir}/public | |
%{portusdir}/tmp | |
%{portusdir}/vendor | |
%{portusdir}/yarn.lock | |
%doc %{portusdir}/README.md | |
%doc %{portusdir}/CONTRIBUTING.md | |
%doc %{portusdir}/CHANGELOG.md | |
%doc %{portusdir}/LICENSE | |
%config(noreplace) %{portusdir}/config | |
%changelog |