Re: Any way to prevent do-extract chmod and chown?

2018-07-03 Thread Joseph Ward
On 07/02/2018 16:50, Chris H wrote:
> On Fri, 29 Jun 2018 00:05:59 +0200 "Mathieu Arnold" 
> said
>
>> On Thu, Jun 28, 2018 at 01:43:41PM -0400, Joseph Ward wrote:
>> > Thank you.  I found that to be the case; even though changing the
>> > "do-extract" target successfully staged the files and directories with
>> > the original permissions, pkg create seems to strip them out again
>> > without the pkg-plist additions.
>> > > Are you aware of an easy/already existing command to create the
>> > pkg-plist with the user/group/permissions items for each file, or is
>> > that a script I'm going to have to write manually?  I'm currently
>> using
>> > the makeplist target as there are no subsitutions or anything else
>> that
>> > would screw up the default scenario.
>>
>> I am not aware of anything.  But if you already have "stuff" creating a
>> big hierarchy with many users and groups, it may be easier to adapt
>> "stuff" to generate a pkg-plist file, or maybe to split your ports into
>> smaller, more manageable bits.
>>
>> make makeplist will give you a correct listing of files and
>> directories, but as everything runs as a regular user, it cannot be
>> aware of the users/groups you intend on using in the plist.
> make makeplist may be of help to you, as it would allow you to assign
> ownership in
> large chunks, thusly:
>
> @a:b:c
> this
> that
> ...
> theother
> @d:f:e
> somefile
> ...
> another
> bunch
> of
> files
> @other:owner:group:perms
> thesefiles
> ...
> thosefiles
>
> This all assumes that the files are grouped as you need them tho. :-)
>
> HTH
>
> --Chris
>
>>
>> -- 
>> Mathieu Arnold
>
>
> ___

Unfortunately, they're not grouped together.  What I'm doing (which is
probably a little crazy) is turning jails into packages so that I can
very easily upgrade them on my remote systems.  So I have a basejail
package which is the dependency for my smtp-jail package, which includes
the mounts into the basejail, etc.  So it's essentially the freebsd base
permissions (and subsets for the thin jails) which of course aren't
grouped at all, and also involves thousands of files.

I ended up using mtree (as suggested by Freddie Cash), having the build
system that creates the jails and their dist-files take the mtree spec
for the jail and include it in the package, and then as a
pkg-post-install script I made it put the permissions back via mtree -u. 

My other option was to take the makeplist target and alter it.  I found
the generate_plist() function in Mk/Scripts/check-stagedir.sh, which
uses find and sed to create the plist.  I was going to add a "stat" in
there, with the formatting of

stat -f "@(%Su,%Sg,%OMp%OLp) %N"

so that I ended up with the plist with the correct permissions on every
file. I'm pretty sure that would have worked, but the mtree solution
suggested by Freddie worked really well, so I just stuck with it.


-Joseph
___
freebsd-ports@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/freebsd-ports
To unsubscribe, send any mail to "freebsd-ports-unsubscr...@freebsd.org"


Re: Any way to prevent do-extract chmod and chown?

2018-07-02 Thread Chris H

On Fri, 29 Jun 2018 00:05:59 +0200 "Mathieu Arnold"  said


On Thu, Jun 28, 2018 at 01:43:41PM -0400, Joseph Ward wrote:
> Thank you.  I found that to be the case; even though changing the
> "do-extract" target successfully staged the files and directories with
> the original permissions, pkg create seems to strip them out again
> without the pkg-plist additions.
> 
> Are you aware of an easy/already existing command to create the

> pkg-plist with the user/group/permissions items for each file, or is
> that a script I'm going to have to write manually?  I'm currently using
> the makeplist target as there are no subsitutions or anything else that
> would screw up the default scenario.

I am not aware of anything.  But if you already have "stuff" creating a
big hierarchy with many users and groups, it may be easier to adapt
"stuff" to generate a pkg-plist file, or maybe to split your ports into
smaller, more manageable bits.

make makeplist will give you a correct listing of files and
directories, but as everything runs as a regular user, it cannot be
aware of the users/groups you intend on using in the plist.

make makeplist may be of help to you, as it would allow you to assign ownership 
in
large chunks, thusly:

@a:b:c
this
that
...
theother
@d:f:e
somefile
...
another
bunch
of
files
@other:owner:group:perms
thesefiles
...
thosefiles

This all assumes that the files are grouped as you need them tho. :-)

HTH

--Chris



--
Mathieu Arnold



___
freebsd-ports@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/freebsd-ports
To unsubscribe, send any mail to "freebsd-ports-unsubscr...@freebsd.org"


