Skip site navigation (1)Skip section navigation (2)
Date:      Thu, 21 Nov 2013 09:13:57 +0100
From:      Matthias Andree <mandree@FreeBSD.org>
To:        "Timur I. Bakeyev" <timur@FreeBSD.org>, ports-committers@freebsd.org,  svn-ports-all@freebsd.org, svn-ports-head@freebsd.org
Subject:   Re: svn commit: r334463 - in head/net/samba4: . files
Message-ID:  <528DC0C5.9020700@FreeBSD.org>
In-Reply-To: <201311202232.rAKMWlbX099940@svn.freebsd.org>
References:  <201311202232.rAKMWlbX099940@svn.freebsd.org>

next in thread | previous in thread | raw e-mail | index | archive | help
Am 20.11.2013 23:32, schrieb Timur I. Bakeyev:
> Author: timur
> Date: Wed Nov 20 22:32:47 2013
> New Revision: 334463
> URL: http://svnweb.freebsd.org/changeset/ports/334463
> 
> Log:
>   Fix STAGEDIR packaging problems in pkg-install script
> 
> Modified:
>   head/net/samba4/Makefile
>   head/net/samba4/files/pkg-install.in
> 
> Modified: head/net/samba4/Makefile
> ==============================================================================
> --- head/net/samba4/Makefile	Wed Nov 20 22:09:45 2013	(r334462)
> +++ head/net/samba4/Makefile	Wed Nov 20 22:32:47 2013	(r334463)
> @@ -3,7 +3,7 @@
>  
>  PORTNAME?=		${SAMBA4_PORTNAME}
>  PORTVERSION?=		${SAMBA4_VERSION}
> -PORTREVISION?=		0
> +PORTREVISION?=		1
>  CATEGORIES?=		net
>  MASTER_SITES=		${MASTER_SITE_SAMBA}
>  MASTER_SITE_SUBDIR=	samba/stable samba/rc
> @@ -519,6 +519,8 @@ post-install:
>  .	endfor
>  			@${LN} -sf smb.conf.5.gz ${STAGEDIR}${PREFIX}/man/man5/smb4.conf.5.gz
>  .endif
> +# Run post-install script
> +			@${SETENV} STAGEDIR=${STAGEDIR} ${SH} ${PKGINSTALL} ${PKGNAME} POST-INSTALL
>  
>  .if ${PORT_OPTIONS:MDEVELOPER}
>  test: build
> 
> Modified: head/net/samba4/files/pkg-install.in
> ==============================================================================
> --- head/net/samba4/files/pkg-install.in	Wed Nov 20 22:09:45 2013	(r334462)
> +++ head/net/samba4/files/pkg-install.in	Wed Nov 20 22:32:47 2013	(r334463)
> @@ -1,4 +1,4 @@
> -#! /bin/sh
> +#!/bin/sh
>  #
>  PATH=/bin:/usr/sbin:/usr/bin:/usr/sbin
>  
> @@ -11,21 +11,20 @@ SAMBA4_OWNER=root
>  SAMBA4_GROUP=wheel
>  INSTALL_DATA="install -c -m 0444"
>  INSTALL_DIR="install -d -m 0755"
> -CHMOD="chmod"
>  
>  post-install() {
>  	if [ $(id -u) -eq 0 ]; then
>  		INSTALL_DATA="${INSTALL_DATA} -o ${SAMBA4_OWNER} -g ${SAMBA4_GROUP}"
>  		INSTALL_DIR="${INSTALL_DIR} -o ${SAMBA4_OWNER} -g ${SAMBA4_GROUP}"
>  	fi
> -	${INSTALL_DIR} ${SAMBA4_LOGDIR}
> -	${INSTALL_DIR} ${SAMBA4_RUNDIR}
> -	${INSTALL_DIR} ${SAMBA4_LOCKDIR}
> -	${INSTALL_DIR} ${SAMBA4_MODULEDIR}
> -	${INSTALL_DIR} ${SAMBA4_PRIVATEDIR}
> +	${INSTALL_DIR} ${STAGEDIR}${SAMBA4_LOGDIR}
> +	${INSTALL_DIR} ${STAGEDIR}${SAMBA4_RUNDIR}
> +	${INSTALL_DIR} ${STAGEDIR}${SAMBA4_LOCKDIR}
> +	${INSTALL_DIR} ${STAGEDIR}${SAMBA4_MODULEDIR}
> +	${INSTALL_DIR} ${STAGEDIR}${SAMBA4_PRIVATEDIR}
>  	for dir in auth bind9 gensec gpext idmap ldb nss_info pdb perfcount \
>  		    process_model service vfs; do
> -		${INSTALL_DIR} "${SAMBA4_MODULEDIR}/${dir}"
> +		${INSTALL_DIR} "${STAGEDIR}${SAMBA4_MODULEDIR}/${dir}"
>  	done
>  }
>  
> 

Timur,

thank you for continued maintenance of samba4.

However, this does not look right to me, although it might work in some
cases, and does not cause issues in my poudriere testport.  The whole
port now hinges on the assumption that STAGEDIR is empty by the time the
pkg-install script runs after adding the package - it does run twice,
and on the implicit assumption that it runs as root.

It runs twice, once from your Makefile (you just added that), once from
pkg_add (or pkg add) - this always happens, but is not tested with "make
package".  This "run the script twice" - and in particular with
differing environments - is what staging was supposed to avoid.

What I was trying to convey on IRC was (but apparently I failed to get
the message to you):

1. With staging, this _only_ belongs in the Makefile's post-install:
section, but _no longer_ in a pkg-install script.  You should move the
commands into the Makefile, under post-install:, and remove the
files/pkg-install.in script.

2. If you have issues with directories not created for packaging, you
can use your pkg-plist @comment hack not only for Samba4 modules, but
also for the @dirrmtry lines.  Why would you want to package empty
directories that are only there for modules that got deselected?  I'd
presume the answer is "not at all".

3. You can waive the "if user id is 0" checks and use @group/@owner in
pkg-plist for the directories/files you need set to a particular
non-default user.  This would then permit packaging as non-root user.

...
@owner %%SAMBA4_OWNER%%
@group %%SAMBA4_GROUP%%
%%SAMBA4_LOGDIR%%
...
%%SAMBA4_PRIVATEDIR%%
@owner root
@group wheel
...

4. Else, if you want to keep install scripts that require root
privileges, add NEED_ROOT=yes to Makefile.


Please double-check that the directories are created with the right
owners, and change the port accordingly.



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?528DC0C5.9020700>