Blob Blame History Raw
%global app_root %{_datadir}/%{name}
%global doc_root %{_datadir}/%{name}-doc

Name:     aeolus-conductor
Version:  0.3.0
Release:  2%{?dist}%{?extra_release}
Summary:  The Aeolus Conductor

Group:    Applications/System
License:  GPLv2+ and MIT and BSD
URL:      http://aeolusproject.org

# to build source tarball
# git clone  git://git.fedorahosted.org/aeolus/conductor.git
# git checkout v0.3.0_RC_1
# make dist
# cp aeolus-conductor-0.0.4.tar.gz ~/rpmbuild/SOURCES
Source0:    aeolus-conductor-%{version}.tar.gz

Requires: ruby >= 1.8.1
Requires: ruby(abi) = 1.8
Requires: rubygem(rails) >= 2.1.1
Requires: rubygem(haml)
Requires: rubygem(nokogiri) >= 1.4.0
Requires: rubygem(will_paginate)
Requires: rubygem(parseconfig)
Requires: rubygem(authlogic)
Requires: rubygem(deltacloud-client) >= 0.0.9.8
Requires: rubygem(compass)
Requires: rubygem(compass-960-plugin)
Requires: rubygem(simple-navigation)
Requires: rubygem(typhoeus)
Requires: rubygem(rest-client)
Requires: rubygem(builder)
Requires: rubygem(json)
Requires: rubygem(rack-restful_submit)
Requires: rubygem(delayed_job)
Requires: rubygem(net-scp)
Requires: rubygem(uuidtools)
Requires: postgresql
Requires: postgresql-server
Requires: ruby-postgres

# to ensure the service is actually started
# and is accessible in the init script
Requires: curl

BuildArch: noarch

%description
The Aeolus Conductor, a web UI for managing cloud instances.

%package daemons
Summary:   Aeolus Conductor daemons
Group:     Applications/Internet
License:   GPLv2+
Requires: %{name} = %{version}-%{release}
Requires: httpd >= 2.0
Requires: rubygem(thin) >= 1.2.5
Requires(post): chkconfig
Requires(preun): chkconfig
Requires(preun): initscripts

%description daemons
The configuration and daemons necessary to run and proxy the Aeolus Conductor.

%package doc
Summary: Aeolus Conductor documentation
Group:   Documentation
Requires: %{name} = %{version}-%{release}

%description doc
Documentation for the Aeolus Conductor.

%package devel
Summary: Aeolus Conductor development and testing files
Group:   Applications/Internet
Requires: %{name} = %{version}-%{release}
Requires: rubygem(cucumber)
Requires: rubygem(rspec)
Requires: rubygem(timecop)
Requires: rubygem(cucumber-rails)
Requires: rubygem(rspec-rails)
Requires: rubygem(webrat)
Requires: rubygem(database_cleaner)
Requires: rubygem(factory_girl)

%description devel
Tests and other development tools for the Aeolus Conductor.

%prep
%setup -q

%build

%pre
getent group aeolus >/dev/null || /usr/sbin/groupadd -g 451 -r aeolus 2>/dev/null || :
getent passwd aeolus >/dev/null || \
    /usr/sbin/useradd -u 451 -g aeolus -c "aeolus" \
    -s /sbin/nologin -r -d /var/aeolus aeolus 2> /dev/null || :

%install
%{__mkdir} -p %{buildroot}
%{__mkdir} -p %{buildroot}%{app_root}
%{__mkdir} -p %{buildroot}%{doc_root}
%{__mkdir} -p %{buildroot}%{_initrddir}
%{__mkdir} -p %{buildroot}%{_sysconfdir}/sysconfig
%{__mkdir} -p %{buildroot}%{_sysconfdir}/httpd/conf.d
%{__mkdir} -p %{buildroot}%{_sysconfdir}/logrotate.d

%{__mkdir} -p %{buildroot}%{_localstatedir}/lib/%{name}
%{__mkdir} -p %{buildroot}%{_localstatedir}/log/%{name}
%{__mkdir} -p %{buildroot}%{_localstatedir}/run/%{name}

# now copy over the rails source files.  This is a bit verbose, but only
# takes in the stuff we need (and no backup files, etc)

# we use these special constructs to find only the files we care about.
# the name of the variable has to be the file extension you are looking for.
# the contents of the variable are the directories in which files with this
# extension may exist.  For instance cgi="public" means that src/public/*.cgi
# will be copied from the source into the RPM.
builder="app/views/errors"
cgi="public"
css="public/stylesheets public/stylesheets/jquery.ui-1.8.1 \
     public/javascripts/jquery-svg"
