From d66b53cf13bb491618ab96335cb422445f8e4395 Mon Sep 17 00:00:00 2001 From: Luke Shumaker Date: Sun, 12 May 2013 20:38:24 -0400 Subject: adjust to not hardcode where the jh-* programs are --- .gitignore | 1 + Makefile | 13 +++++++------ jh.sh | 32 -------------------------------- jh.sh.in | 32 ++++++++++++++++++++++++++++++++ 4 files changed, 40 insertions(+), 38 deletions(-) delete mode 100644 jh.sh create mode 100644 jh.sh.in diff --git a/.gitignore b/.gitignore index b121c6e..2bff4aa 100644 --- a/.gitignore +++ b/.gitignore @@ -2,3 +2,4 @@ !COPYING !Makefile !*.* +jh.sh diff --git a/Makefile b/Makefile index 810b0c4..c2465b5 100644 --- a/Makefile +++ b/Makefile @@ -1,11 +1,9 @@ prefix = /usr bindir = $(prefix)/bin -# pkgdatadir is hardcoded into jh.sh -pkgdatadir = /usr/share/jh - +jh-bindir = $(prefix)/share/jh subcommands = help list-commands mvn-basename mvn-install mvn-localrepo checksource -dirs = $(DESTDIR)$(bindir) $(DESTDIR)$(pkgdatadir) +dirs = $(DESTDIR)$(bindir) $(DESTDIR)$(jh-bindir) #### @@ -17,11 +15,14 @@ all: PHONY build #### build: PHONY jh $(subcommand_files) -install: PHONY $(DESTDIR)$(bindir)/jh $(addprefix $(DESTDIR)$(pkgdatadir)/,$(subcommand_files) $(help_files)) +install: PHONY $(DESTDIR)$(bindir)/jh $(addprefix $(DESTDIR)$(jh-bindir)/,$(subcommand_files) $(help_files)) clean: PHONY rm -f jh $(subcommand_files) -$(DESTDIR)$(pkgdatadir)/%: % | $(DESTDIR)$(pkgdatadir) +jh.sh: jh.sh.in + sed 's|@jh-bindir@|$(jh-bindir)|g' < $< > $@ + +$(DESTDIR)$(jh-bindir)/%: % | $(DESTDIR)$(jh-bindir) cp '$<' '$@' $(DESTDIR)$(bindir)/jh: jh | $(DESTDIR)$(bindir) diff --git a/jh.sh b/jh.sh deleted file mode 100644 index dce758b..0000000 --- a/jh.sh +++ /dev/null @@ -1,32 +0,0 @@ -#!/bin/bash -# Copyright © 2013 Luke Shumaker -# This work is free. You can redistribute it and/or modify it under the -# terms of the Do What The Fuck You Want To Public License, Version 2, -# as published by Sam Hocevar. See the COPYING file for more details. - -if [[ -z $JH_PATH ]]; then - export JH_PATH=/usr/share/jh -fi - -if [[ -z $jh_short ]]; then - export jh_short=${0##*/} - export PATH="$JH_PATH:$PATH" -fi - -main() { - if [[ $# < 1 ]]; then - jh-help >>/dev/stderr - return 1; - fi - cmd=$1 - shift - - if [[ -x "$(which "jh-$cmd" 2>/dev/null)" ]]; then - "jh-$cmd" "$@" - return $? - else - echo "$jh_short: Cannot find command '$cmd'" >> /dev/stderr - fi -} - -main "$@" diff --git a/jh.sh.in b/jh.sh.in new file mode 100644 index 0000000..0d0b9f6 --- /dev/null +++ b/jh.sh.in @@ -0,0 +1,32 @@ +#!/bin/bash +# Copyright © 2013 Luke Shumaker +# This work is free. You can redistribute it and/or modify it under the +# terms of the Do What The Fuck You Want To Public License, Version 2, +# as published by Sam Hocevar. See the COPYING file for more details. + +if [[ -z $JH_PATH ]]; then + export JH_PATH=@jh-bindir@ +fi + +if [[ -z $jh_short ]]; then + export jh_short=${0##*/} + export PATH="$JH_PATH:$PATH" +fi + +main() { + if [[ $# < 1 ]]; then + jh-help >>/dev/stderr + return 1; + fi + cmd=$1 + shift + + if [[ -x "$(which "jh-$cmd" 2>/dev/null)" ]]; then + "jh-$cmd" "$@" + return $? + else + echo "$jh_short: Cannot find command '$cmd'" >> /dev/stderr + fi +} + +main "$@" -- cgit v1.2.3-54-g00ecf