VERSION = $(shell dpkg-parsechangelog | sed -n 's/^Version: //p')
+DIST = $(shell dpkg-parsechangelog | sed -n 's/^Distribution: //p')
all: build
build:
install: build
- install -o root -g root -m 0644 auf-git-etc.sh $(DESTDIR)/etc/profile.d/
+ install -o root -g root -m 0755 -d $(DESTDIR)/usr/sbin
install -o root -g root -m 0755 cron.auf-git-etc $(DESTDIR)/usr/sbin/
+ install -o root -g root -m 0755 -d $(DESTDIR)/etc/profile.d
+ install -o root -g root -m 0644 auf-git-etc.sh $(DESTDIR)/etc/profile.d/
+ install -o root -g root -m 0755 -d $(DESTDIR)/etc/auf-git-etc
+ install -o root -g root -m 0644 git.exclude $(DESTDIR)/etc/auf-git-etc/exclude
+ install -o root -g root -m 0755 git.post-commit $(DESTDIR)/etc/auf-git-etc/post-commit
clean:
test:
- debuild -I.git -I*.ex -b -us -uc -tc
+ debuild -I.git -I*.ex -b -us -uc && \
rsync -avP ../auf-git-etc_$(VERSION)_all.deb test:/tmp/
release:
- debuild -I.git -I*.ex
- debrelease --dput auf-debian
+ debuild -I.git -I*.ex && debrelease --dput $(DIST)
--- /dev/null
+/etc/cron.d/auf-git-etc
+/etc/profile.d/auf-git-etc.sh
+/etc/auf-git-etc/exclude
+/etc/auf-git-etc/post-commit
Package: auf-git-etc
Architecture: all
-Depends: git-core, sudo, ${misc:Depends}
+Depends: git-core (>= 1.4.4), sudo, ${misc:Depends}
Recommends: exim4 | mail-transport-agent, cron
Suggests: tig
Description: suivi de /etc et /usr/local via git
-etc/profile.d
usr/sbin
+etc/cron.d
+etc/profile.d
+etc/auf-git-etc
set -e
+# XXX: debogage, à supprimer avant release
+echo "==> postinst($@) - `date`" >> /tmp/auf-git-etc.debug
+ls -la /etc/auf-git-etc >> /tmp/auf-git-etc.debug
+
# summary of how this script can be called:
# * <postinst> `configure' <most-recently-configured-version>
# * <old-postinst> `abort-upgrade' <new version>
configure)
# on ajoute de la souplesse dans /etc/profile
- # XXX: c'est pas vraiment spécifique à ce paquet...
+ # XXX: pas vraiment spécifique à ce paquet... en attendant Lenny !
if ! grep -q '/etc/profile\.d' /etc/profile; then
sed -i -e '/^$/{r /proc/self/fd/0' -e ':l;n;b l}' \
/etc/profile << __EOF__
# gestion transparente de GIT via sudo
if test -f /etc/sudoers; then
-
# on conserve l'environnement GIT pendant un sudo
if ! grep -q "env_keep.*GIT" /etc/sudoers; then
sed -i '/^$/{s//Defaults env_keep += "GIT_COMMITTER_NAME GIT_COMMITTER_EMAIL GIT_AUTHOR_NAME GIT_AUTHOR_EMAIL"\n/;:l;n;b l}' /etc/sudoers
fi
-
# on autorise le groupe admin à demander le statut GIT
if test -f /etc/sudoers && ! grep -q '^%admin.*git status' /etc/sudoers; then
echo '%admin ALL=(ALL) NOPASSWD: /usr/bin/git status -a' >> /etc/sudoers
fi
-
fi
# on vérifie la présence d'un existant
else
cd /
git init-db
+ # git >= 1.5
+ #git config status.relativePaths false
chmod 0700 /.git
mkdir -p /var/lib/git
mv /.git /var/lib/git/root
ln -s /var/lib/git/root /.git
- cp -a /usr/share/doc/auf-git-etc/sample/exclude /.git/info/
- cp -a /usr/share/doc/auf-git-etc/sample/post-commit /.git/hooks/
- chmod 0755 /.git/hooks/post-commit
+ ln -s -f /etc/auf-git-etc/exclude /.git/info/
+ ln -s -f /etc/auf-git-etc/post-commit /.git/hooks/
git add etc usr/local
+ git add boot/grub/menu.lst || true # absent des serveurs virtuels
+ git add var/chroot/bind/etc || true # absent des serveurs non DNS
# TODO: ajouter -q quand on sera en git ≥ 1.5 (Debian "Lenny")
git commit -m "Mise en route du suivi de /etc et /usr/local." \
--author "Installation auf-git-etc <root@apt.auf.org>"
#DEBHELPER#
exit 0
-
-
--- /dev/null
+#!/bin/sh
+# preinst script for test
+#
+# see: dh_installdeb(1)
+
+set -e
+
+# XXX: debogage, à supprimer avant release
+echo "==> preinst($@) `date`" >> /tmp/auf-git-etc.debug
+ls -la /etc/auf-git-etc >> /tmp/auf-git-etc.debug
+
+# summary of how this script can be called:
+# * <new-preinst> `install'
+# * <new-preinst> `install' <old-version>
+# * <new-preinst> `upgrade' <old-version>
+# * <old-preinst> `abort-upgrade' <new-version>
+# for details, see http://www.debian.org/doc/debian-policy/ or
+# the debian-policy package
+
+
+case "$1" in
+ install|upgrade)
+ if [ "`readlink -f /.git`" = "/var/lib/git/root" ]; then
+ # on gère la migration des exclude et post-commit en conffile
+ if [ ! -L /.git/info/exclude ]; then
+ mv -f /etc/auf-git-etc/exclude /etc/auf-git-etc/exclude.dpkg-dist
+ mv /.git/info/exclude /etc/auf-git-etc/
+ fi
+ if [ ! -L /.git/hooks/post-commit ]; then
+ mv -f /etc/auf-git-etc/post-commit /etc/auf-git-etc/post-commit.dpkg-dist
+ mv /.git/hooks/post-commit /etc/auf-git-etc/
+ fi
+ fi
+ ;;
+
+ abort-upgrade)
+ ;;
+
+ *)
+ echo "preinst 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
--- /dev/null
+# Le fichier /var/lib/git/root/info/exclude à modifier ou créer
+# Par défaut, on exclut tout sauf /etc
+/*
+!/etc
+# ... mais dans /etc on interdit certains fichiers :
+/etc/*shadow*
+/etc/ssh/ssh_host_*_key
+/etc/krb5.keytab
+/etc/mtab
+/etc/adjtime
+/etc/ld.so.cache
+/etc/lvm/.cache
+/etc/lvm/archive
+/etc/blkid.tab*
+/etc/ppp/pap-secrets
+/etc/ppp/chap-secrets
+/etc/aliases.db
+/etc/postfix/*.db
+/etc/postfix/*/*.db
+/etc/samba/schannel_store.tdb
+# On n'interdit pas non plus le parcours de /usr. Mais dans ce parcours,
+# on interdit tout sauf /usr/local. C'est la technique pour inclure /usr/local
+!/usr
+/usr/*
+!/usr/local
+# Pareil pour la config de Bind en chroot
+!/var
+/var/*
+!/var/chroot
+/var/chroot/*
+!/var/chroot/bind
+/var/chroot/bind/*
+!/var/chroot/bind/etc
+/var/chroot/bind/etc/bind/rndc.key
+# Le /boot/grub/menu.lst peut être intéressant à suivre aussi
+!/boot
+/boot/*
+!/boot/grub
+/boot/grub/*
+!/boot/grub/menu.lst
+# quelques type fichiers à ne pas jamais considérer, globalement :
+htpasswd
+.htpasswd
+*.dpkg-old
+*.dpkg-new
+*.dpkg-dist
+*.ucf-old
+*.ucf-new
+*.ucf-dist
+.*.swp
+*~
+*#
+*-
+*.bak
+# toutes les clés, généralement type partie privée RSA/DSA
+*.key
+*-key.pem
+# on ne suit pas les log (dans /etc ?!)
+*.log
--- /dev/null
+#!/bin/sh
+recipients="root+git" # adresse pour l'envoi du mail
+# On modifie un peu la sortie de git show :
+# 1) on insère "git hostname - " devant le nom en From:
+# 2) on remplace "[PATCH]" par "git-commit:" dans le champ Subject:
+# 3) on ajoute un champ To:
+# 4) on ajoute un champ Content-Type:
+# et on envoie le tout via sendmail
+PATH=/usr/sbin:/usr/bin:/sbin:/bin
+git show --pretty=email |
+ sed -e '1,6s/^From: /From: git '`hostname -f`' - /' \
+ -e '1,6s/^Subject: \[PATCH\]/Subject: git-commit:/' \
+ -e '3iTo: '"${recipients}" \
+ -e '4iContent-Type: text/plain; charset=utf-8' |
+ head -c 16k | /usr/sbin/sendmail ${recipients}
+exit 0
+++ /dev/null
-# Le fichier /var/lib/git/root/info/exclude à modifier ou créer
-# Par défaut, on exclut tout sauf /etc
-/*
-!/etc
-# ... mais dans /etc on interdit certains fichiers :
-/etc/*shadow*
-/etc/ssh/ssh_host_*_key
-/etc/krb5.keytab
-/etc/mtab
-/etc/adjtime
-/etc/ld.so.cache
-/etc/lvm/.cache
-/etc/lvm/archive
-/etc/blkid.tab*
-/etc/ppp/pap-secrets
-/etc/ppp/chap-secrets
-/etc/aliases.db
-/etc/postfix/*.db
-/etc/postfix/*/*.db
-/etc/samba/schannel_store.tdb
-# On n'interdit pas non plus le parcours de /usr. Mais dans ce parcours,
-# on interdit tout sauf /usr/local. C'est la technique pour inclure /usr/local
-!/usr
-/usr/*
-!/usr/local
-# Pareil pour la config de Bind en chroot
-!/var
-/var/*
-!/var/chroot
-/var/chroot/*
-!/var/chroot/bind
-/var/chroot/bind/*
-!/var/chroot/bind/etc
-/var/chroot/bind/etc/bind/rndc.key
-# Le /boot/grub/menu.lst peut être intéressant à suivre aussi
-!/boot
-/boot/*
-!/boot/grub
-/boot/grub/*
-!/boot/grub/menu.lst
-# quelques type fichiers à ne pas jamais considérer, globalement :
-htpasswd
-.htpasswd
-*.dpkg-old
-*.dpkg-new
-*.dpkg-dist
-*.ucf-old
-*.ucf-new
-*.ucf-dist
-.*.swp
-*~
-*#
-*-
-*.bak
-# toutes les clés, généralement type partie privée RSA/DSA
-*.key
-*-key.pem
-# on ne suit pas les log (dans /etc ?!)
-*.log
+++ /dev/null
-#!/bin/sh
-recipients="root+git" # adresse pour l'envoi du mail
-# On modifie un peu la sortie de git show :
-# 1) on insère "git hostname - " devant le nom en From:
-# 2) on remplace "[PATCH]" par "git-commit:" dans le champ Subject:
-# 3) on ajoute un champ To:
-# 4) on ajoute un champ Content-Type:
-# et on envoie le tout via sendmail
-PATH=/usr/sbin:/usr/bin:/sbin:/bin
-git show --pretty=email |
- sed -e '1,6s/^From: /From: git '`hostname -f`' - /' \
- -e '1,6s/^Subject: \[PATCH\]/Subject: git-commit:/' \
- -e '3iTo: '"${recipients}" \
- -e '4iContent-Type: text/plain; charset=utf-8' |
- head -c 16k | /usr/sbin/sendmail ${recipients}
-exit 0