File macros.webyast of Package rubygem-webyast-rake-tasks

#--
# Webyast framework
#
# Copyright (C) 2009, 2012 Novell, Inc. 
#   This library is free software; you can redistribute it and/or modify
# it only under the terms of version 2.1 of the GNU Lesser General Public
# License as published by the Free Software Foundation. 
#
#   This library is distributed in the hope that it will be useful, but WITHOUT
# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
# FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more 
# details. 
#
#   You should have received a copy of the GNU Lesser General Public
# License along with this library; if not, write to the Free Software 
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
#++

#
# common RPM macro definitions used by WebYaST
#


# target directories
%webyast_dir /srv/www/webyast

# variable directories
%webyast_vardir /var/lib/webyast

# users who run the services
%webyast_user webyast

# service names (init script names in /etc/init.d)
%webyast_service webyast

# build REST documentation, move it to public/ in webyast-base, pre-gzip it (for nginx)
# and remove the sources
# usage: use in %install section, add target directory parameter
# example: %webyast_build_restdoc public/my_module/restdoc
%webyast_build_restdoc() \
    cd $RPM_BUILD_ROOT/%{_libdir}/ruby/gems/%{rb_ver}/gems/%{mod_full_name} \
    export RAILS_PARENT=%{webyast_dir} \
    cp %{webyast_dir}/Gemfile Gemfile.restility \
    echo 'gem "restility"' >> Gemfile.restility \
    LC_ALL=en_US.UTF-8 BUNDLE_GEMFILE=Gemfile.restility rake restdoc \
    rm -f Gemfile.restility Gemfile.restility.lock \
    rm -rf restdoc \
    cd -

# update manifest.yml file
# use assets.rake file directly (faster loading)
# (Usually not needed, replaced by update script functionality)
%webyast_update_assets \
    cd %{webyast_dir} \
    rake -f lib/tasks/assets.rake assets:join_manifests \
    if test -f "Gemfile" ; then \
      bundle update \
    fi \
    cd -

# update manifest.yml file
# use assets.rake file directly (faster loading)
%webyast_remove_assets \
    cd %{webyast_dir} \
    if test -f "Gemfile" ; then \
      bundle update \
    fi \
    rake -f lib/tasks/assets.rake assets:join_manifests \
    cd -

# run plugin testsuite (from %check section)
%webyast_run_plugin_tests \
    export TEST_DB_PATH=/tmp/webyast_test.sqlite3 \
    export RAILS_PARENT=%{webyast_dir} \
    rm -rf $TEST_DB_PATH \
    cd $RPM_BUILD_ROOT/%{_libdir}/ruby/gems/%{rb_ver}/gems/%{mod_full_name} \
    cp %{webyast_dir}/Gemfile.test Gemfile.test \
    BUNDLE_GEMFILE=Gemfile.test RAILS_ENV=test rake db:create \
    BUNDLE_GEMFILE=Gemfile.test RAILS_ENV=test rake db:schema:load \
    echo 'gem "%{mod_name}", :path => "."' >> Gemfile.test \
    BUNDLE_GEMFILE=Gemfile.test RAILS_ENV=test ADD_BUILD_PATH=1 rake test \
    rm -rf $TEST_DB_PATH Gemfile.test Gemfile.test.lock log \
    cd -

# build (precompile) plugin assets (in %install section)
%webyast_build_plugin_assets \
    export RAILS_PARENT=%{webyast_dir} \
    cd $RPM_BUILD_ROOT/%{_libdir}/ruby/gems/%{rb_ver}/gems/%{mod_full_name} \
    BUNDLE_GEMFILE=Gemfile.assets rake assets:precompile \
    rm -f Gemfile.assets Gemfile.assets.lock \
    rm -rf tmp \
    mkdir -p $RPM_BUILD_ROOT/srv/www/webyast/public/assets \
    mv public/assets/* $RPM_BUILD_ROOT/srv/www/webyast/public/assets \
    rm -rf public/assets \
    mv $RPM_BUILD_ROOT/srv/www/webyast/public/assets/manifest.yml $RPM_BUILD_ROOT/srv/www/webyast/public/assets/manifest.yml.%{mod_name} \
    rm -rf log \
    cd -

# set the flag to restart webyast at the end of libzypp transaction via update script
%restart_webyast \
    touch /var/lib/webyast/restart

# restart file name for files section
%restart_script_name \
    /var/adm/update-scripts/%name-%version-%release-update

# create a restart script (symlink the base script) (for build section)
# make the symlink relative so it is valid even in chroot (/mnt) during initial installation
%create_restart_script \
    mkdir -p $RPM_BUILD_ROOT/var/adm/update-scripts \
    ln -s ../../../usr/sbin/update_webyast_service $RPM_BUILD_ROOT/var/adm/update-scripts/%name-%version-%release-update

%webyast_polkit \
    %if 0%{?suse_version} == 0 || %suse_version > 1110 \
      WEBYAST_POLKIT_DIR='polkit-1/actions' \
    %else \
      # SLES11 or < 11.1 \
      WEBYAST_POLKIT_DIR='PolicyKit/policy'  \
    %endif 
openSUSE Build Service is sponsored by