debian: change projectroot to /var/lib/git

Julian Gilbey wrote:
> On Sun, May 19, 2013 at 12:49:08PM -0700, Jonathan Nieder wrote:

>> Maybe that suggests a way to make a smooth transition:
>>
>>  1. preinst installs symlinks /var/lib/git/* -> /var/cache/git/*
>>  2. updated conffiles refer to /var/lib/git
>>  3. NEWS.Debian helps admins move the data to /var/lib/git
>
> That could work, indeed.

Ok, let's do that.  A more complete automatic migration can always be
built on top of this later if someone writes the scripts for it.

> Though I would recommend /srv/git instead of /var/lib/git, as that is
> the directory recommended by the git documentation.

The FHS says

	The methodology used to name subdirectories of /srv is
	unspecified as there is currently no consensus on how this
	should be done. One method for structuring data under /srv is
	by protocol, eg.  ftp, rsync, www, and cvs. On large systems
	it can be useful to structure /srv by administrative context,
	such as /srv/physics/www, /srv/compsci/cvs, etc. This setup
	will differ from host to host.  Therefore, no program should
	rely on a specific subdirectory structure of /srv existing or
	data necessarily being stored in /srv.

which makes /srv/git a reasonable example for the documentation but
not something I can set up in the packaging.  Users can always switch
to that on their on systems, though.

Here's a rough patch for step 1.  Step 2 would be to make preinst
automatically create the appropriate symlinks to save most sysadmins
from the trouble of having to do anything to keep their system
working.

Fixes: http://bugs.debian.org/483788
Signed-off-by: Jonathan Nieder <jrnieder@gmail.com>
diff --git a/debian/changelog b/debian/changelog
index 8d17304..5a7c8bc 100644
--- a/debian/changelog
+++ b/debian/changelog
@@ -1,3 +1,21 @@
+git (1:1.8.3.2-1.1) experimental; urgency=low
+
+  * use /var/lib/git instead of /var/cache/git as default git
+    project root to comply with the Filesystem Hierarchy Standard
+    (thx Julian Gilbey; closes: #483788):
+    * git-daemon.default, git-daemon.in, git-daemon/run: use
+      base path of /var/lib and projectroot of /var/lib/git.
+    * gitweb.conf: $projectroot = "/var/lib/git".
+    * rules: package git: install empty /var/lib/git directory
+      instead of /var/cache/git.
+    * git.README.Debian, git-daemon-run.README.Debian,
+      git-daemon-sysvinit.README.Debian, gitweb.README.Debian:
+      update for the new project root.
+    * git.NEWS.Debian: advertise the change and explain how to
+      adapt to it.
+
+ -- Jonathan Nieder <jrnieder@gmail.com>  Sat, 06 Jul 2013 15:15:15 -0700
+
 git (1:1.8.3.2-1) unstable; urgency=low
 
   * new upstream point release (see RelNotes/1.8.3.2.txt).
diff --git a/debian/git-daemon-run.README.Debian b/debian/git-daemon-run.README.Debian
index 943096a..ffde9a6 100644
--- a/debian/git-daemon-run.README.Debian
+++ b/debian/git-daemon-run.README.Debian
@@ -17,13 +17,13 @@
  ln -s /usr/bin/sv /etc/init.d/git-daemon
  /etc/init.d/git-daemon status
 
-The git daemon by default looks into the directory /var/cache/git/ for
+The git daemon by default looks into the directory /var/lib/git/ for
 repositories (this is configured in /etc/sv/git-daemon/run).  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 ~pape/git/foo/.git /var/cache/git/foo.git
+ ln -s ~pape/git/foo/.git /var/lib/git/foo.git
 
 This makes 'git-clone git://git.example.org/git/foo' to clone the foo
 repository on remote machines work.
diff --git a/debian/git-daemon-sysvinit.README.Debian b/debian/git-daemon-sysvinit.README.Debian
index 320d700..cea76b6 100644
--- a/debian/git-daemon-sysvinit.README.Debian
+++ b/debian/git-daemon-sysvinit.README.Debian
@@ -17,13 +17,13 @@
 
   # /etc/init.d/git-daemon start
 
-The git daemon by default looks into the directory /var/cache/git/ for
+The git daemon by default looks into the directory /var/lib/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
+ ln -s ~daniel/git/foo/.git /var/lib/git/foo.git
 
 This makes 'git-clone git://git.example.org/git/foo' to clone the foo
 repository on remote machines work.
diff --git a/debian/git-daemon.default b/debian/git-daemon.default
index 2020805..fd62168 100644
--- a/debian/git-daemon.default
+++ b/debian/git-daemon.default
@@ -8,7 +8,7 @@
 
 GIT_DAEMON_ENABLE=false
 GIT_DAEMON_USER=gitdaemon
-GIT_DAEMON_DIRECTORY=/var/cache/git
+GIT_DAEMON_DIRECTORY=/var/lib/git
 
 # Additional options that are passed to the Daemon.
 GIT_DAEMON_OPTIONS=""
diff --git a/debian/git-daemon.init b/debian/git-daemon.init
index 7bfe17d..cc98a00 100644
--- a/debian/git-daemon.init
+++ b/debian/git-daemon.init
@@ -26,8 +26,8 @@
 [ -r /etc/default/$NAME ] && . /etc/default/$NAME
 
 GIT_DAEMON_USER=${GIT_DAEMON_USER:-gitdaemon}
-GIT_DAEMON_BASE_PATH=${GIT_DAEMON_BASE_PATH:-/var/cache}
-GIT_DAEMON_DIRECTORY=${GIT_DAEMON_DIRECTORY:-/var/cache/git}
+GIT_DAEMON_BASE_PATH=${GIT_DAEMON_BASE_PATH:-/var/lib}
+GIT_DAEMON_DIRECTORY=${GIT_DAEMON_DIRECTORY:-/var/lib/git}
 
 DAEMON_ARGS="--user=$GIT_DAEMON_USER --pid-file=$PIDFILE --detach"
 DAEMON_ARGS="$DAEMON_ARGS --reuseaddr --verbose $GIT_DAEMON_OPTIONS"
diff --git a/debian/git-daemon/run b/debian/git-daemon/run
index ef24724..b865526 100755
--- a/debian/git-daemon/run
+++ b/debian/git-daemon/run
@@ -3,4 +3,4 @@
 echo 'git-daemon starting.'
 exec chpst -ugitdaemon \
   "$(git --exec-path)"/git-daemon --verbose --reuseaddr \
-    --base-path=/var/cache /var/cache/git
+    --base-path=/var/lib /var/lib/git
diff --git a/debian/git.NEWS.Debian b/debian/git.NEWS.Debian
index 8502b03..32c8acf 100644
--- a/debian/git.NEWS.Debian
+++ b/debian/git.NEWS.Debian
@@ -1,3 +1,26 @@
+git (1:1.8.3.2-1.1) experimental; urgency=low
+
+  Starting with this version, gitweb and "git daemon" on Debian are
+  configured to look for repositories under /var/lib/git by default
+  instead of /var/cache/git.
+
+  To ensure your existing repositories remain accessible:
+
+    rmdir /var/lib/git
+    mv /var/cache/git /var/lib/git
+
+  Or:
+
+    cd /var/lib/git
+    mv ../../cache/git/* .
+
+  You may also want to adjust your inetd, rsyncd, and web server
+  configuration to use the new base path.
+
+  See /usr/share/doc/git/README.Debian for details.
+
+ -- Jonathan Nieder <jrnieder@gmail.com>  Sat, 06 Jul 2013 15:22:18 -0700
+
 git (1:1.8.2~rc0-1) experimental; urgency=low
 
   The default behavior of "git push" when run without specifying any
diff --git a/debian/git.README.Debian b/debian/git.README.Debian
index b96faf9..7a25a5c 100644
--- a/debian/git.README.Debian
+++ b/debian/git.README.Debian
@@ -9,8 +9,8 @@
 git-daemon service, configure inetd(8) to launch it on demand, or install the
 git-daemon-run package to run it permanently:
  cat >> /etc/inetd.conf <<EOF
-git stream tcp4 nowait nobody /usr/bin/git git daemon --inetd --base-path=/var/cache /var/cache/git
-git stream tcp6 nowait nobody /usr/bin/git git daemon --inetd --base-path=/var/cache /var/cache/git
+git stream tcp4 nowait nobody /usr/bin/git git daemon --inetd --base-path=/var/lib /var/lib/git
+git stream tcp6 nowait nobody /usr/bin/git git daemon --inetd --base-path=/var/lib /var/lib/git
 EOF
 
 Or:
@@ -22,12 +22,12 @@
  sv stat git-daemon
  cat /var/log/git-daemon/current
 
-The git daemon by default looks into the directory /var/cache/git/ for
+The git daemon by default looks into the directory /var/lib/git/ for
 repositories (this is configured in /etc/sv/git-daemon/run).  It expects
-the repositories' .git subdirectories in /var/cache/git/, symlinks pointing
+the repositories' .git subdirectories in /var/lib/git/, symlinks pointing
 to the corresponding subdirectories in the repositories are just fine, e.g.:
 
- ln -s ~pape/git/foo/.git /var/cache/git/foo.git
+ ln -s ~pape/git/foo/.git /var/lib/git/foo.git
 
 Now git-clone git://git.example.org/git/repo will work.
 
@@ -36,7 +36,7 @@
 like this:
 
 [git]
-    path = /var/cache/git
+    path = /var/lib/git
     readonly = yes
 
 Now git-clone rsync://git.example.org/git/repo will work.
@@ -52,12 +52,12 @@
     ServerAdmin webmaster@example.org
     HeaderName HEADER
     # bogus but safe DocumentRoot
-    DocumentRoot /var/cache/git
+    DocumentRoot /var/lib/git
     ErrorLog /var/log/apache2/git.example.org-error.log
     CustomLog /var/log/apache2/git.example.org-access.log combined
     Alias /robots.txt /var/www/cvs.robots.txt
     Alias /static /usr/share/gitweb/static
-    Alias /git /var/cache/git
+    Alias /git /var/lib/git
     ScriptAlias / /usr/share/gitweb/gitweb.cgi
     RedirectMatch permanent "^/~(.*)$" "http://example.org/~$1" 
 </VirtualHost>
diff --git a/debian/gitweb.README.Debian b/debian/gitweb.README.Debian
index f2ea231..331935d 100644
--- a/debian/gitweb.README.Debian
+++ b/debian/gitweb.README.Debian
@@ -1,12 +1,12 @@
 gitweb for Debian
 -----------------
 
-The gitweb CGI by default looks into the directory /var/cache/git/ for
+The gitweb CGI by default looks into the directory /var/lib/git/ for
 browsable repositories (this is configured in /etc/gitweb.conf).  It expects
-the repositories' .git subdirectories in /var/cache/git/, symlinks pointing
+the repositories' .git subdirectories in /var/lib/git/, symlinks pointing
 to the corresponding subdirectories in the repositories are just fine, e.g.:
 
- ln -s ~pape/git/foo/.git /var/cache/git/foo.git
+ ln -s ~pape/git/foo/.git /var/lib/git/foo.git
 
 On systems with an Apache webserver, gitweb is automatically made available at
 http://localhost/gitweb. You can deactivate it by commenting out the first
diff --git a/debian/gitweb.conf b/debian/gitweb.conf
index ea99551..1c398c6 100644
--- a/debian/gitweb.conf
+++ b/debian/gitweb.conf
@@ -1,5 +1,5 @@
 # path to git projects (<project>.git)
-$projectroot = "/var/cache/git";
+$projectroot = "/var/lib/git";
 
 # directory to use for temp files
 $git_temp = "/tmp";
diff --git a/debian/rules b/debian/rules
index 3693ec6..37381e8 100755
--- a/debian/rules
+++ b/debian/rules
@@ -114,7 +114,7 @@
 	rm -rf '$(GIT)'
 	install -d -m0755 '$(GIT)'/usr/bin
 	DESTDIR='$(GIT)' $(MAKE) install $(OPTS)
-	install -d -m0755 '$(GIT)'/var/cache/git
+	install -d -m0755 '$(GIT)'/var/lib/git
 	rm -f '$(GIT)'/usr/share/perl5/Error.pm
 	rm -rf '$(GIT)'/usr/share/man
 	chmod 644 '$(GIT)'/usr/share/perl5/Git.pm