[pacman-dev] [PATCH] Generalise makepkg-wrapper to handle any script using libmakepkg
Allan McRae
allan at archlinux.org
Wed Oct 12 05:49:11 UTC 2016
Signed-off-by: Allan McRae <allan at archlinux.org>
---
scripts/Makefile.am | 27 +++++++++++++++---------
scripts/{makepkg-wrapper.sh.in => wrapper.sh.in} | 4 ++--
2 files changed, 19 insertions(+), 12 deletions(-)
rename scripts/{makepkg-wrapper.sh.in => wrapper.sh.in} (84%)
diff --git a/scripts/Makefile.am b/scripts/Makefile.am
index 92cd50c..9c9fd9f 100644
--- a/scripts/Makefile.am
+++ b/scripts/Makefile.am
@@ -7,9 +7,9 @@ SUBDIRS = po
bin_SCRIPTS = \
$(OURSCRIPTS) \
makepkg-template \
- makepkg-wrapper \
repo-remove \
- repo-elephant
+ repo-elephant \
+ $(WRAPPER)
OURSCRIPTS = \
makepkg \
@@ -103,6 +103,9 @@ LIBMAKEPKG_DIST = \
$(LIBMAKEPKG) \
$(addsuffix .in, $(LIBMAKEPKG_IN))
+WRAPPER = \
+ makepkg-wrapper
+
COMPLETION_IN = \
completion/bash_completion \
completion/zsh_completion
@@ -175,7 +178,7 @@ all-am: $(COMPLETION_IN)
makepkg: \
$(srcdir)/makepkg.sh.in \
- $(srcdir)/makepkg-wrapper.sh.in \
+ $(srcdir)/wrapper.sh.in \
$(srcdir)/library/parseopts.sh \
$(LIBMAKEPKG_IN)
@@ -213,18 +216,20 @@ repo-elephant: $(srcdir)/repo-add.sh.in
$(AM_V_at)$(RM) repo-elephant
$(AM_V_at)$(LN_S) repo-add repo-elephant
-makepkg-wrapper: \
- makepkg
+.SECONDEXPANSION:
+$(WRAPPER): \
+ $$(subst -wrapper,,$$@)
$(AM_V_at)$(MKDIR_P) .lib
- $(AM_V_at)mv -f makepkg .lib
+ $(AM_V_at)mv -f $(subst -wrapper,,$@) .lib
$(AM_V_at)$(RM) $@
$(AM_V_GEN)sed \
-e "s|@PWD[@]|$$(pwd)|" \
+ -e "s|@PROGNAME[@]|$(subst -wrapper,,$@)|g" \
-e '1s|!/bin/bash|!$(BASH_SHELL)|g' \
- $(srcdir)/$@.sh.in > $@
+ $(srcdir)/wrapper.sh.in > $@
$(AM_V_at)chmod +x,a-w $@
- $(AM_V_at)$(LN_S) makepkg-wrapper makepkg
+ $(AM_V_at)$(LN_S) $@ $(subst -wrapper,,$@)
install-data-local:
$(MKDIR_P) $(DESTDIR)$(sysconfdir)/bash_completion.d/
@@ -237,8 +242,10 @@ uninstall-local:
$(RM) $(DESTDIR)$(datarootdir)/zsh/site-functions/_pacman
install-exec-hook:
- cd $(DESTDIR)$(bindir) && \
- $(RM) makepkg makepkg-wrapper
+ for wrapper in $(WRAPPER); do \
+ cd $(DESTDIR)$(bindir) && \
+ $(RM) $$wrapper; \
+ done
$(INSTALL) .lib/makepkg $(DESTDIR)$(bindir)/makepkg
for dir in $(LIBMAKEPKGDIRS); do \
$(MKDIR_P) $(DESTDIR)$(libmakepkgdir)/$$dir; \
diff --git a/scripts/makepkg-wrapper.sh.in b/scripts/wrapper.sh.in
similarity index 84%
rename from scripts/makepkg-wrapper.sh.in
rename to scripts/wrapper.sh.in
index 6e71314..2039c2a 100644
--- a/scripts/makepkg-wrapper.sh.in
+++ b/scripts/wrapper.sh.in
@@ -1,6 +1,6 @@
#!/bin/bash
#
-# makepkg - a wrapper for running the real makepkg in the source tree
+# @PROGNAME@ - a wrapper for running the real @PROGNAME@ in the source tree
#
# Copyright (c) 2013-2016 Pacman Development Team <pacman-dev at archlinux.org>
#
@@ -20,4 +20,4 @@
DIR="@PWD@"
-LIBRARY="$DIR"/libmakepkg exec "$DIR"/.lib/makepkg "$@"
+LIBRARY="$DIR"/libmakepkg exec "$DIR"/.lib/@PROGNAME@ "$@"
--
2.10.0
More information about the pacman-dev
mailing list