[Debpool-commits] [SCM] Debpool Project Repository branch, master, updated. 0.2.3-63-g38a32aa

ceros-guest ceros-guest at alioth.debian.org
Tue Jun 3 07:07:14 UTC 2008


The following commit has been merged in the master branch:
commit d837a0c31d96c2cbf51af69d90a371dbc6cb17f5
Author: ceros-guest <ceros-guest>
Date:   Thu Jan 17 03:32:03 2008 +0000

    Updated example debpool init and default files. Have debpool setup a default user configuration at {'HOME'}/.debpool. Have the use of the 'daemon' option tested first right after modules are loaded.

diff --git a/bin/debpool b/bin/debpool
index 7e034d4..9d41a0b 100755
--- a/bin/debpool
+++ b/bin/debpool
@@ -55,18 +55,6 @@ use DebPool::Logging qw(:functions :facility :level); # Logging routines
 use DebPool::Packages qw(:functions :vars); # Distribution databases
 use DebPool::Signal qw(:functions :vars); # Handle signals
 
-my @compression_methods;
-
-# Have support for multiple compression schemes in a dynamical fashion
-if ($Options{'compress_dists'}) {
-    require DebPool::Gzip; # Gzip interaction routines
-    push @compression_methods, new DebPool::Gzip;
-}
-if ($Options{'bzcompress_dists'}) {
-    require DebPool::Bzip2; # Bzip2 interaction routines
-    push @compression_methods, new DebPool::Bzip2;
-}
-
 # Before we do anything else, let's find out if we need to act as a daemon,
 # and if so, whether we can manage to pull it off.
 
@@ -83,6 +71,24 @@ if ($Options{'daemon'}) {
     }
 }
 
+# Set up a directory for debpool in the user's HOME directory, even if we're
+# sure that it will never be used.
+if (! -d "$ENV{'HOME'}/.debpool") {
+    mkdir("$ENV{'HOME'}/.debpool") or
+    Log_Message("Failed to create user configuration directory '$ENV{'HOME'}/.debpool'.", LOG_GENERAL, LOG_ERROR);
+}
+
+# Have support for multiple compression schemes in a dynamical fashion
+my @compression_methods;
+if ($Options{'compress_dists'}) {
+    require DebPool::Gzip; # Gzip interaction routines
+    push @compression_methods, new DebPool::Gzip;
+}
+if ($Options{'bzcompress_dists'}) {
+    require DebPool::Bzip2; # Bzip2 interaction routines
+    push @compression_methods, new DebPool::Bzip2;
+}
+
 # Create the directory tree. This is clean even it it already exists,
 # so we can do it every time we start up. I believe the fancy word is
 # 'idempotent'. We do this before grabbing a lockfile because it should
diff --git a/debian/changelog b/debian/changelog
index 8e9ae5f..4ec6d94 100644
--- a/debian/changelog
+++ b/debian/changelog
@@ -82,6 +82,8 @@ debpool (0.2.4~unreleased0) experimental; urgency=low
     + Fixed problem when uploading packages to an unconfigured distribution.
     + Fixed problem when uploading packages to an unconfigured architecture.
     + Thanks Alexei Chetroi.
+  * Setup a user configuration directory at $ENV{'HOME'}/.debpool if one
+    doesn't exist.
 
  -- Andres Mejia <mcitadel at gmail.com>  Thu, 10 Jan 2008 01:26:13 -0500
 
diff --git a/examples/multiple_debpools/debpool-distro.default b/examples/multiple_debpools/debpool-distro.default
index ce5682d..5b1c8f8 100644
--- a/examples/multiple_debpools/debpool-distro.default
+++ b/examples/multiple_debpools/debpool-distro.default
@@ -8,9 +8,11 @@ ENABLED="0"
 # to specify --daemon.
 OPTIONS="--config /etc/debpool/$DISTRO-Config.pm"
 
-# User or user:group to run debpool as. If you leave it empty, debpool
-# will run as root.
+# User and group to run debpool as. If you leave DEBPOOL_USER empty, debpool
+# will run as root. If you leave the group empty, DEBPOOL_GROUP will be the
+# same as DEBPOOL_USER.
 DEBPOOL_USER=""
+DEBPOOL_GROUP=""
 
 # Specify a path for the log file
 LOGFILE="/var/log/$NAME-$DISTRO.log"
