summaryrefslogtreecommitdiff
path: root/pbs-absrepo-convert--treefilter
blob: 1462f11c383f43f0f69b98aed3e63d9ae69eae4b (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
#!/bin/bash -e
arch=$1

# generate map of all packages to their treehash
tree="$(mktemp)"
if [[ $arch = master ]]; then
	git ls-tree -d "$arch" */trunk > "$tree"
else
	git ls-tree -d "$arch" */repos/*-"$arch" */repos/*-any > "$tree"
fi

# generate map of all packages to their repo
repos="$(mktemp)"
find */repos/* -type d -printf '%h/%h\n' | sed -r 's@^([^/]*)/repos/(.*)-[^-]*$@\1 \2@'|sort -u > "$repos"

# clean the working directory
rm -rf *

# add the packages back in as remotes
cat "$tree" | while read mode type treehash path; do
	package="${path%%/*}"
	repo="$(sed -n "s/^${package} //p" "$repos")"
	commithash="$(sed -n "s/^${treehash} //p" "${TMPDIR}/packages-${package}.commits")"

	mkdir -p "$repo"
	git submodule add ./ "${repo}/${package}"
	(
		cd "${repo}/${package}"
		git checkout "${commithash}"
	)
done

# clean up
rm -f "$repos" "$tree"