diff --git a/dist-git.spec b/dist-git.spec index e449fe4..ae1c162 100644 --- a/dist-git.spec +++ b/dist-git.spec @@ -137,6 +137,7 @@ install -d %{buildroot}%{_bindir} ln -s %{_datadir}/dist-git/setup_git_package %{buildroot}%{_bindir}/setup_git_package ln -s %{_datadir}/dist-git/mkbranch %{buildroot}%{_bindir}/mkbranch ln -s %{_datadir}/dist-git/mkbranch_branching %{buildroot}%{_bindir}/mkbranch_branching +ln -s %{_datadir}/dist-git/remove_unused_sources %{buildroot}%{_bindir}/remove_unused_sources # ------------------------------------------------------------------------------ # SELinux diff --git a/scripts/dist-git/remove_unused_sources b/scripts/dist-git/remove_unused_sources new file mode 100755 index 0000000..57173e5 --- /dev/null +++ b/scripts/dist-git/remove_unused_sources @@ -0,0 +1,78 @@ +#!/bin/bash + +Usage() { + cat < + + Removes all tarballs in except + for tarballs that are referenced by the latest commit of each + branch in . +EOF +} + +die() { echo "$*" 1>&2 ; exit 1; } + +if [[ $# != 2 ]]; then + Usage + exit 1 +fi + +pkg_git_dir="$1" +pkg_lookaside_dir="$2" + +if [ ! -d "$pkg_git_dir" ]; then + echo "$pkg_git_dir is not a valid directory." + exit 1 +fi +if [ ! -d "$pkg_lookaside_dir" ]; then + echo "$pkg_lookaside_dir is not a valid directory." + exit 1 +fi + +pushd "$pkg_git_dir" > /dev/null || exit 1 + +whitelist=() + +# find sources that are referenced by the latest commit in any of the branches +for branch in $(git for-each-ref --format="%(refname:short)" refs/heads); do + while read -r line; do + set -- $line + hash=$1 + filename=$2 + # skip projects using the new format + test $# -eq 0 && continue + test $# -ne 2 && die "Unsupported format. Only the old '