Skip to content

Commit

Permalink
Make Debian scripts respect configure
Browse files Browse the repository at this point in the history
New configure parameters:
--with-debian-stable
--with-debian-unstable

Fixed debian install scripts trashing the eprints user (blocking upgrades).

Use --prefix, --with-user and --with-group to set debian locations.
  • Loading branch information
Tim Brody committed Apr 17, 2013
1 parent 76718e7 commit 42cbf4f
Show file tree
Hide file tree
Showing 7 changed files with 56 additions and 30 deletions.
1 change: 1 addition & 0 deletions Makefile.am
Expand Up @@ -33,6 +33,7 @@ clean-local:

distclean-local:
-rm -f eprints.spec perl_lib/EPrints/SystemSettings.pm bin/epindexer
-rm -f debian/changelog debian/ debian/postinst debian/postrm debian/preinst debian/prerm

realclean: distclean
-rm -f configure Makefile.in aclocal.m4 install-sh missing
Expand Down
7 changes: 7 additions & 0 deletions configure.in
Expand Up @@ -179,6 +179,13 @@ AC_SUBST(PLATFORM)
AC_SUBST(DEBIAN_DATE)
AC_SUBST(DEBIAN_TYPE)



AC_CONFIG_FILES([debian/rules], [chmod +x debian/rules])
AC_CONFIG_FILES([debian/postinst], [chmod +x debian/postinst])
AC_CONFIG_FILES([debian/postrm], [chmod +x debian/postrm])
AC_CONFIG_FILES([debian/preinst], [chmod +x debian/preinst])
AC_CONFIG_FILES([debian/prerm], [chmod +x debian/prerm])
AC_CONFIG_FILES([bin/epindexer], [chmod +x bin/epindexer])

AC_OUTPUT(Makefile perl_lib/EPrints/SystemSettings.pm install.pl eprints.spec debian/changelog)
24 changes: 12 additions & 12 deletions debian/postinst → debian/postinst.in
Expand Up @@ -20,18 +20,18 @@ set -e

case "$1" in
configure)
adduser --system --home /usr/share/eprints3 --shell /bin/bash --group eprints > /dev/null
adduser www-data eprints > /dev/null
rm -f /etc/apache2/sites-available/eprints3
rm -f /etc/apache2/sites-enabled/eprints3
`echo "Include /usr/share/eprints3/cfg/apache.conf" > /etc/apache2/sites-available/eprints3`
`ln -fs /usr/share/eprints3/bin/epindexer /etc/init.d/epindexer`
`update-rc.d epindexer defaults 99 99 > /dev/null`
`chown eprints:www-data /usr/share/eprints3/ > /dev/null`
`chown eprints:www-data /usr/share/eprints3/* -R > /dev/null`
`chmod g+w /usr/share/eprints3/lib > /dev/null`
`chmod g+w /usr/share/eprints3/lib/* -R > /dev/null`
`chmod g+w /usr/share/eprints3/var > /dev/null`
# Why is this adding a user here (in config?)
#adduser --system --home @PREFIX@ --shell /bin/bash --group @INSTALL_GROUP@ > /dev/null
#adduser www-data @INSTALL_USER@ > /dev/null
# Why disable the site in configure?!
#rm -f /etc/apache2/sites-available/@PACKAGE@
#rm -f /etc/apache2/sites-enabled/@PACKAGE@
echo "Include @PREFIX@/cfg/apache.conf" > /etc/apache2/sites-available/@PACKAGE@
ln -fs @PREFIX@/bin/epindexer /etc/init.d/epindexer
update-rc.d epindexer defaults 99 99 > /dev/null
chown @INSTALL_USER@:www-data @PREFIX@ -R > /dev/null
chmod g+w @PREFIX@/lib -R > /dev/null
chmod g+w @PREFIX@/var > /dev/null
echo "###################################################################";
echo "## ##";
echo "## Welcome to EPrints 3 ##";
Expand Down
28 changes: 21 additions & 7 deletions debian/postrm → debian/postrm.in
Expand Up @@ -18,21 +18,35 @@ set -e
# for details, see http://www.debian.org/doc/debian-policy/ or
# the debian-policy package

reload_apache()
{
if apache2ctl configtest 2>/dev/null; then
invoke-rc.d apache2 $1 || true
else
echo "Your apache2 configuration is broken, so we're not restarting it for you."
fi
}

case "$1" in
purge|remove|failed-upgrade|abort-install|abort-upgrade|disappear)
rm -f /etc/apache2/sites-enabled/eprints3
purge|remove|abort-install|disappear)
rm -f /etc/apache2/sites-enabled/@PACKAGE@
rm -f /etc/apache2/sites-available/@PACKAGE@
update-rc.d -f epindexer remove
rm -f /etc/init.d/epindexer
deluser eprints
if [ `grep "eprints" /etc/group` ]; then
delgroup eprints
if getent passwd @INSTALL_USER@ >/dev/null; then
deluser @INSTALL_USER@
fi
if getent group @INSTALL_GROUP@ >/dev/null; then
delgroup @INSTALL_GROUP@
fi
apache2ctl restart
reload_apache restart
;;

abort-upgrade|failed-upgrade)
;;

upgrade)
apache2ctl restart
reload_apache restart
echo "###################################################################";
echo "## ##";
echo "## EPrints 3 Upgrade Complete ##";
Expand Down
17 changes: 9 additions & 8 deletions debian/preinst → debian/preinst.in
Expand Up @@ -15,14 +15,15 @@ set -e


case "$1" in
install|upgrade)
# export EP3_INSTALL=`grep eprints: /etc/passwd`;
# if [ "$EP3_INSTALL" == "" ]
# then
adduser --system --home /usr/share/eprints3 --shell /bin/bash --group eprints > /dev/null
adduser www-data eprints > /dev/null
adduser eprints www-data > /dev/null
# fi
install|upgrade)
if ! getent passwd @INSTALL_USER@ >/dev/null; then
adduser --system --home @PREFIX@ --shell /bin/bash --group @INSTALL_GROUP@ > /dev/null
fi
if ! getent group @INSTALL_GROUP@ >/dev/null; then
addgroup @INSTALL_GROUP@
fi
adduser www-data @INSTALL_GROUP@ > /dev/null
adduser @INSTALL_USER@ www-data > /dev/null
;;

abort-upgrade)
Expand Down
File renamed without changes.
9 changes: 6 additions & 3 deletions install.pl.in
Expand Up @@ -60,7 +60,7 @@ unless( $gid )
warn("Warning! Group $INSTALL_GROUP doesn't exist. You probably need to do: groupadd $INSTALL_GROUP\n");
}

unless( $< == 0 or (defined $uid and $uid == $<) )
unless( $opts{dist} or $< == 0 or (defined $uid and $uid == $<) )
{
warn("Warning! It looks like you're trying to install as user $INSTALL_USER without root. You probably need to do: sudo $0\n");
}
Expand Down Expand Up @@ -269,8 +269,11 @@ sub ensure_dir
my( $dir, $uid, $gid, $mode ) = @_;

File::Path::make_path($dir, {
user => $uid,
group => $gid,
# we're not installing into the dist
($opts{dist} ? () : (
user => $uid,
group => $gid,
)),
mode => $mode,
});

Expand Down

0 comments on commit 42cbf4f

Please sign in to comment.