diff options
author | Daniel Friesel <derf@derf.homelinux.org> | 2008-08-02 17:42:28 +0200 |
---|---|---|
committer | Daniel Friesel <derf@derf.homelinux.org> | 2008-08-02 17:42:28 +0200 |
commit | bda576f0734a00bd8d39cb63c27b43fa38344567 (patch) | |
tree | 794a5216495a0228239794df42571f8b7144bba5 /bin/pkg | |
parent | b629879e7a68bd00c3c1c11cba470f6c336894a3 (diff) |
bin/pkg: Removed pkg_%_wrapper, use generic wrap function instead
Diffstat (limited to 'bin/pkg')
-rwxr-xr-x | bin/pkg | 78 |
1 files changed, 23 insertions, 55 deletions
@@ -212,9 +212,9 @@ list_update_remote () { list_update_local () { cd $PDIR rm -f .list - all=$(ls -1d $PDIR/*(@,/) | wc -l) + all=$(ls -1d $PDIR/*(/) | wc -l) current=0 - for i in *(@,/); { + for i in *(/); { current=$[$current+1] progress $current $all "Updating package list" $i vcs_to_list $i >> .list @@ -389,6 +389,24 @@ update_provides () { } } +wrap () { + function=$1 + + if [[ -n $2 ]] { + $function $2 + } else { + cd $PDIR + [[ -n $3 ]] && all=$(wc -l < $PDIR/.list) + [[ -n $3 ]] && current=0 + for i in *(/); { + current=$[$current+1] + [[ -n $3 ]] && progress $current $all $3 $i + $function $i + } + [[ -n $3 ]] && clear_line + } +} + ## ## Finally - the functions actually doing something ## @@ -427,22 +445,6 @@ pkg_push () { } } -pkg_push_wrapper () { - if [[ -n $1 ]] { - pkg_push $1 - } else { - cd $PDIR - all=$(wc -l < $PDIR/.list) - current=0 - for i in *(/); { - current=$[$current+1] - progress $current $all "Pushing" $i - pkg_push $i - } - clear_line - } -} - pkg_remove () { check_installed $1 check_valid $1 @@ -483,23 +485,6 @@ pkg_upgrade () { } } -# If no package was specified, update everything -pkg_upgrade_wrapper () { - if [[ -n $1 ]] { - pkg_upgrade $1 - } else { - cd $PDIR - all=$(wc -l < $PDIR/.list) - current=0 - for i in *(/); { - current=$[$current+1] - progress $current $all "Upgrading" $i - pkg_upgrade $i - } - clear_line - } -} - # Change the 'default' url in every package's .hgrc pkg_changesrc () { cd $PDIR @@ -529,23 +514,6 @@ pkg_status () { } } -# Same as with update - if no package is specified, check all -pkg_status_wrapper () { - if [[ -n $1 ]] { - pkg_status $1 - } else { - cd $PDIR - all=$(wc -l < $PDIR/.list) - current=0 - for i in *(/); { - current=$[$current+1] - progress $current $all "Checking package status" $i - pkg_status $i - } - clear_line - } -} - pkg_update () { pkg_update_remote pkg_update_local @@ -653,11 +621,11 @@ case $1 in list-all) pkg_list_available ;; local-update) pkg_update_local ;; log) pkg_log $2 ;; - push) pkg_push_wrapper $2 ;; + push) wrap pkg_push "$2" "Pushing" ;; remote-update) pkg_update_remote ;; remove) pkg_remove $2 ;; - status) pkg_status_wrapper $2 ;; + status) wrap pkg_status "$2" "Checking package status" ;; update) pkg_update ;; - upgrade) pkg_upgrade_wrapper $2 ;; + upgrade) wrap pkg_upgrade "$2" "Looking for updates" ;; *) die "wait, what?\n" ;; esac |