Re: [gentoo-portage-dev] Default Phase Hooks

2007-02-09 Thread Ed Catmur
On Fri, 2007-02-09 at 06:51 +, Alec Warner wrote:
 In order to facilitate better ease of use with phase hooks, I propose a 
 paludis-style default phase hook.  Basically ebuild.sh provides a default 
 hook that looks in PORTAGE_HOOKS_DIR/{pre,post}_${EBUILD_PHASE}/ for shell 
 scripts and sources them.
What is PORTAGE_HOOKS_DIR?  Where is it set?

 ...
 Comments and Questions are welcome.
The quoting doesn't seem quite right.  Assuming you intend to expand the
glob at define time, it should be
+   eval ${prefix}_${EBUILD_PHASE}() {
+   for script in 
\${PORTAGE_HOOKS_DIR}/${prefix}_${EBUILD_PHASE}/\*.sh
+   do
+   ebegin \Sourcing \$script\
+   qa_source \$script || die \Failed to source \$script\
+   eend
+   done
+   }

Ed

-- 
gentoo-portage-dev@gentoo.org mailing list



[gentoo-portage-dev] Default Phase Hooks

2007-02-08 Thread Alec Warner
In order to facilitate better ease of use with phase hooks, I propose a 
paludis-style default phase hook.  Basically ebuild.sh provides a default 
hook that looks in PORTAGE_HOOKS_DIR/{pre,post}_${EBUILD_PHASE}/ for shell 
scripts and sources them.


The patch to ebuild.sh only generates hooks 1 phase at a time.  People 
with existing hooks in bashrc will not be affected (the bashrc hooks will 
over-ride these default hooks).


The motivation here is to have users create functionality in these hooks 
and enable them to easily share hooks.  'hey drop this hook in location X' 
is a lot easier than 'add this hook to bashrc...oh and make sure you don't 
already have a post_pkg_prerm hook in there...oh and make sure if you do 
have an existing hook you make it so that both run...' and so forth.


For people with no hooks the speed penalty is nil; for those with many 
hooks, there is probably some small overhead per phase as the script 
enumerates and sources the hooks.


Comments and Questions are welcome.

-Alec WarnerIndex: ebuild.sh
===
--- ebuild.sh   (revision 5930)
+++ ebuild.sh   (working copy)
@@ -69,6 +69,24 @@
 
 source ${PORTAGE_BIN_PATH}/isolated-functions.sh  /dev/null
 
+
+# Generate default hooks for EBUILD_PHASE
+# Users may over-ride these in their bashrc
+shopt -s nullglob
+for prefix in pre post
+do
+   eval ${prefix}_${EBUILD_PHASE}() {
+   for script in 
\${PORTAGE_HOOKS_DIR}/${prefix}_${EBUILD_PHASE}/*.sh\
+   do
+   ebegin \Sourcing \$script\
+   qa_source \$script || die \Failed to source \$script\
+   eend
+   done
+   }
+done
+
+shopt -u nullglob
+
 OCC=$CC
 OCXX=$CXX