[Pkg-voip-commits] [asterisk] 02/04: asterisk-config-custom (Closes: #760032)
tzafrir at debian.org
tzafrir at debian.org
Wed Dec 31 22:27:03 UTC 2014
This is an automated email from the git hooks/post-receive script.
tzafrir pushed a commit to branch master
in repository asterisk.
commit 9f65c80f602cbf3b3bc2b844988bc2b3362124ef
Author: Geert Stappers <stappers at stappers.it>
Date: Wed Dec 31 13:09:19 2014 +0200
asterisk-config-custom (Closes: #760032)
Adds the command asterisk-config-custom to create and manitain a custom
configuration package for Asterisk.
---
debian/asterisk-config-custom | 362 ++++++++++++++++++++++++++++++++++++++++
debian/asterisk-config-custom.1 | 74 ++++++++
debian/asterisk.install | 1 +
debian/asterisk.manpages | 1 +
debian/control | 4 +
debian/rules | 4 +
6 files changed, 446 insertions(+)
diff --git a/debian/asterisk-config-custom b/debian/asterisk-config-custom
new file mode 100644
index 0000000..2a8ecae
--- /dev/null
+++ b/debian/asterisk-config-custom
@@ -0,0 +1,362 @@
+#!/bin/sh
+#
+# asterisk-config-custom
+# script to help creating a 'asterisk-config-custom' .deb package
+#
+#
+# Created by: Geert Stappers <stappers at stappers.it>
+# And distributed under the terms of the GPL
+#
+#
+acc_usage ()
+{
+cat << HERE
+
+asterisk-config-custom {command}
+
+Where 'command' is 'init', 'next', 'sync' or 'help'
+
+ init: Creates directory 'my-asterisk-config' with content
+
+ next: Provides instruction for next step
+
+ sync: Mostly \`rsync --archive /etc/asterisk etc_asterisk\`
+
+ help: Prints _another_ help text
+
+HERE
+}
+
+acc_help ()
+{
+cat << HERE
+
+Program 'asterisk-config-custom' is for helping you making
+your 'asterisk-config-custom' .deb package.
+
+Typical work flow is running
+ asterisk-config-custom init
+only once.
+
+Now you have a directory named
+ my-asterisk-config
+feel free to rename it
+Important is that it has a debian/ directory
+and an etc_asterisk/ directory
+
+Change working directory with
+ cd my-asterisk-config # or to what you renamed it.
+Edit files in etc_asterisk. You may use
+ asterisk-config-custom sync
+to get you a starting point.
+Create the actual package with
+ dpkg-buildpackge -uc -us
+
+And install with
+ sudo dpkg -i ../asterisk-config-custom_*_all.deb
+
+This package will be considered as an upgrade to the default
+\`asterisk-config\` package and hence that package will will be removed
+upon isntalling the custom package. However, it will not be purged and
+hence all configuration files in \`/etc/asterisk\` from it will remain
+installed. In order to remove them, you'll need to purge the package
+\`asterisk-config\'.
+
+Alternatively, you can install the custom package before installing
+Asterisk.
+
+HERE
+}
+
+acc_init ()
+{
+# Creates a diretory and puts files in it,
+# including the Debian packaging files.
+
+mkdir --parents my-asterisk-config/debian/source
+
+cat << HERE > my-asterisk-config/README
+
+In this directory you can / should run
+
+ dpkg-buildbuildpackage -uc -us
+
+to get your 'asterisk-config-custom' package build.
+
+HERE
+
+cat << LastLine > my-asterisk-config/Makefile
+#
+# Makefile
+#
+all: etc_asterisk/asterisk.conf \
+ usr/share/doc/asterisk-config/examples/configs/modules.conf.sample
+ @echo "FYI: (minimal set of) configuration files are available"
+
+etc_asterisk/asterisk.conf:
+ @mkdir --parents etc_asterisk
+ echo "; only a place holder" > etc_asterisk/asterisk.conf
+
+usr/share/doc/asterisk-config/examples/configs/modules.conf.sample:
+ @mkdir --parents usr/share/doc/asterisk-config/examples/configs
+ echo "; place holder" \\
+ > usr/share/doc/asterisk-config/examples/configs/modules.conf.sample
+
+
+install:
+ install --directory \$(DESTDIR)/usr
+ install --directory \$(DESTDIR)/etc/asterisk
+ rsync --archive --delete usr/* \$(DESTDIR)/usr
+ rsync --archive --delete etc_asterisk/* \$(DESTDIR)/etc/asterisk
+
+# l l
+LastLine
+
+cat << LastLine > my-asterisk-config/acc.config
+# This file will be read during \`asterisk-config-custom sync\`
+#
+ACC_SYNC_CONFIG_EXAMPLES=Yes
+# another value as 'Yes' wouldn't sync the configuration examples
+#
+#
+# l l
+LastLine
+
+##--------------------------------------------
+
+# Those who are familiar with Debian packaging
+# can consider the rest of this function as a dedicated `dh_make`.
+
+cat << LastLine > my-asterisk-config/debian/control
+Source: asterisk-config-custom
+Section: comm
+Priority: optional
+Maintainer: Me Myself <${LOGNAME}@$( hostname --fqdn )>
+Build-Depends: debhelper (>= 9)
+Standards-Version: 3.9.5
+Homepage: <insert the upstream URL, if relevant>
+#Vcs-Git: git://anonscm.debian.org/collab-maint/asterisk-config-custom.git
+#Vcs-Browser: http://anonscm.debian.org/?p=collab-maint/asterisk-config-custom.git;a=summary
+
+Package: asterisk-config-custom
+Architecture: all
+Depends: \${misc:Depends}
+Recommends: asterisk
+Conflicts: asterisk-config
+Replaces: asterisk-config
+Description: Custom configuration files for Asterisk
+ Package that contains custom configuration files for Asterisk.
+ .
+ It is to keep _your_ config files while upgrading Asterisk.
+ .
+ The trick is that Asterisk depends
+ on asterisk-config OR asterisk-config-custom
+LastLine
+
+cat << LastLine > my-asterisk-config/debian/changelog
+asterisk-config-custom (0.6) unstable; urgency=medium
+
+ * Created with \`asterisk-config-custom init\`
+
+ -- Me Myself <${LOGNAME}@$( hostname --fqdn )> $( date --rfc-2822 )
+
+asterisk-config-custom (0.4) unstable; urgency=low
+
+ * Initial release (Closes: #760032).
+
+ -- Geert Stappers <stappers at stappers.it> Fri, 29 Aug 2014 16:25:44 +0200
+LastLine
+
+cat << LastLine > my-asterisk-config/debian/copyright
+Format: http://www.debian.org/doc/packaging-manuals/copyright-format/1.0/
+Upstream-Name: asterisk-config-custom
+Source: <url://example.com>
+
+Files: *
+Copyright: <years> <put author's name and email here>
+ <years> <likewise for another author>
+License: <special license>
+ <Put the license of the package here indented by 1 space>
+ <This follows the format of Description: lines in control file>
+ .
+ <Including paragraphs>
+LastLine
+
+cat << LastLine > my-asterisk-config/debian/rules
+#!/usr/bin/make -f
+# See debhelper(7)
+#
+# output every command that modifies files on the build system.
+#DH_VERBOSE = 1
+
+# main packaging script based on dh7 syntax
+%:
+ dh \$@
+
+# l l
+LastLine
+chmod a+x my-asterisk-config/debian/rules
+
+cat << LastLine > my-asterisk-config/debian/preinst
+#! /bin/sh
+# preinst script
+#
+# see: dh_installdeb(1)
+
+set -e
+
+# summary of how this script can be called:
+# * <new-preinst> \`install'
+# * <new-preinst> \`install' <old-version>
+# * <new-preinst> \`upgrade' <old-version>
+# * <old-preinst> \`abort-upgrade' <new-version>
+#
+# for details, see http://www.debian.org/doc/debian-policy/ or
+# the debian-policy package
+
+case "\$1" in
+ install|upgrade)
+ # chan_modem was removed on 1.4+
+ ;;
+
+ 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
+LastLine
+
+cat << LastLine > my-asterisk-config/debian/postinst
+#! /bin/sh
+
+set -e
+
+# summary of how this script can be called:
+# * <postinst> \`configure' <most-recently-configured-version>
+# * <old-postinst> \`abort-upgrade' <new version>
+# * <conflictor's-postinst> \`abort-remove' \`in-favour' <package>
+# <new-version>
+# * <deconfigured's-postinst> \`abort-deconfigure' \`in-favour'
+# <failed-install-package> <version> \`removing'
+# <conflicting-package> <version>
+
+case "\$1" in
+ configure)
+ set +e # ignore errors temporarily
+
+ # find conffiles under /etc/asterisk belonging to asterisk-config-custom
+ # and chown them to user asterisk.
+ dpkg-query -W -f='\${Conffiles}\n' asterisk-config-custom 2>/dev/null | \\
+ sed -nr -e 's; (/etc/asterisk/.*) [0-9a-f]*;\1;p' | \\
+ while read conffile; do
+ chown asterisk: \${conffile} 2>/dev/null
+ done
+
+ # handle them in the end with a glob since it's way faster
+ dpkg-statoverride --quiet --list '/etc/asterisk/*' | while read STAT; do
+ chown \`echo \$STAT | cut -d' ' -f 1,2,4 | sed 's/ /:/'\` \\
+ 2>/dev/null
+ done
+
+ set -e
+ ;;
+
+ 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
+
+LastLine
+
+cat << LastLine > my-asterisk-config/debian/lintian-overrides
+asterisk-config-custom: non-standard-file-perm
+LastLine
+
+echo 9 > my-asterisk-config/debian/compat
+
+echo '3.0 (native)' > my-asterisk-config/debian/source/format
+
+}
+
+acc_sync ()
+{
+ mkdir --parents etc_asterisk
+ # assuming there are files in /etc/asterisk/
+ rsync --archive --delete /etc/asterisk/* etc_asterisk/
+ if [ -r ./acc.config ] ; then
+ . ./acc.config
+ else
+ echo 'E: file "./acc.config" not readable'
+ echo "I: Are you in the directory that \`${0} init\` created?"
+ exit 1
+ fi
+ if [ x${ACC_SYNC_CONFIG_EXAMPLES} = xYes ] ; then
+ ACC_EX=usr/share/doc/asterisk-config/examples
+ # using asterisk-config directory
+ mkdir --parents ${ACC_EX}
+ rsync --archive --delete /${ACC_EX}/* ${ACC_EX}
+ fi
+}
+
+acc_next ()
+{
+ if ! which dpkg-buildpackage > /dev/null ; then
+ echo 'E: Program `dpkg-buildpackage` is not installed.'
+ echo 'I: It is in the Debian package `dpkg-dev`.'
+ echo 'I: Installing it with `apt-get install build-essential`,'
+ echo 'I: will also install the program `make` that is also needed.'
+ exit 1
+ fi
+ if grep --quiet 'Package: asterisk-config-custom' debian/control ; then
+ echo 'dpkg-buildpackage -uc -us # Running this now'
+ dpkg-buildpackage -uc -us
+ else
+ echo 'E: debian/control file for package asterisk-config-custom not found'
+ echo "I: Are you in the directory that \`${0} init\` created?"
+ exit 1
+ fi
+}
+
+
+# main()
+
+case $1 in
+init)
+ acc_init
+ ;;
+next)
+ acc_next
+ ;;
+sync)
+ acc_sync
+ ;;
+help)
+ acc_help
+ ;;
+*)
+ acc_usage
+ ;;
+esac
+
+# l l
diff --git a/debian/asterisk-config-custom.1 b/debian/asterisk-config-custom.1
new file mode 100644
index 0000000..3bd9572
--- /dev/null
+++ b/debian/asterisk-config-custom.1
@@ -0,0 +1,74 @@
+.TH asterisk-config-custom 1 "2014-12-14" "Asterisk" "Debian Manual"
+.SH NAME
+.B asterisk\-config\-custom
+\(em for helping you making your 'asterisk\-config\-custom' .deb package
+.SH SYNOPSIS
+.PP
+.B asterisk\-config\-custom
+.I { command }
+
+.SH DESCRIPTION
+.B asterisk\-config\-custom
+prints a help text when no
+.I command
+is given. And another help text when command
+.I help
+is given.
+
+.SH WORKFLOW
+
+Recommented usage workflow is described in the actual script.
+Get the instructions with
+.B asterisk\-config\-custom help
+.
+
+.SH FILES
+.B my\-asterisk\-config/
+.RS
+Created during
+.I asterisk\-config\-custom init
+.RE
+
+.B my\-asterisk\-config/etc_asterisk/
+.RS
+Location where you put asterisk configuration files
+you want to get in
+.I /etc/asterisk/
+
+You may use
+.I asterisk\-config\-custom sync
+to get it updated with current configuration.
+.RE
+
+.B my\-asterisk\-config/debian/
+.RS
+Debian packaging files.
+You may leave it default.
+You may change it.
+
+Example given of what to change: version number in
+.I debian/changelog
+.RE
+
+.SH BUGS
+Maybe should script
+.I asterisk\-config\-custom
+have been named into something longer like
+.I asterisk\-config\-custom\-dh\-make
+.
+Where suffix
+.I dh\-make
+comes from debhelper make.
+The software tool that converts source archives into Debian package source
+
+.SH SEE ALSO
+debchange(1) for information on changing the version mumber.
+
+.SH "AUTHOR"
+This manual page was written by Geert Stappers <stappers at stappers.it>
+Permission is granted to copy, distribute and/or modify this document under
+the terms of the GNU General Public License, Version 2 any
+later version published by the Free Software Foundation.
+
+On Debian systems, the complete text of the GNU General Public
+License can be found in /usr/share/common\-licenses/GPL\-2.
diff --git a/debian/asterisk.install b/debian/asterisk.install
index 976f49c..1afb601 100644
--- a/debian/asterisk.install
+++ b/debian/asterisk.install
@@ -1,4 +1,5 @@
usr/sbin
+usr/bin/asterisk-config-custom
usr/share/asterisk/firmware
usr/share/asterisk/keys
usr/share/asterisk/conf
diff --git a/debian/asterisk.manpages b/debian/asterisk.manpages
index a06a0f8..4ee9a69 100644
--- a/debian/asterisk.manpages
+++ b/debian/asterisk.manpages
@@ -1,3 +1,4 @@
utils/*.1
doc/*.8
contrib/scripts/*.8
+debian/asterisk-config-custom.1
diff --git a/debian/control b/debian/control
index 409cf25..d45c492 100644
--- a/debian/control
+++ b/debian/control
@@ -279,8 +279,12 @@ Package: asterisk-config
Depends: ${misc:Depends}
Recommends: asterisk
Conflicts: asterisk-config-custom
+Replaces: asterisk-config-custom
Architecture: all
Description: Configuration files for Asterisk
Asterisk is an Open Source PBX and telephony toolkit.
.
This package contains the default configuration files of Asterisk.
+ .
+ With program asterisk-config-custom in the asterisk package,
+ you can create an asterisk-config replacement package.
diff --git a/debian/rules b/debian/rules
index a22403a..c338853 100755
--- a/debian/rules
+++ b/debian/rules
@@ -138,6 +138,10 @@ SUBPACKS_EXTRA_DIRS_MOD = $(SUBPACKS_EXTRA_DIRS:%=%/usr/lib/asterisk/modules)
override_dh_auto_install:
$(FETCH_ENV) dh_auto_install -- $(BUILDFLAGS) config samples
cp -a configs $(CURDIR)/debian/tmp/usr/share/asterisk/conf
+ mkdir -p $(CURDIR)/debian/tmp/usr/bin/
+ mkdir -p $(CURDIR)/debian/tmp/usr/share/man/man1
+ cp -a debian/asterisk-config-custom $(CURDIR)/debian/tmp/usr/bin/
+ cp -a debian/asterisk-config-custom $(CURDIR)/debian/tmp/usr/share/man/man1/
$(RM) -f $(CURDIR)/debian/tmp/usr/sbin/conf2ael
$(RM) -f $(CURDIR)/debian/tmp/usr/sbin/muted
$(RM) -f $(CURDIR)/debian/tmp/usr/sbin/streamplayer
--
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pkg-voip/asterisk.git
More information about the Pkg-voip-commits
mailing list