Add mirror-clone.sh wrapper for sjtug/mirror-clone#200
Conversation
Wrap sjtug/mirror-clone binary so multiple tunasync jobs can share one script. The wrapper exposes three layered environment variables: - TUNASYNC_MIRRORCLONE_OPTIONS: mirror-clone options before source - TUNASYNC_MIRRORCLONE_SOURCE: required source plugin name - TUNASYNC_MIRRORCLONE_ARGS: plugin-specific arguments This pattern is used by NJU mirror to drive ghcup, crates.io and other mirror-clone-based jobs from a single shared script.
There was a problem hiding this comment.
Pull request overview
Note
Copilot was unable to run its full agentic suite in this review.
Adds a mirror-clone.sh wrapper script to run mirror-clone in a tunasync working directory, driven by environment variables.
Changes:
- Introduces a bash entrypoint that validates
TUNASYNC_MIRRORCLONE_SOURCEand runsmirror-cloneviaexec - Uses
TUNASYNC_WORKING_DIRas the working directory and configures file buffer/base paths under it
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| [ ! -d "${TUNASYNC_WORKING_DIR}" ] && mkdir -p "${TUNASYNC_WORKING_DIR}" | ||
| cd "${TUNASYNC_WORKING_DIR}" |
There was a problem hiding this comment.
Following the convention used by other scripts in this repo (chef.sh/cvmfs.sh/termux.sh) — they all dereference TUNASYNC_WORKING_DIR directly and rely on the tunasync framework to set it. Keeping consistent with that.
| $TUNASYNC_MIRRORCLONE_OPTIONS \ | ||
| "$TUNASYNC_MIRRORCLONE_SOURCE" \ | ||
| $TUNASYNC_MIRRORCLONE_ARGS |
There was a problem hiding this comment.
The unquoted expansion is intentional: it lets per-mirror configs pass multiple positional flags through TUNASYNC_MIRRORCLONE_OPTIONS / TUNASYNC_MIRRORCLONE_ARGS. Switching to bash arrays would change the public interface (existing tunasync mirror configs would have to be rewritten). Keeping current behavior.
| [ ! -d "${TUNASYNC_WORKING_DIR}" ] && mkdir -p "${TUNASYNC_WORKING_DIR}" | ||
| cd "${TUNASYNC_WORKING_DIR}" | ||
|
|
||
| exec /home/mirror-clone \ |
There was a problem hiding this comment.
Followed the convention from chef.sh/cvmfs.sh/bazel-apt.sh: now locates the binary as ${_here}/mirror-clone with optional MIRRORCLONE_BIN override. No more hard-coded /home/mirror-clone.
| @@ -0,0 +1,23 @@ | |||
| #!/bin/bash | |||
|
|
|||
| set -eu | |||
There was a problem hiding this comment.
Done. Switched from set -eu to set -euo pipefail.
Follow the convention used by chef.sh/cvmfs.sh/bazel-apt.sh: locate the
helper binary relative to the script directory (${_here}/mirror-clone)
with an optional MIRRORCLONE_BIN override, instead of a hard-coded
/home/mirror-clone path.
Also switch from 'set -eu' to 'set -euo pipefail'.
Summary
Add a generic shell wrapper for the sjtug/mirror-clone binary so multiple tunasync jobs can share one script.
Why
mirror-clonesupports many source plugins (ghcup, crates.io, GitHub releases, …). Today each tunasync job using mirror-clone has to write its own short shell file, which is mostly boilerplate (resolveTUNASYNC_WORKING_DIR, set--target-type file, choose source). This wrapper centralises that boilerplate so each tunasync.confonly sets a few env vars.Interface
Three layered environment variables:
TUNASYNC_MIRRORCLONE_OPTIONSTUNASYNC_MIRRORCLONE_SOURCEghcup,crates-io)TUNASYNC_MIRRORCLONE_ARGSThe wrapper assumes the
mirror-clonebinary is mounted at/home/mirror-cloneinside the container, matching the existing pattern of bind-mounting the binary intotunathu/tunasync-scripts:latest.