erb="app/views/layouts"
fcgi="public"
feature="features"
gif="public/images public/stylesheets/images"
haml="app/views/hardware_profiles app/views/realm_mappings \
      app/views/users app/views/provider_accounts \
      app/views/roles app/views/providers app/views/settings \
      app/views/realms app/views/pool_families app/views/layouts\
      app/views/quotas app/views/permissions \
      app/views/deployments app/views/pools \
      app/views/instances app/views/user_sessions \
      app/views/suggested_deployables"
html="public"
ico="public"
jpg="public/images public/stylesheets/images"
js="public/javascripts public/javascripts/jquery-svg \
    public/javascripts/jquery.ui-1.8.1 \
    public/javascripts/jquery.ui-1.8.1/ui/minified"
json="spec/fixtures"
key="features/upload_files"
opts="spec"
png="public/images public/images/icons public/stylesheets/images \
     public/stylesheets/jquery.ui-1.8.1/images"
rake="lib/tasks"
rb="app/models app/controllers \
    app/helpers \
    app/services app/util \
    config config/initializers config/environments db db/migrate dutils \
    features/support features/step_definitions lib public spec \
    spec/controllers spec/factories spec/helpers spec/models spec/services"
rhtml="app/views/layouts"
scss="app/stylesheets"
svg="public/images public/images/icons public/javascripts/jquery-svg"
ttf="public/fonts"
txt="public"
yml="config config/locales"

