On Fri, 07 Aug 2020 21:09:11 +0200, ASSI
> Lemures Lemniscati via Cygwin-apps writes:
> >> No, I was talking about things like XZ_OPT or ZSTD_CLEVEL.
> >
> > I think XZ_OPT or ZSTD_CLEVEL can be passed through environment.
> > And this should control xz or zstd..
> >
> > XZ_OPT="..." cygport foo.cygport package
> > ZSTD_CLEVEL="..." cygport foo.cygport package
> >
> > And cygport does not prevent from passing parameter through environment.
> > Maybe I understand you in a wrong way. Pardon me.
> 
> Maybe if you'd gone back to the post I sent on June 14 when I originally
> offered the patch you'd have seen:
> 
> >> This patch keeps the current defaults in place, but allows one to set up
> >> two environment variables to control how tar gets invoked during
> >> packaging.  You could do that from either the cygport file or the
> >> .cygport.conf file:
> >>
> >> CYGPORT_TAR_CMD="env ZSTD_CLEVEL=19 tar -I zstd --group nobody:65534 
> >> --owner nobody:65534"
> >> CYGPORT_TAR_EXT=".tar.zst"
> 
> I don't want to pollute the environment for any other command obviously…
> and really, I still think creating five new configuration variables to
> do what can be accomplished with two isn't a good trade-off.
> 
> Factoring out the command invocation into a function probably is a net
> win, though -- so I'd keep that part.  It'd probably be useful in some
> other instances to so a similar refactoring.

Thank you for your patience, Achim.
Now I've understood.

But I feel uneasy about the usase of CYGPORT_TAR_CMD, because we must
specify 'tar' in it. It is a redundancy.



The following is a thought experiment to avoid this redundancy.


Still, a work-around is to split it into two variables CYGPORT_TAR_ENV
and CYGPORT_TAR_OPTS, and do something like 

(1)  env ${CYGPORT_TAR_ENV} tar ${CYGPORT_TAR_OPTS} ...

or 

(2)  sh -c "env ${CYGPORT_TAR_ENV} tar ${CYGPORT_TAR_OPTS} ..."


The problem is that it is demanding more keystrokes when we use both of
them:

CYGPORT_TAR_ENV="..." CYGPORT_TAR_OPTS="..." cygport zzz.cygport package


But when specifying owner/group, we can do it simply,

CYGPORT_TAR_OPTS="--group=nobody:65534 --owner=nobody:65534" cygport 
zzz.cygport package

or by invoking tar as (2) you would be able to specify compression level
and multi-threading like this:

CYGPORT_TAR_OPTS="-I 'zstd -19 -T2' --group=nobody:65534 --owner=nobody:65534" 
cygport zzz.cygport package

This looks good enough to me.


And I've looked into the GNU tar source, and found that tar calls
a compression filter through execv 'sh' '-c' ...
https://git.savannah.gnu.org/cgit/tar.git/tree/src/system.c?h=release_1_32#n26
So, I guess it is not so bad to use 'sh' '-c' here in the script like 
(2).

Regards, 

Lem

Reply via email to