Re: Any way to prevent do-extract chmod and chown?

2018-07-01 Thread Joseph Ward


On 06/29/2018 09:51, Joseph Ward wrote:
> Thank you, I'll look into that tool and will reply back (for future
> seekers) if it does what I need.
>
> -Joseph
>
>
> On 06/28/2018 19:00, Freddie Cash wrote:
>> On Thu, Jun 28, 2018, 3:06 PM Mathieu Arnold,  wrote:
>>
>>> On Thu, Jun 28, 2018 at 01:43:41PM -0400, Joseph Ward wrote:
 Thank you.  I found that to be the case; even though changing the
 "do-extract" target successfully staged the files and directories with
 the original permissions, pkg create seems to strip them out again
 without the pkg-plist additions.

 Are you aware of an easy/already existing command to create the
 pkg-plist with the user/group/permissions items for each file, or is
 that a script I'm going to have to write manually?  I'm currently using
 the makeplist target as there are no subsitutions or anything else that
 would screw up the default scenario.
>>> I am not aware of anything.  But if you already have "stuff" creating a
>>> big hierarchy with many users and groups, it may be easier to adapt
>>> "stuff" to generate a pkg-plist file, or maybe to split your ports into
>>> smaller, more manageable bits.
>>>
>>> make makeplist will give you a correct listing of files and
>>> directories, but as everything runs as a regular user, it cannot be
>>> aware of the users/groups you intend on using in the plist.
>>>
>> Isn't this something mtree can be used for?
>>
>> Use it to generate a listing of the files, permissions, and ownership of a
>> tree, include the mtree output file in the port, and use a post-install
>> script to run mtree to set ownership/permission.
>>
>> Cheers,
>> Freddie
>>
>> Typos courtesy of my phone's keyboard.
>>
>> ___
>> freebsd-ports@freebsd.org mailing list
>> https://lists.freebsd.org/mailman/listinfo/freebsd-ports
>> To unsubscribe, send any mail to "freebsd-ports-unsubscr...@freebsd.org"
> ___
> freebsd-ports@freebsd.org mailing list
> https://lists.freebsd.org/mailman/listinfo/freebsd-ports
> To unsubscribe, send any mail to "freebsd-ports-unsubscr...@freebsd.org"


Using mtree worked well.  I generated the mtree file for the hierarchy
on the original build machine, packaged it up as part of the package,
and then ran mtree -up  -f  in the pkg-post-install
script and it worked well.

One item I did encounter was the following error: pkg: POST-INSTALL
script failed but it didn't seem to impact anything; it ran successfully
and everything was permissioned as it should be.

Thanks,

Joseph
___
freebsd-ports@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/freebsd-ports
To unsubscribe, send any mail to "freebsd-ports-unsubscr...@freebsd.org"


Re: Any way to prevent do-extract chmod and chown?

2018-06-28 Thread Freddie Cash
On Thu, Jun 28, 2018, 3:06 PM Mathieu Arnold,  wrote:

> On Thu, Jun 28, 2018 at 01:43:41PM -0400, Joseph Ward wrote:
> > Thank you.  I found that to be the case; even though changing the
> > "do-extract" target successfully staged the files and directories with
> > the original permissions, pkg create seems to strip them out again
> > without the pkg-plist additions.
> >
> > Are you aware of an easy/already existing command to create the
> > pkg-plist with the user/group/permissions items for each file, or is
> > that a script I'm going to have to write manually?  I'm currently using
> > the makeplist target as there are no subsitutions or anything else that
> > would screw up the default scenario.
>
> I am not aware of anything.  But if you already have "stuff" creating a
> big hierarchy with many users and groups, it may be easier to adapt
> "stuff" to generate a pkg-plist file, or maybe to split your ports into
> smaller, more manageable bits.
>
> make makeplist will give you a correct listing of files and
> directories, but as everything runs as a regular user, it cannot be
> aware of the users/groups you intend on using in the plist.
>

Isn't this something mtree can be used for?

Use it to generate a listing of the files, permissions, and ownership of a
tree, include the mtree output file in the port, and use a post-install
script to run mtree to set ownership/permission.

Cheers,
Freddie

Typos courtesy of my phone's keyboard.

>
___
freebsd-ports@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/freebsd-ports
To unsubscribe, send any mail to "freebsd-ports-unsubscr...@freebsd.org"


Re: Any way to prevent do-extract chmod and chown?

