why does pkgmk exports PKG and SRC?

phi crispyfrog at 163.com
Wed Jan 25 11:16:47 UTC 2017

Hi, everyone, I've just encountered a weird bug when I'm making a port, the
configure script works fine if I run it by hand, but always fail if it was
invoked inside pkgmk. After digging for a while, I found out that the configure
script uses the shell variable PKG internally. Checked pkgmk, I see that pkgmk
exports PKG and SRC before calling build().
Relevant code in pkgmk:

	build_package() {
		make_work_dir    # here export PKG and SRC
		(set -e -x ; build)

I think it's better to change that to:

	build_package() {
		make_work_dir # do not export
		(set -e -x; PKG=$PKG SRC=$SRC build)

I don't know if this change would affect other things.
Without making any change in pkgmk, my port currently looks like:

	build() {
		local pkg=$PKG
		unset PKG
		... # build using $pkg
		export PKG=$pkg

More information about the CRUX mailing list