Skip to content

Instantly share code, notes, and snippets.

@mfansler
Created December 22, 2022 23:43
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save mfansler/973e3b3dd794ea3bf5411d52e273b3cd to your computer and use it in GitHub Desktop.
Save mfansler/973e3b3dd794ea3bf5411d52e273b3cd to your computer and use it in GitHub Desktop.
List all libraries a Conda Forge R library links against
#!/usr/bin/env bash -l
## PARAMS
## file should have one "[name]=[version]=[build]" per line
FILE_PKG_BUILDS="r-tiff.cf_pkgs.txt"
##
DYLIB_LOC="lib/R/library/tiff/libs"
tmp=$(mktemp -d)
## create tmp env
conda create -qyp ${tmp}/0
TMP_TAR="${tmp}/tar"
while read build; do
echo "Processing ${build}"
FILE="${tmp}/${build//[=]/-}.tar.bz2"
rm -rf ${TMP_TAR} && mkdir -p ${TMP_TAR}
## download tarball
CONDA_PKGS_DIRS=${tmp} mamba install -p ${tmp}/0 \
--override-channels -c conda-forge -C \
-d --download-only --json --no-deps ${build} |\
grep '"url"' | grep -oE 'https[^"]+' |\
xargs wget -qcO ${FILE}
## extract dylib file
DYLIB_FILE=$(tar -tf ${FILE} ${DYLIB_LOC})
tar -xf ${FILE} -C ${TMP_TAR} ${DYLIB_FILE}
## analyze dylib
otool -L ${TMP_TAR}/${DYLIB_FILE}
done < ${FILE_PKG_BUILDS}
## remove environment
conda env remove -qyp ${tmp}/0
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment