package rpm : avancement dans le postinst

This commit is contained in:
Thomas NOËL 2012-07-24 23:31:58 +02:00
parent aedadd88a0
commit 1a9400732a
1 changed files with 24 additions and 2 deletions

View File

@ -48,6 +48,7 @@
Summary: Polycopiés numériques
Name: polynum
Version: %git_get_ver
Release: %git_get_rel
License: AGPLv3+
@ -58,6 +59,7 @@ Source0: %{name}-%{version}.tar.gz
BuildRoot: %{_tmppath}/%{name}-%{version}-%{release}-root
BuildArch: noarch
Provides: polynum
# depends
Requires: python26
Requires: python26-virtualenv
@ -97,7 +99,7 @@ make DESTDIR=%{buildroot} install
# set perms and ownerships of packaged files
# the - indicates that the current permissions on the files should be used
%defattr(-,root,root)
%doc help local_settings.py.example gunicorn_config.py.example README polynum/base/fixtures
%doc requirements help local_settings.py.example gunicorn_config.py.example README polynum/base/fixtures
%config(noreplace) %{_sysconfdir}/sysconfig/%{name}
/opt/polynum/*
/etc/init.d/*
@ -106,12 +108,32 @@ make DESTDIR=%{buildroot} install
%pre
# add polynum group & user
/usr/sbin/groupadd -r polynum || :
/usr/sbin/useradd -r -c "PolyNum daemon user" -d /opt/polynum -g polynum -s /sbin/nologin polynum || :
/usr/sbin/useradd -r -c "PolyNum daemon user" -d /opt/polynum -M -g polynum -s /sbin/nologin polynum || :
%post
# This adds the proper /etc/rc*.d links for the script
/sbin/chkconfig --add polynum
[ -f "%{_sysconfdir}/sysconfig/%{name}" ] && . %{_sysconfdir}/sysconfig/%{name}
# Sane defaults:
[ -z "$POLYNUM_USER" ] && POLYNUM_USER=polynum
[ -z "$POLYNUM_NAME" ] && POLYNUM_NAME="PolyNum daemon user"
[ -z "$POLYNUM_HOME" ] && POLYNUM_HOME=/opt/polynum
[ -z "$POLYNUM_GROUP" ] && POLYNUM_GROUP=polynum
[ -z "$POLYNUM_VAR" ] && POLYNUM_VAR=/var/lib/polynum
[ -z "$POLYNUM_ETC" ] && POLYNUM_ETC=%{_sysconfdir}/polynum
[ -z "$PIDFILE" ] && PIDFILE=/var/run/polynum/polynum.pid
# create pyc with python2.6
echo -n "(re)creating pyc files in "
for pydir in polynum bin virtualenv
do
echo -n "$POLYNUM_HOME/$pydir "
python2.6 -m compileall -f -q $POLYNUM_HOME/$pydir
done
echo "...ok"
%preun
# 'if [ $1 -eq 0 ] ' checks that this is the actual deinstallation of the
# package, as opposed to just removing the old package on upgrade. These