From 27dabac18582c2a97af30090c63988ed09644011 Mon Sep 17 00:00:00 2001 From: Daniel Friesel Date: Wed, 24 Dec 2008 21:03:14 +0100 Subject: bin/pkg: Introduced global hooks --- bin/pkg | 76 ++++++++++++++++++++++++++++++++--------------------------------- 1 file changed, 38 insertions(+), 38 deletions(-) (limited to 'bin') diff --git a/bin/pkg b/bin/pkg index 8641652..5670717 100755 --- a/bin/pkg +++ b/bin/pkg @@ -329,6 +329,38 @@ 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 ]] { + 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 @@ -540,18 +572,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 +583,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 +597,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 +615,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 } -- cgit v1.2.3 From 6a88b3dfb7ea2cf71d73a0ce8ecdf95a93277d61 Mon Sep 17 00:00:00 2001 From: Daniel Friesel Date: Wed, 24 Dec 2008 21:22:03 +0100 Subject: bin/pkg: pkg_refresh: Use global hooks --- bin/pkg | 9 ++------- 1 file changed, 2 insertions(+), 7 deletions(-) (limited to 'bin') diff --git a/bin/pkg b/bin/pkg index 5670717..860be01 100755 --- a/bin/pkg +++ b/bin/pkg @@ -645,15 +645,10 @@ function pkg_refresh { cd $PDIR/$1 if [[ -r Makefile ]] { clear_line - info "$1: re-building with make\n" + 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 { -- cgit v1.2.3 From b45548b814d95164bfe11c7538784ce06d06f62f Mon Sep 17 00:00:00 2001 From: Daniel Friesel Date: Mon, 29 Dec 2008 17:58:46 +0100 Subject: bin/pkg: Try to use git fetch to avoid merging master into another branch by accident --- bin/pkg | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) (limited to 'bin') diff --git a/bin/pkg b/bin/pkg index 1bc1c35..352e3df 100755 --- a/bin/pkg +++ b/bin/pkg @@ -229,7 +229,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' ]] && ok=1 + } + if ((ok)) { + git pull $PKG_ROOT/${PWD:t} master + } else { + git fetch $PKG_rOOT/${PWD:t} master + } } function vcs_push { -- cgit v1.2.3 From 065f17afd86960f0d61f3f634becd698a7f74c6a Mon Sep 17 00:00:00 2001 From: Daniel Friesel Date: Mon, 29 Dec 2008 18:01:39 +0100 Subject: bin/pkg: Fixed syntax error in vcs_upgrade --- bin/pkg | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'bin') diff --git a/bin/pkg b/bin/pkg index 352e3df..0b0a0c2 100755 --- a/bin/pkg +++ b/bin/pkg @@ -231,7 +231,7 @@ function vcs_log { function vcs_upgrade { typeset IFS=$'\n' line typeset -i merge_ok=0 - for line in $(git branch) { + for line in $(git branch); { [[ $line == '* master' ]] && ok=1 } if ((ok)) { -- cgit v1.2.3 From 13a7dcb4ff695b898cf79045c862b96064e7761d Mon Sep 17 00:00:00 2001 From: Daniel Friesel Date: Wed, 31 Dec 2008 12:27:12 +0100 Subject: checklinks: Added copyright notice --- bin/checklinks | 2 ++ 1 file changed, 2 insertions(+) (limited to 'bin') 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 +## License: WTFPL use strict; use warnings; use Term::ANSIColor; -- cgit v1.2.3 From 8f3c9be9bae336fe90c08ab783fee92645e1003c Mon Sep 17 00:00:00 2001 From: Daniel Friesel Date: Tue, 6 Jan 2009 19:20:37 +0100 Subject: pkg: vcs_upgrade: Fixed parameter name --- bin/pkg | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'bin') diff --git a/bin/pkg b/bin/pkg index 0b0a0c2..519bfe1 100755 --- a/bin/pkg +++ b/bin/pkg @@ -232,9 +232,9 @@ function vcs_upgrade { typeset IFS=$'\n' line typeset -i merge_ok=0 for line in $(git branch); { - [[ $line == '* master' ]] && ok=1 + [[ $line == '* master' ]] && merge_ok=1 } - if ((ok)) { + if ((merge_ok)) { git pull $PKG_ROOT/${PWD:t} master } else { git fetch $PKG_rOOT/${PWD:t} master -- cgit v1.2.3 From f0b31c94a2647b5161a46adb860b9b28112558ea Mon Sep 17 00:00:00 2001 From: Daniel Friesel Date: Tue, 6 Jan 2009 19:49:43 +0100 Subject: pkg: Added wrap_info to prefix output if neccessary (e.g. in pkg refresh) [zsh fun fact: One cannot set aliases in functions] --- bin/pkg | 20 +++++++++++++------- 1 file changed, 13 insertions(+), 7 deletions(-) (limited to 'bin') diff --git a/bin/pkg b/bin/pkg index 519bfe1..3751ddd 100755 --- a/bin/pkg +++ b/bin/pkg @@ -183,6 +183,8 @@ function confirm_no { ## Major internal functions ## +function wrap_info {} + function progress { (( SILENT )) && return current=$1 @@ -351,6 +353,7 @@ function global_hook { triggers+=$1 check_prereqs $1 if [[ -r Makefile ]] { + wrap_info $1 info "Running make\n" make } @@ -384,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 @@ -438,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/*/*; { @@ -471,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 )) { @@ -502,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/*/*; { @@ -555,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 @@ -653,7 +659,7 @@ function pkg_refresh { check_installed $1 cd $PDIR/$1 if [[ -r Makefile ]] { - clear_line + wrap_info info "Cleaning build diroctery\n" make clean } -- cgit v1.2.3 From f7c8f9f07b6e5ca4b2c60c76dc35953d98d423ae Mon Sep 17 00:00:00 2001 From: Daniel Friesel Date: Tue, 6 Jan 2009 21:46:25 +0100 Subject: pkg: pkg_status: Fixed hooks and infos --- bin/pkg | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'bin') diff --git a/bin/pkg b/bin/pkg index 3751ddd..ce8f3d7 100755 --- a/bin/pkg +++ b/bin/pkg @@ -658,8 +658,9 @@ function pkg_status { function pkg_refresh { check_installed $1 cd $PDIR/$1 + global_hook $1 pre-update if [[ -r Makefile ]] { - wrap_info + wrap_info $1 info "Cleaning build diroctery\n" make clean } -- cgit v1.2.3