On 06/16/2011 12:44 PM, Jonathan Nieder wrote:
Sure. Looking back over the review at Bug#422139, I see:
- /etc/init.d/git-daemon is not handled as a configuration file,
which violates policy ยง10.7.3. I don't think that's a fundamental
problem, but I am not willing to merge this unless it's at least
documented so people do not get bitten by trying to make
customizations.
done in git.
- some small style nitpicks. If you care deeply about these things,
I'm fine with leaving them alone, obviously.
i used the current 'style' used within the git packaging, if you prefere
another one, it would be nice if you would adjust that after merging the
patch.
- the initscript uses start-stop-daemon --make-pidfile instead of
using the git daemon's own --pid-file support. I don't understand
why the patch does this; daemons that know how to make their own
pid files are not what --make-pidfile is for.
done in git.
- the initscript tries to kill git-daemon's children based on the
executable used. That's dangerous if someone is running another
instance of git-daemon not managed by the initscript on another
port, and it's totally unnecessary --- git-daemon doesn't have any
children using the git-daemon executable, since the children
serving connections are git-upload-pack, git-upload-archive, etc.
done in git.
attached is an updated patch.
Regards,
Daniel
--
Address: Daniel Baumann, Donnerbuehlweg 3, CH-3012 Bern
Email: [email protected]
Internet: http://people.progress-technologies.net/~daniel.baumann/
diff --git a/debian/control b/debian/control
index 60707ec..2f02369 100644
--- a/debian/control
+++ b/debian/control
@@ -21,7 +26,7 @@ Depends: ${shlibs:Depends}, perl-modules, liberror-perl,
git-man (>> ${source:Upstream-Version}), git-man (<< ${source:Upstream-Version}-.),
libc6.1 (>= 2.10.2-6) [ia64]
Recommends: patch, less, rsync, ssh-client
-Suggests: git-doc, git-el, git-arch, git-cvs, git-svn, git-email, git-daemon-run, git-gui, gitk, gitweb
+Suggests: git-doc, git-el, git-arch, git-cvs, git-svn, git-email, git-daemon-run | git-daemon-sysvinit, git-gui, gitk, gitweb
Replaces: gitweb (<< 1:1.7.4~rc1),
cogito (<< 0.16rc2-0), git-core (<< 1:1.7.0.4-1.)
Breaks: gitweb (<< 1:1.7.4~rc1),
@@ -182,6 +187,7 @@ 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-sysvinit
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
@@ -197,6 +203,25 @@ 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-sysvinit
+Architecture: all
+Depends: git (>> ${source:Upstream-Version}), git (<< ${source:Upstream-Version}-.), adduser
+Conflicts: 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
@@ -296,7 +321,7 @@ Package: git-all
Architecture: all
Depends: git (>> ${source:Upstream-Version}), git (<< ${source:Upstream-Version}-.),
git-doc, git-el, git-arch, git-cvs, git-svn, git-email, git-gui, gitk, gitweb
-Recommends: git-daemon-run
+Recommends: git-daemon-run | git-daemon-sysvinit
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-sysvinit.README.Debian b/debian/git-daemon-sysvinit.README.Debian
new file mode 100644
index 0000000..320d700
--- /dev/null
+++ b/debian/git-daemon-sysvinit.README.Debian
@@ -0,0 +1,31 @@
+git-daemon-sysvinit 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 <[email protected]> Tue, 19 Oct 2010 00:54:58 +0200
diff --git a/debian/git-daemon-sysvinit.conffiles b/debian/git-daemon-sysvinit.conffiles
new file mode 100644
index 0000000..c626099
--- /dev/null
+++ b/debian/git-daemon-sysvinit.conffiles
@@ -0,0 +1,2 @@
+/etc/default/git-daemon
+/etc/init.d/git-daemon
diff --git a/debian/git-daemon-sysvinit.postinst b/debian/git-daemon-sysvinit.postinst
new file mode 100644
index 0000000..d186c68
--- /dev/null
+++ b/debian/git-daemon-sysvinit.postinst
@@ -0,0 +1,19 @@
+#!/bin/sh
+set -e
+
+test "$1" = 'configure' || exit 0
+
+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-sysvinit.postrm b/debian/git-daemon-sysvinit.postrm
new file mode 100644
index 0000000..f195c2c
--- /dev/null
+++ b/debian/git-daemon-sysvinit.postrm
@@ -0,0 +1,6 @@
+#!/bin/sh
+set -e
+
+test "$1" = 'remove' || exit 0
+
+update-rc.d git-daemon remove >/dev/null
diff --git a/debian/git-daemon-sysvinit.prerm b/debian/git-daemon-sysvinit.prerm
new file mode 100644
index 0000000..c9a6a6a
--- /dev/null
+++ b/debian/git-daemon-sysvinit.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/sysvinit b/debian/git-daemon/sysvinit
new file mode 100644
index 0000000..d53fd7b
--- /dev/null
+++ b/debian/git-daemon/sysvinit
@@ -0,0 +1,124 @@
+#!/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 --pid-file=$PIDFILE --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 -- \
+ $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
+ # 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 8bc334a..afe1c64 100755
--- a/debian/rules
+++ b/debian/rules
@@ -74,7 +74,7 @@ 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
- rm -rf '$(GIT)'-svn '$(GIT)'-email '$(GIT)'-daemon-run '$(GIT)'-gui
+ rm -rf '$(GIT)'-svn '$(GIT)'-email '$(GIT)'-daemon-run '$(GIT)'-daemon-sysvinit '$(GIT)'-gui
rm -rf '$(GIT)'k '$(GIT)'web '$(GIT)'-all '$(GIT)'-man '$(GIT)'-core
rm -rf '$(GIT)'-el
rm -f debian/files debian/substvars changelog
@@ -197,6 +197,14 @@ install-indep-real: 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-sysvinit
+ rm -rf '$(GIT)'-daemon-sysvinit
+ install -d -m0755 '$(GIT)'-daemon-sysvinit/etc/init.d
+ install -m0755 debian/git-daemon/sysvinit \
+ '$(GIT)'-daemon-sysvinit/etc/init.d/git-daemon
+ install -d -m0755 '$(GIT)'-daemon-sysvinit/etc/default
+ install -m0644 debian/git-daemon/default \
+ '$(GIT)'-daemon-sysvinit/etc/default/git-daemon
# git-el
rm -rf '$(GIT)'-el
install -m0644 -D debian/git-el.emacsen-startup \
@@ -271,10 +279,10 @@ 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-daemon-run.deb git-daemon-sysvinit.deb git-email.deb git-gui.deb gitk.deb gitweb.deb \
git-all.deb git-el.deb git-man.deb git-core.deb-DEBIAN
rm -f debian/substvars
- for i in -doc -arch -cvs -svn -daemon-run -email -gui k web -all \
+ for i in -doc -arch -cvs -svn -daemon-run -daemon-sysvinit -email -gui k web -all \
-core -el -man; do \
dpkg-gencontrol -isp -pgit$$i -P'$(GIT)'$$i && \
dpkg -b '$(GIT)'$$i .. || exit 1; \