From c3d8da0e89d3f2213933ff85dc0cca7d829442ed Mon Sep 17 00:00:00 2001 From: Luke Shumaker Date: Thu, 27 Sep 2012 14:42:10 -0400 Subject: Initial commit --- .gitignore | 3 +++ Makefile | 24 ++++++++++++++++++++++++ jh-.help.txt | 0 jh-help.sh | 8 ++++++++ jh-mvn-basename.help.txt | 7 +++++++ jh-mvn-basename.sh | 18 ++++++++++++++++++ jh-mvn-install.help.txt | 9 +++++++++ jh-mvn-install.sh | 16 ++++++++++++++++ jh-mvn-localrepo.help.txt | 6 ++++++ jh-mvn-localrepo.sh | 9 +++++++++ jh.sh | 39 +++++++++++++++++++++++++++++++++++++++ 11 files changed, 139 insertions(+) create mode 100644 .gitignore create mode 100644 Makefile create mode 100644 jh-.help.txt create mode 100644 jh-help.sh create mode 100644 jh-mvn-basename.help.txt create mode 100644 jh-mvn-basename.sh create mode 100644 jh-mvn-install.help.txt create mode 100644 jh-mvn-install.sh create mode 100644 jh-mvn-localrepo.help.txt create mode 100644 jh-mvn-localrepo.sh create mode 100644 jh.sh 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 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 + +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 + +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 diff --git a/jh.sh b/jh.sh new file mode 100644 index 0000000..a7c25a9 --- /dev/null +++ b/jh.sh @@ -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 "$@" -- cgit v1.2.3-54-g00ecf