Fetching contributors…
Cannot retrieve contributors at this time
226 lines (186 sloc) 7.11 KB
# 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
%define branch __BRANCH__
%define portusdir /srv/Portus
# Base ruby engine.
%define rb_build_versions ruby25
%define rb_build_abi ruby:2.5.0
%define rb_suffix ruby2.5
%define rb_ver 2.5.0
%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;\
for i in $(grep '^#!/usr/bin/ruby$' * -r | cut -d: -f1 | uniq);do\
sed -e 's|^#!/usr/bin/ruby$|#!/usr/bin/ruby.ruby2.5|g' -i $i;\
Name: portus
Version: __VERSION__
Release: 0.0.1
License: Apache-2.0
Summary: Authorization service and fronted for Docker registry (v2)
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
# We need to add bundler cause
# 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
BuildRequires: fdupes
BuildRequires: ruby-macros >= 5
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
Requires: config(%{rb_suffix}) >= %{rb_default_ruby_abi}
BuildRequires: libcurl-devel
Requires: libcurl4
BuildRequires: libffi-devel
%if 0%{?suse_version} <= 1320
BuildRequires: libmysqlclient-devel < 10.1
Requires: libmysqlclient18 < 10.1
BuildRequires: libmysqlclient-devel
Requires: libmysqlclient18
BuildRequires: libxml2-devel libxslt-devel
BuildRequires: postgresql-devel
Requires: postgresql-devel
Requires: %rb_default_ruby_suffix
BuildRequires: %rb_default_ruby_suffix %{rb_default_ruby_suffix}-rubygem-gem2rpm
BuildRequires: %{rb_suffix}-devel
BuildRoot: %{_tmppath}/%{name}-%{version}-build
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__
%setup -q -n Portus-%{branch}
# Untar Javascript dependencies
cp %{SOURCE1} .
tar xzvf 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
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
gem.%{rb_suffix} install --no-rdoc --no-ri 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-rdoc --no-ri --install-dir vendor/bundle/ruby/%{rb_ver}/ vendor/cache/bundler-*.gem
# Compile assets
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/%{rb_ver}/*
gem.%{rb_suffix} install --no-rdoc --no-ri --install-dir vendor/bundle/ruby/%{rb_ver}/ vendor/cache/bundler-*.gem
bundle install --retry=3 --local --deployment --without test development assets
# 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 \
# 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"
for i in "${ary[@]}"; do
find . -name "$i" -type f -delete
# 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 -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
%fdupes %{buildroot}/%{portusdir}
%exclude %{portusdir}/packaging/suse/.gitignore
%exclude %{portusdir}/packaging/suse/
%exclude %{portusdir}/packaging/suse/
%exclude %{portusdir}/packaging/suse/
%exclude %{portusdir}/packaging/suse/conf
%exclude %{portusdir}/packaging/suse/
%exclude %{portusdir}/packaging/suse/patches
%exclude %{portusdir}/packaging/suse/
%exclude %{portusdir}/packaging/suse/release
%doc %{portusdir}/
%doc %{portusdir}/
%doc %{portusdir}/LICENSE
%defattr(0640, root, www)
%config(noreplace) %{portusdir}/config/environment.rb
%defattr(-, root, www, 1770)