harbor run -t openthoughts/tasktrove-exp-rpt-stack-bash-withtests-gpt5mini-v2-stack-bash-withtests-gpt4o-5121harbor download openthoughts/tasktrove-exp-rpt-stack-bash-withtests-gpt5mini-v2-stack-bash-withtests-gpt4o-5121Create an install-time (post-link) shell script that downloads a prebuilt R package tarball from one of several mirror URLs, verifies its checksum, installs it into the R library inside the conda prefix, and then cleans up.
Requirements
File and location
Environment and staging
Download sources and checksum
Installation and cleanup
Robustness
Notes (for implementation)
Implement the script at /app/post-link.sh so the above behavior is satisfied.
The following test script will be used to verify your solution:
#!/bin/bash
FN="RaExExonProbesetLocation_1.15.0.tar.gz"
URLS=(
"https://bioconductor.org/packages/3.10/data/annotation/src/contrib/RaExExonProbesetLocation_1.15.0.tar.gz"
"https://bioarchive.galaxyproject.org/RaExExonProbesetLocation_1.15.0.tar.gz"
"https://depot.galaxyproject.org/software/bioconductor-raexexonprobesetlocation/bioconductor-raexexonprobesetlocation_1.15.0_src_all.tar.gz"
"https://depot.galaxyproject.org/software/bioconductor-raexexonprobesetlocation/bioconductor-raexexonprobesetlocation_1.15.0_src_all.tar.gz"
)
MD5="d547bcd30685495283b32f0f86ecc79b"
# Use a staging area in the conda dir rather than temp dirs, both to avoid
# permission issues as well as to have things downloaded in a predictable
# manner.
STAGING=$PREFIX/share/$PKG_NAME-$PKG_VERSION-$PKG_BUILDNUM
mkdir -p $STAGING
TARBALL=$STAGING/$FN
SUCCESS=0
for URL in ${URLS[@]}; do
curl $URL > $TARBALL
[[ $? == 0 ]] || continue
# Platform-specific md5sum checks.
if [[ $(uname -s) == "Linux" ]]; then
if md5sum -c <<<"$MD5 $TARBALL"; then
SUCCESS=1
break
fi
else if [[ $(uname -s) == "Darwin" ]]; then
if [[ $(md5 $TARBALL | cut -f4 -d " ") == "$MD5" ]]; then
SUCCESS=1
break
fi
fi
fi
done
if [[ $SUCCESS != 1 ]]; then
echo "ERROR: post-link.sh was unable to download any of the following URLs with the md5sum $MD5:"
printf '%s\n' "${URLS[@]}"
exit 1
fi
# Install and clean up
R CMD INSTALL --library=$PREFIX/lib/R/library $TARBALL
rm $TARBALL
rmdir $STAGING