diff --git a/examples/multiple_debpools/debpool-distro.init b/examples/multiple_debpools/debpool-distro.init
index 65aa07d..065f6f6 100644
--- a/examples/multiple_debpools/debpool-distro.init
+++ b/examples/multiple_debpools/debpool-distro.init
@@ -44,6 +44,7 @@ fi
 # Run as root if DEBPOOL_USER not specified
 if [ ! $DEBPOOL_USER ]; then
 	DEBPOOL_USER=root
+	DEBPOOL_GROUP=root
 fi
 
 # Check for an invalid user or one without a home directory
@@ -53,33 +54,34 @@ if [ "${USERHOME#/}" = "${USERHOME}" ]; then
 	exit 1
 fi
 
-# Run as $DEBPOOL_USER if not running as root
+# Run as $DEBPOOL_USER:$DEBPOOL_GROUP if not running as root
 if [ "$DEBPOOL_USER" != "root" ]; then
-	CHUID="--chuid $DEBPOOL_USER"
+	if [ -z "$DEBPOOL_GROUP" ]; then
+		DEBPOOL_GROUP="$DEBPOOL_USER"
+	fi
+	CHUID="--chuid $DEBPOOL_USER:$DEBPOOL_GROUP"
 fi
 
 # If lock file specified, pass it to debpool with --lock_file
 # else try to determine lock file using Debpool::Config
 if [ "$LOCKFILE" ]; then
-	PIDFILE=$LOCKFILE
-	LOCKFILE="--lock_file $LOCKFILE"
+	LOCKFILE_OPT="--lock_file $LOCKFILE"
 else
 	LOCKFILE=$(HOME=$USERHOME debpool --get_lock_path) || \
 		{
 			log_failure_msg "$NAME: could not determine lock file path."
 			exit 1
 		}
-	PIDFILE=$LOCKFILE
-	LOCKFILE="--lock_file $LOCKFILE"
+	LOCKFILE_OPT="--lock_file $LOCKFILE"
 fi
 
 # If log file specified, pass it to debpool with --log_file option
 if [ "$LOGFILE" ]; then
-	LOGFILE="--log_file $LOGFILE"
+	LOGFILE_OPT="--log_file $LOGFILE"
 fi
 
 # Specify all options to use for debpool
-DAEMON_ARGS="--daemon $LOGFILE $LOCKFILE $OPTIONS"
+DAEMON_ARGS="--daemon $LOGFILE_OPT $LOCKFILE_OPT $OPTIONS"
 
 #
 # Function that starts the daemon/service
@@ -90,10 +92,14 @@ do_start()
 	#   0 if daemon has been started
 	#   1 if daemon was already running
 	#   2 if daemon could not be started
-	start-stop-daemon --start --quiet --pidfile $PIDFILE \
+	touch $LOCKFILE
+	chown $DEBPOOL_USER:$DEBPOOL_GROUP $LOCKFILE
+	touch $LOGFILE
+	chown $DEBPOOL_USER:$DEBPOOL_GROUP $LOGFILE
+	start-stop-daemon --start --quiet --pidfile $LOCKFILE \
 		--startas $DAEMON $CHUID --test > /dev/null || \
 		return 1
-	start-stop-daemon --start --quiet --pidfile $PIDFILE \
+	start-stop-daemon --start --quiet --pidfile $LOCKFILE \
 		--startas $DAEMON $CHUID -- $DAEMON_ARGS || \
 		return 2
 }
@@ -108,9 +114,10 @@ do_stop()
 	#   1 if daemon was already stopped
 	#   2 if daemon could not be stopped
 	#   other if a failure occurred
-	start-stop-daemon --stop --quiet --retry=TERM/30/KILL/5 --pidfile $PIDFILE --name $NAME
+	start-stop-daemon --stop --quiet --retry=TERM/30/KILL/5 --pidfile $LOCKFILE --name $NAME
 	RETVAL="$?"
 	[ "$RETVAL" = 2 ] && return 2
+	[ ! -f $LOCKFILE ] || rm $LOCKFILE
 	return "$RETVAL"
 }
 
@@ -126,7 +133,7 @@ do_stop()
 # 	# restarting (for example, when it is sent a SIGHUP),
 # 	# then implement that here.
 # 	#
-# 	start-stop-daemon --stop --signal 1 --quiet --pidfile $PIDFILE --name $NAME
+# 	start-stop-daemon --stop --signal 1 --quiet --pidfile $LOCKFILE --name $NAME
 # 	return 0
 # }
 

-- 
Debpool Project Repository



More information about the Debpool-commits mailing list