tag 535608 patch
thanks

Hi,

here's a patch against 1:1.7.2.3-2 which i've applied on my local git
packages and which i'm using successfully since some time on my own servers.

I've tried to do it as less intrusive as possible to integrate it with
your packaging style. Please let me know if there's anything you'd like
me to change before you can apply it on the package.

Regards,
Daniel

-- 
Address:        Daniel Baumann, Burgunderstrasse 3, CH-4562 Biberist
Email:          daniel.baum...@panthera-systems.net
Internet:       http://people.panthera-systems.net/~daniel-baumann/
>From 4edc5bcdfd51b99437cc71eff790ae9098299e0c Mon Sep 17 00:00:00 2001
From: Daniel Baumann <dan...@debian.org>
Date: Mon, 18 Oct 2010 11:53:58 +0200
Subject: [PATCH] Adding sysvinit integration for git-daemon (Closes: #422139, #426731, #535608).

---
 debian/control                  |   26 +++++++-
 debian/git-daemon-sysv.postinst |   21 +++++++
 debian/git-daemon-sysv.postrm   |   10 +++
 debian/git-daemon-sysv.prerm    |   13 ++++
 debian/git-daemon/default       |   14 ++++
 debian/git-daemon/sysv          |  127 +++++++++++++++++++++++++++++++++++++++
 debian/rules                    |   20 ++++--
 7 files changed, 223 insertions(+), 8 deletions(-)
 create mode 100644 debian/git-daemon-sysv.postinst
 create mode 100644 debian/git-daemon-sysv.postrm
 create mode 100644 debian/git-daemon-sysv.prerm
 create mode 100644 debian/git-daemon/default
 create mode 100644 debian/git-daemon/sysv

diff --git a/debian/control b/debian/control
index 418dbc7..d740c07 100644
--- a/debian/control
+++ b/debian/control
@@ -17,7 +17,7 @@ Architecture: any
 Depends: ${shlibs:Depends}, perl-modules, liberror-perl,
  libc6.1 (>= 2.10.2-6) [ia64]
 Recommends: patch, less, rsync, ssh-client
-Suggests: git-doc, git-arch, git-cvs, git-svn, git-email, git-daemon-run, git-gui, gitk, gitweb
+Suggests: git-doc, git-arch, git-cvs, git-svn, git-email, git-daemon-run | git-daemon-sysv, git-gui, gitk, gitweb
 Replaces: cogito (<< 0.16rc2-0), git-core (<= 1:1.7.0.4-1)
 Breaks: qgit (<< 1.5.5), git-buildpackage (<< 0.4.38), cogito (<= 0.18.2+),
  stgit (<< 0.15), stgit-contrib (<< 0.15), gitpkg (<< 0.15),
@@ -150,6 +150,8 @@ Description: fast, scalable, distributed revision control system (email add-on)
 Package: git-daemon-run
 Architecture: all
 Depends: git (>> ${source:Upstream-Version}), git (<< ${source:Upstream-Version}-.), runit (>= 1.8.0-2), adduser
+Conflicts: git-daemon-sysv
+Replaces: git-daemon-sysv
 Description: fast, scalable, distributed revision control system (git-daemon service)
  Git is popular version control system designed to handle very large
  projects with speed and efficiency; it is used for many high profile
@@ -165,6 +167,26 @@ Description: fast, scalable, distributed revision control system (git-daemon ser
  repositories through the network.  This package provides a runit service
  for running git-daemon permanently.
 
+Package: git-daemon-sysv
+Architecture: all
+Depends: git (>> ${source:Upstream-Version}), git (<< ${source:Upstream-Version}-.), sysvinit (>= 2.88dsf-12), adduser
+Conflicts: git-daemon-run
+Replaces: git-daemon-run
+Description: fast, scalable, distributed revision control system (git-daemon service)
+ Git is popular version control system designed to handle very large
+ projects with speed and efficiency; it is used for many high profile
+ open source projects, most notably the Linux kernel.
+ .
+ Git falls in the category of distributed source code management tools.
+ Every Git working directory is a full-fledged repository with full
+ revision tracking capabilities, not dependent on network access or a
+ central server.
+ .
+ git-daemon, as provided by the git package, is a simple server for git
+ repositories, ideally suited for read-only updates, i.e. pulling from git
+ repositories through the network.  This package provides a sysvinit service
+ for running git-daemon permanently.
+
 Package: git-gui
 Architecture: all
 Depends: git (>> ${source:Upstream-Version}), git (<< ${source:Upstream-Version}-.), tk (>= 8.4)
@@ -220,7 +242,7 @@ Description: fast, scalable, distributed revision control system (web interface)
 Package: git-all
 Architecture: all
 Depends: git (>> ${source:Upstream-Version}), git (<< ${source:Upstream-Version}-.), git-doc, git-arch, git-cvs, git-svn, git-email, git-gui, gitk, gitweb
-Recommends: git-daemon-run
+Recommends: git-daemon-run | git-daemon-sysv
 Description: fast, scalable, distributed revision control system (all subpackages)
  Git is popular version control system designed to handle very large
  projects with speed and efficiency; it is used for many high profile
diff --git a/debian/git-daemon-sysv.postinst b/debian/git-daemon-sysv.postinst
new file mode 100644
index 0000000..af81dc9
--- /dev/null
+++ b/debian/git-daemon-sysv.postinst
@@ -0,0 +1,21 @@
+#!/bin/sh
+set -e
+
+test "$1" = 'configure' || exit 0
+
+getent passwd gitlog >/dev/null || \
+  adduser --system --home /nonexistent --no-create-home gitlog
+getent passwd gitdaemon >/dev/null || \
+  adduser --system --home /nonexistent --no-create-home gitdaemon
+
+if [ -x "/etc/init.d/git-daemon" ]; then
+	# enable git-daemon service
+	update-rc.d git-daemon defaults >/dev/null
+
+	# restart git-daemon service if it was running
+	if [ -x "`which invoke-rc.d 2>/dev/null`" ]; then
+		invoke-rc.d git-daemon start || exit $?
+	else
+		etc/init.d/git-daemon start || exit $?
+	fi
+fi
diff --git a/debian/git-daemon-sysv.postrm b/debian/git-daemon-sysv.postrm
new file mode 100644
index 0000000..0b00ba1
--- /dev/null
+++ b/debian/git-daemon-sysv.postrm
@@ -0,0 +1,10 @@
+#!/bin/sh
+set -e
+
+test "$1" = 'purge' || exit 0
+
+update-rc.d git-daemon remove >/dev/null
+
+getent passwd gitlog >/dev/null || exit 0
+! deluser --version >/dev/null 2>&1 || exec deluser -f gitlog
+echo 'deluser program not available, not removing system user "gitlog".' >&2
diff --git a/debian/git-daemon-sysv.prerm b/debian/git-daemon-sysv.prerm
new file mode 100644
index 0000000..7a2dfd0
--- /dev/null
+++ b/debian/git-daemon-sysv.prerm
@@ -0,0 +1,13 @@
+#!/bin/sh
+set -e
+
+test "$1" = 'remove' || test "$1" = 'deconfigure' || \
+  test "$1" = 'failed-upgrade' || exit 0
+
+if [ -x "/etc/init.d/git-daemon" ]; then
+	if [ -x "`which invoke-rc.d 2>/dev/null`" ]; then
+		invoke-rc.d git-daemon stop || exit $?
+	else
+		etc/init.d/git-daemon stop || exit $?
+	fi
+fi
diff --git a/debian/git-daemon/default b/debian/git-daemon/default
new file mode 100644
index 0000000..2020805
--- /dev/null
+++ b/debian/git-daemon/default
@@ -0,0 +1,14 @@
+# Defaults for git-daemon initscript
+# sourced by /etc/init.d/git-daemon
+# installed at /etc/default/git-daemon by the maintainer scripts
+
+#
+# This is a POSIX shell fragment
+#
+
+GIT_DAEMON_ENABLE=false
+GIT_DAEMON_USER=gitdaemon
+GIT_DAEMON_DIRECTORY=/var/cache/git
+
+# Additional options that are passed to the Daemon.
+GIT_DAEMON_OPTIONS=""
diff --git a/debian/git-daemon/sysv b/debian/git-daemon/sysv
new file mode 100644
index 0000000..d2c31ac
--- /dev/null
+++ b/debian/git-daemon/sysv
@@ -0,0 +1,127 @@
+#!/bin/sh
+### BEGIN INIT INFO
+# Provides:          git-daemon
+# Required-Start:    $network $remote_fs $syslog
+# Required-Stop:     $network $remote_fs $syslog
+# Default-Start:     2 3 4 5
+# Default-Stop:      0 1 6
+# Short-Description: git-daemon service
+# Description:       git-daemon is a simple server for git repositories,
+#                    ideally suited for read-only updates, i.e. pulling from
+#                    git repositories through the network.
+### END INIT INFO
+
+# PATH should only include /usr/* if it runs after the mountnfs.sh script
+PATH=/sbin:/usr/sbin:/bin:/usr/bin:/usr/lib/git-core
+DESC="git-daemon service"
+NAME=git-daemon
+DAEMON=/usr/lib/git-core/$NAME
+PIDFILE=/var/run/$NAME.pid
+SCRIPTNAME=/etc/init.d/$NAME
+
+# Exit if the package is not installed
+[ -x $DAEMON ] || exit 0
+
+# Read configuration variable file if it is present
+[ -r /etc/default/$NAME ] && . /etc/default/$NAME
+
+GIT_DAEMON_ENABLE=${GIT_DAEMON_ENABLE:-false}
+GIT_DAEMON_USER=${GIT_DAEMON_USER:-gitdaemon}
+GIT_DAEMON_DIRECTORY=${GIT_DAEMON_DIRECTORY:-/var/cache/git}
+
+DAEMON_ARGS="--user=$GIT_DAEMON_USER --reuseaddr --syslog --verbose $GIT_DAEMON_OPTIONS --base-path=$GIT_DAEMON_DIRECTORY $GIT_DAEMON_DIRECTORY"
+
+# Load the VERBOSE setting and other rcS variables
+. /lib/init/vars.sh
+
+# Define LSB log_* functions.
+# Depend on lsb-base (>= 3.0-6) to ensure that this file is present.
+. /lib/lsb/init-functions
+
+#
+# Function that starts the daemon/service
+#
+do_start()
+{
+	# Return
+	#   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 --exec $DAEMON --test > /dev/null \
+		|| return 1
+	start-stop-daemon --start --quiet --pidfile $PIDFILE --exec $DAEMON --background --make-pidfile -- \
+		$DAEMON_ARGS \
+		|| return 2
+}
+
+#
+# Function that stops the daemon/service
+#
+do_stop()
+{
+	# Return
+	#   0 if daemon has been stopped
+	#   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
+	RETVAL="$?"
+	[ "$RETVAL" = 2 ] && return 2
+	# Wait for children to finish too if this is a daemon that forks
+	# and if the daemon is only ever run from this initscript.
+	# If the above conditions are not satisfied then add some other code
+	# that waits for the process to drop all resources that could be
+	# needed by services started subsequently.  A last resort is to
+	# sleep for some time.
+	start-stop-daemon --stop --quiet --oknodo --retry=0/30/KILL/5 --exec $DAEMON
+	[ "$?" = 2 ] && return 2
+	# Many daemons don't delete their pidfiles when they exit.
+	rm -f $PIDFILE
+	return "$RETVAL"
+}
+
+case "$1" in
+  start)
+    [ "$VERBOSE" != no ] && log_daemon_msg "Starting $DESC " "$NAME"
+    do_start
+    case "$?" in
+		0|1) [ "$VERBOSE" != no ] && log_end_msg 0 ;;
+		2) [ "$VERBOSE" != no ] && log_end_msg 1 ;;
+	esac
+  ;;
+  stop)
+	[ "$VERBOSE" != no ] && log_daemon_msg "Stopping $DESC" "$NAME"
+	do_stop
+	case "$?" in
+		0|1) [ "$VERBOSE" != no ] && log_end_msg 0 ;;
+		2) [ "$VERBOSE" != no ] && log_end_msg 1 ;;
+	esac
+	;;
+  status)
+       status_of_proc "$DAEMON" "$NAME" && exit 0 || exit $?
+       ;;
+  restart|force-reload)
+	log_daemon_msg "Restarting $DESC" "$NAME"
+	do_stop
+	case "$?" in
+	  0|1)
+		do_start
+		case "$?" in
+			0) log_end_msg 0 ;;
+			1) log_end_msg 1 ;; # Old process is still running
+			*) log_end_msg 1 ;; # Failed to start
+		esac
+		;;
+	  *)
+		# Failed to stop
+		log_end_msg 1
+		;;
+	esac
+	;;
+  *)
+	echo "Usage: $SCRIPTNAME {start|stop|status|restart|force-reload}" >&2
+	exit 3
+	;;
+esac
+
+:
diff --git a/debian/rules b/debian/rules
index aae9d02..01c5a6c 100755
--- a/debian/rules
+++ b/debian/rules
@@ -62,8 +62,8 @@ clean: deb-checkdir
 	rm -rf '$(TMP)'
 	rm -f patch-stamp build-arch-stamp build-indep-stamp
 	rm -rf '$(GIT)' '$(GIT)'-doc '$(GIT)'-arch '$(GIT)'-cvs \