2018-06-28 Thread Mathieu Arnold
On Thu, Jun 28, 2018 at 01:43:41PM -0400, Joseph Ward wrote:
> Thank you.  I found that to be the case; even though changing the
> "do-extract" target successfully staged the files and directories with
> the original permissions, pkg create seems to strip them out again
> without the pkg-plist additions.
> 
> Are you aware of an easy/already existing command to create the
> pkg-plist with the user/group/permissions items for each file, or is
> that a script I'm going to have to write manually?  I'm currently using
> the makeplist target as there are no subsitutions or anything else that
> would screw up the default scenario.

I am not aware of anything.  But if you already have "stuff" creating a
big hierarchy with many users and groups, it may be easier to adapt
"stuff" to generate a pkg-plist file, or maybe to split your ports into
smaller, more manageable bits.

make makeplist will give you a correct listing of files and
directories, but as everything runs as a regular user, it cannot be
aware of the users/groups you intend on using in the plist.

-- 
Mathieu Arnold


signature.asc
Description: PGP signature


Re: Any way to prevent do-extract chmod and chown?

2018-06-28 Thread Joseph Ward
Thank you.  I found that to be the case; even though changing the
"do-extract" target successfully staged the files and directories with
the original permissions, pkg create seems to strip them out again
without the pkg-plist additions.

Are you aware of an easy/already existing command to create the
pkg-plist with the user/group/permissions items for each file, or is
that a script I'm going to have to write manually?  I'm currently using
the makeplist target as there are no subsitutions or anything else that
would screw up the default scenario.

Thanks,

Joseph


On 06/28/2018 04:27, Mathieu Arnold wrote:
> 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
>

___
freebsd-ports@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/freebsd-ports
To unsubscribe, send any mail to "freebsd-ports-unsubscr...@freebsd.org"


Re: Any way to prevent do-extract chmod and chown?

2018-06-28 Thread Mathieu Arnold
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


signature.asc
Description: PGP signature


Re: Any way to prevent do-extract chmod and chown?

2018-06-27 Thread Joseph Ward
Overriding the do-extract target is exactly what I was looking for. 
Something I didn't know I could do.  It worked perfectly, thanks! 
Unfortunately there are way too many files with various owners to try
and fix the permissions afterwards or in the pkg-plist.  (I did consider
creating a script to traverse everything, save the permissions, and
apply it after the fact, but I wanted something easier and more elegant,
and this is great!)

Thank you again!

-Joseph


On 06/27/2018 07:22 PM, Bob Eager wrote:
> On Wed, 27 Jun 2018 19:06:44 -0400
> Joseph Ward  wrote:
>
>> 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:
>  .
>  .
>  .
>
>> 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? 
> If the ownership is well defined and not complex, you could add a
> post-extract: target in your Makefile and fix up the ownerships then.
>
> Or, you could override the do-extract: target with your own, and
> extract the files as you want (probably replicating part of the real
> do-extract: target).
> ___
> freebsd-ports@freebsd.org mailing list
> https://lists.freebsd.org/mailman/listinfo/freebsd-ports
> To unsubscribe, send any mail to "freebsd-ports-unsubscr...@freebsd.org"

___
freebsd-ports@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/freebsd-ports
To unsubscribe, send any mail to "freebsd-ports-unsubscr...@freebsd.org"


Re: Any way to prevent do-extract chmod and chown?

2018-06-27 Thread Adam Weinberger
On Wed, Jun 27, 2018 at 5:09 PM 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?
>
>
> Thanks,
>
> Joseph Ward

Hi Joseph,

Your best bet is to use plist keywords. See
https://www.freebsd.org/doc/en_US.ISO8859-1/books/porters-handbook/plist-keywords.html
for details.

You can set owner/group on individual files in the pkg-plist:
  @(ownername,groupname,444) path/to/file
Or you can set it on a block of files:
  @group groupname
  @owner ownername
  path/to/file1
  path/to/file2

# Adam


-- 
Adam Weinberger
ad...@adamw.org
https://www.adamw.org
___
freebsd-ports@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/freebsd-ports
To unsubscribe, send any mail to "freebsd-ports-unsubscr...@freebsd.org"


Re: Any way to prevent do-extract chmod and chown?

2018-06-27 Thread Bob Eager
On Wed, 27 Jun 2018 19:06:44 -0400
Joseph Ward  wrote:

> 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:

 .
 .
 .

> 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? 

If the ownership is well defined and not complex, you could add a
post-extract: target in your Makefile and fix up the ownerships then.

Or, you could override the do-extract: target with your own, and
extract the files as you want (probably replicating part of the real
do-extract: target).
___
freebsd-ports@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/freebsd-ports
To unsubscribe, send any mail to "freebsd-ports-unsubscr...@freebsd.org"