From ec48dd455397e1653ac7ba6810435c9d1a7cf2f9 Mon Sep 17 00:00:00 2001 From: Luke Shumaker Date: Sat, 3 Nov 2012 01:05:47 -0400 Subject: add a fast (but slightly incorrect) mode for absrepo-convert's collect-data and make convert-arch able to deal with it --- pbs-absrepo-convert | 27 +++++++++++++++++++++++---- pbs-absrepo-convert--filterpackage | 17 ++++++++++------- 2 files changed, 33 insertions(+), 11 deletions(-) diff --git a/pbs-absrepo-convert b/pbs-absrepo-convert index 901b924..417c2da 100755 --- a/pbs-absrepo-convert +++ b/pbs-absrepo-convert @@ -16,7 +16,9 @@ abort() { } ## -# Usage: collect-data +# Usage: collect-data MODE +# MODE is either 'correct' or 'fast' +# # Assumptions: # - currently in a working copy of the repo # - git branch "master" exists and is untouched @@ -29,9 +31,17 @@ abort() { ## collect-data() { msg "$(gettext "Collecting package data...")" - [[ $# = 0 ]] || { usage; return 1; } + [[ $# = 1 ]] || { usage; return 1; } + local mode=$1 - git log --pretty=format:'%H' master > "${TMPDIR}/commits" + case "$mode" in + correct) + git log --pretty=format:'%H' master > "${TMPDIR}/commits";; + fast) + echo master > "${TMPDIR}/commits";; + *) + usage; return 1;; + esac # actual data collection ############################################### local count="$(wc -l < "${TMPDIR}/commits")" @@ -116,6 +126,8 @@ convert-packages() { # - currently in a working copy of the repo # Effects: # - creates git branch "${ARCH}" +# - TMPDIR is set +# - creates file "${TMPDIR}/missing-packages.${ARCH}" # Side effects: # - changes git working tree # - prints output of git commands @@ -124,10 +136,17 @@ convert-arch() { [[ $# = 1 ]] || { usage; return 1; } local arch=$1 + touch "${PKGDIR}/missing-packages.${arch}.tmp" + git checkout orig git checkout -b "$arch" git filter-branch -f --tree-filter \ "pbs-absrepo-convert--filterpackage $arch" "$arch" + + sort -u \ + < "${PKGDIR}/missing-packages.${arch}.tmp" \ + > "${PKGDIR}/missing-packages.${arch}" + rm -f "${PKGDIR}/missing-packages.${arch}.tmp" } ## @@ -165,7 +184,7 @@ main() { cd "${TMPDIR}/repo" git checkout -b orig git checkout master - collect-data + collect-data fast git branch -D master # main ################################################################# diff --git a/pbs-absrepo-convert--filterpackage b/pbs-absrepo-convert--filterpackage index 24ba8b0..3118909 100755 --- a/pbs-absrepo-convert--filterpackage +++ b/pbs-absrepo-convert--filterpackage @@ -21,13 +21,16 @@ 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}" - ) + if [[ -n "$commithash" ]]; then + 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 # clean up -- cgit v1.1-4-g5e80