aboutsummaryrefslogtreecommitdiff
path: root/debian/gnunet.postrm
diff options
context:
space:
mode:
authorChristian Grothoff <christian@grothoff.org>2020-12-28 11:19:30 +0100
committerChristian Grothoff <christian@grothoff.org>2020-12-28 11:19:30 +0100
commite9d73b0a901d7dfe1fd219aecc960747e7c49483 (patch)
tree94f835cf56a1feb453a1f65534e28334c6e258f8 /debian/gnunet.postrm
parentdebba1a49a46ba963553da222ade563d6d67932b (diff)
downloadgnunet-e9d73b0a901d7dfe1fd219aecc960747e7c49483.tar.gz
gnunet-e9d73b0a901d7dfe1fd219aecc960747e7c49483.zip
import Debian build rules, split off libgnunet
Diffstat (limited to 'debian/gnunet.postrm')
-rw-r--r--debian/gnunet.postrm99
1 files changed, 99 insertions, 0 deletions
diff --git a/debian/gnunet.postrm b/debian/gnunet.postrm
new file mode 100644
index 000000000..0aba484db
--- /dev/null
+++ b/debian/gnunet.postrm
@@ -0,0 +1,99 @@
1#!/bin/sh
2
3set -e
4
5pathfind() {
6 OLDIFS="$IFS"
7 IFS=:
8 for p in $PATH; do
9 if [ -x "$p/$*" ]; then
10 IFS="$OLDIFS"
11 return 0
12 fi
13 done
14 IFS="$OLDIFS"
15 return 1
16}
17
18remove_gns() {
19 # abort if /etc/nsswitch.conf does not exist
20 if ! [ -e /etc/nsswitch.conf ]; then
21 return
22 fi
23 perl -i -pe '
24 my @remove=(
25 "gns [NOTFOUND=return]",
26 );
27 sub remove {
28 my $s=shift;
29 foreach my $bit (@remove) {
30 $s=~s/\s+\Q$bit\E//g;
31 }
32 return $s;
33 }
34 s/^(hosts:)(.*)/$1.remove($2)/e;
35 ' /etc/nsswitch.conf
36 # remove the gns nsswitch plugins as well
37 rm -rf /usr/lib/x86_64-linux-gnu/usr/libnss_gns.so.2
38 rm -rf /usr/lib/x86_64-linux-gnu/usr/libnss_gns4.so.2
39 rm -rf /usr/lib/x86_64-linux-gnu/usr/libnss_gns6.so.2
40}
41
42
43case "${1}" in
44 purge)
45 if [ -e /usr/share/debconf/confmodule ]
46 then
47 . /usr/share/debconf/confmodule
48 db_version 2.0
49
50 db_get gnunet-systempeer/username
51 _USERNAME="${RET:-gnunet}"
52
53 db_get gnunet-systempeer/groupname
54 _GROUPNAME="${RET:-gnunet}"
55
56 db_get gnunet-dns/libnsswitch
57 _LIBNSSWITCH="${RET}"
58 else
59 _USERNAME="gnunet"
60 _GROUPNAME="gnunet"
61 fi
62
63 GNUNETDNS_GROUP="gnunetdns"
64
65 if $_LIBNSSWITCH
66 then
67 rm -rf /usr/lib/x86_64-linux-gnu/usr/libnss_gns.so.2
68 rm -rf /usr/lib/x86_64-linux-gnu/usr/libnss_gns4.so.2
69 rm -rf /usr/lib/x86_64-linux-gnu/usr/libnss_gns6.so.2
70 remove_gns
71 fi
72
73 if pathfind deluser
74 then
75 deluser --quiet --system ${_USERNAME} || true
76 fi
77
78 if pathfind delgroup
79 then
80 delgroup --quiet --system --only-if-empty ${_GROUPNAME} || true
81 delgroup --quiet --system --only-if-empty ${GNUNETDNS_GROUP} || true
82 fi
83
84 rm -rf /var/log/gnunetd /var/lib/gnunet /etc/default/gnunet
85 ;;
86
87 remove|upgrade|failed-upgrade|abort-install|abort-upgrade|disappear)
88
89 ;;
90
91 *)
92 echo "postrm called with unknown argument \`${1}'" >&2
93 exit 1
94 ;;
95esac
96
97#DEBHELPER#
98
99exit 0