mirror of
https://github.com/chocolate-doom/chocpkg.git
synced 2024-11-10 07:11:39 +00:00
Don't set environment variables until build.
The pkg-config variables can affect how a package is discovered, and if set by a package that depends on another, could lead to the recursive call to chocpkg producing the wrong result. Instead, set only when specificly needed (by build or check_installed), and always invoke commands by recursively invoking the script, never by function call.
This commit is contained in:
parent
4876563b75
commit
658b94e635
1 changed files with 38 additions and 27 deletions
|
@ -55,6 +55,23 @@ dependencies() {
|
|||
DEPENDENCIES="$*"
|
||||
}
|
||||
|
||||
# set_pkgconfig_paths sets the values of the PKG_CONFIG_PATH and
|
||||
# PKG_CONFIG_LIBDIR environment variables. This is deliberately only done
|
||||
# when needed, as otherwise the value could affect child builds when
|
||||
# recursing to build dependent packages.
|
||||
set_pkgconfig_paths() {
|
||||
PKG_CONFIG_PATH="$PACKAGE_INSTALL_DIR/lib/pkgconfig:${PKG_CONFIG_PATH:-}"
|
||||
export PKG_CONFIG_PATH
|
||||
|
||||
# When cross-compiling, reconfigure pkg-config to not look for .pc
|
||||
# files in the standard system directories; only in our own build
|
||||
# directory. It may be that a library is installed on the system
|
||||
# but that is useless if it is for the wrong architecture.
|
||||
if $IS_CROSS_COMPILE && [ "$PACKAGE_TYPE" = "target" ]; then
|
||||
export PKG_CONFIG_LIBDIR=
|
||||
fi
|
||||
}
|
||||
|
||||
# Given a package name, find the pkgdef file associated with it, source
|
||||
# the contents of the file and set various variables.
|
||||
configure_for_package() {
|
||||
|
@ -88,21 +105,14 @@ configure_for_package() {
|
|||
error_exit "Unknown package type $PACKAGE_TYPE"
|
||||
;;
|
||||
esac
|
||||
|
||||
# We must set PKG_CONFIG_PATH now so we know where to look for packages.
|
||||
PKG_CONFIG_PATH="$PACKAGE_INSTALL_DIR/lib/pkgconfig:${PKG_CONFIG_PATH:-}"
|
||||
export PKG_CONFIG_PATH
|
||||
|
||||
# When cross-compiling, reconfigure pkg-config to not look for .pc
|
||||
# files in the standard system directories; only in our own build
|
||||
# directory. It may be that a library is installed on the system
|
||||
# but that is useless if it is for the wrong architecture.
|
||||
if $IS_CROSS_COMPILE && [ "$PACKAGE_TYPE" = "target" ]; then
|
||||
export PKG_CONFIG_LIBDIR=
|
||||
fi
|
||||
}
|
||||
|
||||
fetch_package() {
|
||||
cmd_installed() {
|
||||
set_pkgconfig_paths
|
||||
check_installed
|
||||
}
|
||||
|
||||
cmd_fetch() {
|
||||
do_fetch
|
||||
}
|
||||
|
||||
|
@ -130,9 +140,10 @@ prebuild_setup() {
|
|||
true
|
||||
}
|
||||
|
||||
build_package() {
|
||||
cmd_build() {
|
||||
set_pkgconfig_paths
|
||||
install_dependencies
|
||||
fetch_package "$PACKAGE_NAME"
|
||||
chocpkg fetch "$PACKAGE_NAME"
|
||||
|
||||
echo =======================================================
|
||||
echo "Building $PACKAGE_NAME..."
|
||||
|
@ -149,16 +160,16 @@ build_package() {
|
|||
do_build
|
||||
}
|
||||
|
||||
reinstall_package() {
|
||||
build_package "$PACKAGE_NAME"
|
||||
cmd_reinstall() {
|
||||
chocpkg build "$PACKAGE_NAME"
|
||||
cd "$PACKAGE_BUILD_DIR"
|
||||
do_install
|
||||
}
|
||||
|
||||
install_package() {
|
||||
cmd_install() {
|
||||
# Already installed? Don't install again.
|
||||
if ! check_installed; then
|
||||
reinstall_package
|
||||
if ! chocpkg installed "$PACKAGE_NAME"; then
|
||||
chocpkg reinstall "$PACKAGE_NAME"
|
||||
fi
|
||||
}
|
||||
|
||||
|
@ -171,20 +182,20 @@ cmd=$1; package=$2
|
|||
configure_for_package "$package"
|
||||
|
||||
case "$cmd" in
|
||||
installed)
|
||||
cmd_installed
|
||||
;;
|
||||
fetch)
|
||||
fetch_package
|
||||
cmd_fetch
|
||||
;;
|
||||
build)
|
||||
build_package
|
||||
cmd_build
|
||||
;;
|
||||
reinstall)
|
||||
reinstall_package
|
||||
cmd_reinstall
|
||||
;;
|
||||
install)
|
||||
install_package
|
||||
;;
|
||||
installed)
|
||||
check_installed
|
||||
cmd_install
|
||||
;;
|
||||
esac
|
||||
|
||||
|
|
Loading…
Reference in a new issue