summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLuke Shumaker <LukeShu@sbcglobal.net>2013-01-29 14:25:02 -0500
committerLuke Shumaker <LukeShu@sbcglobal.net>2013-01-29 14:25:02 -0500
commit694a9d979213280ad503a53c64eb195c5277b63e (patch)
treec3e57be553e34620bbc2ccc50ff3be1cb81d9113
parent0531586cb23eec0a23931f302eb8ecf0b52ff1d2 (diff)
pbs-absrepo-convert: restructure
-rwxr-xr-xpbs-absrepo-convert55
1 files changed, 26 insertions, 29 deletions
diff --git a/pbs-absrepo-convert b/pbs-absrepo-convert
index c03d58e..465c2ac 100755
--- a/pbs-absrepo-convert
+++ b/pbs-absrepo-convert
@@ -31,10 +31,7 @@ trailing-newline() {
}
##
-# Usage: collect-data MODE
-# MODE is either 'correct' or 'fast'
-#
-# 'fast' may omit some packages that have been deleted.
+# Usage: collect-data
#
# Assumptions:
# - currently in the working repo
@@ -48,9 +45,10 @@ trailing-newline() {
# - creates file "${TMPDIR}/commits"
##
collect-data() {
+ local mode=fast # 'correct' or 'fast
+ # 'fast' may omit some packages that have been deleted.
+
msg "$(gettext "Collecting package data...")"
- [[ $# = 1 ]] || { usage; return 1; }
- local mode=$1
case "$mode" in
correct) git log --pretty=format:'%H' master > "${TMPDIR}/commits";;
@@ -84,23 +82,21 @@ collect-data() {
}
##
-# Usage: convert-package SOURCE PACKAGE
+# Usage: convert-package PACKAGE
#
# Assumptions:
# - currently in the working repo
# Effects:
-# - creates git branch "packages/${SOURCE}/${PACKAGE}"
-# - creates file "../packages-${PACKAGE}.commits"
+# - creates git branch "pkgs/${PACKAGE}"
+# - creates file "../pkg-${PACKAGE}.commits"
# Side effects:
# - changes git working tree
# - prints output of git commands
##
convert-package() {
- [[ $# = 2 ]] || { usage; return 1; }
- local source=$1
- local package=$2
+ local package=$1
- local obranch="packages/${source}/${package}"
+ local obranch="pkgs/${package}"
local ibranch
local dir
if git checkout "packages/${package}" &>/dev/null; then
@@ -121,11 +117,11 @@ convert-package() {
fi
git log "$obranch" --pretty=format:'%T %H' \
- > "../packages-${package}.commits"
+ > "../pkg-${package}.commits"
}
##
-# Usage: convert-packages SOURCENAME
+# Usage: convert-packages
# Assumptions:
# - currently in the working repo
# - file "../packages" contains a newline-separated list of packages
@@ -135,13 +131,10 @@ convert-package() {
##
convert-packages() {
msg "$(gettext "Converting packages...")"
- [[ $# = 1 ]] || { usage; return 1; }
- local source=$1
-
local count="$(wc -l < ../packages)"
cat -n ../packages | while read n package; do
msg2 "$(gettext "(%d/%d) %s")" "$n" "$count" "$package"
- convert-package "$source" "$package"
+ convert-package "$package"
done
}
@@ -158,14 +151,13 @@ convert-packages() {
# - prints output of git commands
##
convert-arch() {
- [[ $# = 1 ]] || { usage; return 1; }
local arch=$1
mkdir -p "${TMPDIR}/missing-packages"
touch "${TMPDIR}/missing-packages/${arch}.tmp"
git rewrite-branch master "$arch" \
- --tree-filter "pbs-absrepo-convert--filterarch $arch" "$arch"
+ --tree-filter "pbs-absrepo-convert--filterarch $arch"
sort -u \
< "${TMPDIR}/missing-packages/${arch}.tmp" \
@@ -177,22 +169,27 @@ convert-arch() {
# Usage: convert-arches
# Assumptions:
# - currently in the working repo
-# - file "${TMPDIR}/architectures" contains a newline-separated list of arches
+# - file "../architectures" contains a newline-separated list of arches
# Effects:
# - runs `convert-arch` for every arch listed in "${TMPDIR}/architectures"
# - prints status updates about what it is doing
##
convert-arches() {
msg "$(gettext "Converting architectures...")"
- [[ $# = 0 ]] || { usage; return 1; }
-
- local count="$(wc -l < "${TMPDIR}/architectures")"
- cat -n "${TMPDIR}/architectures" | while read n arch; do
+ local count="$(wc -l < "../architectures")"
+ cat -n "../architectures" | while read n arch; do
msg2 "$(gettext "(%d/%d) %s")" "$n" "$count" "$arch"
convert-arch "$arch"
done
}
+usage() {
+ echo "Usage: ${0##*/} SOURCE"
+ echo "Convert the absrepo-format SOURCE to pbs-format"
+ echo
+ echo "SOURCE must be configured in /etc/libretools.d/pbs.conf"
+}
+
main() {
trap abort EXIT
[[ $# = 1 ]] || { usage; return 1; }
@@ -211,8 +208,8 @@ main() {
# main #################################################################
- collect-data fast
- convert-packages "$source"
+ collect-data fast
+ convert-packages
convert-arches
# save results #########################################################
@@ -230,7 +227,7 @@ main() {
fi
# copy other data
- cp -f "${TMPDIR}/packages" "${sourceir}/${source}.packages"
+ cp -f "../packages" "${sourceir}/${source}.packages"
cat "${TMPDIR}"/missing-packages/* > "${sourceir}/${source}.missing-packages"
trap cleanup EXIT