File crowbar.spec of Package crowbar

# spec file for package crowbar
# Copyright (c) 2017 SUSE LINUX 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

# keep in sync with macros.crowbar
%define crowbar_ruby21 0%{?suse_version} == 1110 || 0%{?suse_version} == 1310
%define crowbar_base /opt/dell

%if 0%{?crowbar_ruby21}
%define crowbar_ruby_bin ruby.ruby2.1
%define crowbar_ruby_abi ruby:2.1.0
%define crowbar_ruby_bin ruby
%define crowbar_ruby_abi %{rb_default_ruby_abi}

%define crowbar_arches x86_64 s390x

Name:           crowbar
Version:        3.0+git.1487260088.de9ef19
Release:        0
Summary:        Platform for server provisioning and deployment from bare metal
License:        Apache-2.0
Group:          System/Management
Source0:        %{name}-%{version}.tar.bz2
Source1:        crowbar.json
Source2:        createrepo-cloud-ptf
Source10:       macros.crowbar
Source11:       crowbar.sudoers
Provides:       crowbar = 3.0
# For directory ownership:
BuildRequires:  sudo
BuildRequires:  tftp
Requires:       couchdb
Requires:       netcat
# for killall and similar
Requires:       psmisc
Requires:       rabbitmq-server
Requires:       rsync
Requires:       sudo
Requires:       tcpdump
Requires:       rubygem(%{crowbar_ruby_abi}:activesupport:4.2)
Requires:       rubygem(%{crowbar_ruby_abi}:chef)
Requires:       rubygem(%{crowbar_ruby_abi}:chef-server)
Requires:       rubygem(%{crowbar_ruby_abi}:i18n)
Requires:       rubygem(%{crowbar_ruby_abi}:json:1.7)
Requires:       rubygem(%{crowbar_ruby_abi}:kwalify)
Requires:       rubygem(%{crowbar_ruby_abi}:net-http-digest_auth)
Requires:       rubygem(%{crowbar_ruby_abi}:ruby-shadow)

# These requires extracted from chef/cookbooks/crowbar/recipes/default.rb
Requires:       curl

# for the install-chef-suse script
Requires:       iptables
Requires:       screen
Recommends:     dialog

# require bind (bnc#770021)
Requires:       bind

# to be able to update Cloud-PTF repo
Requires:       createrepo

%if 0%{?suse_version} >= 1200
Requires(pre):  shadow
Requires(pre):  pwdutils

BuildRoot:      %{_tmppath}/%{name}-%{version}-build
BuildArch:      noarch

Crowbar is a platform for server provisioning and deployment from bare
metal. It provides server discovery, firmware upgrades, and operating
system installation using PXE Boot. It deploys applications on top of
functioning operating systems using Chef.

%package devel
Summary:        Utilities to help build packages for Crowbar barclamps
Group:          Development/Tools/Building
Requires:       %{name} = %{version}
Requires:       rubygem(%{crowbar_ruby_abi}:closure-compiler)
Requires:       rubygem(%{crowbar_ruby_abi}:sass:3.4)
Requires:       rubygem(%{crowbar_ruby_abi}:sprockets-standalone)
# sprockets-standalone requires sprockets ~> 2.0
Requires:       rubygem(%{crowbar_ruby_abi}:sprockets:2.11)

%description devel
This package provides utilities to help building packages for Crowbar

%setup -q
perl -p -i -e 's|#!/usr/bin/env\ ruby|#!/usr/bin/env\ %{crowbar_ruby_bin}|s' scripts/*
perl -p -i -e 's|#!/usr/bin/ruby|#!/usr/bin/env\ %{crowbar_ruby_bin}|s' scripts/*


install -d %{buildroot}%{_sysconfdir}/crowbar
install -m 640 %{SOURCE1} %{buildroot}%{_sysconfdir}/crowbar/crowbar.json

install -d -m 755 %{buildroot}%{crowbar_base}/bin
install -d -m 755 %{buildroot}%{_sbindir}
install -d -m 755 %{buildroot}%{_prefix}/lib/suse-cloud
install -m 755 scripts/{barclamp*,branding_install.rb,,json-edit,json-read,network-json-validator,,} %{buildroot}%{crowbar_base}/bin
install -m 755 scripts/repos-check-suse %{buildroot}%{_prefix}/lib/suse-cloud/repos-check
ln -s %{crowbar_base}/bin/ %{buildroot}%{_sbindir}/install-suse-cloud

install -m 755 %{SOURCE2} %{buildroot}%{_sbindir}/createrepo-cloud-ptf

for a in %crowbar_arches; do
    mkdir -p %{buildroot}/srv/tftpboot/suse-12.1/$a
    mkdir -p %{buildroot}/srv/tftpboot/suse-12.1/$a/repos/PTF/{repodata,rpm}
    mkdir -p %{buildroot}/srv/tftpboot/suse-12.1/$a/repos/PTF/rpm/{noarch,src,$a}

install -d %{buildroot}/var/lib/crowbar/backup
install -d %{buildroot}/var/lib/crowbar/config
install -d %{buildroot}/var/lib/crowbar/install
install -d %{buildroot}/var/lib/crowbar/upgrade
install -d %{buildroot}/var/log/crowbar/{chef-client,sledgehammer}

install -D -m 644 %{SOURCE10} %{buildroot}%{_sysconfdir}/rpm/macros.crowbar

# Directory that we own for convenience, as they are used by barclamps
install -d %{buildroot}%{crowbar_base}/barclamps
install -d %{buildroot}%{crowbar_base}/chef/{cookbooks,data_bags/crowbar,data_bags/crowbar/migrate,roles}

# Add crowbar user to sudoers
install -d 750 %{buildroot}/etc/sudoers.d
install -m 440 %{SOURCE11} %{buildroot}/etc/sudoers.d/crowbar

getent group crowbar >/dev/null || groupadd -r crowbar
getent passwd crowbar >/dev/null || useradd -r -g crowbar -d /var/lib/crowbar -s /sbin/nologin crowbar

# create here, but do not own it as depending on how people mirror the
# installation media, they might change the perms of this directory
for a in %crowbar_arches; do
    mkdir -p /srv/tftpboot/suse-12.1/$a/install


%dir %{crowbar_base}
%dir %{crowbar_base}/bin
%exclude %{crowbar_base}/bin/barclamp_create.rb

# Directory that we own for convenience, as they are used by barclamps
%dir %{crowbar_base}/barclamps

%dir %{_sysconfdir}/crowbar
%config(noreplace) %{_sysconfdir}/crowbar/crowbar.json


# directories where we put bits during
%dir %attr(0750, crowbar, crowbar) /var/lib/crowbar
%dir %attr(0750, crowbar, crowbar) /var/lib/crowbar/backup
%dir %attr(0750, crowbar, crowbar) /var/lib/crowbar/config
%dir %attr(0750, crowbar, crowbar) /var/lib/crowbar/install
%dir %attr(0750, crowbar, crowbar) /var/lib/crowbar/upgrade

%dir %attr(0750, crowbar, crowbar) /var/log/crowbar
%dir %attr(0750, crowbar, crowbar) /var/log/crowbar/chef-client
%dir /var/log/crowbar/sledgehammer


%files devel
%config %{_sysconfdir}/rpm/macros.crowbar