On Sat, Jul 20, 2019 at 11:41 PM Waldemar Kozaczuk <jwkozac...@gmail.com>
wrote:

> This patch enhances scripts/build to allow passing arguments to
> modules/apps
> makefiles like so:
>
> ./script/build m_JAVA_VERSION=11
> m_JAVA_MODULES=ava.base,java.sql,java.logging,java.xml,jdk.unsupported
> image=openjdk-zulu-9-and-above
>
> That way corresponding app makefile can use passed in m_* variable and
> customize
> its build behavior. This new mechanism should let us remove redundant
> openjdk
> apps.
>

Nice idea. But I wonder, would it hurt if we pass *all* the parameters
(which we already store in the "args" array) same as we pass them to the
kernel "make", instead of just those starting with "m_*"?



-fs_type=$fs_type jdkbase=$jdkbase ARCH=$arch mode=$mode OSV_BASE=$SRC
> OSV_BUILD_PATH=$OSV_BUILD_PATH scripts/module.py $j_arg build -c "$modules"
> $usrskel_arg $no_required_arg
> +# the m_*=* arguments have been sanitized above so we deem it is safe
> enough
> +# to use eval to set corresponding variables (is there a way to do it
> without eval?)
> +eval ${module_make_args[@]} fs_type=$fs_type jdkbase=$jdkbase ARCH=$arch
> mode=$mode OSV_BASE=$SRC OSV_BUILD_PATH=$OSV_BUILD_PATH scripts/module.py
> $j_arg build -c "$modules" $usrskel_arg $no_required_arg
>

Note that "eval" evaluates twice not just the module_make_args but also
everything else in this command line, which can cause a mess in various
cases including when the paths have spaces. I'd very much prefer not to do
this eval.

One thing you could do is to use a subshell, and in it *export* all these
variables, and then run. For example, I didn't test the following as a
whole, but I checked some of the details so I think it should work:

# The parentheses start a subshell. Whatever is exported there, doesn't
effect the external shell
(
    # Note: the double-quotes and almost everything in the line below is
important to correctly allow spaces
    for i in "${args[@]}"
    do
          # again, the double-quotes is important in case the variable's
value contains spaces
          export "$i"
    done
    # Export the variables we already have. This makes it unnecessary to do
"fs__type=$fstype jdkbase $jdkbase ..."
    export fs_type jdkbase mode OSV_BUILD_PATH
    # Other variables we wanted to rename, I don't know why
    export ARCH=$arch OSV_BASE=$SRC
    # Run what we wanted to run. It will inherit everything we exported
above.
    scripts/module.py $j_arg build -c "$modules" $usrskel_arg
$no_required_arg
)



>
>  if [[ ${vars[append_manifest]} == "true" && -f
> "$OSV_BUILD_PATH/append.manifest" ]]; then
>     cat "$OSV_BUILD_PATH/append.manifest" >> "$OSV_BUILD_PATH/usr.manifest"
> --
> 2.20.1
>
> --
> You received this message because you are subscribed to the Google Groups
> "OSv Development" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to osv-dev+unsubscr...@googlegroups.com.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/osv-dev/20190720204132.9662-1-jwkozaczuk%40gmail.com
> .
>

-- 
You received this message because you are subscribed to the Google Groups "OSv 
Development" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to osv-dev+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/osv-dev/CANEVyjtn%2BNSVZMd80nLxP%3DZapEURAnCqpSrvfnko%3DtCL9POSqg%40mail.gmail.com.

Reply via email to