summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLuke Shumaker <LukeShu@sbcglobal.net>2012-11-01 02:20:42 -0400
committerLuke Shumaker <LukeShu@sbcglobal.net>2012-11-01 02:20:42 -0400
commitc1c7f3a2516b1101cae844e2506ef8aace5cca29 (patch)
treeec85341767969d108ff44a609aa5a63cbae29a47
initial commit
-rw-r--r--config20
-rwxr-xr-xpbs-absrepo-convert58
-rwxr-xr-xpbs-absrepo-convert--treefilter34
-rwxr-xr-xpbs-plumb-config43
-rwxr-xr-xpbs-plumb-download36
5 files changed, 191 insertions, 0 deletions
diff --git a/config b/config
new file mode 100644
index 0000000..e97e3e6
--- /dev/null
+++ b/config
@@ -0,0 +1,20 @@
+[core]
+ cachedir = /var/cache/pbs
+ sourcedir = /var/pbs-sources
+ treedir = /var/pbs
+
+[source "arch-packages"]
+ type = absrepo
+ url = git://projects.archlinux.org/svntogit/packages.git
+
+[source "arch-community"]
+ type = absrepo
+ url = git://projects.archlinux.org/svntogit/community.git
+
+[source "parabola-abslibre"]
+ type = abstree
+ url = git://projects.parabolagnulinux.org/abslibre.git
+
+[source "parabola-abslibre-mips64el"]
+ type = abstree
+ url = git://projects.parabolagnulinux.org/abslibre-mips64el.git
diff --git a/pbs-absrepo-convert b/pbs-absrepo-convert
new file mode 100755
index 0000000..2482d44
--- /dev/null
+++ b/pbs-absrepo-convert
@@ -0,0 +1,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 "$@"
diff --git a/pbs-absrepo-convert--treefilter b/pbs-absrepo-convert--treefilter
new file mode 100755
index 0000000..1462f11
--- /dev/null
+++ b/pbs-absrepo-convert--treefilter
@@ -0,0 +1,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"
diff --git a/pbs-plumb-config b/pbs-plumb-config
new file mode 100755
index 0000000..f175742
--- /dev/null
+++ b/pbs-plumb-config
@@ -0,0 +1,43 @@
+#!/bin/bash
+
+##
+# Usage: list FILE
+# stdout: A newline-separated list of settings in FILE
+##
+list() {
+ [[ $# != 1 ]] && { usage; return 1; }
+ local file=$1
+ git config --file "$file" -z --list | awk -vRS='\0' -vFS='\n' '{ print $1 }' && return $PIPESTATUS
+}
+
+##
+# Usage: get FILE SETTING
+# stdout: The raw value of SETTING in FILE; *not* terminated by a newline
+##
+get() {
+ [[ $# != 2 ]] && { usage; return 1; }
+ local file=$1
+ local setting=$2
+ git config --file "$file" -z --get "$setting"
+}
+
+main() {
+ [[ $# < 1 ]] && { usage; return 1; }
+ local cmd=$1
+ shift
+
+ local file="/home/luke/parabola/pbs2/pbs-utils/config" # XXX
+ case "$cmd" in
+ list)
+ list "$file" "$@"
+ return $?;;
+ get)
+ get "$file" "$@"
+ return $?;;
+ *)
+ usage
+ return 1;;
+ esac
+}
+
+main "$@"
diff --git a/pbs-plumb-download b/pbs-plumb-download
new file mode 100755
index 0000000..8d4abf2
--- /dev/null
+++ b/pbs-plumb-download
@@ -0,0 +1,36 @@
+#!/bin/bash -e
+
+. /usr/bin/libremessages
+
+main() {
+ [[ $# != 1 ]] && { usage; return 1; }
+ local source=$1
+ local url="$(pbs-plumb-config get "source.$source.url")"
+
+ local cachedir="$(pbs-plumb-config get core.cachedir)"
+ [[ -d "${cachedir}" ]] || mkdir -p "${cachedir}"
+
+ if [[ ! -d "${cachedir}/${source}.git" ]]; then
+ cd "${cachedir}"
+ msg "$(gettext "Cloning %s")" "${cachedir}/${source}.git"
+ if ! git clone --mirror "$url" "$source.git"; then
+ error "$(gettext "Failed to download source %s")" "$source"
+ exit 1
+ fi
+ else
+ cd "${cachedir}/${source}.git"
+ # Make sure we are fetching the right repo
+ if [[ "$url" != "$(git config --get remote.origin.url)" ]] ; then
+ error "$(gettext "%s is not a clone of %s")" "$source" "$url"
+ plain "$(gettext "Aborting...")"
+ exit 1
+ fi
+ msg "$(gettext "Updating %s")" "${cachedir}/${source}.git"
+ if ! git fetch --all -p; then
+ error "$(gettext "Failed to update source %s")" "$source"
+ exit 1
+ fi
+ fi
+}
+
+main "$@"