here's the updated patch. -- Address: Daniel Baumann, Burgunderstrasse 3, CH-4562 Biberist Email: daniel.baum...@panthera-systems.net Internet: http://people.panthera-systems.net/~daniel-baumann/
>From f83d3746522596ec58fce9dc12f407c2f503012d 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.README.Debian | 31 ++++++++ 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 | 132 ++++++++++++++++++++++++++++++++++ debian/rules | 20 ++++-- 8 files changed, 259 insertions(+), 8 deletions(-) create mode 100644 debian/git-daemon-sysv.README.Debian 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.README.Debian b/debian/git-daemon-sysv.README.Debian new file mode 100644 index 0000000..03f0646 --- /dev/null +++ b/debian/git-daemon-sysv.README.Debian @@ -0,0 +1,31 @@ +git-daemon-sysv for Debian +-------------------------- + +This package enables a git-daemon service. This allows people to use a +git:// URL to access your repositories. + +After installing this package, the daemon needs to be enabled in +/etc/default/git-daemon by setting: + + GIT_DAEMON_ENABLE=false + +to: + + GIT_DAEMON_ENABLE=true + +After that, the git daemon can be started with: + + # /etc/init.d/git-daemon start + +The git daemon by default looks into the directory /var/cache/git/ for +repositories (this is configured in /etc/default/git-daemon). It expects +the repositories' .git subdirectories in that directory, symlinks +pointing to the corresponding subdirectories in the repositories are just +fine, e.g.: + + ln -s ~daniel/git/foo/.git /var/cache/git/foo.git + +This makes 'git-clone git://git.example.org/git/foo' to clone the foo +repository on remote machines work. + + -- Daniel Baumann <dan...@debian.org> Tue, 19 Oct 2010 00:54:58 +0200 diff --git a/debian/git-daemon-sysv.postinst b/debian/git-daemon-sysv.postinst new file mode 100644 index 0000000..bb734c7 --- /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..c9a6a6a --- /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..2c3657c --- /dev/null +++ b/debian/git-daemon/sysv @@ -0,0 +1,132 @@ +#!/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_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) + if [ $GIT_DAEMON_ENABLE = true ]; then + [ "$VERBOSE" != no ] && log_daemon_msg "Starting $DESC " "$NAME" + else + [ "$VERBOSE" != no ] && log_warning_msg "$NAME not enabled in /etc/default/$NAME, not starting..." + exit 0 + fi + + 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.2.3