On 01/24/2017 01:20 PM, Jonas Smedegaard wrote: > Quoting James Valleroy (2017-01-23 23:48:00) >> On Tue, 13 Dec 2016 12:14:52 -0500 James Valleroy >> <jvalle...@mailbox.org> wrote: >>> The attached patch set implements this, by adding several debconf >>> questions to set the server hostnames, base url, well-known paths, >>> authentication type, and rights type. These questions all have low >>> priority. I used augtool (from augeas-tools) to read/modify the >>> config file, and ucf to merge user settings with updates to the >>> packaged file. >> >> After sending this patch, I discovered this rule given in the Debconf >> Programmer's Tutorial: >> "Note that the config script is run before the package is unpacked. It >> should only use commands that are in essential packages." >> >> But in the patch I submitted (part 0002), I used augtool in >> debian/radicale.config to parse the ini-file config and read current >> settings from disk. So that is a problem for the 0002 and 0003 patches >> above.
I'm attaching another patch that switches debian/radicale.config to use awk to read the current configuration. This should resolve the issue mentioned above.
From 4274c6ac412b536cda4e909e65563a71c09c5248 Mon Sep 17 00:00:00 2001 From: James Valleroy <jvalle...@mailbox.org> Date: Sat, 25 Feb 2017 14:45:49 -0500 Subject: [PATCH 4/4] Use awk to read config in config script --- debian/radicale.config | 25 ++++++++++++------------- 1 file changed, 12 insertions(+), 13 deletions(-) diff --git a/debian/radicale.config b/debian/radicale.config index 4699cff..e95f84e 100644 --- a/debian/radicale.config +++ b/debian/radicale.config @@ -6,23 +6,22 @@ CONF=/etc/radicale/config . /usr/share/debconf/confmodule -aug_get () { - cat <<EOF | augtool -L -A | awk -F'=[[:blank:]]*' '{print $2}' -set /augeas/load/Puppet/lens Puppet.lns -set /augeas/load/Puppet/incl[last() + 1] "$CONF" -load -get "/files$CONF/$1" -EOF +get_conf () { + awk -F'=' -v section="[$1]" -v name="$2" ' +$0==section{ flag=1; next } # Set flag when entering given section. +/^\[/{ flag=0; next } # Disable flag when entering another section. +flag && $1==name{ print $2 } # If flag is set and name matches, print value. +' "$CONF" } # Load config file, if it exists. if [ -e $CONF ]; then - SERVER_HOSTS=$(aug_get server/hosts) - SERVER_BASE_PREFIX=$(aug_get server/base_prefix) - WELLKNOWN_CALDAV=$(aug_get well-known/caldav) - WELLKNOWN_CARDDAV=$(aug_get well-known/carddav) - AUTH_TYPE=$(aug_get auth/type) - RIGHTS_TYPE=$(aug_get rights/type) + SERVER_HOSTS=$(get_conf server hosts) + SERVER_BASE_PREFIX=$(get_conf server base_prefix) + WELLKNOWN_CALDAV=$(get_conf well-known caldav) + WELLKNOWN_CARDDAV=$(get_conf well-known carddav) + AUTH_TYPE=$(get_conf auth type) + RIGHTS_TYPE=$(get_conf rights type) # Store values from config file into debconf db. db_set radicale/server_hosts "$SERVER_HOSTS" -- 2.11.0
signature.asc
Description: OpenPGP digital signature