Skip to content

Commit

Permalink
Merge pull request conda-forge#313 from mbargull-feedstocks/posix-act…
Browse files Browse the repository at this point in the history
…ivation-scripts

Use POSIX scripts for de-/activation scripts
  • Loading branch information
isuruf committed Jun 27, 2024
1 parent af8f3eb commit 8fbc98a
Show file tree
Hide file tree
Showing 6 changed files with 53 additions and 31 deletions.
19 changes: 11 additions & 8 deletions recipe/activate-cross-r-base.sh
Original file line number Diff line number Diff line change
@@ -1,14 +1,17 @@
if [[ "$CONDA_BUILD" == "" ]]; then
# shellcheck shell=sh

if [ -z "${CONDA_BUILD:+x}" ]; then
echo "This package can only be used in conda-build"
exit 1
fi

if [[ "$CONDA_BUILD_STATE" != "TEST" && "$build_platform" != "$target_platform" ]]; then
export R=$BUILD_PREFIX/bin/R
export R_ARGS="--library=$PREFIX/lib/R/library --no-test-load"
echo "R_HOME=$PREFIX/lib/R" > $BUILD_PREFIX/lib/R/etc/Makeconf
cat $PREFIX/lib/R/etc/Makeconf >> $BUILD_PREFIX/lib/R/etc/Makeconf
if [[ -d $BUILD_PREFIX/lib/R/library ]]; then
rsync -a -I $BUILD_PREFIX/lib/R/library/ $PREFIX/lib/R/library/
# shellcheck disable=SC2154 # assume variables are set at this point
if [ "${CONDA_BUILD_STATE-}" != "TEST" ] && [ "${build_platform}" != "${target_platform}" ]; then
export R="${BUILD_PREFIX}/bin/R"
export R_ARGS="--library=${PREFIX}/lib/R/library --no-test-load"
echo "R_HOME=${PREFIX}/lib/R" > "${BUILD_PREFIX}/lib/R/etc/Makeconf"
cat "${PREFIX}/lib/R/etc/Makeconf" >> "${BUILD_PREFIX}/lib/R/etc/Makeconf"
if [ -d "${BUILD_PREFIX}/lib/R/library" ]; then
rsync -a -I "${BUILD_PREFIX}/lib/R/library/" "${PREFIX}/lib/R/library/"
fi
fi
10 changes: 6 additions & 4 deletions recipe/activate-r-base.sh
Original file line number Diff line number Diff line change
@@ -1,8 +1,10 @@
#!/usr/bin/env sh
# shellcheck shell=sh

R CMD javareconf > /dev/null 2>&1 || true

# store existing RSTUDIO_WHICH_R
if [[ ! -z ${RSTUDIO_WHICH_R+x} ]]; then
export RSTUDIO_WHICH_R_PREV="$RSTUDIO_WHICH_R"
if [ -n "${RSTUDIO_WHICH_R+x}" ]; then
export RSTUDIO_WHICH_R_PREV="${RSTUDIO_WHICH_R}"
fi
export RSTUDIO_WHICH_R="$CONDA_PREFIX/bin/R"
# shellcheck disable=SC2154 # CONDA_PREFIX is always set in this context
export RSTUDIO_WHICH_R="${CONDA_PREFIX}/bin/R"
40 changes: 24 additions & 16 deletions recipe/build-r-base.sh
Original file line number Diff line number Diff line change
Expand Up @@ -455,22 +455,30 @@ Darwin() {
popd
}

