diff options
Diffstat (limited to 'bin')
-rwxr-xr-x | bin/checklinks | 2 | ||||
-rwxr-xr-x | bin/pkg | 117 |
2 files changed, 66 insertions, 53 deletions
diff --git a/bin/checklinks b/bin/checklinks index 0b99b1e..ef96386 100755 --- a/bin/checklinks +++ b/bin/checklinks @@ -1,4 +1,6 @@ #!/usr/bin/env perl +## Copyright (C) 2008 by Daniel Friesel <derf@derf.homelinux.org> +## License: WTFPL <http://sam.zoy.org/wtfpl> use strict; use warnings; use Term::ANSIColor; @@ -183,6 +183,8 @@ function confirm_no { ## Major internal functions ## +function wrap_info {} + function progress { (( SILENT )) && return current=$1 @@ -229,7 +231,16 @@ function vcs_log { } function vcs_upgrade { - git pull $PKG_ROOT/${PWD:t} master + typeset IFS=$'\n' line + typeset -i merge_ok=0 + for line in $(git branch); { + [[ $line == '* master' ]] && merge_ok=1 + } + if ((merge_ok)) { + git pull $PKG_ROOT/${PWD:t} master + } else { + git fetch $PKG_rOOT/${PWD:t} master + } } function vcs_push { @@ -329,6 +340,39 @@ function exec_hook { } } +function global_hook { + cd $PDIR/$1 + case $2 in + post-add) + exec_hook $1 post-add + global_hook $1 post-update + ;; + pre-update) + ;; + post-update) + triggers+=$1 + check_prereqs $1 + if [[ -r Makefile ]] { + wrap_info $1 + info "Running make\n" + make + } + checklinks $CL_OPTIONS + populate_collected $1 + update_provides $1 + fix_origin $1 + list_update_package $1 + ;; + pre-remove) + exec_hook $1 pre-remove + genocide_collected $1 + checklinks -r + list_remove_package $1 + update_provides $1 'remove' + ;; + esac +} + # Set the correct origin function fix_origin { cd $PDIR/$1 @@ -343,7 +387,8 @@ function check_prereqs { package=$1 [[ -r $PDIR/$package/prereqs ]] || return 0 cd $PDIR/$package - info "$package: checking prerequisites\n" + wrap_info $1 + info "checking prerequisites\n" typeset -a install typeset warn @@ -397,10 +442,7 @@ function populate_collected { cd $PDIR/$1 || return typeset -i bins=0 bino=0 mans=0 mano=0 - if (( wrapped )) { - clear_line - info "$1: " - } + wrap_info $1 info "Enabling documentation " if [[ -d man ]] { for i in man/*/*; { @@ -430,7 +472,7 @@ function populate_collected { } clear_line if (( bins + mans > 0 )) { - (( wrapped )) && info "$1: " + wrap_info $1 info "Compiled documentation " say -n '(' if (( bins + bino > 0 )) { @@ -461,6 +503,7 @@ function populate_collected { # TODO: Make sure there are none function genocide_collected { cd $PDIR/$1 || return + wrap_info $1 info "Removing documentation" if [[ -d man ]] { for i in man/*/*; { @@ -514,6 +557,10 @@ function wrap { $function $2 } else { wrapped=1 + function wrap_info { + clear_line + info "$1: " + } cd $PDIR [[ -n $progress ]] && all=$(wc -l < $PDIR/.list) [[ -n $progress ]] && current=0 @@ -540,18 +587,7 @@ function pkg_add { cd $PDIR || return 255 vcs_add $1 || return 255 cd $1 || return 255 - check_prereqs $1 - if [[ -r $PDIR/$1/Makefile ]] { - info "Running make\n" - make - } - exec_hook $1 'post-add' - exec_hook $1 'post-update' - checklinks $CL_OPTIONS - populate_collected $1 - update_provides $1 - list_update_package $1 - fix_origin $1 + global_hook $1 post-add } function pkg_push { @@ -562,17 +598,9 @@ function pkg_push { if [[ $? = 0 ]] { clear_line info "Pushing $1\n" + global_hook $1 pre-update vcs_push - check_prereqs $1 - if [[ -r Makefile ]] { - info "Running make\n" - make - } - triggers+=$1 - checklinks $CL_OPTIONS - populate_collected $1 - update_provides $1 - fix_origin $1 + global_hook $1 post-update } } @@ -584,11 +612,7 @@ function pkg_remove { confirm_no "Package '$1' is $(real_priority $(cat priority)). Really remove?" || return } } - exec_hook $1 "pre-remove" - genocide_collected $1 - checklinks -r - list_remove_package $1 - update_provides $1 'remove' + global_hook $1 pre-remove rm -rf $PDIR/$1 info "Package removed.\n" } @@ -606,18 +630,9 @@ function pkg_upgrade { if list_incoming $1; then clear_line info "Updating $1 to $(list_remote_version $1)\n" + global_hook $1 pre-update vcs_upgrade - check_prereqs $1 - if [[ -r Makefile ]] { - info "Building binaries\n" - make - } - triggers+=$1 - checklinks $CL_OPTIONS - populate_collected $1 - update_provides $1 - list_update_package $1 - fix_origin $1 + global_hook $1 post-update fi } @@ -643,17 +658,13 @@ function pkg_status { function pkg_refresh { check_installed $1 cd $PDIR/$1 + global_hook $1 pre-update if [[ -r Makefile ]] { - clear_line - info "$1: re-building with make\n" + wrap_info $1 + info "Cleaning build diroctery\n" make clean - make } - populate_collected $1 - checklinks $CL_OPTIONS - check_prereqs $1 - triggers+=$1 - fix_origin $1 + global_hook $1 post-update } function pkg_update { |