Add Linux script
This commit is contained in:
@@ -0,0 +1,27 @@
|
||||
#!/bin/bash
|
||||
# Clone a git repo as a full mirror and pack it into a zip archive.
|
||||
# Works on Linux and macOS.
|
||||
|
||||
set -euo pipefail
|
||||
|
||||
if [ $# -lt 1 ]; then
|
||||
echo "Usage: $0 <git-repo-url> [output.zip]"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
URL="$1"
|
||||
OUT="${2:-repo.zip}"
|
||||
WORK_DIR=".tmp_git_mirror"
|
||||
|
||||
# Cleanup on exit
|
||||
cleanup() { rm -rf "$WORK_DIR"; }
|
||||
trap cleanup EXIT
|
||||
|
||||
echo "[1/3] Cloning mirror of $URL ..."
|
||||
git clone --mirror "$URL" "$WORK_DIR"
|
||||
|
||||
echo "[2/3] Creating $OUT with maximum compression ..."
|
||||
(cd "$WORK_DIR" && zip -9 -r "../$OUT" .)
|
||||
|
||||
SIZE=$(du -m "$OUT" | cut -f1)
|
||||
echo "[3/3] Done: $OUT (${SIZE} MB)"
|
||||
Reference in New Issue
Block a user