chown built artifacts to the correct owner after build. Closes #37

Avoids having files be created on host as `root`
This commit is contained in:
Pedro Pombeiro 2018-09-20 16:50:13 +02:00 committed by Pedro Pombeiro
parent d164e4e53d
commit 3de7d5718e
No known key found for this signature in database
GPG Key ID: A65DEB11E4BBC647
2 changed files with 12 additions and 1 deletions

View File

@ -46,7 +46,7 @@ function extension {
fi
}
# Either set a local build environemnt, or pull any remote imports
# Either set a local build environment, or pull any remote imports
if [ "$EXT_GOPATH" != "" ]; then
# If local builds are requested, inject the sources
echo "Building locally $1..."
@ -296,6 +296,9 @@ for TARGET in $TARGETS; do
(cd $archive && zip -r $bundle *)
rm -rf $jni $archive
fi
# Fix up permissions on bundle file
chown $UID:$GID $bundle
fi
# Clean up the android builds, toolchains and runtimes
rm -rf /build-android-aar
@ -600,6 +603,8 @@ for TARGET in $TARGETS; do
echo -e "framework module \"$title\" {\n header \"$title.h\"\n export *\n}" > $framework/Versions/A/Modules/module.modulemap
(cd $framework && ln -nsf Versions/A/Modules Modules)
# Fix up permissions on bundle file
chown $UID:$GID /build/$NAME-ios-$PLATFORM-framework
chmod 777 -R /build/$NAME-ios-$PLATFORM-framework
fi
rm -rf /build-ios-fw

6
xgo.go
View File

@ -299,6 +299,12 @@ func compile(image string, config *ConfigFlags, flags *BuildFlags, folder string
"-e", fmt.Sprintf("FLAG_BUILDMODE=%s", flags.Mode),
"-e", "TARGETS=" + strings.Replace(strings.Join(config.Targets, " "), "*", ".", -1),
}
user, err := user.Current()
if err == nil {
args = append(args,
"-e", fmt.Sprintf("UID=%s", user.Uid),
"-e", fmt.Sprintf("GID=%s", user.Gid))
}
for i := 0; i < len(locals); i++ {
args = append(args, []string{"-v", fmt.Sprintf("%s:%s:ro", locals[i], mounts[i])}...)
}