for filetype in builder cgi css erb fcgi feature gif haml html ico jpg js json \
    key opts png rake rb rhtml scss svg ttf txt yml; do
    dirs=${!filetype}

    for dir in $dirs; do
        %{__mkdir} -p %{buildroot}%{app_root}/$dir
        %{__cp} src/$dir/*.$filetype %{buildroot}%{app_root}/$dir
    done
done

# misc files
%{__cp} src/Rakefile %{buildroot}%{app_root}
%{__cp} src/config.ru %{buildroot}%{app_root}

%{__mkdir} -p %{buildroot}%{app_root}/config
%{__cp} src/config/database.pg %{buildroot}%{app_root}/config
%{__cp} src/config/database.mysql %{buildroot}%{app_root}/config
%{__cp} src/config/database.sqlite %{buildroot}%{app_root}/config
# here we copy the postgres configuration to be the default.  While this is
# something of a policy we are encoding in the RPM, it is nice to give the user
# sane defaults.  The user can still override this with their own configuration
%{__cp} src/config/database.pg %{buildroot}%{app_root}/config/database.yml

%{__mkdir} -p %{buildroot}%{app_root}/dbomatic
%{__cp} src/dbomatic/dbomatic %{buildroot}%{app_root}/dbomatic

# move documentation to the correct place
%{__cp} src/doc/* %{buildroot}/%{doc_root}

# copy over init scripts and various config
%{__cp} conf/aeolus-conductor %{buildroot}%{_initrddir}
%{__cp} conf/conductor-dbomatic %{buildroot}%{_initrddir}
%{__cp} conf/conductor-delayed_job %{buildroot}%{_initrddir}
%{__cp} conf/aeolus-conductor-httpd.conf %{buildroot}%{_sysconfdir}/httpd/conf.d/aeolus-conductor.conf
%{__cp} conf/aeolus-conductor.logrotate %{buildroot}%{_sysconfdir}/logrotate.d/aeolus-conductor
%{__cp} conf/aeolus-conductor.sysconf %{buildroot}%{_sysconfdir}/sysconfig/aeolus-conductor
%{__cp} conf/conductor-rails.sysconf %{buildroot}%{_sysconfdir}/sysconfig/conductor-rails

%{__mkdir} -p %{buildroot}%{app_root}/config/image_descriptor_xmls

# Creating these files now to make sure the logfiles will be owned
# by aeolus:aeolus. This is a temporary workaround while we've still
# got root-owned daemon processes. Once we resolve that issue
# these files will no longer be added explicitly here.
touch %{buildroot}%{_localstatedir}/log/%{name}/thin.log
touch %{buildroot}%{_localstatedir}/log/%{name}/rails.log
touch %{buildroot}%{_localstatedir}/log/%{name}/dbomatic.log
touch %{buildroot}%{_localstatedir}/run/%{name}/event_log_position

%{__mkdir} -p %{buildroot}%{app_root}/log
touch %{buildroot}%{app_root}/log/delayed_job.log

# copy script files over
%{__cp} -r src/script %{buildroot}%{app_root}

%{__mkdir} -p %{buildroot}%{_sysconfdir}/%{name}

%post
# symlink the configuration bits from /usr/share/aeolus-conductor/config
# into /etc/aeolus-conductor.  Note that we unceremoniously use -f here;
# if the user had broken the symlinks and put data in here, it would have been
# completely ignored *anyway*
%{__ln_s} -f %{app_root}/config/environments/development.rb %{_sysconfdir}/%{name}
%{__ln_s} -f %{app_root}/config/environments/production.rb %{_sysconfdir}/%{name}
%{__ln_s} -f %{app_root}/config/environments/test.rb %{_sysconfdir}/%{name}
%{__ln_s} -f %{app_root}/config/database.yml %{_sysconfdir}/%{name}

%postun
# kind of a weird construct.  There are two cases where postun gets called;
# during the removal of a package and during the cleanup after an upgrade.
# During removal, we want to remove the symlinks; during upgrade we do not.
# Therefore, we check to see if app_root/app is still there; if it is,
# then we assume it is an upgrade and do nothing, otherwise we assume it is
# a removal and delete the symlinks
if [ ! -d %{app_root}/app ]; then
   rm -f %{_sysconfdir}/%{name}/development.rb
   rm -f %{_sysconfdir}/%{name}/production.rb
   rm -f %{_sysconfdir}/%{name}/test.rb
   rm -f %{_sysconfdir}/%{name}/database.yml
fi

%post daemons
# Register the services
/sbin/chkconfig --add aeolus-conductor
/sbin/chkconfig --add conductor-dbomatic
/sbin/chkconfig --add conductor-delayed_job

%preun daemons
if [ $1 = 0 ]; then
   /sbin/service aeolus-conductor stop > /dev/null 2>&1
   /sbin/chkconfig --del aeolus-conductor
   /sbin/service conductor-dbomatic stop > /dev/null 2>&1
   /sbin/chkconfig --del conductor-dbomatic
   /sbin/service conductor-delayed_job stop > /dev/null 2>&1
   /sbin/chkconfig --del conductor-delayed_job
fi

%files
%dir %{app_root}
%{app_root}/app
%{app_root}/config
%{app_root}/config.ru
%{app_root}/db
%{app_root}/dbomatic
%{app_root}/dutils
%{app_root}/lib
%{app_root}/log
%{app_root}/public
%{app_root}/Rakefile
%{app_root}/script/delayed_job
%config %{_sysconfdir}/%{name}
%doc AUTHORS COPYING

%files daemons
%{_initrddir}/aeolus-conductor
%{_initrddir}/conductor-dbomatic
%{_initrddir}/conductor-delayed_job
%config(noreplace) %{_sysconfdir}/logrotate.d/%{name}
%config(noreplace) %{_sysconfdir}/sysconfig/aeolus-conductor
%config(noreplace) %{_sysconfdir}/sysconfig/conductor-rails
%config(noreplace) %{_sysconfdir}/httpd/conf.d/%{name}.conf
%attr(-, aeolus, aeolus) %{_localstatedir}/lib/%{name}
%attr(-, aeolus, aeolus) %{_localstatedir}/run/%{name}
%attr(-, aeolus, aeolus) %{_localstatedir}/log/%{name}
%attr(-, aeolus, aeolus) %{app_root}/log/delayed_job.log
%doc AUTHORS COPYING

%files doc
%{doc_root}
%doc AUTHORS COPYING

%files devel
%{app_root}/features
%{app_root}/script
%{app_root}/spec

%changelog
* Thu Jul 21 2011 Mo Morsi <mmorsi@redhat.com> - 0.3.0-2
- update Source0 checkout instructions

* Wed Jul 20 2011 Mo Morsi <mmorsi@redhat.com> - 0.3.0-1
- new upstream release
- changes to conform to fedora guidelines

* Tue Apr 05 2011 Chris Lalancette <clalance@redhat.com> - 0.0.3-2
- Large spec file cleanup
- Split out development files into a -devel package
- Remove external dependencies and add to the aeolus-all package

* Thu Jan 20 2011 Chris Lalancette <clalance@redhat.com> - 0.0.3-1
- Rename from deltacloud-aggregator to aeolus-conductor

* Mon Sep 27 2010 Chris Lalancette <clalance@redhat.com> - 0.0.2-3
- Added new rubygem-parseconfig dependency
- Turn on services during install with chkconfig

* Sat Mar 6 2010 Ian Main <imain@redhat.com> - 0.0.2-2
- removed taskomatic from packaging.

* Wed Feb 18 2010 Mohammed Morsi <mmorsi@redhat.com> - 0.0.2-1
- renamed portal to aggregator
- updated / cleaned up package

* Fri Sep  1 2009  <sseago@redhat.com> - 0.0.1-1
- Initial build.