ports/148859: Fix config file handling for mail/alpine
Ganael Laplanche
ganael.laplanche at martymac.com
Fri Jul 23 09:00:14 UTC 2010
>Number: 148859
>Category: ports
>Synopsis: Fix config file handling for mail/alpine
>Confidential: no
>Severity: non-critical
>Priority: low
>Responsible: freebsd-ports-bugs
>State: open
>Quarter:
>Keywords:
>Date-Required:
>Class: update
>Submitter-Id: current-users
>Arrival-Date: Fri Jul 23 09:00:13 UTC 2010
>Closed-Date:
>Last-Modified:
>Originator: Ganael Laplanche
>Release: 9.0-CURRENT
>Organization:
http://contribs.martymac.org
>Environment:
FreeBSD laptop.martymac.com 9.0-CURRENT FreeBSD 9.0-CURRENT #9 r209412: Tue Jun 22 14:21:19 UTC 2010 martymac at laptop.martymac.com:/usr/obj/usr/src/sys/GENERIC i386
>Description:
The Alpine port always remove its configuration file on uninstall, making port upgrades leading to unconditionnaly loosing a previously modified configuration.
This problem occurs because Alpine uses the -conf option to dump a "fresh" configuration file. Unfortunately, the configuration file generated with this option always includes variables already set in the system-wide Alpine configuration file (/usr/local/etc/alpine.conf). See pith/conf.c :
[...]
6029 /*------------------------------------------------------------
6030 Dump out a global pine.conf on the standard output with fresh
6031 comments. Preserves variables currently set in SYSTEM_PINERC, if any.
6032 ----*/
6033 void
6034 dump_global_conf(void)
6035 {
[...]
Thus, any file generated with the -conf option is *stricly* similar to the current /usr/local/etc/alpine.conf file (except for comments), even if variables have been modified. During uninstall, as those files are similar, the /usr/local/etc/alpine.conf is removed.
The attached patches include a patch already sent upstream to the University of Washington (via http://www.washington.edu/alpine/commentform.html) to allow Alpine to use the -P option together with the -conf one. Specifying an empty file with -P makes Alpine to produce a *really* clean config file which can be used by the port as a .conf.sample file (as it is usually done in the ports tree).
>How-To-Repeat:
>Fix:
Patch attached with submission follows:
diff -aurN alpine.orig/Makefile alpine/Makefile
--- alpine.orig/Makefile 2010-07-22 16:44:26.487772607 +0000
+++ alpine/Makefile 2010-07-23 07:59:57.635039788 +0000
@@ -7,7 +7,7 @@
PORTNAME?= alpine
PORTVERSION= 2.00
-PORTREVISION?= 1
+PORTREVISION?= 2
CATEGORIES?= mail news ipv6
MASTER_SITES= ftp://ftp.cac.washington.edu/alpine/ \
http://dougbarton.us/Downloads/alpine-${PORTVERSION}/
@@ -182,8 +182,12 @@
${INSTALL_DATA} ${WRKSRC}/doc/tech-notes.txt ${DOCSDIR}
${INSTALL_DATA} ${WRKSRC}/doc/tech-notes/*.html ${DOCSDIR}/tech-notes
.endif
- ${PREFIX}/bin/alpine -P ${PREFIX}/etc/alpine.conf -conf >${WRKSRC}/alpine.conf
- ${INSTALL_DATA} ${WRKSRC}/alpine.conf ${PREFIX}/etc/alpine.conf
+ ${PREFIX}/bin/alpine -P /dev/null -conf >${WRKSRC}/alpine.conf.sample
+ ${INSTALL_DATA} ${WRKSRC}/alpine.conf.sample \
+ ${PREFIX}/etc/alpine.conf.sample
+ @if [ ! -f ${PREFIX}/etc/alpine.conf ]; then \
+ ${CP} -p ${PREFIX}/etc/alpine.conf.sample \
+ ${PREFIX}/etc/alpine.conf; fi
@${CAT} ${PKGMESSAGE}
.endif # !defined(PICO_ALPINE_SLAVE)
diff -aurN alpine.orig/files/patch-alpine-conf-option alpine/files/patch-alpine-conf-option
--- alpine.orig/files/patch-alpine-conf-option 1970-01-01 00:00:00.000000000 +0000
+++ alpine/files/patch-alpine-conf-option 2010-07-23 08:46:55.846999548 +0000
@@ -0,0 +1,70 @@
+--- alpine/arg.c.orig 2010-07-22 16:47:48.668603132 +0000
++++ alpine/arg.c 2010-07-22 16:56:39.038755763 +0000
+@@ -839,8 +839,12 @@
+ exit(0);
+ }
+
+- if(do_conf)
+- dump_global_conf();
++ if(do_conf) {
++ if(pine_state->pconf)
++ dump_global_conf(pine_state->pconf->name);
++ else
++ dump_global_conf(SYSTEM_PINERC);
++ }
+
+ if(pinerc_file)
+ dump_new_pinerc(pinerc_file);
+--- pith/conf.c.orig 2010-07-22 16:45:34.449756882 +0000
++++ pith/conf.c 2010-07-22 17:06:36.641670938 +0000
+@@ -6028,16 +6028,16 @@
+
+ /*------------------------------------------------------------
+ Dump out a global pine.conf on the standard output with fresh
+- comments. Preserves variables currently set in SYSTEM_PINERC, if any.
++ comments. Preserves variables currently set in refPrc, if any.
+ ----*/
+ void
+-dump_global_conf(void)
++dump_global_conf(char *refPrc)
+ {
+ FILE *f;
+ struct variable *var;
+ PINERC_S *prc;
+
+- prc = new_pinerc_s(SYSTEM_PINERC);
++ prc = new_pinerc_s(refPrc);
+ read_pinerc(prc, variables, ParseGlobal);
+ if(prc)
+ free_pinerc_s(&prc);
+--- pith/conf.h.orig 2010-07-22 17:09:08.101585257 +0000
++++ pith/conf.h 2010-07-22 17:09:26.156839207 +0000
+@@ -853,7 +853,7 @@
+ int write_pinerc(struct pine *, EditWhich, int);
+ void quit_to_edit_msg(PINERC_S *);
+ int var_in_pinerc(char *);
+-void dump_global_conf(void);
++void dump_global_conf(char *);
+ void dump_new_pinerc(char *);
+ int set_variable(int, char *, int, int, EditWhich);
+ int set_variable_list(int, char **, int, EditWhich);
+--- doc/alpine.1.orig 2008-08-22 20:40:16.000000000 +0000
++++ doc/alpine.1 2010-07-23 06:02:09.000000000 +0000
+@@ -111,12 +111,13 @@
+ .I -f
+ argument is applied to the first defined folder-collection.
+ .IP \fB-conf\fR 20
+-Produce a sample/fresh copy of the
+-system-wide configuration file,
++Produce a copy of the system-wide configuration file,
+ .I pine.conf,
+-on the standard output. This is distinct from the per-user
++with fresh comments on the standard output.
++This is distinct from the per-user
+ .I .pinerc
+-file.
++file and will preserve variables currently set in the default
++system-wide configuration file (or the file specified with -P, if any).
+ .IP \fB-convert_sigs\ \fI-p\ pinerc\fR 20
+ Convert signature files into literal signatures.
+ .IP \fB-copy_abook\ <\fIlocal_abook\fR>\ <\fIremote_abook\fR> 20
diff -aurN alpine.orig/pkg-plist alpine/pkg-plist
--- alpine.orig/pkg-plist 2010-07-22 16:44:26.478771743 +0000
+++ alpine/pkg-plist 2010-07-23 07:58:45.404206679 +0000
@@ -1,11 +1,9 @@
- at unexec %D/bin/alpine -conf >%D/etc/alpine.conf.tmp
- at unexec if cmp -s %D/etc/alpine.conf %D/etc/alpine.conf.tmp; then rm -f %D/etc/alpine.conf; fi
- at unexec rm -f %D/etc/alpine.conf.tmp
+ at unexec if cmp -s %D/etc/alpine.conf.sample %D/etc/alpine.conf; then rm -f %D/etc/alpine.conf; fi
+etc/alpine.conf.sample
+ at exec if [ ! -f %D/etc/alpine.conf ]; then cp -p %D/%F %B/alpine.conf; fi
bin/alpine
bin/rpdump
bin/rpload
- at exec %D/bin/alpine -P %D/etc/alpine.conf -conf >%D/etc/alpine.conf.tmp
- at exec /bin/mv %D/etc/alpine.conf.tmp %D/etc/alpine.conf
%%PORTDOCS%%%%DOCSDIR%%/LICENSE
%%PORTDOCS%%%%DOCSDIR%%/NOTICE
%%PORTDOCS%%%%DOCSDIR%%/README
>Release-Note:
>Audit-Trail:
>Unformatted:
More information about the freebsd-ports-bugs
mailing list