2 # postinst script for auf-git-etc
4 # see: dh_installdeb(1)
8 # summary of how this script can be called:
9 # * <postinst> `configure' <most-recently-configured-version>
10 # * <old-postinst> `abort-upgrade' <new version>
11 # * <conflictor's-postinst> `abort-remove' `in-favour' <package>
13 # * <postinst> `abort-remove'
14 # * <deconfigured's-postinst> `abort-deconfigure' `in-favour'
15 # <failed-install-package> <version> `removing'
16 # <conflicting-package> <version>
17 # for details, see http://www.debian.org/doc/debian-policy/ or
18 # the debian-policy package
24 # gestion transparente de GIT via sudo
25 if test -f /etc/sudoers; then
26 # on conserve l'environnement GIT pendant un sudo
27 if ! grep -q "env_keep.*GIT" /etc/sudoers; then
28 sed -i '/^$/{s//Defaults env_keep += "GIT_COMMITTER_NAME GIT_COMMITTER_EMAIL GIT_AUTHOR_NAME GIT_AUTHOR_EMAIL GIT_DIR GIT_WORK_TREE"\n/;:l;n;b l}' /etc/sudoers
29 # configuration déjà là, on ajoute les nouveautés avec 1.5
30 elif ! grep -q "env_keep.*GIT_DIR" /etc/sudoers; then
31 sed -i 's/GIT_AUTHOR_EMAIL/GIT_AUTHOR_EMAIL GIT_DIR GIT_WORK_TREE/' /etc/sudoers
33 # on autorise le groupe admin à demander le statut GIT
34 if test -f /etc/sudoers; then
35 if ! grep -q '^%admin.*git status' /etc/sudoers; then
36 echo '%admin ALL=(ALL) NOPASSWD: /usr/bin/git status' >> /etc/sudoers
38 sed -i '/^%admin /s/git status -a/git status/' /etc/sudoers
43 # on vérifie la présence d'un existant
45 # est-il à notre norme ?
46 if [ "`readlink -f /.git`" != "/var/lib/git/root" ]; then
48 echo "ATTENTION : un /.git existe mais ne pointe pas sur /var/lib/git/root !"
49 echo "ATTENTION : vous avez pris de l'avance, ce sera à vous de gérer ça... ;-)"
52 # ok, on gère la migration en conffiles
53 if [ ! -L /.git/info ]; then
54 for f in /etc/auf-git-etc/info/* ; do
55 mv -f ${f} ${f}.dpkg-dist
57 mv /.git/info/* /etc/auf-git-etc/info/
59 ln -s /etc/auf-git-etc/info /.git/
61 if [ ! -L /.git/hooks ]; then
62 for f in /etc/auf-git-etc/hooks/* ; do
63 mv -f ${f} ${f}.dpkg-dist
65 mv /.git/hooks/* /etc/auf-git-etc/hooks/
67 ln -s /etc/auf-git-etc/hooks /.git/
69 # on gère l'annulation du suivi du dpkg.log
71 if git ls-files | grep -q var/log/dpkg.log ; then
72 git rm --cached var/log/dpkg.log
74 # compensation des changements qui viennent avec 1.5…
75 if ! git-repo-config status.relativePaths >/dev/null ; then
76 git-repo-config status.relativePaths false
78 #if ! git-repo-config core.worktree >/dev/null ; then
79 # git-repo-config core.worktree /
82 # on vérifie la présence d'un existant
83 elif [ -d /var/lib/git/root ]; then
85 echo "ATTENTION : un /var/lib/git/root existe mais il manque le lien dans /.git !"
86 echo "ATTENTION : vous pouvez le réinstaller avec : ln -s /var/lib/git/root /.git"
88 # on crée le dépôt GIT global à ce système
91 git init-db > /dev/null
92 git config status.relativePaths false
93 # TODO ? git-repo-config core.worktree /
96 mv /.git /var/lib/git/root
97 ln -s /var/lib/git/root /.git
98 # déplacement des configurations par défaut dans /etc/auf-git-etc/
100 for d in info hooks ; do
102 if [ -e /etc/auf-git-etc/${f} ]; then
105 mv ${f} /etc/auf-git-etc/${f}
109 ln -s /etc/auf-git-etc/$d $d
111 # mise en route du suivi
113 git add etc usr/local var boot
114 git commit -q -m "Mise en route du suivi de /etc et /usr/local." \
115 --author "Installation auf-git-etc <root@apt.auf.org>"
120 abort-upgrade|abort-remove|abort-deconfigure)
124 echo "postinst called with unknown argument \`$1'" >&2
129 # dh_installdeb will replace this with shell code automatically
130 # generated by other debhelper scripts.