diff options
author | aleksana <me@aleksana.moe> | 2023-08-17 20:51:35 +0800 |
---|---|---|
committer | aleksana <me@aleksana.moe> | 2023-08-31 18:25:06 +0800 |
commit | 981754aba87cb66ed37485632e39235e7f6fe381 (patch) | |
tree | 1795c6155bec5fbb133783c3e4ccb4f2e832c788 /pkgs/build-support | |
parent | 85eb9355b5f1fcb79bfc159e02f9987b7c178aca (diff) | |
download | nixlib-981754aba87cb66ed37485632e39235e7f6fe381.tar nixlib-981754aba87cb66ed37485632e39235e7f6fe381.tar.gz nixlib-981754aba87cb66ed37485632e39235e7f6fe381.tar.bz2 nixlib-981754aba87cb66ed37485632e39235e7f6fe381.tar.lz nixlib-981754aba87cb66ed37485632e39235e7f6fe381.tar.xz nixlib-981754aba87cb66ed37485632e39235e7f6fe381.tar.zst nixlib-981754aba87cb66ed37485632e39235e7f6fe381.zip |
nix-prefetch-git: fix make_deterministic_repo in submodules
Diffstat (limited to 'pkgs/build-support')
-rwxr-xr-x | pkgs/build-support/fetchgit/nix-prefetch-git | 16 |
1 files changed, 11 insertions, 5 deletions
diff --git a/pkgs/build-support/fetchgit/nix-prefetch-git b/pkgs/build-support/fetchgit/nix-prefetch-git index 79ab699bcc25..3027e1532dff 100755 --- a/pkgs/build-support/fetchgit/nix-prefetch-git +++ b/pkgs/build-support/fetchgit/nix-prefetch-git @@ -256,9 +256,15 @@ make_deterministic_repo(){ cd "$repo" # Remove files that contain timestamps or otherwise have non-deterministic # properties. - rm -rf .git/logs/ .git/hooks/ .git/index .git/FETCH_HEAD .git/ORIG_HEAD \ - .git/refs/remotes/origin/HEAD .git/config - + if [ -f .git ]; then + local dotgit_content=$(<.git) + local dotgit_dir="${dotgit_content#gitdir: }" + else + local dotgit_dir=".git" + fi + pushd "$dotgit_dir" + rm -rf logs/ hooks/ index FETCH_HEAD ORIG_HEAD refs/remotes/origin/HEAD config + popd # Remove all remote branches. git branch -r | while read -r branch; do clean_git branch -rD "$branch" @@ -276,7 +282,7 @@ make_deterministic_repo(){ # Do a full repack. Must run single-threaded, or else we lose determinism. clean_git config pack.threads 1 clean_git repack -A -d -f - rm -f .git/config + rm -f "$dotgit_dir/config" # Garbage collect unreferenced objects. # Note: --keep-largest-pack prevents non-deterministic ordering of packs @@ -325,7 +331,7 @@ clone_user_rev() { find "$dir" -name .git -print0 | xargs -0 rm -rf else find "$dir" -name .git | while read -r gitdir; do - make_deterministic_repo "$(readlink -f "$gitdir/..")" + make_deterministic_repo "$(readlink -f "$(dirname "$gitdir")")" done fi } |