Control: tags -1 + patch Hello Asterisk maintainers,
Find attached two files, asterisk-config-custom.patch and debiancontrol.patch asterisk-config-custom.patch ---------------------------- This file is for in the directory debian/patches It creates the file contrib/script/asterisk-config-custom and manual page contrib/scripts/asterisk-config-custom.8 Plus updates toplevel Makefile so they will be installed. Activate it will be some something like echo asterisk-config-custom.patch >> debian/patches/series or quilt import -P asterisk-config-custom.patch path/to/file Updating debian/changelog would be something like debchange "Added asterisk-config-custom (Closes: #760032)" debiancontrol.patch ------------------- A unified patch that has to be applied. It will tell asterisk(-config) users about asterisk-config-custom Looking forward to your feedback. Regards Geert Stappers
Descirption: asterisk config custom Author: Geert Stappers <stapp...@stappers.it> Forwarded-Upstream: no Bug-Debian: #760032 Upgrading the asterik package, is usualy upgrading the asterisk-config package. But changing the asterisk-config package effects the custom configuration. Unless the asterisk configuration is in the package asterisk-config-custom. This patch provides the script asterisk-config-custom that helps to create the asterisk-config-custom package --- /dev/null +++ b/contrib/scripts/asterisk-config-custom @@ -0,0 +1,385 @@ +#!/bin/bash +# +# asterisk-config-custom +# script to help creating a 'asterisk-config-custom' .deb package +# +# +# Created by: Geert Stappers <stapp...@stappers.it> +# And distributed under the terms of the GPL +# +# +function acc_usage () +{ +cat << HERE + +asterisk-config-custom {command} + +Where 'command' is 'init', 'next', 'sync', 'help' or 'force'. + + 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 + + force: How to force the first install when asterisk-config is installed + +HERE +} + +function 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 + +See also \`asterisk-config-custom force\` + +HERE +} + +function acc_force () +{ +cat << HERE + +When package \`asterisk-config\` is installed, you have to +use force to install your \`asterisk-config-custom\` package. + sudo dpkg --force-conflicts --force-overwrite -i ../asterisk-config-custom_*_all.deb +Purge the conflicting package with + sudo dpkg --purge asterisk-config + +Now you can use the typical workflow which includes + sudo dpkg -i ../asterisk-config-custom_*_all.deb + +You can avoid '--force-conflicts' and '--force-overwrite' by +installing \`asterisk-config-custom\` _before_ you install \`asterisk\`. +Or by + sudo apt-get remove asterisk + sudo dpkg -i ../asterisk-config-custom_*_all.deb + sudo apt-get install asterisk +That gives you downtime on Asterisk, but you get a reload/restart. +Note: Installing asterisk-config-custom does no asterisk reload. + +HERE +} + +function 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 +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 <stapp...@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 + +} + +function 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 + source ./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 +} + +function acc_next () +{ + if type dpkg-buildpackage > /dev/null ; then + : # Okay + else + 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 + ;; +force) + acc_force + ;; +*) + acc_usage + ;; +esac + +# l l --- /dev/null +++ b/contrib/scripts/asterisk-config-custom.8 @@ -0,0 +1,76 @@ +.TH asterisk-config-custom 8 "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 +and +.B asterisk-config-custom force +. + +.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 <stapp...@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. --- a/Makefile +++ b/Makefile @@ -552,6 +552,7 @@ main-bininstall: bininstall: _all installdirs $(SUBDIRS_INSTALL) main-bininstall $(INSTALL) -m 755 contrib/scripts/astgenkey "$(DESTDIR)$(ASTSBINDIR)/" $(INSTALL) -m 755 contrib/scripts/autosupport "$(DESTDIR)$(ASTSBINDIR)/" + $(INSTALL) -m 755 contrib/scripts/asterisk-config-custom "$(DESTDIR)$(ASTSBINDIR)/" if [ ! -f "$(DESTDIR)$(ASTSBINDIR)/safe_asterisk" -a ! -f /sbin/launchd ]; then \ cat contrib/scripts/safe_asterisk | sed 's|__ASTERISK_SBIN_DIR__|$(ASTSBINDIR)|;s|__ASTERISK_VARRUN_DIR__|$(ASTVARRUNDIR)|;s|__ASTERISK_LOG_DIR__|$(ASTLOGDIR)|;' > contrib/scripts/safe.tmp ; \ $(INSTALL) -m 755 contrib/scripts/safe.tmp "$(DESTDIR)$(ASTSBINDIR)/safe_asterisk" ; \ @@ -571,6 +572,7 @@ bininstall: _all installdirs $(SUBDIRS_I $(INSTALL) -m 644 contrib/scripts/astgenkey.8 "$(DESTDIR)$(ASTMANDIR)/man8" $(INSTALL) -m 644 contrib/scripts/autosupport.8 "$(DESTDIR)$(ASTMANDIR)/man8" $(INSTALL) -m 644 contrib/scripts/safe_asterisk.8 "$(DESTDIR)$(ASTMANDIR)/man8" + $(INSTALL) -m 644 contrib/scripts/asterisk-config-custom.8 "$(DESTDIR)$(ASTMANDIR)/man8" if [ -f contrib/firmware/iax/iaxy.bin ] ; then \ $(INSTALL) -m 644 contrib/firmware/iax/iaxy.bin "$(DESTDIR)$(ASTDATADIR)/firmware/iax/iaxy.bin"; \ fi @@ -840,12 +842,14 @@ _uninstall: $(SUBDIRS_UNINSTALL) main-bi rm -f "$(DESTDIR)$(ASTMODDIR)/"* rm -f "$(DESTDIR)$(ASTSBINDIR)/astgenkey" rm -f "$(DESTDIR)$(ASTSBINDIR)/autosupport" + rm -f "$(DESTDIR)$(ASTSBINDIR)/asterisk-config-custom" rm -rf "$(DESTDIR)$(ASTHEADERDIR)" rm -rf "$(DESTDIR)$(ASTDATADIR)/firmware" rm -f "$(DESTDIR)$(ASTMANDIR)/man8/asterisk.8" rm -f "$(DESTDIR)$(ASTMANDIR)/man8/astgenkey.8" rm -f "$(DESTDIR)$(ASTMANDIR)/man8/autosupport.8" rm -f "$(DESTDIR)$(ASTMANDIR)/man8/safe_asterisk.8" + rm -f "$(DESTDIR)$(ASTMANDIR)/man8/asterisk-config-custom.8" $(MAKE) -C sounds uninstall uninstall: _uninstall
--- a/debian/control +++ b/debian/control @@ -278,3 +278,6 @@ 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.