diff options
| author | Czarek Nakamoto <cyjan@mrcyjanek.net> | 2025-02-17 11:23:33 +0100 |
|---|---|---|
| committer | Czarek Nakamoto <cyjan@mrcyjanek.net> | 2025-02-17 11:23:33 +0100 |
| commit | e64ac9c4f14f9c0e45606fe67aeeeb3a5f9af777 (patch) | |
| tree | 6ada5abb929ebb331b007ca5719c589fac40eef1 /tools/mirror/mirror.sh | |
| parent | 9d9b1f2f2373fc9a99c6556a93eea63fe343cf58 (diff) | |
Add mirror fot git repo
Improve apply_patches.sh
Improve build_single.sh
Create tools to mirror all repositories in git bundles
Diffstat (limited to 'tools/mirror/mirror.sh')
| -rw-r--r-- | tools/mirror/mirror.sh | 62 |
1 files changed, 62 insertions, 0 deletions
diff --git a/tools/mirror/mirror.sh b/tools/mirror/mirror.sh new file mode 100644 index 0000000..7a2ab64 --- /dev/null +++ b/tools/mirror/mirror.sh @@ -0,0 +1,62 @@ +#!/bin/bash + +# Create directories +mkdir -p mirrors/bundles mirrors/temp + +# Function to convert URL to bundle name +url_to_bundle_name() { + local url="$1" + local hash="$2" + # Remove https:// and .git, replace / and . with - + # Append first 8 chars of hash before .bundle + echo -n -e "$url" | sed 's|https://||' | sed 's|\.git$||' | tr '/' '-' | tr '.' '-' | tr '[:upper:]' '[:lower:]' + echo -n -e "-${hash:0:8}.bundle" +} + +> mirrors/gitbundlemap.txt + +while read -r line; do + url=$(echo "$line" | cut -d' ' -f1) + commit=$(echo "$line" | cut -d' ' -f2) + if [ "$commit" == "b7a695cf4b41645a5f5c5a5c1f0d565b283a3585" ]; then + echo "Skipping $url ($commit)" + continue + fi + bundle_name="$(url_to_bundle_name "$url" "$commit")" + + if [ ! -f "mirrors/bundles/$bundle_name" ]; then + + echo "Processing $url ($commit) -> $bundle_name" + + if curl -f -s -o "mirrors/bundles/$bundle_name" "https://static.mrcyjanek.net/download_mirror/git/$bundle_name"; then + echo "Downloaded existing bundle for $url ($commit)" + else + echo "No existing bundle found, cloning repository..." + rm -rf mirrors/temp/repo || true + # Clone repository + git clone --mirror "$url" "mirrors/temp/repo" || { + echo "Failed to clone $url" + exit 1 + } + + # Create bundle for specific commit + cd mirrors/temp/repo + git bundle create "../../bundles/$bundle_name" --all "$commit" || { + echo "Failed to create bundle for $url ($commit)" + cd ../../.. + exit 1 + } + cd ../../.. + + rm -rf mirrors/temp/repo + fi + fi + + echo "$commit $bundle_name" >> mirrors/gitbundlemap.txt + +done < submodule-list.txt + +sort -u mirrors/gitbundlemap.txt -o mirrors/gitbundlemap.txt +echo rsync -raz --progress $PWD/mirrors/bundles/'*' mrcyjanek@static.mrcyjanek.net:/home/mrcyjanek/web/static.mrcyjanek.net/public_html/download_mirror/git/ +echo "Done! Bundles are in mirrors/bundles/" +echo "Commit mappings are in mirrors/gitbundlemap.txt"
\ No newline at end of file |
