From 8f7df1c8334674979263935c9ebb9874e39c8f20 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Antoine=20Beaupr=C3=A9?= <anarcat@koumbit.org>
Date: Tue, 23 Nov 2010 17:03:04 -0500
Subject: [PATCH] resurrect the debian branch

---
 debian/README.Debian            |  21 ++++++
 debian/TODO                     |  20 ++++++
 debian/aegir-provision.dirs     |   6 ++
 debian/aegir-provision.examples |   2 +
 debian/aegir-provision.lintian  |   1 +
 debian/aegir-provision.postinst | 122 ++++++++++++++++++++++++++++++++
 debian/aegir-provision.postrm   |  57 +++++++++++++++
 debian/apache.conf              |   1 +
 debian/changelog                |  62 ++++++++++++++++
 debian/compat                   |   1 +
 debian/control                  |  27 +++++++
 debian/copyright                |  47 ++++++++++++
 debian/rules                    |  94 ++++++++++++++++++++++++
 debian/watch                    |  24 +++++++
 14 files changed, 485 insertions(+)
 create mode 100644 debian/README.Debian
 create mode 100644 debian/TODO
 create mode 100644 debian/aegir-provision.dirs
 create mode 100644 debian/aegir-provision.examples
 create mode 100644 debian/aegir-provision.lintian
 create mode 100644 debian/aegir-provision.postinst
 create mode 100644 debian/aegir-provision.postrm
 create mode 100644 debian/apache.conf
 create mode 100644 debian/changelog
 create mode 100644 debian/compat
 create mode 100644 debian/control
 create mode 100644 debian/copyright
 create mode 100755 debian/rules
 create mode 100644 debian/watch

