build-cran-binaries/local/find-R-api-packages.sh
pat-s a9ad907f9c
chore(local): add S3 migration and CRAN-source helper scripts
- migrate-s3-hetzner-to-backblaze.sh: rclone-based bucket migration helper.
- find-R-api-packages.sh: scan CRAN package sources for a C-API usage pattern.
- query-pkgs-without-old-versions.R, test-package-loading.R: ad-hoc helpers.
2026-06-14 13:02:48 +02:00

34 lines
916 B
Shell

#!/bin/bash
# Directory to clone repos into
WORKDIR="cran_repos"
mkdir -p "$WORKDIR"
cd "$WORKDIR"
# GitHub API paginates results, so we loop through pages
PAGE=1
PER_PAGE=100
MATCHES=()
while :; do
# Fetch a page of repos
REPOS=$(curl -s "https://api.github.com/orgs/cran/repos?per_page=$PER_PAGE&page=$PAGE" | jq -r '.[].clone_url')
[ -z "$REPOS" ] && break
for REPO_URL in $REPOS; do
REPO_NAME=$(basename "$REPO_URL" .git)
# Skip if already cloned
[ -d "$REPO_NAME" ] && continue
git clone --depth 1 "$REPO_URL" "$REPO_NAME" >/dev/null 2>&1
if [ -d "$REPO_NAME/src" ]; then
# Search for Rinternals.h in src/
if grep -r -q 'R_VERSION < R_Version(' "$REPO_NAME/src"; then
echo "$REPO_NAME"
fi
fi
# Clean up to save space
rm -rf "$REPO_NAME"
done
PAGE=$((PAGE + 1))
done