why does pkgmk exports PKG and SRC?

phi crispyfrog at 163.com
Thu Jan 26 07:26:22 UTC 2017

> On the other hand I can't find a difference in> exporting PKG and SRC and calling build afterwards versus calling
> "PKG=$PKG SRC=$SRC build" - maybe I'm missing something here ...
Oh I was wrong, they are the same if build was a shell script, since build is a
function, "PKG=$PKG SRC=$SRC build" is equivalent to "build". 

> If I look at pkgmk, it should not be required to "export PKG=$pkg" in your
> build function at the end.
Yes, I just forgot the build function is already inside a subshell:

	(set -e -x ; build)

So no need to retain $PKG after the build.

While export does have side effects on build scripts.
I think the build function itself works even if PKG is not exported, since the
Pkgfile is sourced inside pkgmk. if does not export PKG, then PKG is still
available inside the build function, and it won't propagate to build scripts.
I have verified that by removing the export command from pkgmk, my port builds
fine without any special treatment.

More information about the CRUX mailing list