diff options
author | Ondřej Surý <ondrej@sury.org> | 2011-08-24 13:46:08 +0200 |
---|---|---|
committer | Ondřej Surý <ondrej@sury.org> | 2011-09-13 12:52:24 +0200 |
commit | d36e4c370f4778823e8dd31bc4900bad011a7508 (patch) | |
tree | 5d24adc1d598f3a904ce9485bdfd000fdff0dd90 | |
parent | e0fc37f46d4390d28f908b46e71bb8ed983bbc27 (diff) | |
download | golang-d36e4c370f4778823e8dd31bc4900bad011a7508.tar.gz |
Add support for goinstall dashboard debconf question in the Debian packaging (now it needs to Go counterpart)
-rw-r--r-- | debian/golang-weekly-tools.config | 23 | ||||
-rw-r--r-- | debian/golang-weekly-tools.postinst | 75 | ||||
-rw-r--r-- | debian/golang-weekly-tools.postrm | 19 | ||||
-rw-r--r-- | debian/golang-weekly-tools.templates | 16 |
4 files changed, 133 insertions, 0 deletions
diff --git a/debian/golang-weekly-tools.config b/debian/golang-weekly-tools.config new file mode 100644 index 000000000..61ae6a440 --- /dev/null +++ b/debian/golang-weekly-tools.config @@ -0,0 +1,23 @@ +#!/bin/sh + +set -e + +conffile=/etc/golang/goinstall.conf + +. /usr/share/debconf/confmodule + +if [ -f $conffile ] ; then + if grep -q DASHBOARD $conffile; then + :; + fi + . $conffile + if [ yes = "$DASHBOARD" ] ; then + DASHBOARD=true + else + DASHBOARD=false + fi + db_set popularity-contest/dashboard "$DASHBOARD" +fi + +db_input high popularity-contest/dashboard || [ $? -eq 30 ] +db_go || true diff --git a/debian/golang-weekly-tools.postinst b/debian/golang-weekly-tools.postinst new file mode 100644 index 000000000..b511b971b --- /dev/null +++ b/debian/golang-weekly-tools.postinst @@ -0,0 +1,75 @@ +#!/bin/sh + +# Load debconf variables +. /usr/share/debconf/confmodule + +confdir=/etc/golang +conffile=$confdir/goinstall.conf + +set -e + +if [ -e $conffile ] ; then + # Fetch current values. + . $conffile +fi + +# Get this setting from debconf. It was set based on the content of +# /etc/golang/goinstall.conf in the 'config' script, so it should be +# safe to ignore the value fetched by loading the file above. This +# should allow for using debconf to reconfigure the package. +db_get golang-weekly-tools/dashboard || true +if [ "$RET" = "yes" ] || [ "$RET" = "YES" ] || [ "$RET" = "true" ]; then + DASHBOARD="yes" +else + DASHBOARD="no" +fi + +generate_conffile() { + if [ ! -d $confdir ]; then + mkdir $confdir + fi + cat <<-EOF >$conffile + # Config file for goinstall tool. + # + # To change this file, use: + # dpkg-reconfigure golang-weekly-tools + # + # You can also edit it by hand, if you so choose. + + DASHBOARD="$DASHBOARD" + EOF + + # Make sure user nobody can read the file. + chmod a+r $conffile +} + +case "$1" in + configure) + if [ ! -e $conffile ]; then + generate_conffile + else + # Replace only if the content changed, to avoid changing the + # config file date when no change was done. + + # Commenting out the obsolete addresses, to use the + # default config from /usr/share/ on hosts where + # the old default was unchanged. Replace the "empty" id. + + sedopts=" \ + s/^DASHBOARD=.*$/DASHBOARD=\"$DASHBOARD\"/; \ + " + if sed "$sedopts" < $conffile > $conffile.new && + ! cmp $conffile $conffile.new > /dev/null; then + mv $conffile.new $conffile + # Make sure user nobody can read the file. + chmod a+r $conffile + else + rm $conffile.new + fi + fi + ;; + *) + ;; +esac + +#DEBHELPER# diff --git a/debian/golang-weekly-tools.postrm b/debian/golang-weekly-tools.postrm new file mode 100644 index 000000000..2cf582ef7 --- /dev/null +++ b/debian/golang-weekly-tools.postrm @@ -0,0 +1,19 @@ +#!/bin/sh + +set -e + +# purge the config file which is created in the postinst script +if [ "$1" = purge ] ; then + rm -f /etc/golang/goinstall.conf + rmdir /etc/golang || true +fi + +if [ "$1" = "purge" ] && [ -e /usr/share/debconf/confmodule ]; then + # Source debconf library. + . /usr/share/debconf/confmodule + # Remove my changes to the db. + db_purge +fi + +#DEBHELPER# + diff --git a/debian/golang-weekly-tools.templates b/debian/golang-weekly-tools.templates new file mode 100644 index 000000000..d7f325b75 --- /dev/null +++ b/debian/golang-weekly-tools.templates @@ -0,0 +1,16 @@ +Template: golang-weekly-tools/dashboard +Type: boolean +Default: true +_Description: Report installation of public packages to Go Dashboard? + goinstall reports the successful installation of the public packages + to godashboard.appspot.com, which increments a count associated with + the package and the time of its most recent installation. This + mechanism powers the package list at the Go Dashboard, allowing Go + programmers to learn about popular packages that might be worth + looking at. + . + If you choose to participate, the goinstall will report each + successful installation to the Go Dashboard. + . + This choice can be later modified by running "dpkg-reconfigure + popularity-contest". |