From 539b9d2f83a9cf6f5523dc445025ddae72f0946b Mon Sep 17 00:00:00 2001 From: Progfou Date: Fri, 7 Nov 2008 04:09:17 +0700 Subject: [PATCH] =?utf8?q?Premi=C3=A8re=20tentative=20de=20support=20de=20fi?= =?utf8?q?chiers=20de=20configuration=20Debian.?= MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit --- Makefile | 13 ++++++++---- debian/conffiles | 4 ++++ debian/control | 2 +- debian/dirs | 4 +++- debian/postinst | 20 ++++++++++-------- debian/preinst | 50 ++++++++++++++++++++++++++++++++++++++++++++ git.exclude | 59 ++++++++++++++++++++++++++++++++++++++++++++++++++++ git.post-commit | 16 ++++++++++++++ sample/exclude | 59 ---------------------------------------------------- sample/post-commit | 16 -------------- 10 files changed, 153 insertions(+), 90 deletions(-) create mode 100644 debian/conffiles create mode 100644 debian/preinst create mode 100644 git.exclude create mode 100644 git.post-commit delete mode 100644 sample/exclude delete mode 100644 sample/post-commit diff --git a/Makefile b/Makefile index f50a829..66a2e77 100644 --- a/Makefile +++ b/Makefile @@ -1,20 +1,25 @@ 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) diff --git a/debian/conffiles b/debian/conffiles new file mode 100644 index 0000000..b7b9f72 --- /dev/null +++ b/debian/conffiles @@ -0,0 +1,4 @@ +/etc/cron.d/auf-git-etc +/etc/profile.d/auf-git-etc.sh +/etc/auf-git-etc/exclude +/etc/auf-git-etc/post-commit diff --git a/debian/control b/debian/control index 41b893c..e37b197 100644 --- a/debian/control +++ b/debian/control @@ -7,7 +7,7 @@ Standards-Version: 3.7.2 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 diff --git a/debian/dirs b/debian/dirs index 65f6236..cd8514b 100644 --- a/debian/dirs +++ b/debian/dirs @@ -1,2 +1,4 @@ -etc/profile.d usr/sbin +etc/cron.d +etc/profile.d +etc/auf-git-etc diff --git a/debian/postinst b/debian/postinst index 6fcf9a7..c53a7fb 100644 --- a/debian/postinst +++ b/debian/postinst @@ -5,6 +5,10 @@ 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: # * `configure' # * `abort-upgrade' @@ -22,7 +26,7 @@ case "$1" in 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__ @@ -40,17 +44,14 @@ __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 @@ -72,14 +73,17 @@ __EOF__ 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 " @@ -102,5 +106,3 @@ esac #DEBHELPER# exit 0 - - diff --git a/debian/preinst b/debian/preinst new file mode 100644 index 0000000..9965a8e --- /dev/null +++ b/debian/preinst @@ -0,0 +1,50 @@ +#!/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: +# * `install' +# * `install' +# * `upgrade' +# * `abort-upgrade' +# 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 diff --git a/git.exclude b/git.exclude new file mode 100644 index 0000000..e0745d6 --- /dev/null +++ b/git.exclude @@ -0,0 +1,59 @@ +# 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 diff --git a/git.post-commit b/git.post-commit new file mode 100644 index 0000000..ca5bec4 --- /dev/null +++ b/git.post-commit @@ -0,0 +1,16 @@ +#!/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 diff --git a/sample/exclude b/sample/exclude deleted file mode 100644 index e0745d6..0000000 --- a/sample/exclude +++ /dev/null @@ -1,59 +0,0 @@ -# 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 diff --git a/sample/post-commit b/sample/post-commit deleted file mode 100644 index ca5bec4..0000000 --- a/sample/post-commit +++ /dev/null @@ -1,16 +0,0 @@ -#!/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 -- 1.7.10.4