-	  '$(GIT)'-svn '$(GIT)'-email '$(GIT)'-daemon-run '$(GIT)'-gui \
-	  '$(GIT)'k '$(GIT)'web '$(GIT)'-all '$(GIT)'-core
+	  '$(GIT)'-svn '$(GIT)'-email '$(GIT)'-daemon-run '$(GIT)'-daemon-sysv \
+	  '$(GIT)'-gui '$(GIT)'k '$(GIT)'web '$(GIT)'-all '$(GIT)'-core
 	rm -f debian/files debian/substvars changelog
 
 install: install-arch install-indep
@@ -166,6 +166,14 @@ install-indep: build-arch-stamp build-indep-stamp
 	  '$(GIT)'-daemon-run/etc/sv/git-daemon/run
 	install -m0755 debian/git-daemon/log/run \
 	  '$(GIT)'-daemon-run/etc/sv/git-daemon/log/run
+	# git-daemon-sysv
+	rm -rf '$(GIT)'-daemon-sysv
+	install -d -m0755 '$(GIT)'-daemon-sysv/etc/init.d
+	install -m0755 debian/git-daemon/sysv \
+	  '$(GIT)'-daemon-sysv/etc/init.d/git-daemon
+	install -d -m0755 '$(GIT)'-daemon-sysv/etc/default
+	install -m0644 debian/git-daemon/default \
+	  '$(GIT)'-daemon-sysv/etc/default/git-daemon
 	# git-gui
 	rm -rf '$(GIT)'-gui
 	install -d -m0755 '$(GIT)'-gui/usr/lib/git-core
@@ -230,11 +238,11 @@ binary-arch: install-arch git.deb
 	dpkg-gencontrol -isp -pgit -P'$(GIT)'
 	dpkg -b '$(GIT)' ..
 binary-indep: install-indep git-doc.deb git-arch.deb git-cvs.deb git-svn.deb \
-	  git-daemon-run.deb git-email.deb git-gui.deb gitk.deb gitweb.deb \
-	  git-all.deb git-core.deb-DEBIAN
+	  git-daemon-run.deb git-daemon-sysv.deb git-email.deb git-gui.deb \
+	  gitk.deb gitweb.deb git-all.deb git-core.deb-DEBIAN
 	rm -f debian/substvars
-	for i in -doc -arch -cvs -svn -daemon-run -email -gui k web -all \
-	 -core; do \
+	for i in -doc -arch -cvs -svn -daemon-run -daemon-sysv -email -gui k \
+	 web -all -core; do \
 	  dpkg-gencontrol -isp -pgit$$i -P'$(GIT)'$$i && \
 	  dpkg -b '$(GIT)'$$i .. || exit 1; \
 	done
-- 
1.7.1

Reply via email to