From 5b94e9ecc30e9f3b96c083e41235e4df2d0d75c9 Mon Sep 17 00:00:00 2001 From: Wilmer van der Gaast Date: Wed, 18 Aug 2010 00:34:25 +0100 Subject: Move scripts, debconf and /etc stuff to bitlbee-common and really have *just* the binary in bitlbee{,-libpurple}. This should fix issues with installing the package on a clean machine. --- debian/bitlbee-common.init | 88 +++++++++++++++++++++++++++++++++++ debian/bitlbee-common.postinst | 94 +++++++++++++++++++++++++++++++++++++ debian/bitlbee-common.postrm | 14 ++++++ debian/bitlbee-common.prerm | 13 ++++++ debian/bitlbee.init | 88 ----------------------------------- debian/bitlbee.postinst | 102 ----------------------------------------- debian/bitlbee.postrm | 14 ------ debian/bitlbee.prerm | 16 +------ debian/changelog | 2 +- debian/rules | 19 +++----- 10 files changed, 219 insertions(+), 231 deletions(-) create mode 100644 debian/bitlbee-common.init create mode 100644 debian/bitlbee-common.postinst create mode 100644 debian/bitlbee-common.postrm create mode 100644 debian/bitlbee-common.prerm delete mode 100644 debian/bitlbee.init delete mode 100644 debian/bitlbee.postinst delete mode 100644 debian/bitlbee.postrm (limited to 'debian') diff --git a/debian/bitlbee-common.init b/debian/bitlbee-common.init new file mode 100644 index 00000000..be1dcd66 --- /dev/null +++ b/debian/bitlbee-common.init @@ -0,0 +1,88 @@ +#! /bin/sh +### BEGIN INIT INFO +# Provides: bitlbee +# Required-Start: $remote_fs $syslog +# Required-Stop: $remote_fs $syslog +# Default-Start: 2 3 4 5 +# Default-Stop: 1 +### END INIT INFO +# +# Init script for BitlBee Debian package. Based on skeleton init script: +# +# Version: @(#)skeleton 2.85-23 28-Jul-2004 miquels@cistron.nl +# + +PATH=/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin +DESC="BitlBee IRC/IM gateway" +NAME=bitlbee +DAEMON=/usr/sbin/$NAME +PIDFILE=/var/run/$NAME.pid +SCRIPTNAME=/etc/init.d/$NAME + +# Gracefully exit if the package has been removed. +[ -x $DAEMON ] || exit 0 + +# Default value +BITLBEE_PORT=6667 +BITLBEE_OPTS=-F + +# Read config file if it is present. +if [ -r /etc/default/$NAME ]; then + . /etc/default/$NAME +fi + + +# +# Function that starts the daemon/service. +# +d_start() { + # Make sure BitlBee can actually write its PID... + touch $PIDFILE + chown bitlbee: $PIDFILE + + start-stop-daemon --start --quiet --pidfile $PIDFILE \ + --exec $DAEMON -- -p $BITLBEE_PORT -P $PIDFILE $BITLBEE_OPTS +} + +# +# Function that stops the daemon/service. +# +d_stop() { + start-stop-daemon --stop --quiet --pidfile $PIDFILE \ + --name $NAME +} + + +case "$1" in + start) + [ "$BITLBEE_DISABLED" = "1" ] && exit 0 + + echo -n "Starting $DESC: $NAME" + d_start + echo "." + ;; + stop) + echo -n "Stopping $DESC: $NAME" + d_stop + echo "." + ;; + #reload) + # + # No reload target, but there's a REHASH command which we + # might use later... + # + #;; + restart|force-reload) + echo -n "Restarting $DESC: $NAME" + d_stop + sleep 1 + d_start + echo "." + ;; + *) + echo "Usage: $SCRIPTNAME {start|stop|restart|force-reload}" >&2 + exit 1 + ;; +esac + +exit 0 diff --git a/debian/bitlbee-common.postinst b/debian/bitlbee-common.postinst new file mode 100644 index 00000000..c91fa89f --- /dev/null +++ b/debian/bitlbee-common.postinst @@ -0,0 +1,94 @@ +#!/bin/sh -e + +. /usr/share/debconf/confmodule + +db_get bitlbee/serveport +PORT="$RET" + +CONFDIR=/var/lib/bitlbee/ + +update-rc.d bitlbee defaults > /dev/null 2>&1 + +## Load default option. Don't want to put this in debconf (yet?) +BITLBEE_OPTS=-F +BITLBEE_DISABLED=0 +BITLBEE_UPGRADE_DONT_RESTART=0 +[ -r /etc/default/bitlbee ] && . /etc/default/bitlbee + +if [ "$BITLBEE_DISABLED" = "0" ] && type update-inetd > /dev/null 2> /dev/null && + ( expr "$2" : '0\..*' > /dev/null || expr "$2" : '1\.0\..*' > /dev/null ); then + ## Make sure the inetd entry is gone (can still be there from a + ## previous version. + update-inetd --remove '.*/usr/sbin/bitlbee' + if grep -q /usr/sbin/bitlbee /etc/inetd.conf 2> /dev/null; then + # Thanks for breaking update-inetd! (bugs.debian.org/311111) + # I hope that it works at least with xinetd, because this + # emergency hack doesn't: + perl -pi -e 's:^[^#].*/usr/sbin/bitlbee$:## Now using daemon mode\: # $&:' /etc/inetd.conf + killall -HUP inetd || true + fi +fi + +cat</etc/default/bitlbee +## /etc/default/bitlbee: Auto-generated/updated script. +## +## If running in (fork)daemon mode, listen on this TCP port. +BITLBEE_PORT="$PORT" + +## Use single-process or forking daemon mode? Can't be changed from debconf, +## but maintainer scripts will save your changes here. +BITLBEE_OPTS="$BITLBEE_OPTS" + +## In case you want to stick with inetd mode (or if you just want to disable +## the init scripts for some other reason), you can disable the init script +## here. (Just set it to 1) +BITLBEE_DISABLED=$BITLBEE_DISABLED + +## As a server operator, you can use the RESTART command to restart only the +## master process while keeping all the child processes and their IPC +## connections. By enabling this, the maintainer scripts won't restart +## BitlBee during upgrades so you can restart the master process by hand. +BITLBEE_UPGRADE_DONT_RESTART=$BITLBEE_UPGRADE_DONT_RESTART +EOF + +## Bye-bye DebConf, we don't need you anymore. +db_stop + +## Restore the helpfile in case we weren't upgrading but just reconfiguring: +if [ -e /usr/share/bitlbee/help.upgrading ]; then + if [ -e /usr/share/bitlbee/help.txt ]; then + rm -f /usr/share/bitlbee/help.upgrading + else + mv /usr/share/bitlbee/help.upgrading /usr/share/bitlbee/help.txt + fi +fi + +if [ -n "$2" -a "$BITLBEE_UPGRADE_DONT_RESTART" != "1" ]; then + invoke-rc.d bitlbee restart +fi + +## If we're upgrading, we'll probably skip this next part +if [ -d $CONFDIR ] && chown -R bitlbee: $CONFDIR; then + echo 'BitlBee (probably) already installed, skipping user/configdir installation' + exit 0 +fi + +adduser --system --group --disabled-login --disabled-password --home /var/lib/bitlbee/ bitlbee +chmod 700 /var/lib/bitlbee/ + +## Can't do this in packaging phase: Don't know the UID yet. Access to +## the file should be limited, now that it stores passwords. Added +## --group later for a little more security, but have to see if I can +## apply this change to existing installations on upgrades. Will think +## about that later. +if getent group bitlbee > /dev/null; then + chmod 640 /etc/bitlbee/bitlbee.conf + chown root:bitlbee /etc/bitlbee/bitlbee.conf +else + chmod 600 /etc/bitlbee/bitlbee.conf + chown bitlbee /etc/bitlbee/bitlbee.conf +fi + +if [ -z "$2" ]; then + invoke-rc.d bitlbee start +fi diff --git a/debian/bitlbee-common.postrm b/debian/bitlbee-common.postrm new file mode 100644 index 00000000..5c3b4b2e --- /dev/null +++ b/debian/bitlbee-common.postrm @@ -0,0 +1,14 @@ +#!/bin/sh -e + +[ "$1" = "purge" ] || exit 0 + +if [ -e /usr/share/debconf/confmodule ]; then + . /usr/share/debconf/confmodule; + db_purge; +fi + +update-rc.d bitlbee remove > /dev/null 2>&1 || true +rm -f /etc/default/bitlbee + +deluser --system --remove-home bitlbee || true +rm -rf /var/lib/bitlbee ## deluser doesn't seem to do this for homedirs in /var diff --git a/debian/bitlbee-common.prerm b/debian/bitlbee-common.prerm new file mode 100644 index 00000000..50a49bee --- /dev/null +++ b/debian/bitlbee-common.prerm @@ -0,0 +1,13 @@ +#!/bin/sh -e + +if [ "$1" = "upgrade" ]; then + ## To prevent the help function from breaking in currently running + ## BitlBee processes. Have to do it like this because dpkg-reconfigure + ## looks a lot like an upgrade and we don't want to lose help.txt... + if [ -e /usr/share/bitlbee/help.txt ]; then + rm -f /usr/share/bitlbee/help.upgrading + mv /usr/share/bitlbee/help.txt /usr/share/bitlbee/help.upgrading + fi +else + invoke-rc.d bitlbee stop || exit 0 +fi diff --git a/debian/bitlbee.init b/debian/bitlbee.init deleted file mode 100644 index be1dcd66..00000000 --- a/debian/bitlbee.init +++ /dev/null @@ -1,88 +0,0 @@ -#! /bin/sh -### BEGIN INIT INFO -# Provides: bitlbee -# Required-Start: $remote_fs $syslog -# Required-Stop: $remote_fs $syslog -# Default-Start: 2 3 4 5 -# Default-Stop: 1 -### END INIT INFO -# -# Init script for BitlBee Debian package. Based on skeleton init script: -# -# Version: @(#)skeleton 2.85-23 28-Jul-2004 miquels@cistron.nl -# - -PATH=/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin -DESC="BitlBee IRC/IM gateway" -NAME=bitlbee -DAEMON=/usr/sbin/$NAME -PIDFILE=/var/run/$NAME.pid -SCRIPTNAME=/etc/init.d/$NAME - -# Gracefully exit if the package has been removed. -[ -x $DAEMON ] || exit 0 - -# Default value -BITLBEE_PORT=6667 -BITLBEE_OPTS=-F - -# Read config file if it is present. -if [ -r /etc/default/$NAME ]; then - . /etc/default/$NAME -fi - - -# -# Function that starts the daemon/service. -# -d_start() { - # Make sure BitlBee can actually write its PID... - touch $PIDFILE - chown bitlbee: $PIDFILE - - start-stop-daemon --start --quiet --pidfile $PIDFILE \ - --exec $DAEMON -- -p $BITLBEE_PORT -P $PIDFILE $BITLBEE_OPTS -} - -# -# Function that stops the daemon/service. -# -d_stop() { - start-stop-daemon --stop --quiet --pidfile $PIDFILE \ - --name $NAME -} - - -case "$1" in - start) - [ "$BITLBEE_DISABLED" = "1" ] && exit 0 - - echo -n "Starting $DESC: $NAME" - d_start - echo "." - ;; - stop) - echo -n "Stopping $DESC: $NAME" - d_stop - echo "." - ;; - #reload) - # - # No reload target, but there's a REHASH command which we - # might use later... - # - #;; - restart|force-reload) - echo -n "Restarting $DESC: $NAME" - d_stop - sleep 1 - d_start - echo "." - ;; - *) - echo "Usage: $SCRIPTNAME {start|stop|restart|force-reload}" >&2 - exit 1 - ;; -esac - -exit 0 diff --git a/debian/bitlbee.postinst b/debian/bitlbee.postinst deleted file mode 100644 index db541f6c..00000000 --- a/debian/bitlbee.postinst +++ /dev/null @@ -1,102 +0,0 @@ -#!/bin/sh -e - -. /usr/share/debconf/confmodule - -db_get bitlbee/serveport -PORT="$RET" - -CONFDIR=/var/lib/bitlbee/ - -update-rc.d bitlbee defaults > /dev/null 2>&1 - -## Load default option. Don't want to put this in debconf (yet?) -BITLBEE_OPTS=-F -BITLBEE_DISABLED=0 -BITLBEE_UPGRADE_DONT_RESTART=0 -[ -r /etc/default/bitlbee ] && . /etc/default/bitlbee - -if [ "$BITLBEE_DISABLED" = "0" ] && type update-inetd > /dev/null 2> /dev/null && - ( expr "$2" : '0\..*' > /dev/null || expr "$2" : '1\.0\..*' > /dev/null ); then - ## Make sure the inetd entry is gone (can still be there from a - ## previous version. - update-inetd --remove '.*/usr/sbin/bitlbee' - if grep -q /usr/sbin/bitlbee /etc/inetd.conf 2> /dev/null; then - # Thanks for breaking update-inetd! (bugs.debian.org/311111) - # I hope that it works at least with xinetd, because this - # emergency hack doesn't: - perl -pi -e 's:^[^#].*/usr/sbin/bitlbee$:## Now using daemon mode\: # $&:' /etc/inetd.conf - killall -HUP inetd || true - fi -fi - -cat</etc/default/bitlbee -## /etc/default/bitlbee: Auto-generated/updated script. -## -## If running in (fork)daemon mode, listen on this TCP port. -BITLBEE_PORT="$PORT" - -## Use single-process or forking daemon mode? Can't be changed from debconf, -## but maintainer scripts will save your changes here. -BITLBEE_OPTS="$BITLBEE_OPTS" - -## In case you want to stick with inetd mode (or if you just want to disable -## the init scripts for some other reason), you can disable the init script -## here. (Just set it to 1) -BITLBEE_DISABLED=$BITLBEE_DISABLED - -## As a server operator, you can use the RESTART command to restart only the -## master process while keeping all the child processes and their IPC -## connections. By enabling this, the maintainer scripts won't restart -## BitlBee during upgrades so you can restart the master process by hand. -BITLBEE_UPGRADE_DONT_RESTART=$BITLBEE_UPGRADE_DONT_RESTART -EOF - -## Bye-bye DebConf, we don't need you anymore. -db_stop - -## Restore the helpfile in case we weren't upgrading but just reconfiguring: -if [ -e /usr/share/bitlbee/help.upgrading ]; then - if [ -e /usr/share/bitlbee/help.txt ]; then - rm -f /usr/share/bitlbee/help.upgrading - else - mv /usr/share/bitlbee/help.upgrading /usr/share/bitlbee/help.txt - fi -fi - -if [ -n "$2" -a "$BITLBEE_UPGRADE_DONT_RESTART" != "1" ]; then - if which invoke-rc.d >/dev/null 2>&1; then - invoke-rc.d bitlbee restart - else - /etc/init.d/bitlbee restart - fi -fi - -## If we're upgrading, we'll probably skip this next part -if [ -d $CONFDIR ] && chown -R bitlbee: $CONFDIR; then - echo 'BitlBee (probably) already installed, skipping user/configdir installation' - exit 0 -fi - -adduser --system --group --disabled-login --disabled-password --home /var/lib/bitlbee/ bitlbee -chmod 700 /var/lib/bitlbee/ - -## Can't do this in packaging phase: Don't know the UID yet. Access to -## the file should be limited, now that it stores passwords. Added -## --group later for a little more security, but have to see if I can -## apply this change to existing installations on upgrades. Will think -## about that later. -if getent group bitlbee > /dev/null; then - chmod 640 /etc/bitlbee/bitlbee.conf - chown root:bitlbee /etc/bitlbee/bitlbee.conf -else - chmod 600 /etc/bitlbee/bitlbee.conf - chown bitlbee /etc/bitlbee/bitlbee.conf -fi - -if [ -z "$2" ]; then - if which invoke-rc.d >/dev/null 2>&1; then - invoke-rc.d bitlbee start - else - /etc/init.d/bitlbee start - fi -fi diff --git a/debian/bitlbee.postrm b/debian/bitlbee.postrm deleted file mode 100644 index 5c3b4b2e..00000000 --- a/debian/bitlbee.postrm +++ /dev/null @@ -1,14 +0,0 @@ -#!/bin/sh -e - -[ "$1" = "purge" ] || exit 0 - -if [ -e /usr/share/debconf/confmodule ]; then - . /usr/share/debconf/confmodule; - db_purge; -fi - -update-rc.d bitlbee remove > /dev/null 2>&1 || true -rm -f /etc/default/bitlbee - -deluser --system --remove-home bitlbee || true -rm -rf /var/lib/bitlbee ## deluser doesn't seem to do this for homedirs in /var diff --git a/debian/bitlbee.prerm b/debian/bitlbee.prerm index 687c2cc1..c61db24b 100644 --- a/debian/bitlbee.prerm +++ b/debian/bitlbee.prerm @@ -1,17 +1,5 @@ #!/bin/sh -e -if [ "$1" = "upgrade" ]; then - ## To prevent the help function from breaking in currently running - ## BitlBee processes. Have to do it like this because dpkg-reconfigure - ## looks a lot like an upgrade and we don't want to lose help.txt... - if [ -e /usr/share/bitlbee/help.txt ]; then - rm -f /usr/share/bitlbee/help.upgrading - mv /usr/share/bitlbee/help.txt /usr/share/bitlbee/help.upgrading - fi -else - if which invoke-rc.d >/dev/null 2>&1; then - invoke-rc.d bitlbee stop || exit 0 - else - /etc/init.d/bitlbee stop || exit 0 - fi +if [ "$1" != "upgrade" ]; then + invoke-rc.d bitlbee stop || exit 0 fi diff --git a/debian/changelog b/debian/changelog index 70f1ed47..9606800a 100644 --- a/debian/changelog +++ b/debian/changelog @@ -1,4 +1,4 @@ -bitlbee (1.3-0) unstable; urgency=low +bitlbee (1.3-1) unstable; urgency=low * Setting some bogus version number, fix that later. * Now using debhelper to improve maintainability. diff --git a/debian/rules b/debian/rules index a93f4db4..0b8a4dd6 100755 --- a/debian/rules +++ b/debian/rules @@ -40,7 +40,7 @@ clean: dh_testroot rm -f build-stamp - rm -rf build-arch-stamp debian/build-* + rm -rf build-arch-stamp debian/build-* debian/bitlbee-libpurple.prerm $(MAKE) distclean dh_clean @@ -51,13 +51,14 @@ install: build dh_clean -k dh_installdirs - $(MAKE) -C debian/build-native install install-etc DESTDIR=`pwd`/debian/bitlbee + $(MAKE) -C debian/build-native install DESTDIR=`pwd`/debian/bitlbee + $(MAKE) -C debian/build-native install-etc DESTDIR=`pwd`/debian/bitlbee-common $(MAKE) -C debian/build-native install-dev DESTDIR=`pwd`/debian/bitlbee-dev - patch debian/bitlbee/etc/bitlbee/bitlbee.conf debian/patches/bitlbee.conf.diff + patch debian/bitlbee-common/etc/bitlbee/bitlbee.conf debian/patches/bitlbee.conf.diff ifeq ($(BITLBEE_LIBPURPLE),1) - $(MAKE) -C debian/build-libpurple install install-etc DESTDIR=`pwd`/debian/bitlbee-libpurple - patch debian/bitlbee-libpurple/etc/bitlbee/bitlbee.conf debian/patches/bitlbee.conf.diff + $(MAKE) -C debian/build-libpurple install DESTDIR=`pwd`/debian/bitlbee-libpurple + ln -sf debian/bitlbee.prerm debian/bitlbee-libpurple.prerm endif mkdir -p debian/bitlbee-common/usr @@ -75,19 +76,13 @@ binary-common: # Hardy and Lenny are deprecated. for p in bitlbee bitlbee-libpurple bitlbee-dev; do rm -r debian/$$p/usr/share/doc/$$p && ln -s bitlbee-common debian/$$p/usr/share/doc/$$p; done dh_installdebconf - dh_installinit -ifeq ($(BITLBEE_LIBPURPLE)$(DH_OPTIONS),1-a) - cp -a debian/bitlbee/etc debian/bitlbee-libpurple -endif + dh_installinit --init-script=bitlbee dh_installman dh_strip dh_link dh_compress dh_fixperms dh_installdeb -ifeq ($(BITLBEE_LIBPURPLE)$(DH_OPTIONS),1-a) - cp -a debian/bitlbee/DEBIAN/post* debian/bitlbee/DEBIAN/pre* debian/bitlbee-libpurple/DEBIAN -endif dh_shlibdeps ifdef BITLBEE_VERSION dh_gencontrol -- -v1:$(BITLBEE_VERSION)-0 -Vbee:Version=1:$(BITLBEE_VERSION)-0 -- cgit v1.2.3