On Wed, Aug 22, 2012 at 12:41:45AM -0300, Gerardo Exequiel Pozzi wrote: > On 08/19/2012 05:39 PM, Lukas Fleischer wrote: > >On Sun, Aug 19, 2012 at 04:21:01PM -0300, Gerardo Exequiel Pozzi wrote: > >>On 08/19/2012 11:21 AM, Lukas Fleischer wrote: > >>>On Sun, Aug 19, 2012 at 12:21:32AM -0300, Gerardo Exequiel Pozzi wrote: > >>>>On 08/18/2012 06:48 AM, Lukas Fleischer wrote: > >>>>>Move all hooks into a list and create shell commands dynamically instead > >>>>>of specifying all of them in every recipe. > >>>>> > >>>>>Signed-off-by: Lukas Fleischer<[email protected]> > >>>>>--- > >>>>> Makefile | 57 +++++++++++++++++++++++---------------------------------- > >>>>> 1 file changed, 23 insertions(+), 34 deletions(-) > >>>>> > >>>>>diff --git a/Makefile b/Makefile > >>>>>index 309f890..552d8cc 100644 > >>>>>--- a/Makefile > >>>>>+++ b/Makefile > >>>>>@@ -1,5 +1,24 @@ > >>>>> V=1 > >>>>>+HOOKS = \ > >>>>>+ hooks/archiso \ > >>>>>+ install/archiso \ > >>>>>+ archiso_shutdown \ > >>>>>+ hooks/archiso_shutdown \ > >>>>>+ install/archiso_shutdown \ > >>>>>+ archiso_pxe_nbd \ > >>>>>+ hooks/archiso_pxe_common \ > >>>>>+ install/archiso_pxe_common \ > >>>>>+ hooks/archiso_pxe_nbd \ > >>>>>+ install/archiso_pxe_nbd \ > >>>>>+ hooks/archiso_pxe_http \ > >>>>>+ install/archiso_pxe_http \ > >>>>>+ hooks/archiso_pxe_nfs \ > >>>>>+ install/archiso_pxe_nfs \ > >>>>>+ hooks/archiso_loop_mnt \ > >>>>>+ install/archiso_loop_mnt \ > >>>>>+ install/archiso_kms > >>>>>+ > >>>>> all: > >>>>> install: install-program install-hooks install-examples install-doc > >>>>>@@ -9,23 +28,9 @@ install-program: > >>>>> install-hooks: > >>>>> # hooks/install are needed by mkinitcpio > >>>>>- install -D -m 644 archiso/hooks/archiso > >>>>>$(DESTDIR)/usr/lib/initcpio/hooks/archiso > >>>>>- install -D -m 644 archiso/install/archiso > >>>>>$(DESTDIR)/usr/lib/initcpio/install/archiso > >>>>>- install -D -m 755 archiso/archiso_shutdown > >>>>>$(DESTDIR)/usr/lib/initcpio/archiso_shutdown > >>>>>- install -D -m 644 archiso/hooks/archiso_shutdown > >>>>>$(DESTDIR)/usr/lib/initcpio/hooks/archiso_shutdown > >>>>>- install -D -m 644 archiso/install/archiso_shutdown > >>>>>$(DESTDIR)/usr/lib/initcpio/install/archiso_shutdown > >>>>>- install -D -m 644 archiso/archiso_pxe_nbd > >>>>>$(DESTDIR)/usr/lib/initcpio/archiso_pxe_nbd > >>>>>- install -D -m 644 archiso/hooks/archiso_pxe_common > >>>>>$(DESTDIR)/usr/lib/initcpio/hooks/archiso_pxe_common > >>>>>- install -D -m 644 archiso/install/archiso_pxe_common > >>>>>$(DESTDIR)/usr/lib/initcpio/install/archiso_pxe_common > >>>>>- install -D -m 644 archiso/hooks/archiso_pxe_nbd > >>>>>$(DESTDIR)/usr/lib/initcpio/hooks/archiso_pxe_nbd > >>>>>- install -D -m 644 archiso/install/archiso_pxe_nbd > >>>>>$(DESTDIR)/usr/lib/initcpio/install/archiso_pxe_nbd > >>>>>- install -D -m 644 archiso/hooks/archiso_pxe_http > >>>>>$(DESTDIR)/usr/lib/initcpio/hooks/archiso_pxe_http > >>>>>- install -D -m 644 archiso/install/archiso_pxe_http > >>>>>$(DESTDIR)/usr/lib/initcpio/install/archiso_pxe_http > >>>>>- install -D -m 644 archiso/hooks/archiso_pxe_nfs > >>>>>$(DESTDIR)/usr/lib/initcpio/hooks/archiso_pxe_nfs > >>>>>- install -D -m 644 archiso/install/archiso_pxe_nfs > >>>>>$(DESTDIR)/usr/lib/initcpio/install/archiso_pxe_nfs > >>>>>- install -D -m 644 archiso/hooks/archiso_loop_mnt > >>>>>$(DESTDIR)/usr/lib/initcpio/hooks/archiso_loop_mnt > >>>>>- install -D -m 644 archiso/install/archiso_loop_mnt > >>>>>$(DESTDIR)/usr/lib/initcpio/install/archiso_loop_mnt > >>>>>- install -D -m 644 archiso/install/archiso_kms > >>>>>$(DESTDIR)/usr/lib/initcpio/install/archiso_kms > >>>>>+ $(foreach hook,$(HOOKS), \ > >>>>>+ install -D -m 644 archiso/$(hook) > >>>>>$(DESTDIR)/usr/lib/initcpio/$(hook) ; \ > >>>>>+ ) > >>>>Warning, not all files are 644, look... ;) > >>>An oversight of mine :) This should be easy to fix, though... > >>> > >>>>> install-examples: > >>>>> install -d -m 755 $(DESTDIR)/usr/share/archiso/ > >>>>>@@ -37,23 +42,7 @@ install-doc: > >>>>> uninstall: > >>>>> rm -f $(DESTDIR)/usr/sbin/mkarchiso > >>>>>- rm -f $(DESTDIR)/usr/lib/initcpio/hooks/archiso > >>>>>- rm -f $(DESTDIR)/usr/lib/initcpio/install/archiso > >>>>>- rm -f $(DESTDIR)/usr/lib/initcpio/archiso_shutdown > >>>>>- rm -f $(DESTDIR)/usr/lib/initcpio/hooks/archiso_shutdown > >>>>>- rm -f $(DESTDIR)/usr/lib/initcpio/install/archiso_shutdown > >>>>>- rm -f $(DESTDIR)/usr/lib/initcpio/archiso_pxe_nbd > >>>>>- rm -f $(DESTDIR)/usr/lib/initcpio/hooks/archiso_pxe_common > >>>>>- rm -f $(DESTDIR)/usr/lib/initcpio/install/archiso_pxe_common > >>>>>- rm -f $(DESTDIR)/usr/lib/initcpio/hooks/archiso_pxe_nbd > >>>>>- rm -f $(DESTDIR)/usr/lib/initcpio/install/archiso_pxe_nbd > >>>>>- rm -f $(DESTDIR)/usr/lib/initcpio/hooks/archiso_pxe_http > >>>>>- rm -f $(DESTDIR)/usr/lib/initcpio/install/archiso_pxe_http > >>>>>- rm -f $(DESTDIR)/usr/lib/initcpio/hooks/archiso_pxe_nfs > >>>>>- rm -f $(DESTDIR)/usr/lib/initcpio/install/archiso_pxe_nfs > >>>>>- rm -f $(DESTDIR)/usr/lib/initcpio/hooks/archiso_loop_mnt > >>>>>- rm -f $(DESTDIR)/usr/lib/initcpio/install/archiso_loop_mnt > >>>>>- rm -f $(DESTDIR)/usr/lib/initcpio/install/archiso_kms > >>>>>+ $(foreach hook,$(HOOKS),rm -f > >>>>>$(DESTDIR)/usr/lib/initcpio/$(hook) ; ) > >>>>> rm -rf $(DESTDIR)/usr/share/archiso/ > >>>>> rm -f $(DESTDIR)/usr/share/doc/archiso/README > >>>>Thanks you, but If this will be refactored, I prefer to do in a more > >>>>"makefile way" if possible. > >>>Could you please elaborate on this? "foreach" is a valid Makefile > >>>construct supported by GNU make [1]. We use a similar approach in > >>>initscripts [2] and devtools [3] (even though the latter uses the shell > >>>builtin "for" instead of "foreach"). Feel free to suggest a more elegant > >>>alternative -- we would all be very grateful. > >>ok, something like (DRAFT) > >> > >>INITCPIO_RUN_HOOKS=archiso archiso_shutdown.... > >>INITCPIO_INSTALL_HOOKS=archiso_kms > >>INITCPIO_SCRIPTS=archiso_shutdown > >> > >>INITCPIO_INSTALL_HOOKS+=INITCPIO_RUN_HOOKS > >> > >>install-run-hooks: $(INITCPIO_RUN_HOOKS) > >> install -t $(DESTDIR).... $^ > >Are you aware that this still requires the "foreach" function (or > >something similar)? `install -t $(DESTDIR).... $^` won't work since the > >hooks are not located in the top-level source directory. There's only > >two obvious fixes for that: > > > >* Use something like > > > > $(foreach hook, $(INITCPIO_RUN_HOOKS),archiso/hooks/$(hook)) > > > > to add the relative path to every source file. > > > >* Split the Makefile into several modules and place these in the > > appropriate directories. > > > >>etc... > >> > >> > >>>>-- > >>>>Gerardo Exequiel Pozzi > >>>>\cos^2\alpha + \sin^2\alpha = 1 > >>>[1] http://www.gnu.org/software/make/manual/make.html#Foreach-Function > >>>[2] https://projects.archlinux.org/initscripts.git/tree/Makefile#n22 > >>>[3] https://projects.archlinux.org/devtools.git/tree/Makefile#n85 > >>> > >> > >>-- > >>Gerardo Exequiel Pozzi > >>\cos^2\alpha + \sin^2\alpha = 1 > > I reworked and reorded files, there is no need now to change > makefiles for new hooks, removed hooks... > > INSTALL_FILES=$(wildcard archiso/initcpio/install/*) > HOOKS_FILES=$(wildcard archiso/initcpio/hooks/*) > SCRIPT_FILES=$(wildcard archiso/initcpio/script/*) > > INSTALL_DIR=$(DESTDIR)/usr/lib/initcpio/install > HOOKS_DIR=$(DESTDIR)/usr/lib/initcpio/hooks > SCRIPT_DIR=$(DESTDIR)/usr/lib/initcpio > > install-initcpio: > install -d $(SCRIPT_DIR) $(HOOKS_DIR) $(INSTALL_DIR) > install -m 755 -t $(SCRIPT_DIR) $(SCRIPT_FILES) > install -m 644 -t $(HOOKS_DIR) $(HOOKS_FILES) > install -m 644 -t $(INSTALL_DIR) $(INSTALL_FILES)
... and what does the uninstall target look like now? > > > > -- > Gerardo Exequiel Pozzi > \cos^2\alpha + \sin^2\alpha = 1
