From 00423440547d2a8315f5816bdeeb67d149310624 Mon Sep 17 00:00:00 2001 From: Jan Vidar Krey Date: Tue, 24 Mar 2009 18:38:59 +0100 Subject: [PATCH] Better dpkg system. --- admin/common.sh | 30 ++++---- admin/make_pkg_deb.sh | 89 ++++++++++++++++++++++++ debian/changelog | 5 -- debian/compat | 1 - debian/conffiles | 3 - debian/control | 15 ---- debian/copyright | 9 --- debian/dirs | 1 - debian/docs | 3 - debian/files | 1 - debian/init.d | 157 ------------------------------------------ debian/postinst | 39 ----------- debian/postrm | 37 ---------- debian/preinst | 35 ---------- debian/prerm | 38 ---------- debian/rules | 91 ------------------------ debian/uhub.default | 10 --- 17 files changed, 106 insertions(+), 458 deletions(-) create mode 100755 admin/make_pkg_deb.sh delete mode 100644 debian/changelog delete mode 100644 debian/compat delete mode 100644 debian/conffiles delete mode 100644 debian/control delete mode 100644 debian/copyright delete mode 100644 debian/dirs delete mode 100644 debian/docs delete mode 100644 debian/files delete mode 100644 debian/init.d delete mode 100644 debian/postinst delete mode 100644 debian/postrm delete mode 100644 debian/preinst delete mode 100644 debian/prerm delete mode 100755 debian/rules delete mode 100644 debian/uhub.default diff --git a/admin/common.sh b/admin/common.sh index 091dc8d..e390428 100644 --- a/admin/common.sh +++ b/admin/common.sh @@ -84,20 +84,25 @@ function export_sources cp ChangeLog ChangeLog-${VERSION} } +function build_binaries +{ + if [ ! -d ${PACKAGE} ]; then + export_source_directory + fi + + cd ${PACKAGE} + ${MAKE} ${MAKEARGS} RELEASE=YES + cd .. + + if [ ! -x ${PACKAGE}/${BINARY} ]; then + echo "Build failed, no binary found..." + exit 1 + fi +} + function export_binaries { - if [ ! -d ${PACKAGE} ]; then - export_source_directory - fi - - cd ${PACKAGE} - ${MAKE} ${MAKEARGS} RELEASE=YES - cd .. - - if [ ! -x ${PACKAGE}/${BINARY} ]; then - echo "Packaging failed, no binary found..." - exit 1 - fi + build_binaries rm -Rf ${PACKAGE}/admin rm -Rf ${PACKAGE}/autotest @@ -111,7 +116,6 @@ function export_binaries rm -f ${PACKAGE}/libuhub* package_zips ${PACKAGE_BIN} ${PACKAGE} - rm -Rf ${PACKAGE}; } diff --git a/admin/make_pkg_deb.sh b/admin/make_pkg_deb.sh new file mode 100755 index 0000000..5ea298d --- /dev/null +++ b/admin/make_pkg_deb.sh @@ -0,0 +1,89 @@ +#!/bin/sh +. admin/common.sh + +export_source_directory +build_binaries + +DEB_REVISION=1 + +if [ -d deb ]; then + rm -Rf deb +fi + +mkdir -p \ + deb/DEBIAN \ + deb/usr/bin \ + deb/usr/share/doc/uhub \ + deb/etc/uhub \ + || exit 1 + +find deb -type d | xargs chmod 755 + +# Copy binaries... +cp ${PACKAGE}/${BINARY} deb/usr/bin +strip deb/usr/bin/${BINARY} + +# Copy configuration files... +cp ${PACKAGE}/doc/uhub.conf deb/etc/uhub +cp ${PACKAGE}/doc/users.conf deb/etc/uhub +echo "Welcome to uHub" > deb/etc/uhub/motd.txt + +# Copy debian policy files +cp ${PACKAGE}/README deb/usr/share/doc/uhub +cp ${PACKAGE}/AUTHORS deb/usr/share/doc/uhub +gzip -c --best < ${PACKAGE}/ChangeLog > deb/usr/share/doc/uhub/changelog.gz + +cat > deb/usr/share/doc/uhub/copyright < + +uHub is free and open source software, licensed under the +GNU General Public License version 3. + +For details, see /usr/share/common-licenses/GPL-3 +EOF + +gzip -c --best > deb/usr/share/doc/uhub/changelog.Debian.gz < `date -R` +EOF + +### Write control files +cd deb +echo "/etc/uhub/uhub.conf" > DEBIAN/conffiles +echo "/etc/uhub/users.conf" >> DEBIAN/conffiles +echo "/etc/uhub/motd.txt" >> DEBIAN/conffiles + +md5sum `find usr -type f` > DEBIAN/md5sums + +INSTALL_SIZE=`du -s | cut -f 1` + +cat > DEBIAN/control < +Installed-Size: ${INSTALL_SIZE} +Depends: libc6 (>= 2.7-1), libevent1 (>= 1.3e-1) +Section: net +Priority: optional +Description: a high performance hub for the ADC peer-to-peer network + uHub is a high performance peer-to-peer hub for the ADC network. + Its low memory footprint allows it to handle several thousand users + on high-end servers, or a small private hub on embedded hardware. + . +Homepage: http://www.extatic.org/uhub/ +EOF +cd .. + +### Create deb file +fakeroot dpkg-deb --build deb +mv deb.deb uhub_${VERSION}-${DEB_REVISION}_${HOST_MACHINE}.deb + +### Check for errors +lintian uhub_${VERSION}-${DEB_REVISION}_${HOST_MACHINE}.deb + diff --git a/debian/changelog b/debian/changelog deleted file mode 100644 index ad1af2e..0000000 --- a/debian/changelog +++ /dev/null @@ -1,5 +0,0 @@ -uhub (0.2.6-1) unstable; urgency=low - - * Initial release (Closes: #nnnn) - - -- Jan Vidar Krey Tue, 17 Mar 2009 00:38:12 +0100 diff --git a/debian/compat b/debian/compat deleted file mode 100644 index 7f8f011..0000000 --- a/debian/compat +++ /dev/null @@ -1 +0,0 @@ -7 diff --git a/debian/conffiles b/debian/conffiles deleted file mode 100644 index 45da062..0000000 --- a/debian/conffiles +++ /dev/null @@ -1,3 +0,0 @@ -etc/uhub/uhub.conf -etc/uhub/users.conf -etc/uhub/motd.txt diff --git a/debian/control b/debian/control deleted file mode 100644 index b3428f4..0000000 --- a/debian/control +++ /dev/null @@ -1,15 +0,0 @@ -Source: uhub -Section: net -Priority: extra -Maintainer: Jan Vidar Krey -Build-Depends: debhelper (>= 7) -Standards-Version: 3.8.1 -Homepage: http://www.extatic.org/uhub/ - -Package: uhub -Architecture: any -Depends: ${shlibs:Depends}, ${misc:Depends} -Description: uHub is a high performance peer-to-peer hub for the ADC network. - Its low memory footprint allows it to handle several thousand users on high-end servers, - or a small private hub on embedded hardware. - uHub uses the ADC protocol, and is compatible with DC++, jUCy and other ADC clients. diff --git a/debian/copyright b/debian/copyright deleted file mode 100644 index 7a61bf5..0000000 --- a/debian/copyright +++ /dev/null @@ -1,9 +0,0 @@ -Copyright: - - Copyright (C) 2008-2009 Jan Vidar Krey - -License: - -Licensed under the GPL version 3, -see `/usr/share/common-licenses/GPL-3'. - diff --git a/debian/dirs b/debian/dirs deleted file mode 100644 index e772481..0000000 --- a/debian/dirs +++ /dev/null @@ -1 +0,0 @@ -usr/bin diff --git a/debian/docs b/debian/docs deleted file mode 100644 index f714b73..0000000 --- a/debian/docs +++ /dev/null @@ -1,3 +0,0 @@ -BUGS -README -AUTHORS diff --git a/debian/files b/debian/files deleted file mode 100644 index 437d594..0000000 --- a/debian/files +++ /dev/null @@ -1 +0,0 @@ -uhub_0.2.6-1_amd64.deb net extra diff --git a/debian/init.d b/debian/init.d deleted file mode 100644 index 628ae89..0000000 --- a/debian/init.d +++ /dev/null @@ -1,157 +0,0 @@ -#! /bin/sh -# -# skeleton example file to build /etc/init.d/ scripts. -# This file should be used to construct scripts for /etc/init.d. -# -# Written by Miquel van Smoorenburg . -# Modified for Debian -# by Ian Murdock . -# Further changes by Javier Fernandez-Sanguino -# -# Version: @(#)skeleton 1.9 26-Feb-2001 miquels@cistron.nl -# - -PATH=/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin -DAEMON=/usr/bin/uhub -NAME=uhub -DESC=uhub - -test -x $DAEMON || exit 0 - -LOGDIR=/var/log/uhub -PIDFILE=/var/run/$NAME.pid -DODTIME=1 # Time to wait for the server to die, in seconds - # If this value is set too low you might not - # let some servers to die gracefully and - # 'restart' will not work - -# Include uhub defaults if available -if [ -f /etc/default/uhub ] ; then - . /etc/default/uhub -fi - -set -e - -running_pid() -{ - # Check if a given process pid's cmdline matches a given name - pid=$1 - name=$2 - [ -z "$pid" ] && return 1 - [ ! -d /proc/$pid ] && return 1 - cmd=`cat /proc/$pid/cmdline | tr "\000" "\n"|head -n 1 |cut -d : -f 1` - # Is this the expected child? - [ "$cmd" != "$name" ] && return 1 - return 0 -} - -running() -{ -# Check if the process is running looking at /proc -# (works for all users) - - # No pidfile, probably no daemon present - [ ! -f "$PIDFILE" ] && return 1 - # Obtain the pid and check it against the binary name - pid=`cat $PIDFILE` - running_pid $pid $DAEMON || return 1 - return 0 -} - -force_stop() { -# Forcefully kill the process - [ ! -f "$PIDFILE" ] && return - if running ; then - kill -15 $pid - # Is it really dead? - [ -n "$DODTIME" ] && sleep "$DODTIME"s - if running ; then - kill -9 $pid - [ -n "$DODTIME" ] && sleep "$DODTIME"s - if running ; then - echo "Cannot kill $LABEL (pid=$pid)!" - exit 1 - fi - fi - fi - rm -f $PIDFILE - return 0 -} - -case "$1" in - start) - echo -n "Starting $DESC: " - start-stop-daemon --start --quiet --pidfile $PIDFILE \ - --exec $DAEMON -- $DAEMON_OPTS - if running ; then - echo "$NAME." - else - echo " ERROR." - fi - ;; - stop) - echo -n "Stopping $DESC: " - start-stop-daemon --stop --quiet --pidfile $PIDFILE \ - --exec $DAEMON - echo "$NAME." - ;; - force-stop) - echo -n "Forcefully stopping $DESC: " - force_stop - if ! running ; then - echo "$NAME." - else - echo " ERROR." - fi - ;; - reload) - # - # If the daemon can reload its config files on the fly - # for example by sending it SIGHUP, do it here. - # - # If the daemon responds to changes in its config file - # directly anyway, make this a do-nothing entry. - # - echo "Reloading $DESC configuration files." - start-stop-daemon --stop --signal 1 --quiet --pidfile \ - /var/run/$NAME.pid --exec $DAEMON - #;; - force-reload) - # - # If the "reload" option is implemented, move the "force-reload" - # option to the "reload" entry above. If not, "force-reload" is - # just the same as "restart" except that it does nothing if the - # daemon isn't already running. - # check wether $DAEMON is running. If so, restart - start-stop-daemon --stop --test --quiet --pidfile \ - /var/run/$NAME.pid --exec $DAEMON \ - && $0 restart \ - || exit 0 - ;; - restart) - echo -n "Restarting $DESC: " - start-stop-daemon --stop --quiet --pidfile \ - /var/run/$NAME.pid --exec $DAEMON - [ -n "$DODTIME" ] && sleep $DODTIME - start-stop-daemon --start --quiet --pidfile \ - /var/run/$NAME.pid --exec $DAEMON -- $DAEMON_OPTS - echo "$NAME." - ;; - status) - echo -n "$LABEL is " - if running ; then - echo "running" - else - echo " not running." - exit 1 - fi - ;; - *) - N=/etc/init.d/$NAME - # echo "Usage: $N {start|stop|restart|reload|force-reload}" >&2 - echo "Usage: $N {start|stop|restart|force-reload|status|force-stop}" >&2 - exit 1 - ;; -esac - -exit 0 diff --git a/debian/postinst b/debian/postinst deleted file mode 100644 index 8c64049..0000000 --- a/debian/postinst +++ /dev/null @@ -1,39 +0,0 @@ -#!/bin/sh -# postinst script for uhub -# -# see: dh_installdeb(1) - -set -e - -# summary of how this script can be called: -# * `configure' -# * `abort-upgrade' -# * `abort-remove' `in-favour' -# -# * `abort-remove' -# * `abort-deconfigure' `in-favour' -# `removing' -# -# for details, see http://www.debian.org/doc/debian-policy/ or -# the debian-policy package - - -case "$1" in - configure) - ;; - - abort-upgrade|abort-remove|abort-deconfigure) - ;; - - *) - echo "postinst called with unknown argument \`$1'" >&2 - exit 1 - ;; -esac - -# dh_installdeb will replace this with shell code automatically -# generated by other debhelper scripts. - -#DEBHELPER# - -exit 0 diff --git a/debian/postrm b/debian/postrm deleted file mode 100644 index 93737af..0000000 --- a/debian/postrm +++ /dev/null @@ -1,37 +0,0 @@ -#!/bin/sh -# postrm script for uhub -# -# see: dh_installdeb(1) - -set -e - -# summary of how this script can be called: -# * `remove' -# * `purge' -# * `upgrade' -# * `failed-upgrade' -# * `abort-install' -# * `abort-install' -# * `abort-upgrade' -# * `disappear' -# -# for details, see http://www.debian.org/doc/debian-policy/ or -# the debian-policy package - - -case "$1" in - purge|remove|upgrade|failed-upgrade|abort-install|abort-upgrade|disappear) - ;; - - *) - echo "postrm called with unknown argument \`$1'" >&2 - exit 1 - ;; -esac - -# dh_installdeb will replace this with shell code automatically -# generated by other debhelper scripts. - -#DEBHELPER# - -exit 0 diff --git a/debian/preinst b/debian/preinst deleted file mode 100644 index f8559dd..0000000 --- a/debian/preinst +++ /dev/null @@ -1,35 +0,0 @@ -#!/bin/sh -# preinst script for uhub -# -# see: dh_installdeb(1) - -set -e - -# summary of how this script can be called: -# * `install' -# * `install' -# * `upgrade' -# * `abort-upgrade' -# for details, see http://www.debian.org/doc/debian-policy/ or -# the debian-policy package - - -case "$1" in - install|upgrade) - ;; - - abort-upgrade) - ;; - - *) - echo "preinst called with unknown argument \`$1'" >&2 - exit 1 - ;; -esac - -# dh_installdeb will replace this with shell code automatically -# generated by other debhelper scripts. - -#DEBHELPER# - -exit 0 diff --git a/debian/prerm b/debian/prerm deleted file mode 100644 index f0a8219..0000000 --- a/debian/prerm +++ /dev/null @@ -1,38 +0,0 @@ -#!/bin/sh -# prerm script for uhub -# -# see: dh_installdeb(1) - -set -e - -# summary of how this script can be called: -# * `remove' -# * `upgrade' -# * `failed-upgrade' -# * `remove' `in-favour' -# * `deconfigure' `in-favour' -# `removing' -# -# for details, see http://www.debian.org/doc/debian-policy/ or -# the debian-policy package - - -case "$1" in - remove|upgrade|deconfigure) - ;; - - failed-upgrade) - ;; - - *) - echo "prerm called with unknown argument \`$1'" >&2 - exit 1 - ;; -esac - -# dh_installdeb will replace this with shell code automatically -# generated by other debhelper scripts. - -#DEBHELPER# - -exit 0 diff --git a/debian/rules b/debian/rules deleted file mode 100755 index 65ff9a9..0000000 --- a/debian/rules +++ /dev/null @@ -1,91 +0,0 @@ -#!/usr/bin/make -f -# -*- makefile -*- -# Sample debian/rules that uses debhelper. -# This file was originally written by Joey Hess and Craig Small. -# As a special exception, when this file is copied by dh-make into a -# dh-make output file, you may use that output file without restriction. -# This special exception was added by Craig Small in version 0.37 of dh-make. - -# Uncomment this to turn on verbose mode. -#export DH_VERBOSE=1 - - - - - -configure: configure-stamp -configure-stamp: - dh_testdir - # Add here commands to configure the package. - - touch configure-stamp - - -build: build-stamp - -build-stamp: configure-stamp - dh_testdir - - # Add here commands to compile the package. - $(MAKE) - #docbook-to-man debian/uhub.sgml > uhub.1 - - touch $@ - -clean: - dh_testdir - dh_testroot - rm -f build-stamp configure-stamp - - # Add here commands to clean up after the build process. - $(MAKE) clean - - dh_clean - -install: build - dh_testdir - dh_testroot - dh_prep - dh_installdirs - - # Add here commands to install the package into debian/uhub. - $(MAKE) DESTDIR=$(CURDIR)/debian/uhub install - - -# Build architecture-independent files here. -binary-indep: install -# We have nothing to do by default. - -# Build architecture-dependent files here. -binary-arch: install - dh_testdir - dh_testroot - dh_installchangelogs ChangeLog - dh_installdocs - dh_installexamples -# dh_install -# dh_installmenu -# dh_installdebconf -# dh_installlogrotate -# dh_installemacsen -# dh_installpam -# dh_installmime -# dh_python -# dh_installinit -# dh_installcron -# dh_installinfo - dh_installman - dh_link - dh_strip - dh_compress - dh_fixperms -# dh_perl -# dh_makeshlibs - dh_installdeb - dh_shlibdeps - dh_gencontrol - dh_md5sums - dh_builddeb - -binary: binary-indep binary-arch -.PHONY: build clean binary-indep binary-arch binary install configure diff --git a/debian/uhub.default b/debian/uhub.default deleted file mode 100644 index 828c5cd..0000000 --- a/debian/uhub.default +++ /dev/null @@ -1,10 +0,0 @@ -# Defaults for uhub initscript -# sourced by /etc/init.d/uhub -# installed at /etc/default/uhub by the maintainer scripts - -# Additional options that are passed to the Daemon. -ENABLED=1 -LOGFILE="/var/log/uhug.log" -USER=nobody -GROUP=nogroup -DAEMON_OPTS="-f -l ${LOGFILE} -u ${USER} -g {GROUP}"