Skip site navigation (1)Skip section navigation (2)
Date:      Fri, 4 Jan 2013 02:12:46 -0600
From:      Scot Hetzel <swhetzel@gmail.com>
To:        Miroslav Lachman <000.fbsd@quip.cz>
Cc:        freebsd-ports@freebsd.org
Subject:   Re: What is policy about auto-editing config files on port install / deinstall?
Message-ID:  <CACdU%2Bf__iAzrOoSOHunb3x7Ot7usZ7zjfhT%2Bz95uTy8HUqr83g@mail.gmail.com>
In-Reply-To: <50E5FCDA.80906@quip.cz>
References:  <50E49A73.2070008@quip.cz> <CACdU%2Bf9WKAsLZHqHMZKtgGoBRL%2BR9do0qfTL0d_c_8_e6Tb4bw@mail.gmail.com> <50E5FCDA.80906@quip.cz>

next in thread | previous in thread | raw e-mail | index | archive | help
On Thu, Jan 3, 2013 at 3:49 PM, Miroslav Lachman <000.fbsd@quip.cz> wrote:
>> What errors are you getting when re-installing an Apache module?
>
>
> Apache modules are not enabled by default. I am talking about 3rd party
> modules. In some cases, they do nothing with httpd.conf, in other cases,
> they are adding commented line and I must manualy uncomment this line, so it
> is my will to have this module loaded / enabled.
>
> But upgrade or reinstall or deinstall of this module causes commenting this
> line out. It is undesirable.
> If I enable this module and this module will be updated 10 times a year, why
> am I forced to re-enable it 10 times again?
>
> Real world example follows:
>
> root@spare ~/# uname -srmi
> FreeBSD 8.3-RC2 amd64 GENERIC
>
> ___________________________________________________
> Only Apache is installed, no 3rd party modules
>
> root@spare ~/# pkg_info -E ap22\* apache22-\*
> apache22-2.2.23_4
>
> ___________________________________________________
> Copy the config file for later comparision
>
> root@spare ~/# cp -P /usr/local/etc/apache22/httpd.conf httpd.conf.orig
>
> ___________________________________________________
> Install mod_xsendfile
>
> root@spare ~/# portmaster www/mod_xsendfile
>
> ===>>> Installation of www/mod_xsendfile (ap22-mod_xsendfile-0.12_2)
> complete
>
> ___________________________________________________
> There is commented LoadModule line after install added to httpd.conf
>
> root@spare ~/# diff -U 2 httpd.conf.orig /usr/local/etc/apache22/httpd.conf
> --- httpd.conf.orig     2013-01-03 12:56:22.000000000 +0100
> +++ /usr/local/etc/apache22/httpd.conf  2013-01-03 21:25:03.000000000 +0100
> @@ -75,4 +75,5 @@
>  LoadModule rewrite_module libexec/apache22/mod_rewrite.so
>  LoadModule php5_module        libexec/apache22/libphp5.so
> +#LoadModule xsendfile_module   libexec/apache22/mod_xsendfile.so
>
> ___________________________________________________
> I must manually uncomment the line (which is OK, I don't need to modules be
> auto enabled as services are not enabled in rc.conf)
>
> root@spare ~/# vi /usr/local/etc/apache22/httpd.conf
>
> LoadModule xsendfile_module   libexec/apache22/mod_xsendfile.so
>
> ___________________________________________________
> Then I added some configuration to VirtualHost
>
> root@spare ~/# vi
> /usr/local/etc/apache22/vhosts/available/www.example.com.conf
>
>     XSendFile  on
>     XSendFilePath      /vol0/web/test
>
> ___________________________________________________
> Diff shows that module is enabled
>
> root@spare ~/# diff -U 2 httpd.conf.orig /usr/local/etc/apache22/httpd.conf
> --- httpd.conf.orig     2013-01-03 12:56:22.000000000 +0100
> +++ /usr/local/etc/apache22/httpd.conf  2013-01-03 21:26:46.000000000 +0100
> @@ -75,4 +75,5 @@
>  LoadModule rewrite_module libexec/apache22/mod_rewrite.so
>  LoadModule php5_module        libexec/apache22/libphp5.so
> +LoadModule xsendfile_module   libexec/apache22/mod_xsendfile.so
>
> ___________________________________________________
> Syntax check
>
> root@spare ~/# httpd -t
> Syntax OK
>
> ___________________________________________________
> Reinstallation of the module (same as upgrading)
>
> root@spare ~/# portmaster ap22-mod_xsendfile-0.12_2
>
> ===>>> Creating a backup package for old version ap22-mod_xsendfile-0.12_2
>         ===>>> Package saved to /usr/ports/packages/portmaster-backup
>
> Don't forget to remove all mod_xsendfile-related directives in your
> httpd.conf
>
> ===>  Installing for ap22-mod_xsendfile-0.12_2
> ===>   Generating temporary packing list
> ===>  Checking if www/mod_xsendfile already installed
> /usr/local/share/apache22/build/instdso.sh
> SH_LIBTOOL='/usr/local/share/apr/build-1/libtool'
> /usr/ports/www/mod_xsendfile/work/mod_xsendfile-0.12/mod_xsendfile.la
> /usr/local/libexec/apache22
> /usr/local/share/apr/build-1/libtool --mode=install cp
> /usr/ports/www/mod_xsendfile/work/mod_xsendfile-0.12/mod_xsendfile.la
> /usr/local/libexec/apache22/
> libtool: install: cp
> /usr/ports/www/mod_xsendfile/work/mod_xsendfile-0.12/.libs/mod_xsendfile.so
> /usr/local/libexec/apache22/mod_xsendfile.so
> libtool: install: cp
> /usr/ports/www/mod_xsendfile/work/mod_xsendfile-0.12/.libs/mod_xsendfile.lai
> /usr/local/libexec/apache22/mod_xsendfile.la
> libtool: install: cp
> /usr/ports/www/mod_xsendfile/work/mod_xsendfile-0.12/.libs/mod_xsendfile.a
> /usr/local/libexec/apache22/mod_xsendfile.a
> libtool: install: chmod 644 /usr/local/libexec/apache22/mod_xsendfile.a
> libtool: install: ranlib /usr/local/libexec/apache22/mod_xsendfile.a
> chmod 755 /usr/local/libexec/apache22/mod_xsendfile.so
> [preparing module `xsendfile' in /usr/local/etc/apache22/httpd.conf]
> ===>   Registering installation for ap22-mod_xsendfile-0.12_2
>
> ===>>> Creating a package for new version ap22-mod_xsendfile-0.12_2
>         ===>>> Package saved to /usr/ports/packages/All
>
> ===>>> Re-installation of ap22-mod_xsendfile-0.12_2 complete
>
>
> ___________________________________________________
> And there is a problem - syntax error, because module was disabled
> (commented out on deinstall) and some directives remained in VirtualHost
> definition - Apache will not start!
>
> root@spare ~/# httpd -t
> Syntax error on line 57 of
> /usr/local/etc/apache22/vhosts/available/www.example.com.conf:
> Invalid command 'XSendFile', perhaps misspelled or defined by a module not
> included in the server configuration
>
> ___________________________________________________
> Diff shows commented out line
>
> root@spare ~/# diff -U 2 httpd.conf.orig /usr/local/etc/apache22/httpd.conf
> --- httpd.conf.orig     2013-01-03 12:56:22.000000000 +0100
> +++ /usr/local/etc/apache22/httpd.conf  2013-01-03 21:32:26.000000000 +0100
> @@ -75,4 +75,5 @@
>  LoadModule rewrite_module libexec/apache22/mod_rewrite.so
>  LoadModule php5_module        libexec/apache22/libphp5.so
> +#LoadModule xsendfile_module   libexec/apache22/mod_xsendfile.so
>
> ___________________________________________________
>
> I think this behavior is wrong.
>
> Why am I forced to manualy re-enable all 3rd party modules on each upgrade?
>
> Modules should not disable something that is explicitly enabled by user /
> system administrator.
>
>
I found the cause of your issue, the www/mod_sendfile/Makefile has
AP_GENPLIST= yes defined.  This causes the port to use this code to
create the packing list:

Mk/bsd.apache.mk

451 	ap-gen-plist:
452 	.if defined(AP_GENPLIST)
453 	. if !exists(${PLIST})
454 	@${ECHO} "===> Generating apache plist"
455 	# apache22
456 	@${ECHO} "@unexec ${SED} -i '' -E
'/LoadModule[[:blank:]]+%%AP_NAME%%_module/d'
%D/%%APACHEETCDIR%%/httpd.conf" >> ${PLIST}
457 	@${ECHO} "%%APACHEMODDIR%%/%%AP_MODULE%%" >> ${PLIST}
458 	@${ECHO} "@exec %D/sbin/apxs -e -A -n %%AP_NAME%% %D/%F" >> ${PLIST}
459 	@${ECHO} "@unexec echo \"Don't forget to remove all
${MODULENAME}-related directives in your httpd.conf\"">> ${PLIST}
460 	. endif
461 	.else
462 	@${DO_NADA}
463 	.endif
464 	.endif

As well as adding the module disabled in the httpd.conf file:

472 	do-install:
473 	@${APXS} -i -A -n ${SHORTMODNAME} ${WRKSRC}/${MODULENAME}.${AP_BUILDEXT}

This is what is causing your problem with the module being disabled
after an upgrade of the port/package.  Mk/bsd.apache.mk should be
changed to:

451 	ap-gen-plist:
452 	.if defined(AP_GENPLIST)
453 	. if !exists(${PLIST})
454 	@${ECHO} "===> Generating apache plist"
455 	# apache22
D456
457 	@${ECHO} "%%APACHEMODDIR%%/%%AP_MODULE%%" >> ${PLIST}
C458 	@${ECHO} "@exec %D/sbin/apxs -e -a -n %%AP_NAME%% %D/%F" >> ${PLIST}
        @${ECHO} "@unexec %D/sbin/apxs -e -A -n %%AP_NAME%% %D/%F" >> ${PLIST}
459 	@${ECHO} "@unexec echo \"Don't forget to remove all
${MODULENAME}-related directives in your httpd.conf\"">> ${PLIST}
460 	. endif
461 	.else
462 	@${DO_NADA}
463 	.endif
464 	.endif

472 	do-install:
C473 	@${APXS} -i -a -n ${SHORTMODNAME} ${WRKSRC}/${MODULENAME}.${AP_BUILDEXT}

Then it will do the right thing when
installing/uninstalling/re-installing the port.  Give the above
changes a try, it should do the right thing.  If it works for you,
send-pr a diff of the changes.

For a port that installs/uninstalls it's module the correct way have a
look at www/mod_xmlns.

-- 
DISCLAIMER:

No electrons were maimed while sending this message. Only slightly bruised.



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?CACdU%2Bf__iAzrOoSOHunb3x7Ot7usZ7zjfhT%2Bz95uTy8HUqr83g>