blob: 2482d44e059c2103f559197dc054fdf7c35c2805 (
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
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
|
#!/bin/bash -e
. /usr/bin/libremessages
cachedir="$(pbs-plumb-config get core.cachedir)"
sourcedir="$(pbs-plumb-config get core.sourcedir)"
tmpdir="`mktemp -d --tmpdir pbs-absrepo-convert.XXXXXXXXXX`"
export TMPDIR=$tmpdir
cleanup() {
rm -rf "$tmpdir"
}
trap cleanup EXIT
main() {
[[ $# != 1 ]] && { usage; return 1; }
local source=$1
# init #################################################################
cd "${cachedir}/${source}.git"
git branch > "${tmpdir}/branches"
git clone "${cachedir}/${source}.git" "${tmpdir}/repo"
cd "${tmpdir}/repo"
git checkout -b orig
git branch -D master
find */repos/* -type d -printf '%f\n' | sed -e 's/.*/-//' -e '/^any$/d' | sort -u > "${tmpdir}/architectures"
# convert packages #####################################################
msg "$(gettext "Converting packages...")"
package_count="$(wc -l "${tmpdir}/branches")"
package_count="${package_count%% *}"
cat "${tmpdir}/branches" | sed -n 's@^\s*packages/@@p' | cat -n | while read n package; do
msg2 "$(gettext "(%d/%d) %s")" "$n" "$package_count" "$package"
git checkout "packages/${package}"
git filter-branch -f --prune-empty --subdirectory-filter trunk "packages/${package}"
git log --pretty=format:'%T %H' > "${tmpdir}/packages-${package}.commits"
done
# convert architectures ################################################
for arch in master $(cat "${tmpdir}/architectures"); do
msg "$(gettext "Creating architecture %s...")" "$arch"
git checkout orig
git checkout -b "$arch"
git filter-branch --tree-filter "pbs-absrepo-convert--treefilter $arch" "$arch"
done
# save results #########################################################
msg "$(gettext "Copying into source directory...")"
[[ -d "$sourcedir" ]] || mkdir -p "$sourcedir"
git clone --mirror "${tmpdir}/repo" "${sourcedir}/${source}.new.git"
[[ -d "${sourcedir}/${source}.git" ]] && mv "${sourcedir}/${source}"{,.old}.git
mv "${sourcedir}/${source}"{.new,}.git
[[ -d "${sourcedir}/${source}.old.git" ]] && rm -rf "${sourcedir}/${source}".old.git
}
main "$@"
|