summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLuke Shumaker <LukeShu@sbcglobal.net>2013-03-19 14:29:04 -0400
committerLuke Shumaker <LukeShu@sbcglobal.net>2013-03-19 14:29:04 -0400
commit9eff1e08b3e580d1e2a998af0243e27c8370c14e (patch)
treeb8d5df160dbc49d166553b81094fd8310e676e3d
parent21b3a17b9b3e0ab21354b22b8b4017380d0a39ea (diff)
Add pbs and pbs-help, to have it work like git
-rw-r--r--.gitignore1
-rw-r--r--Makefile55
-rwxr-xr-xpbs-help39
-rwxr-xr-xpbs.in21
4 files changed, 106 insertions, 10 deletions
diff --git a/.gitignore b/.gitignore
new file mode 100644
index 0000000..974b555
--- /dev/null
+++ b/.gitignore
@@ -0,0 +1 @@
+/pbs \ No newline at end of file
diff --git a/Makefile b/Makefile
index 96fe6b2..cfbe4a9 100644
--- a/Makefile
+++ b/Makefile
@@ -1,20 +1,55 @@
PREFIX=/usr/local
-BINPROGS=$(shell find * -type f -executable)
+# in a bind, thes can all be set to the same directory
+pbs-bindir = $(PREFIX)/lib/pbs-core
+git-bindir = $(PREFIX)/lib/git-core
+bindir = $(PREFIX)/bin
+libreconfdir = /etc/libretools.d
-all: $(BINPROGS) pbs-convert.conf
+pbs-progs := $(shell printf '%s\n' pbs-* | fgrep -v .)
+git-progs := $(shell printf '%s\n' git-* | fgrep -v .)
+bin-progs = pbs
+libreconf := $(wildcard pbs-*.conf)
-install: $(addprefix $(DESTDIR)$(PREFIX)/bin/,$(BINPROGS)) $(DESTDIR)/etc/libretools.d/pbs.conf
+install-targets := \
+ $(addprefix $(DESTDIR)$(pbs-bindir)/,$(pbs-progs)) \
+ $(addprefix $(DESTDIR)$(git-bindir)/,$(git-progs)) \
+ $(addprefix $(DESTDIR)$(bindir)/,$(bin-progs)) \
+ $(addprefix $(DESTDIR)$(libreconfdir)/,$(libreconf))
-uninstall:
- for f in $(BINPROGS); do rm -f $(DESTDIR)$(PREFIX)/bin/$$f; done
- rm -f $(DESTDIR)/etc/libretools.d/pbs-convert.conf
+# phony rules
-$(DESTDIR)$(PREFIX)/bin/%: % | $(DESTDIR)$(PREFIX)/bin
- install -m755 '$*' '${@D}'
+all: PHONY $(pbs-progs) $(git-progs) $(bin-progs) $(libreconf)
-$(DESTDIR)/etc/libretools.d/pbs-convert.conf: pbs-convert.conf | $(DESTDIR)/etc/libretools.d
+clean: PHONY
+ rm -f pbs
+
+install: PHONY $(install-targets)
+
+uninstall: PHONY
+ for f in $(install-targets); do rm -f -- $(f); done
+
+# actual file rules
+
+pbs: pbs.in
+ sed 's|@pbs-bindir@|$(pbs-bindir)|g' < $< > $@
+ chmod 755 $@
+
+$(DESTDIR)$(pbs-bindir)/%: % | $(DESTDIR)$(pbs-bindir)
+ cp '$*' '${@D}'
+
+$(DESTDIR)$(git-bindir)/%: % | $(DESTDIR)$(git-bindir)
+ cp '$*' '${@D}'
+
+$(DESTDIR)$(bindir)/%: % | $(DESTDIR)$(bindir)
+ cp '$*' '${@D}'
+
+$(DESTDIR)$(libreconfdir)/%: % | $(DESTDIR)$(libreconfdir)
install -m644 '$*' '${@D}'
-$(DESTDIR)$(PREFIX)/bin $(DESTDIR)/etc/libretools.d:
+$(addprefix $(DESTDIR),$(pbs-bindir) $(git-bindir) $(bindir) $(libreconfdir)):
install -d '$@'
+
+# tricks
+
+.PHONY: PHONY
diff --git a/pbs-help b/pbs-help
new file mode 100755
index 0000000..60d4270
--- /dev/null
+++ b/pbs-help
@@ -0,0 +1,39 @@
+#!/bin/bash -euE
+
+. libremessages
+
+stem=pbs
+
+list_commands() {
+ find ${PATH//:/ } -type f -executable -name "$stem-*" \
+ -printf '%f\n' 2>/dev/null | sed "s/^${stem}-//;/--/d"
+}
+
+master_usage() {
+ echo "Usage: ${pbs_short:-${stem}} COMMAND [OPTIONS]"
+ echo
+ echo "Commands:"
+ list_commands | sed 's/^/ /'
+}
+
+help_usage() {
+ echo "Usage: ${pbs_short:-${stem}} help [OPTIONS] COMMAND"
+ echo "Shows the manual page for a command"
+ echo ''
+ echo 'Options:'
+ echo ' -h Show this message'
+}
+
+main() {
+ if [[ $# < 1 ]]; then
+ master_usage
+ else
+ if in_array '-h' "$@"; then
+ help_usage
+ else
+ man "$stem-$1"
+ fi
+ fi
+}
+
+main "$@"
diff --git a/pbs.in b/pbs.in
new file mode 100755
index 0000000..bf7cc27
--- /dev/null
+++ b/pbs.in
@@ -0,0 +1,21 @@
+#!/bin/bash
+
+if [[ -z PBS_PATH ]]; then
+ export PBS_PATH=@pbs-bindir@
+fi
+
+if [[ -z "$pbs_cmd" ]]; then
+ export pbs_cmd=$0
+ export pbs_short=${pbs_cmd##*/}
+ export PATH="$PBS_PATH:$PATH"
+fi
+
+main() {
+ if [[ $# < 1 ]]; then
+ pbs-help
+ return 1
+ fi
+ pbs-"$@"
+}
+
+main "$@"