You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
151 lines
5.3 KiB
151 lines
5.3 KiB
## |
|
## node-pm2.spec -- OpenPKG RPM Package Specification |
|
## Copyright (c) 2000-2015 OpenPKG Foundation e.V. <http://openpkg.net/> |
|
## |
|
## Permission to use, copy, modify, and distribute this software for |
|
## any purpose with or without fee is hereby granted, provided that |
|
## the above copyright notice and this permission notice appear in all |
|
## copies. |
|
## |
|
## THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED |
|
## WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF |
|
## MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. |
|
## IN NO EVENT SHALL THE AUTHORS AND COPYRIGHT HOLDERS AND THEIR |
|
## CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, |
|
## SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT |
|
## LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF |
|
## USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND |
|
## ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, |
|
## OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT |
|
## OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF |
|
## SUCH DAMAGE. |
|
## |
|
|
|
# package version |
|
%define V_pm2 0.12.9 |
|
%define V_pm2_snap 20150331 |
|
|
|
# package information |
|
Name: node-pm2 |
|
Summary: Node Process Manager |
|
URL: https://github.com/Unitech/pm2 |
|
Vendor: UnitTech |
|
Packager: OpenPKG Foundation e.V. |
|
Distribution: OpenPKG Community |
|
Class: EVAL |
|
Group: Process |
|
License: MIT |
|
Version: %{V_pm2} |
|
Release: 20150331 |
|
|
|
# list of sources |
|
Source0: http://download.openpkg.org/components/versioned/node-pm2/node-pm2-%{V_pm2}-%{V_pm2_snap}.tar.gz |
|
Source1: node-pm2.sh |
|
Source2: node-pm2.c |
|
Source3: rc.node-pm2 |
|
|
|
# build information |
|
BuildPreReq: OpenPKG, openpkg >= 20120101 |
|
PreReq: OpenPKG, openpkg >= 20120101, node |
|
|
|
%description |
|
PM2 is the next-generation CLI process manager for Node.js with |
|
native clusterization and load-balancing. |
|
|
|
%track |
|
prog node-pm2 = { |
|
version = %{V_pm2}-%{V_pm2_snap} |
|
url = http://download.openpkg.org/components/versioned/node-pm2/ |
|
regex = node-pm2-(__VER__)\.tar\.gz |
|
} |
|
|
|
%prep |
|
%setup -q -c |
|
|
|
%build |
|
# build the setuid wrapper |
|
cp %{SOURCE node-pm2.c} . |
|
%{l_shtool} subst %{l_value -s -a} node-pm2.c |
|
%{l_cc} %{l_cflags} %{l_ldflags} -o node-pm2 node-pm2.c |
|
|
|
# remove useless content |
|
rm -rf \ |
|
node_modules/pm2/node_modules/coffee-script/node_modules/mkdirp/test \ |
|
node_modules/pm2/node_modules/cron/tests \ |
|
node_modules/pm2/node_modules/pidusage/tests \ |
|
node_modules/pm2/node_modules/cli-table/test \ |
|
node_modules/pm2/node_modules/chokidar/node_modules/recursive-readdir/test \ |
|
node_modules/pm2/node_modules/pm2-interface/example \ |
|
node_modules/pm2/node_modules/pm2-multimeter/example \ |
|
node_modules/pm2/node_modules/pm2-multimeter/node_modules/charm/example \ |
|
node_modules/pm2/examples \ |
|
node_modules/pm2/test |
|
find . -name ".npmignore" -print | xargs rm -f |
|
find . -name ".travis.yml" -print | xargs rm -f |
|
find . -name "Makefile" -print | xargs rm -f |
|
find . -name "History*" -print | xargs rm -f |
|
find . -name "Readme*" -print | xargs rm -f |
|
find . -name "ReadMe*" -print | xargs rm -f |
|
find . -name "README*" -print | xargs rm -f |
|
find . -name "*LICENSE*" -print | xargs rm -f |
|
find . -name "CHANGELOG*" -print | xargs rm -f |
|
find . -name "GNU*" -print | xargs rm -f |
|
find . -name "CNAME*" -print | xargs rm -f |
|
|
|
%install |
|
# create installation hierarchy |
|
%{l_shtool} mkdir -f -p -m 755 \ |
|
$RPM_BUILD_ROOT%{l_prefix}/bin \ |
|
$RPM_BUILD_ROOT%{l_prefix}/sbin \ |
|
$RPM_BUILD_ROOT%{l_prefix}/etc/rc.d \ |
|
$RPM_BUILD_ROOT%{l_prefix}/lib/node-pm2 \ |
|
$RPM_BUILD_ROOT%{l_prefix}/var/node-pm2/app \ |
|
$RPM_BUILD_ROOT%{l_prefix}/var/node-pm2/run |
|
|
|
# install program parts |
|
cp -rp \ |
|
node_modules/pm2/* \ |
|
$RPM_BUILD_ROOT%{l_prefix}/lib/node-pm2/ |
|
|
|
# install setuid wrapper script |
|
%{l_shtool} install -c -m 755 \ |
|
node-pm2 \ |
|
$RPM_BUILD_ROOT%{l_prefix}/sbin/pm2 |
|
|
|
# install startup wrapper script |
|
%{l_shtool} install -c -m 755 %{l_value -s -a} \ |
|
%{SOURCE node-pm2.sh} \ |
|
$RPM_BUILD_ROOT%{l_prefix}/bin/pm2 |
|
|
|
# install run-command script |
|
%{l_shtool} install -c -m 755 %{l_value -s -a} \ |
|
%{SOURCE rc.node-pm2} \ |
|
$RPM_BUILD_ROOT%{l_prefix}/etc/rc.d/ |
|
|
|
# determine installation files |
|
%{l_rpmtool} files -v -ofiles -r$RPM_BUILD_ROOT \ |
|
%{l_files_std} \ |
|
'%attr(4755,%{l_nusr},%{l_ngrp}) %{l_prefix}/sbin/pm2' \ |
|
'%attr(-,%{l_nusr},%{l_ngrp}) %{l_prefix}/var/node-pm2' \ |
|
'%attr(-,%{l_nusr},%{l_ngrp}) %{l_prefix}/var/node-pm2/app' \ |
|
'%attr(-,%{l_nusr},%{l_ngrp}) %{l_prefix}/var/node-pm2/run' |
|
|
|
%files -f files |
|
|
|
%clean |
|
|
|
%post |
|
# after upgrade, restart service |
|
[ $1 -eq 2 ] || exit 0 |
|
eval `%{l_rc} node-pm2 status 2>/dev/null` |
|
[ ".$node_pm2_active" = .yes ] && %{l_rc} node-pm2 restart |
|
exit 0 |
|
|
|
%preun |
|
# before erase, stop service and remove log files |
|
[ $1 -eq 0 ] || exit 0 |
|
%{l_rc} node-pm2 stop 2>/dev/null |
|
rm -rf $RPM_INSTALL_PREFIX/var/node-pm2/run/* >/dev/null 2>&1 || true |
|
rm -rf $RPM_INSTALL_PREFIX/var/node-pm2/app/* >/dev/null 2>&1 || true |
|
exit 0 |
|
|
|
|