Skip to content

Commit

Permalink
Fix path duplication in env vars
Browse files Browse the repository at this point in the history
  • Loading branch information
brandoncc committed Sep 20, 2023
1 parent 4d51d1c commit 80abfc0
Showing 1 changed file with 24 additions and 18 deletions.
42 changes: 24 additions & 18 deletions bin/compile
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,8 @@ arrow() {
sed -u 's/^/-----> /'
}

ADD_PATH=""

function vendor() {
binary="$1"
path="$2"
Expand All @@ -30,20 +32,24 @@ function vendor() {
tar -xz -f $binary -C $path

if [ -d "$path/bin" ]; then
export PATH=$path/bin:$PATH
ADD_PATH="$path/bin"
else
ADD_PATH=""
fi

if [ -d "$path/lib/pkgconfig" ]; then
# pkg-config should handle compiler options (if used)
export PKG_CONFIG_PATH="$path/lib/pkgconfig:$PKG_CONFIG_PATH"
ADD_PKG_CONFIG_PATH="$path/lib/pkgconfig"
else
ADD_PKG_CONFIG_PATH=""
fi

# standard paths
export CPPPATH="$path/include:$CPPPATH"
export CPATH="$path/include:$CPATH"
export LIBRARY_PATH="$path/lib:$LIBRARY_PATH"
ADD_CPPPATH="$path/include"
ADD_CPATH="$path/include"
ADD_LIBRARY_PATH="$path/lib"

export LD_LIBRARY_PATH="$path/lib:$LD_LIBRARY_PATH"
ADD_LD_LIBRARY_PATH="$path/lib"
}

echo "Vendoring binaries" | arrow
Expand All @@ -53,22 +59,22 @@ vendor "${ROOT_DIR}/build/${STACK}.tar.gz" "$BUILD_DIR/vendor/vips"
echo "Configuring build environment" | arrow

cat <<EOF > export
export PATH="/app/bin:$PATH:\$PATH"
export LD_LIBRARY_PATH="\$LD_LIBRARY_PATH:$LD_LIBRARY_PATH"
export LIBRARY_PATH="\$LIBRARY_PATH:$LIBRARY_PATH"
export PKG_CONFIG_PATH="\$PKG_CONFIG_PATH:$PKG_CONFIG_PATH"
export CPPPATH="\$CPPPATH:$CPPPATH"
export CPATH="\$CPATH:$CPATH"
export PATH="/app/bin:$ADD_PATH:\$PATH"
export LD_LIBRARY_PATH="\$LD_LIBRARY_PATH:$ADD_LD_LIBRARY_PATH"
export LIBRARY_PATH="\$LIBRARY_PATH:$ADD_LIBRARY_PATH"
export PKG_CONFIG_PATH="\$PKG_CONFIG_PATH:$ADD_PKG_CONFIG_PATH"
export CPPPATH="\$CPPPATH:$ADD_CPPPATH"
export CPATH="\$CPATH:$ADD_CPATH"
EOF

echo "Building runtime environment" | arrow
mkdir -p $BUILD_DIR/.profile.d

cat <<EOF > $BUILD_DIR/.profile.d/$BUILDPACK_NAME.sh
export PATH="/app/bin:${PATH//$BUILD_DIR//app}:\$PATH"
export LD_LIBRARY_PATH="\$LD_LIBRARY_PATH:${LD_LIBRARY_PATH//$BUILD_DIR//app}"
export LIBRARY_PATH="\$LIBRARY_PATH:${LIBRARY_PATH//$BUILD_DIR//app}"
export PKG_CONFIG_PATH="\$PKG_CONFIG_PATH:${PKG_CONFIG_PATH//$BUILD_DIR//app}"
export CPPPATH="\$CPPPATH:${CPPPATH//$BUILD_DIR//app}"
export CPATH="\$CPATH:${CPATH//$BUILD_DIR//app}"
export PATH="/app/bin:${ADD_PATH//$BUILD_DIR//app}:\$PATH"
export LD_LIBRARY_PATH="\$LD_LIBRARY_PATH:${ADD_LD_LIBRARY_PATH//$BUILD_DIR//app}"
export LIBRARY_PATH="\$LIBRARY_PATH:${ADD_LIBRARY_PATH//$BUILD_DIR//app}"
export PKG_CONFIG_PATH="\$PKG_CONFIG_PATH:${ADD_PKG_CONFIG_PATH//$BUILD_DIR//app}"
export CPPPATH="\$CPPPATH:${ADD_CPPPATH//$BUILD_DIR//app}"
export CPATH="\$CPATH:${ADD_CPATH//$BUILD_DIR//app}"
EOF

0 comments on commit 80abfc0

Please sign in to comment.