diff --git a/debian/README.Debian b/debian/README.Debian
new file mode 100644
index 000000000..bd2683af3
--- /dev/null
+++ b/debian/README.Debian
@@ -0,0 +1,21 @@
+aegir-provision for Debian
+--------------------------
+
+This is part of the Aegir suite. This package takes care of installing
+the provision file in the proper location so it's seen by Drush and sets
+up some directories and the aegir user. See the INSTALL.txt in the
+hostmaster project for install instructions:
+
+http://drupal.org/project/hostmaster
+
+The directories, under Debian, are:
+
+ Platforms and Aegir home: /var/lib/aegir
+ Backups: /var/backups/aegir
+ Configs: /etc/aegir
+
+All those directories should be owned by the webserver user. You will
+need to enter those paths in the install wizard when setting up the
+platforms and frontend.
+
+ -- Antoine Beaupré <anarcat@koumbit.org>, Fri, 12 Jun 2009 17:11:14 -0400
diff --git a/debian/TODO b/debian/TODO
new file mode 100644
index 000000000..3148ec310
--- /dev/null
+++ b/debian/TODO
@@ -0,0 +1,20 @@
+Here are the parts missing from this package:
+
+ 1. create the aegir user (done)
+ 2. setup sudo (mostly done: need to warn the user if #includedir not
+    set)
+ 3. setup the file infrastructure (done)
+ 4. hook into the apache config: (done)
+   Include /var/aegir/config/vhost.d
+ 5. create a database superuser:
+   GRANT ALL PRIVILEGES ON *.* TO 'username_here'@'%' IDENTIFIED BY 'mypassword' WITH GRANT OPTION;
+   this needs to be done with db-common thingy
+ 6. those settings need to be written to the system-wide drushrc:
+   * mysql creds
+   * config and backup paths (done)
+   * apache restart commands (done)
+   * user and group settings (done)
+ 7. find a proper place for the documentation below.
+
+Some of that code is already available in install.sh.txt in hostmaster
+HEAD.
diff --git a/debian/aegir-provision.dirs b/debian/aegir-provision.dirs
new file mode 100644
index 000000000..4e2addb17
--- /dev/null
+++ b/debian/aegir-provision.dirs
@@ -0,0 +1,6 @@
+usr/share/drush/commands/provision
+var/lib/aegir
+etc/aegir/vhost.d
+var/backups/aegir
+usr/share/lintian/overrides
+etc/drush
diff --git a/debian/aegir-provision.examples b/debian/aegir-provision.examples
new file mode 100644
index 000000000..72bc55910
--- /dev/null
+++ b/debian/aegir-provision.examples
@@ -0,0 +1,2 @@
+example.drushrc.php
+example.sudoers
diff --git a/debian/aegir-provision.lintian b/debian/aegir-provision.lintian
new file mode 100644
index 000000000..26ca8fd28
--- /dev/null
+++ b/debian/aegir-provision.lintian
@@ -0,0 +1 @@
+aegir-provision: non-standard-dir-in-var var/backups/
diff --git a/debian/aegir-provision.postinst b/debian/aegir-provision.postinst
new file mode 100644
index 000000000..b7f1bac74
--- /dev/null
+++ b/debian/aegir-provision.postinst
@@ -0,0 +1,122 @@
+#!/bin/sh
+# postinst script for provision
+#
+# see: dh_installdeb(1)
+
+set -e
+
+# summary of how this script can be called:
+#        * <postinst> `configure' <most-recently-configured-version>
+#        * <old-postinst> `abort-upgrade' <new version>
+#        * <conflictor's-postinst> `abort-remove' `in-favour' <package>
+#          <new-version>
+#        * <postinst> `abort-remove'
+#        * <deconfigured's-postinst> `abort-deconfigure' `in-favour'
+#          <failed-install-package> <version> `removing'
+#          <conflicting-package> <version>
+# for details, see http://www.debian.org/doc/debian-policy/ or
+# the debian-policy package
+
+VARLIB="/var/lib/aegir"
+
+case "$1" in
+    configure)
+        # add a aegir user if one does not already exist
+        if ! getent passwd aegir >/dev/null ; then
+            echo "adding aegir user..."
+            adduser --quiet --system --no-create-home --group \
+                --home "$VARLIB" \
+                --shell '/bin/bash' \
+                --gecos 'Aegir user,,,' \
+                aegir
+        fi
+        adduser --quiet aegir www-data
+
+        TEMPFILE=`tempfile`
+        sedscript=""
+        for binary in /usr/sbin/apachectl /usr/sbin/apache2ctl ; do
+            if [ -x $binary ] ; then
+                sedscript=$sedscript';s#^\#\?\(.*'$binary'.*\)$#\1#'
+            else
+                sedscript=$sedscript';s#^\#\?\(.*'$binary'.*\)$#\#\1#'
+            fi
+        done
+        if ! [ -z "$sedscript" ]; then
+            sed -e "$sedscript" /usr/share/doc/aegir-provision/examples/example.sudoers >> $TEMPFILE
+        else
+            # this should happend, but still handle gracefully
+            cp /usr/share/doc/aegir-provision/examples/examples.sudoers $TEMPFILE
+        fi
+        
+        ucf $TEMPFILE /etc/sudoers.d/aegir
+        rm -f $TEMPFILE
+        ucfr aegir-provision /etc/sudoers.d/aegir
+
+        # create apache configuration for aegir
+        if [ -x /usr/sbin/apache2ctl ] ; then
+            ln -sf /etc/aegir/apache.conf /etc/apache2/conf.d/aegir.conf
+            invoke-rc.d apache2 force-reload
+        elif [ -x /usr/sbin/apachectl ] ; then
+            ln -sf /etc/aegir/apache.conf /etc/apache/conf.d/aegir.conf
+            invoke-rc.d apache force-reload
+        fi
+
+        # fix permissions on installed directories
+        chown aegir:aegir "$VARLIB"
+        for dir in /etc/drush /etc/aegir /var/backups/aegir ; do
+            chown aegir:aegir $dir
+            chmod 0700 $dir
+        done
+
+        # old 0.3-2 cruft, we now write directly to /etc/drush
+        if [ -e /etc/aegir/drushrc.php ]; then
+            ucf /etc/aegir/drushrc.php /etc/drush/drushrc.php
+            ucf --purge /etc/aegir/drushrc.php
+            rm -f /etc/aegir/drushrc.php
+        fi
+
+        TEMPFILE=`tempfile`
+        # fix the apache restart command if we're running apache2
+        if [ -x /usr/sbin/apache2ctl ] ; then
+            command='/usr/sbin/apache2ctl'
+        else
+            command='/usr/sbin/apachectl'
+        fi
+
+        cat >> $TEMPFILE <<EOF
+<?php
+# this file is automatically regenerated by aegir-provision postinst scripts
+# modify at your own risks
+\$options['web_group'] = 'www-data';
+\$options['script_user'] = 'aegir';
+\$options['backup_path'] = '/var/backups/aegir';
+\$options['config_path'] = '/etc/aegir';
+\$options['restart_cmd'] = 'sudo $command graceful';
+EOF
+        # note that aegir-provision is the owner of the drushrc.php
+        # configuration file, not drush.
+        ucf $TEMPFILE /etc/drush/drushrc.php
+        rm -f $TEMPFILE
+        ucfr aegir-provision /etc/drush/drushrc.php
+        chown aegir:aegir /etc/drush/drushrc.php
+        chown 640 /etc/drush/drushrc.php
+
+    ;;
+
+    abort-upgrade|abort-remove|abort-deconfigure)
+    ;;
+
+    *)
+        echo "postinst called with unknown argument \`$1'" >&2
+        exit 1
+    ;;
+esac
+
+# dh_installdeb will replace this with shell code automatically
+# generated by other debhelper scripts.
+
+#DEBHELPER#
+
+exit 0
+
+
diff --git a/debian/aegir-provision.postrm b/debian/aegir-provision.postrm
new file mode 100644
index 000000000..7f7240165
--- /dev/null
+++ b/debian/aegir-provision.postrm
@@ -0,0 +1,57 @@
+#!/bin/sh
+# postrm script for provision
+#
+# see: dh_installdeb(1)
+
+set -e
+
+# summary of how this script can be called:
+#        * <postrm> `remove'
+#        * <postrm> `purge'
+#        * <old-postrm> `upgrade' <new-version>
+#        * <new-postrm> `failed-upgrade' <old-version>
+#        * <new-postrm> `abort-install'
+#        * <new-postrm> `abort-install' <old-version>
+#        * <new-postrm> `abort-upgrade' <old-version>
+#        * <disappearer's-postrm> `disappear' <overwriter>
+#          <overwriter-version>
+# for details, see http://www.debian.org/doc/debian-policy/ or
+# the debian-policy package
+
+
+case "$1" in
+    purge)
+        # delete the aegir user
+        # http://wiki.debian.org/AccountHandlingInMaintainerScripts
+        if which deluser >/dev/null 2>&1 ; then
+            deluser --quiet --system aegir > /dev/null || true
+        else
+            echo >&2 "not removing aegir system account because deluser command was not found"
+        fi
+
+        for conffile in /etc/sudoers.d/aegir /etc/drush/drushrc.php /etc/aegir/drushrc.php; do
+            ucf --purge $conffile
+            rm -f $conffile
+        done
+
+        ( rm /etc/apache/conf.d/aegir.conf > /dev/null 2>&1 && invoke-rc.d apache force-reload ) || true
+        ( rm /etc/apache2/conf.d/aegir.conf > /dev/null 2>&1 && invoke-rc.d apache2 force-reload ) || true
+        
+        ;;
+    remove|upgrade|failed-upgrade|abort-install|abort-upgrade|disappear)
+    ;;
+
+    *)
+        echo "postrm called with unknown argument \`$1'" >&2
+        exit 1
+    ;;
+esac
+
+# dh_installdeb will replace this with shell code automatically
+# generated by other debhelper scripts.
+
+#DEBHELPER#
+
+exit 0
+
+
diff --git a/debian/apache.conf b/debian/apache.conf
new file mode 100644
index 000000000..f56e9f7f5
--- /dev/null
+++ b/debian/apache.conf
@@ -0,0 +1 @@
+Include /etc/aegir/vhost.d/
diff --git a/debian/changelog b/debian/changelog
new file mode 100644
index 000000000..d5b14e802
--- /dev/null
+++ b/debian/changelog
@@ -0,0 +1,62 @@
+aegir-provision (0.3-3) UNRELEASED; urgency=low
+
+  * clarify GPL2+ copyright of drupal.org material
+  * make a standard git-based release process in debian/rules
+  * properly escape meta-characters when generating the drushrc.php file (Closes: #548084).
+  * set proper permissions on drushrc.php (Closes: #548085).
+
+ --
+
+aegir-provision (0.3-2) unstable; urgency=low
+
+  * install sudoers file in /etc/sudoers.d, and the drushrc using ucf so
+    that local changes are preserved
+
+ -- Antoine Beaupré <anarcat@koumbit.org>  Wed, 09 Sep 2009 16:07:37 +0200
+
+aegir-provision (0.3-1) unstable; urgency=low
+
+  * new upstream version (0.3)
+  * update to latest standards (no changes)
+  * make DM-Upload-Allowed
+  * make the aegir user part of the www-data group, as recommended by the
+    upstream INSTALL.txt file (in the hostmaster package)
+
+ -- Antoine Beaupré <anarcat@koumbit.org>  Sun, 30 Aug 2009 16:27:17 -0400
+
+aegir-provision (0.3~rc2-1) unstable; urgency=low
+
+  * new upstream version (0.3-rc2)
+  * fix typos in changelog
+
+ -- Antoine Beaupré <anarcat@koumbit.org>  Wed, 29 Jul 2009 18:34:30 -0400
+
+aegir-provision (0.2-4) unstable; urgency=low
+
+  * add DM-Upload-Allowed field since I'm now a Debian Maintainer
+
+ -- Antoine Beaupré <anarcat@koumbit.org>  Tue, 14 Jul 2009 21:08:05 -0400
+
+aegir-provision (0.2-3) unstable; urgency=low
+
+  * remove parts of the post* scripts that were violating section 10.7.4
+    of the Debian policy, namely the edition of /etc/sudoers and
+    /etc/drush/drushrc.php.
+
+ -- Antoine Beaupré <anarcat@koumbit.org>  Sun, 14 Jun 2009 20:52:54 -0400
+
+aegir-provision (0.2-2) unstable; urgency=low
+
+  * configure apache properly
+  * configure backup and config paths properly
+  * setup users and groups, fix ownership
+  * setup sudoers line
+
+ -- Antoine Beaupré <anarcat@koumbit.org>  Fri, 12 Jun 2009 17:57:38 -0400
+
+aegir-provision (0.2-1) unstable; urgency=low
+
+  * Initial release (Closes: #532923)
+
+ -- Antoine Beaupré <anarcat@koumbit.org>  Fri, 12 Jun 2009 13:30:16 -0400
+
diff --git a/debian/compat b/debian/compat
new file mode 100644
index 000000000..7f8f011eb
--- /dev/null
+++ b/debian/compat
@@ -0,0 +1 @@
+7
diff --git a/debian/control b/debian/control
new file mode 100644
index 000000000..c037732de
--- /dev/null
+++ b/debian/control
@@ -0,0 +1,27 @@
+Source: aegir-provision
+Section: admin
+Priority: optional
+Maintainer: Antoine Beaupré <anarcat@koumbit.org>
+DM-Upload-Allowed: yes
+Build-Depends: debhelper (>= 7)
+Standards-Version: 3.8.3
+Homepage: http://drupal.org/project/provision
+Vcs-git: git://git.koumbit.net/drupal/modules/provision
+Vcs-browser: http://git.koumbit.net/?p=drupal/modules/provision
+
+Package: aegir-provision
+Architecture: all
+Depends: drush (>= 2.0), php5-mysql, mysql-client, sudo (>= 1.7.2p1-1), postfix | mail-transport-agent, apache2 | apache, adduser, ucf
+Description: backend of the Aegir hosting system
+ Provision is a component of the Aegir hosting system.
+ .
+ Ægir is a new set of contributed modules for Drupal that aims to
+ solve the problem of managing a large number of Drupal sites. It does
+ this by providing you with a simple Drupal based hosting front end
+ for your entire network of sites. To deploy a new site you simply
+ have to create a new Site node. To backup or upgrade sites, you
+ simply manage your site nodes as you would any other node.
+ .
+ The provision component of this system provides the back end used for
+ system level tasks such as creating configuration files and managing
+ databases and backup files.
diff --git a/debian/copyright b/debian/copyright
new file mode 100644
index 000000000..2d100e854
--- /dev/null
+++ b/debian/copyright
@@ -0,0 +1,47 @@
+This package was debianized by Antoine Beaupré <anarcat@koumbit.org> on
+Fri, 12 Jun 2009 13:25:02 -0400.
+
+It was downloaded from <url://drupal.org/project/provision>
+
+Upstream Authors:
+
+    Adrian Rossouw, Antoine Beaupré
+
+Copyright:
+
+    Copyright (C) 2008-2009 Adrian Rossouw, Antoine Beaupré
+
+License:
+
+    This package is free software; you can redistribute it and/or modify
+    it under the terms of the GNU General Public License as published by
+    the Free Software Foundation; either version 2 of the License, or
+    (at your option) any later version.
+
+    This package is distributed in the hope that it will be useful,
+    but WITHOUT ANY WARRANTY; without even the implied warranty of
+    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+    GNU General Public License for more details.
+
+    You should have received a copy of the GNU General Public License
+    along with this package; if not, write to the Free Software
+    Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301 USA
+
+Provision is a Drupal module, and as all Drupal.org hosted code, it is
+GPL2+, according to the Drupal association:
+
+http://drupal.org/licensing/faq
+
+"Drupal and all contributed files hosted on Drupal.org are licensed
+under the GNU General Public License, version 2 or later. That means you
+are free to download, reuse, modify, and distribute any files hosted on
+Drupal.org's CVS repository under the terms of either the GPL version 2
+or version 3, and to run Drupal in combination with any code with any
+license that is compatible with either versions 2 or 3, such as the
+Affero General Public License (AGPL) version 3."
+
+On Debian systems, the complete text of the GNU General
+Public License can be found in `/usr/share/common-licenses/GPL'.
+
+The Debian packaging is (C) 2009, Antoine Beaupré <anarcat@koumbit.org> and
+is licensed under the GPL, see above.
diff --git a/debian/rules b/debian/rules
new file mode 100755
index 000000000..de4e9c557
--- /dev/null
+++ b/debian/rules
@@ -0,0 +1,94 @@
+#!/usr/bin/make -f
+# -*- makefile -*-
+# Sample debian/rules that uses debhelper.
+# This file was originally written by Joey Hess and Craig Small.
+# As a special exception, when this file is copied by dh-make into a
+# dh-make output file, you may use that output file without restriction.
+# This special exception was added by Craig Small in version 0.37 of dh-make.
+
+# Uncomment this to turn on verbose mode.
+#export DH_VERBOSE=1
+
+configure: configure-stamp
+configure-stamp:
+	dh_testdir
+
+	touch configure-stamp
+
+build: build-stamp
+
+build-stamp: configure-stamp  
+	dh_testdir
+	touch $@
+
+clean: 
+	dh_testdir
+	dh_testroot
+	rm -f build-stamp configure-stamp
+	dh_clean 
+
+install: build
+	dh_testdir
+	dh_testroot
+	dh_prep
+	dh_installdirs
+
+	cp -r $(CURDIR)/db_server $(CURDIR)/platform $(CURDIR)/provision.* $(CURDIR)/web_server $(CURDIR)/debian/aegir-provision/usr/share/drush/commands/provision/
+	cp $(CURDIR)/debian/aegir-provision.lintian $(CURDIR)/debian/aegir-provision/usr/share/lintian/overrides/aegir-provision
+	cp $(CURDIR)/debian/apache.conf $(CURDIR)/debian/aegir-provision/etc/aegir/apache.conf
+
+# Build architecture-dependent files here.
+binary-arch: build install
+# We have nothing to do by default.
+
+# Build architecture-independent files here.
+binary-indep: build install
+	dh_testdir
+	dh_testroot
+	dh_installchangelogs 
+	dh_installdocs
+	dh_installexamples
+#	dh_install
+#	dh_installmenu
+#	dh_installdebconf	
+#	dh_installlogrotate
+#	dh_installemacsen
+#	dh_installpam
+#	dh_installmime
+#	dh_python
+#	dh_installinit
+#	dh_installcron
+#	dh_installinfo
+	dh_installman
+	dh_link
+	dh_strip
+	dh_compress
+	dh_fixperms
+#	dh_perl
+#	dh_makeshlibs
+	dh_installdeb
+	dh_shlibdeps
+	dh_gencontrol
+	dh_md5sums
+	dh_builddeb
+
+binary: binary-indep binary-arch
+.PHONY: build clean binary-indep binary-arch binary install configure
+
+release: git-buildpackage
+
+MAJOR=$(shell sed -ne 's/^[^(]*(\([^)]*\)).*/\1/;1p' debian/changelog)
+REV=$(shell env LANG=C git show --pretty=format:%h | head -1)
+VERSION="${MAJOR}~git${REV}"
+export VERSION
+export MAJOR
+DRUPAL_VERSION=$(shell sed -ne 's/^[^(]*(\([^)-]*\).*).*/\1/;s/\./-/;1p' debian/changelog )
+
+build-snapshot:
+	@echo "building a package based on the current snapshot (${VERSION})"
+	svn update || true
+	svn export . ../alternc-${VERSION}
+	cd ../alternc-${VERSION} && sed -i -e '1s/)/~svn${REV})/' debian/changelog && debuild
+
+git-buildpackage:
+	git-buildpackage --git-debian-branch=debian --git-upstream-tag=DRUPAL-6--${DRUPAL_VERSION}
diff --git a/debian/watch b/debian/watch
new file mode 100644
index 000000000..d19e5acc6
--- /dev/null
+++ b/debian/watch
@@ -0,0 +1,24 @@
+# Example watch control file for uscan
+# Rename this file to "watch" and then you can run the "uscan" command
+# to check for upstream updates and more.
+# See uscan(1) for format
+
+# Compulsory line, this is a version 3 file
+version=3
+
+# Uncomment to examine a Webpage
+# <Webpage URL> <string match>
+#http://www.example.com/downloads.php drush-(.*)\.tar\.gz
+
+http://ftp.drupal.org/files/projects/provision-6.x-([0-9].*)\.tar\.gz
+# Uncomment to examine a Webserver directory
+#http://www.example.com/pub/drush-(.*)\.tar\.gz
+
+# Uncommment to examine a FTP server
+#ftp://ftp.example.com/pub/drush-(.*)\.tar\.gz debian uupdate
+
+# Uncomment to find new files on sourceforge, for devscripts >= 2.9
+# http://sf.net/drush/drush-(.*)\.tar\.gz
+
+# Uncomment to find new files on GooglePages
+# http://example.googlepages.com/foo.html drush-(.*)\.tar\.gz
-- 
GitLab