diff options
author | Luke Shumaker <LukeShu@sbcglobal.net> | 2012-09-27 14:42:10 -0400 |
---|---|---|
committer | Luke Shumaker <LukeShu@sbcglobal.net> | 2012-09-27 14:42:10 -0400 |
commit | c3d8da0e89d3f2213933ff85dc0cca7d829442ed (patch) | |
tree | 967259a8338aa703195b94a9d5131c00545b0f3a |
Initial commit
-rw-r--r-- | .gitignore | 3 | ||||
-rw-r--r-- | Makefile | 24 | ||||
-rw-r--r-- | jh-.help.txt | 0 | ||||
-rw-r--r-- | jh-help.sh | 8 | ||||
-rw-r--r-- | jh-mvn-basename.help.txt | 7 | ||||
-rw-r--r-- | jh-mvn-basename.sh | 18 | ||||
-rw-r--r-- | jh-mvn-install.help.txt | 9 | ||||
-rw-r--r-- | jh-mvn-install.sh | 16 | ||||
-rw-r--r-- | jh-mvn-localrepo.help.txt | 6 | ||||
-rw-r--r-- | jh-mvn-localrepo.sh | 9 | ||||
-rw-r--r-- | jh.sh | 39 |
11 files changed, 139 insertions, 0 deletions
diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..74b7ae0 --- /dev/null +++ b/.gitignore @@ -0,0 +1,3 @@ +* +!Makefile +!*.* diff --git a/Makefile b/Makefile new file mode 100644 index 0000000..b8971b4 --- /dev/null +++ b/Makefile @@ -0,0 +1,24 @@ +subcommands = help mvn-basename mvn-install mvn-localrepo + +#### + +subcommand_files = $(addprefix jh-,$(subcommands)) +help_files = $(addsuffic .help.,jh- $(subcommands)) + +all: PHONY build + +#### + +build: PHONY jh $(subcommand_files) $(help_files) +install: $(DESTDIR)/usr/bin/jh $(addprefix $(DESTDIR)/usr/share/jh/,$(subcommand_files) $(help_files)) + +$(DESTDIR)/usr/share/jh/%: % + cp '$<' '$@' + +$(DESTDIR)/usr/bin/jh: jh + cp '$<' '$@' + +#### + +.PHONY: PHONY FORCE +PHONY FORCE: ; @: diff --git a/jh-.help.txt b/jh-.help.txt new file mode 100644 index 0000000..e69de29 --- /dev/null +++ b/jh-.help.txt diff --git a/jh-help.sh b/jh-help.sh new file mode 100644 index 0000000..a88206c --- /dev/null +++ b/jh-help.sh @@ -0,0 +1,8 @@ +#!/bin/bash +. /usr/bin/jh + +case $# in + 0) usage ''; exit 0;; + 1) usage "$1"; exit 0;; + *) usage help; exit 1;; +esac diff --git a/jh-mvn-basename.help.txt b/jh-mvn-basename.help.txt new file mode 100644 index 0000000..acffdf5 --- /dev/null +++ b/jh-mvn-basename.help.txt @@ -0,0 +1,7 @@ +Usage: @cmd@ mvn-basename <groupId> <artifactId> <version> + +Prints the directory and basename of file for a Maven artifact. + +Example: + $ @cmd@ mvn-basename junit junit-dep 4.10 + /usr/share/maven/repository/junit/junit-dep/4.10/junit-dep-4.10 diff --git a/jh-mvn-basename.sh b/jh-mvn-basename.sh new file mode 100644 index 0000000..7c1d8a1 --- /dev/null +++ b/jh-mvn-basename.sh @@ -0,0 +1,18 @@ +#!/bin/bash +. /usr/bin/jh + +if [[ $# != 3 ]]; then + usage + exit 1 +fi + +mvn_repo="`$jh_cmd mvn-localrepo`" + +mvn_groupId=$0 +mvn_artifactId=$1 +mvn_version=$2 + +dir="${mvn_repo}/${mvn_groupId}/${mvn_artifactId}/${mvn_version}" +file="${mvn_artifactId}-${mvn_version}" + +echo "${dir}/${file}" diff --git a/jh-mvn-install.help.txt b/jh-mvn-install.help.txt new file mode 100644 index 0000000..aa3c16d --- /dev/null +++ b/jh-mvn-install.help.txt @@ -0,0 +1,9 @@ +Usage: @cmd@ mvn-install <groupId> <artifactId> <version> <jar-file> <pom-file> + +Installs an artifact into the local Maven 2 repository. + +This command obeys the DESTDIR environmental variable. + +Example: + $ @cmd@ mvn-install junit junit-dep 4.10 \ + /path/to/junit-dep.jar /path/to/junit-dep.pom diff --git a/jh-mvn-install.sh b/jh-mvn-install.sh new file mode 100644 index 0000000..84b0fc4 --- /dev/null +++ b/jh-mvn-install.sh @@ -0,0 +1,16 @@ +#!/bin/bash +. /usr/bin/jh + +if [[ $# != 5 ]]; then + usage + exit 1 +fi + +base="`$jh_cmd mvn-basename $1 $2 $3" +jarfile=$3 +pomfile=$4 + +dir="${base%/*}" +install -d "${DESTDIR}${dir}" +install -m 644 "$jarfile" "${DESTDIR}${base}.jar" +install -m 644 "$pomfile" "${DESTDIR}${base}.pom" diff --git a/jh-mvn-localrepo.help.txt b/jh-mvn-localrepo.help.txt new file mode 100644 index 0000000..3887916 --- /dev/null +++ b/jh-mvn-localrepo.help.txt @@ -0,0 +1,6 @@ +Usage: @cmd@ mvn-localrepo + +Prints the configured localRepository for Maven + +Warning: This is configured from /etc; if it has been changed from the + default it will alter how packages are built. diff --git a/jh-mvn-localrepo.sh b/jh-mvn-localrepo.sh new file mode 100644 index 0000000..a126613 --- /dev/null +++ b/jh-mvn-localrepo.sh @@ -0,0 +1,9 @@ +#!/bin/bash +. /usr/bin/jh + +if [[ $# > 0 ]]; then + usage + exit 1 +fi + +xml sel -T -t -v "//*[local-name()='localRepository']" -n /etc/maven/settings.xml @@ -0,0 +1,39 @@ +#!/bin/bash + +if [[ -z "$jh_cmd" ]]; then + export jh_cmd=$0 +fi +export jh_short=${jh_cmd##*/} + +if [[ -z "$JH_PATH" ]]; then + export JH_PATH=/usr/share/jh +fi + +usage() { + cmd="${1-$0}" + file="$JH_PATH/jh-$cmd.help.txt" + if [[ -f "$JH_PATH/jh-$cmd.help.txt" ]]; then + sed "s|@cmd@|$jh_short|g" "$file" >> /dev/stderr + else + echo "$jh_short: Cannot find help file for '$cmd'" >> /dev/stderr + fi +} + +run() { + if [[ $# < 1 ]]; then + usage '' + exit 1; + fi + cmd=$1 + shift + + file="$JH_PATH/jh-$cmd" + if [[ -x "$file" ]]; then + "$file" "$@" + exit $? + else + echo "$jh_short: Cannot find command '$cmd'" >> /dev/stderr + fi +} + +[[ "$jh_cmd" == "$0" ]] && run "$@" |