summaryrefslogtreecommitdiff
path: root/pbs-convert-absgit--filterarch
diff options
context:
space:
mode:
authorLuke Shumaker <LukeShu@sbcglobal.net>2013-01-29 14:48:10 -0500
committerLuke Shumaker <LukeShu@sbcglobal.net>2013-01-29 14:48:10 -0500
commitf35b3a4ed063e940918d8ca28ece75ff80679944 (patch)
treee8af8c4b9df2d7b4c74adf289a66f61a0bc63613 /pbs-convert-absgit--filterarch
parent6ca7a10796da3afea4dee311b2f48d7190e02fd1 (diff)
Rename a few things
- s/absrepo/absgit/ - s/pbs-(.*)-convert/pbs-convert-\1/
Diffstat (limited to 'pbs-convert-absgit--filterarch')
-rwxr-xr-xpbs-convert-absgit--filterarch45
1 files changed, 45 insertions, 0 deletions
diff --git a/pbs-convert-absgit--filterarch b/pbs-convert-absgit--filterarch
new file mode 100755
index 0000000..73fa96a
--- /dev/null
+++ b/pbs-convert-absgit--filterarch
@@ -0,0 +1,45 @@
+#!/bin/bash -e
+arch=$1
+
+echo # newline
+echo Preparing...
+
+# generate map of all packages to their treehash
+tree="$(mktemp)"
+if [[ $arch = master ]]; then
+ git ls-tree -d "$GIT_COMMIT" */trunk > "$tree"
+else
+ git ls-tree -d "$GIT_COMMIT" */repos/*-"$arch" */repos/*-any > "$tree"
+fi
+
+# generate map of all packages to their repo
+repos="$(mktemp)"
+printf '%s\n' */repos/*-"$arch" | sed -r 's@^([^/]*)/repos/(.*)-[^-]*$@\1 \2@' | sort -u > "$repos"
+
+# clean the working directory
+rm -rf *
+
+# add the packages back in as remotes
+count="$(wc -l < "$tree")"
+cat -n "$tree" | while read n mode type treehash path; do
+ printf '\r%s (%i/%i)' "$(gettext 'Adding package')" "$n" "$count"
+
+ package="${path%%/*}"
+ repo="$(sed -n "s/^${package} //p" "$repos")"
+ commitfile="../packages-${package}.commits"
+ if [[ -f "$commitfile" ]]; then
+ commithash="$(sed -n "s/^${treehash} //p" "$commitfile")"
+ mkdir -p "$repo"
+ git submodule add ./ "${repo}/${package}"
+ (
+ cd "${repo}/${package}"
+ git checkout "${commithash}"
+ )
+ else
+ printf '%s\n' "$package" >> "${TMPDIR}/missing-packages/${arch}.tmp"
+ fi
+done
+echo # newline
+
+# clean up
+rm -f "$repos" "$tree"