Publish a source package to an S3 CRAN and update PACKAGES files
Source:R/s3cran.R
s3cran_add_source_package.RdAdds a local source tarball (*.tar.gz, etc.) to an S3-hosted CRAN-like
repository and updates all PACKAGES* indexes under src/contrib.
The tarball is uploaded first (long cache), then the indexes are uploaded
(short cache), minimizing client fetch races.
The function performs a single ETag-based concurrency check: if the index ETag has changed between read and write, it re-reads the latest index, re-merges the new package entry, and writes again.
All uploads use --acl public-read and --sse AES256 (SSE-S3) by default.
Value
Invisibly, a list with:
uploaded_tar_key— the S3 key of the uploaded tarballindex_keys— character vector of the three index keys written
Details
Steps performed:
Read current index from S3 (prefers
PACKAGES.rds) and record its ETag.Build a one-row
pkg_indexfromlocal_tar(validates filename vs DESCRIPTION).Merge the new row with the existing index (keeping all distinct
(Package, Version)pairs).Write
PACKAGES.rds,PACKAGES, andPACKAGES.gzto a temp dir.If
retry_on_change = TRUEand the original index existed, re-check the ETag once. If it differs, re-read the latest index, re-merge, and re-write.Upload the tarball (long cache), then upload the three index files (short cache), all with
public-readand SSE-S3 (AES256).
Cache headers used:
Tarball:
Cache-Control: max-age=31536000,immutableIndexes:
Cache-Control: max-age=60
Requires the AWS CLI and the helpers s3cran_read_pkg_index(), s3_upload(),
s3_etag(), pkg_index_from_tar(), pkg_index_bind(), and pkg_index_write().