]> git.donarmstrong.com Git - neurodebian.git/blob - debian/neurodebian-popularity-contest.postinst
popcon: cleanup **only** when upgrading from older version of the neurodebian-popcon
[neurodebian.git] / debian / neurodebian-popularity-contest.postinst
1 #!/bin/bash -e
2
3 # following to be duplicated within postrm as well, but may be with
4 # "Removing" message
5 popcon_conf=/etc/popularity-contest.conf
6 nd_popcon_conf=/etc/popularity-contest.d/neurodebian.conf
7 remove_neurodebian_popcon_pre161() {
8         # Adjust popularity-contest.conf
9         if [ -e "$popcon_conf" ] \
10            && grep -q "http://neuro.debian.net/cgi-bin/popcon-submit.cgi" $popcon_conf; then
11                 #echo "Removing NeuroDebian url for Popularity Contest submissions."
12                 # First remove any explicit mentioning and then empty additions
13                 sed -i -e 's,http://neuro.debian.net/cgi-bin/popcon-submit.cgi,,g' \
14                            -e '/SUBMITURLS+=" *"/d' \
15                            -e '/SUBMITURLS="$SUBMITURLS *"/d' \
16                         "$popcon_conf"
17         fi
18 }
19
20 add_neurodebian_popcon_pre161() {
21         # Adjust main popularity-contest configuration file.  Should be
22         # used only with older versions of the popularity contest.
23         if [ -e "$popcon_conf" ]; then
24                 # Fix dashism missing += operator
25                 if grep -q 'SUBMITURLS+="' "$popcon_conf"; then
26                         echo "Adjusting addition of new entries in $popcon_conf for dash."
27                         sed -i -e 's,SUBMITURLS+=",SUBMITURLS="$SUBMITURLS,g' "$popcon_conf"
28                 fi
29                 if ! grep -q 'SUBMITURLS.*neuro.debian.net' "$popcon_conf"; then
30                         echo "Adding NeuroDebian url for Popularity Contest submissions."
31                         echo -e 'SUBMITURLS="$SUBMITURLS http://neuro.debian.net/cgi-bin/popcon-submit.cgi"' >> "$popcon_conf"
32                 fi
33         fi
34 }
35
36 add_neurodebian_popcon_161() {
37         # 1.60 introduced encryption and a way to provide multiple keys to
38         # encrypt submissions to multiple servers.
39
40         # "Installation" is taken care of through installing files under
41         # /etc/popularity-contest.d, so no additional actions necessary here
42         :
43 }
44
45 popcon_version=$(dpkg -l popularity-contest | tail -n 1 | awk '{print $3;}')
46
47 if [ "$1" = "configure" -o "$1" = "abort-upgrade" ]; then
48         if dpkg --compare-versions $popcon_version lt 1.61; then
49                 add_neurodebian_popcon_pre161
50         else
51                 # Assure that we have no "old" settings for submission if
52                 # previous version of our package was old
53                 if [ "$1" = "configure" ] && [ -z "$2" ] && dpkg --compare-versions "$2" lt 0.33; then
54                         remove_neurodebian_popcon_pre161 || :
55                 fi
56         fi
57 fi
58
59 #DEBHELPER#