summaryrefslogtreecommitdiff
path: root/bin
diff options
context:
space:
mode:
authorDaniel Friesel <derf@derf.homelinux.org>2008-06-15 14:35:30 +0200
committerDaniel Friesel <derf@derf.homelinux.org>2008-06-15 14:35:30 +0200
commitedcc7cf15c42a48f0f5f90aabc5241c20c26ffb6 (patch)
tree516f0ca101565e6274b644ef40cbf7585487217f /bin
parent8e5926c4559aa98a4d5a1d36d44ae20004407b6b (diff)
bin/pkg: Made hook-handling simpler
Diffstat (limited to 'bin')
-rwxr-xr-xbin/pkg25
1 files changed, 13 insertions, 12 deletions
diff --git a/bin/pkg b/bin/pkg
index 11ba47d..040917b 100755
--- a/bin/pkg
+++ b/bin/pkg
@@ -135,6 +135,16 @@ real_priority () {
esac
}
+# Execute a hook
+exec_hook () {
+ package="$1"
+ hook="$2"
+ if ([ -r $PDIR/$package/hooks/$hook ]) {
+ info "Executing $hook hook\n"
+ . $PDIR/$package/hooks/$hook
+ }
+}
+
# Check dependencies and offer to install them
check_deps () {
[ -r $PDIR/$1/dependencies ] || return 0
@@ -265,10 +275,7 @@ pkg_add () {
cd $PDIR/$1
make
}
- if ([ -r $PDIR/$1/hooks/post-add ]) {
- info 'Executing post-add hook\n'
- . $PDIR/$1/hooks/post-add
- }
+ exec_hook "$1" "post-add"
check_deps "$1"
check_conflicts "$1"
cd $PDIR/$1
@@ -286,10 +293,7 @@ pkg_remove () {
confirm_no "Package '$1' is $(real_priority $(cat priority)). Really remove?" || return
}
}
- if ([ -f $PDIR/$1/hooks/pre-remove ]) {
- info 'Executing pre-remove hook\n'
- . $PDIR/$1/hooks/pre-remove
- }
+ exec_hook "$1" "pre-remove"
genocide_collected "$1"
removelinks "$1"
rm -r $PDIR/$1
@@ -311,10 +315,7 @@ pkg_update () {
info "Building binaries\n"
make
}
- if ([ -r hooks/post-update ]) {
- info 'Executing post-update hook\n'
- . hooks/post-update
- }
+ exec_hook "$1" "post-update"
checklinks $CL_OPTIONS
populate_collected "$1"
} else {