Any way to prevent do-extract chmod and chown?

Mathieu Arnold mat at FreeBSD.org
Thu Jun 28 08:27:44 UTC 2018


On Wed, Jun 27, 2018 at 07:06:44PM -0400, Joseph Ward wrote:
> Hi everyone,
> 
> I'm creating some internal-only ports and I'm trying to maintain the
> permissions and owners of the files present in the distfile.tar.gz when
> they get packaged up for install.
> 
> When I "make extract", the "do-extract" target is performing a chmod and
> chown on everything, as seen from the following excerpt from the
> bsd.port.mk file:
> 
> 
> .if !target(do-extract)
> do-extract: ${EXTRACT_WRKDIR}
>         @for file in ${EXTRACT_ONLY}; do \
>                 if ! (cd ${EXTRACT_WRKDIR} && ${EXTRACT_CMD}
> ${EXTRACT_BEFORE_ARGS} ${_DISTDIR}/$$file ${EXTRACT_AFTER_ARGS});\
>                 then \
>                         exit 1; \
>                 fi; \
>         done
>         @if [ ${UID} = 0 ]; then \
>                 ${CHMOD} -R ug-s ${WRKDIR}; \
>                 ${CHOWN} -R 0:0 ${WRKDIR}; \
>         fi
> .endif
> 
> 
> Short of commenting those lines out (which I really don't want to do
> because I have 0 idea why it's there or what I'd break with other ports)
> is there any way at all to maintain the ownership of the files? 

Building ports as root is a rare thing these days, most build tools
build everything as a regular user (most of the time, nobody) so
ownership of files in distribution files is not retained anyway.

To set user/group/mode ownership in the resulting packages, you need to use
the @user, @group and @mode keywords in the pkg-plist file. (or the @
keyword if one file needs a specific user/group/mode.) See:

https://www.freebsd.org/doc/en/books/porters-handbook/plist-keywords.html

-- 
Mathieu Arnold
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 963 bytes
Desc: not available
URL: <http://lists.freebsd.org/pipermail/freebsd-ports/attachments/20180628/6a5fba28/attachment.sig>


More information about the freebsd-ports mailing list