if [[ $target_platform =~ .*osx.* ]]; then
Darwin
mkdir -p ${PREFIX}/etc/conda/activate.d
cp "${RECIPE_DIR}"/activate-${PKG_NAME}.sh ${PREFIX}/etc/conda/activate.d/activate-${PKG_NAME}.sh
mkdir -p ${PREFIX}/etc/conda/deactivate.d
cp "${RECIPE_DIR}"/deactivate-${PKG_NAME}.sh ${PREFIX}/etc/conda/deactivate.d/deactivate-${PKG_NAME}.sh
elif [[ $target_platform =~ .*linux.* ]]; then
Linux
mkdir -p ${PREFIX}/etc/conda/activate.d
cp "${RECIPE_DIR}"/activate-${PKG_NAME}.sh ${PREFIX}/etc/conda/activate.d/activate-${PKG_NAME}.sh
mkdir -p ${PREFIX}/etc/conda/deactivate.d
cp "${RECIPE_DIR}"/deactivate-${PKG_NAME}.sh ${PREFIX}/etc/conda/deactivate.d/deactivate-${PKG_NAME}.sh
elif [[ $target_platform =~ .*win.* ]]; then
# Mingw_w64_autotools
Mingw_w64_makefiles
fi
case "${target_platform}" in
osx-* )
Darwin
;;
linux-* )
Linux
;;
win-* )
# Mingw_w64_autotools
Mingw_w64_makefiles
;;
esac
case "${target_platform}" in
osx-* | linux-* )
for action in activate deactivate; do
if [[ "${build_platform}" != linux-ppc64le ]] ; then
shellcheck --shell=sh --severity=style --enable=check-unassigned-uppercase \
"${RECIPE_DIR}/${action}-${PKG_NAME}.sh"
fi
mkdir -p "${PREFIX}/etc/conda/${action}.d"
cp "${RECIPE_DIR}/${action}-${PKG_NAME}.sh" "${PREFIX}/etc/conda/${action}.d/"
done
;;
esac

if [[ "$CONDA_BUILD_CROSS_COMPILATION" == "1" ]]; then
pushd $BUILD_PREFIX/lib/R
Expand Down
6 changes: 3 additions & 3 deletions recipe/deactivate-r-base.sh
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
#!/usr/bin/env sh
# shellcheck shell=sh

# restore pre-existing RSTUDIO_WHICH_R
if [[ ! -z ${RSTUDIO_WHICH_R_PREV+x} ]]; then
export RSTUDIO_WHICH_R="$RSTUDIO_WHICH_R_PREV"
if [ -n "${RSTUDIO_WHICH_R_PREV+x}" ]; then
export RSTUDIO_WHICH_R="${RSTUDIO_WHICH_R_PREV}"
unset RSTUDIO_WHICH_R_PREV
else
unset RSTUDIO_WHICH_R
Expand Down
4 changes: 4 additions & 0 deletions recipe/install-cross-activate.sh
Original file line number Diff line number Diff line change
@@ -1,2 +1,6 @@
if [[ "${build_platform}" != linux-ppc64le ]] ; then
shellcheck --shell=sh --severity=style --enable=check-unassigned-uppercase \
"${RECIPE_DIR}/activate-cross-r-base.sh"
fi
mkdir -p $PREFIX/etc/conda/activate.d/
cp $RECIPE_DIR/activate-cross-r-base.sh $PREFIX/etc/conda/activate.d/activate-cross-r-base.sh
5 changes: 5 additions & 0 deletions recipe/meta.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,8 @@ outputs:
- m2-automake-wrapper # [win]
- automake # [not win]
- make # [not win]
# shellcheck is used to check activation scripts; it is not yet built for linux-ppc64le.
- shellcheck # [unix and build_platform != "linux-ppc64le"]
- libcurl # [not win]
- readline # [build_platform != target_platform]
- libcurl # [build_platform != target_platform]
Expand Down Expand Up @@ -192,6 +194,9 @@ outputs:
skip: true # [win]
script: install-cross-activate.sh
requirements:
build:
# shellcheck is used to check activation scripts; it is not yet built for linux-ppc64le.
- shellcheck # [build_platform != "linux-ppc64le"]
run:
- {{ pin_subpackage("r-base", exact=True) }}
- rsync
Expand Down

0 comments on commit 8fbc98a

Please sign in to comment.