commit: 1b456bef3c706d1cc9e26bc237a5bbba365e2907
Author: Benda Xu <heroxbd <AT> gentoo <DOT> org>
AuthorDate: Thu Oct 6 04:29:20 2016 +0000
Commit: Michał Górny <mgorny <AT> gentoo <DOT> org>
CommitDate: Thu Oct 6 04:47:19 2016 +0000
URL: https://gitweb.gentoo.org/proj/java-ebuilder.git/commit/?id=1b456bef
meta.sh also use configuration file, create movl wrapper script.
README | 22 +++----------------
java-ebuilder.conf | 7 ++++++
maven.conf | 2 ++
scripts/meta.sh | 11 +++++-----
scripts/movl | 62 ++++++++++++++++++++++++++++++++++++++++++++++++++++++
5 files changed, 80 insertions(+), 24 deletions(-)
diff --git a/README b/README
index e74f482..febc04d 100644
--- a/README
+++ b/README
@@ -1,23 +1,7 @@
Java team tool for semi-automatic creation of ebuilds from pom.xml.
-Use example:
+1. Edit /etc/java-ebuilder.conf to add the artifact you want to MAVEN_ARTS,
separated by space.
-1. Generate cache of java related packages from portage tree.
-java-ebuilder --refresh-cache -t /usr/portage
-
-2. Find corresponding maven groupId, artifactId and version in the cache.
-cd $HOME/.java-ebuilder
-mv cache cache.raw0
-( echo 1.0; tail -n +2 cache.raw0 | parallel -j -2 scripts/meta.sh; ) > cache.0
-
-3. Generate cache of java related packages from java overaly.
-java-ebuilder --refresh-cache -t /var/lib/layman/java
-
-4. Find corresponding maven groupId, artifactId and version in the cache.
-cd $HOME/.java-ebuilder
-mv cache cache.raw1
-( echo 1.0; tail -n +2 cache.raw1 | parallel -j -2 scripts/meta.sh; ) > cache.1
-
-5. Create ebuild recursively.
-script/tree.sh org.apache.spark:spark-core_2.11:2.0.0
+2. Run `movl build`
+To start over, run `movl clean` first.
diff --git a/java-ebuilder.conf b/java-ebuilder.conf
new file mode 100644
index 0000000..1bf7e33
--- /dev/null
+++ b/java-ebuilder.conf
@@ -0,0 +1,7 @@
+PORTDIR=/usr/portage
+PORTAGE_TMPDIR=/var/tmp
+# JAVA_OVERLAY_DIR=/var/lib/layman/java
+POMDIR=/var/lib/java-ebuilder/poms
+MAVEN_OVERLAY_DIR=/var/lib/java-ebuilder/maven
+CACHEDIR=/var/lib/java-ebuilder/cache
+# MAVEN_ARTS="org.apache.spark:spark-core_2.11:2.0.0"
diff --git a/maven.conf b/maven.conf
new file mode 100644
index 0000000..7621417
--- /dev/null
+++ b/maven.conf
@@ -0,0 +1,2 @@
+[maven]
+location = /var/lib/java-ebuilder/maven
diff --git a/scripts/meta.sh b/scripts/meta.sh
index 4917098..10c317f 100755
--- a/scripts/meta.sh
+++ b/scripts/meta.sh
@@ -2,15 +2,15 @@
# read in cache from java-ebuilder and find out the groupId,
# artifactId and version.
-# cache is by default at $HOME/.java-ebuilder/cache
# example:
# ( echo 1.0; tail -n +2 cache | parallel -j -2 meta.sh; ) > cache.1
+source /etc/java-ebuilder.conf
pkg=$(awk -F ":" '{print $1"/"$2"-"$3}' <<< $1)
spkg=$(cut -d: -f2 <<< $1)
sver=$(cut -d: -f3 <<< $1)
case ${spkg} in
- guava)
+ guava)
echo $1:com.google.guava:${spkg}:${sver%%-*}
exit 0
;;
@@ -70,6 +70,7 @@ case ${spkg} in
exit 0
esac
+touch bebd bpom
grep -q ${pkg} <bebd <bpom && exit 0
ebd=$(equery w ${pkg} 2>/dev/null)
@@ -81,13 +82,13 @@ fi
# java-utils-2.eclass:java-pkg_needs-vm()
export JAVA_PKG_NV_DEPEND="nothing"
-if ! ebuild ${ebd} unpack >/dev/null 2>&1; then
+if ! ebuild "${ebd}" unpack >/dev/null 2>&1; then
echo $1:${pkg} >> bebd
exit 0
fi
bad_pom="yes"
-for subd in /dev/shm/portage/${pkg}/work/*; do
+for subd in "${PORTAGE_TMPDIR}"/portage/${pkg}/work/*; do
[[ -f ${subd}/pom.xml ]] || continue
bad_pom=""
pushd ${subd} > /dev/null
@@ -107,4 +108,4 @@ if [[ -n "${bad_pom}" ]]; then
echo $1:${pkg} >> bpom
fi
-ebuild ${ebd} clean >/dev/null 2>&1
+ebuild "${ebd}" clean >/dev/null 2>&1
diff --git a/scripts/movl b/scripts/movl
new file mode 100755
index 0000000..c2f7c0d
--- /dev/null
+++ b/scripts/movl
@@ -0,0 +1,62 @@
+#!/usr/bin/env bash
+source /etc/java-ebuilder.conf
+
+clean-maven() {
+ rm -f "${CACHEDIR}"/maven-cache
+ rm -rf "${MAVEN_OVERLAY_DIR}"/app-maven
+}
+
+clean-pom() {
+ rm -f "${POMDIR}"/*.pom
+}
+
+clean-cache() {
+ rm -f "${CACHEDIR}"/cache.{raw,}{0,1}
+ rm -f "${CACHEDIR}"/b{ebd,pom}
+}
+
+clean() {
+ clean-cache
+ clean-pom
+ clean-maven
+}
+
+build() {
+ if [[ ! -f "${CACHEDIR}"/cache.0 ]]; then
+ # 1. Generate cache of java related packages from portage tree.
+ [[ -f "${CACHEDIR}"/cache.raw0 ]] || \
+ java-ebuilder --refresh-cache -t "${PORTDIR}" --cache-file
"${CACHEDIR}"/cache.raw0
+
+ # 2. Find corresponding maven groupId, artifactId and version in the
cache.
+ pushd "${CACHEDIR}" > /dev/null
+ ( echo 1.0; tail -n +2 cache.raw0 | parallel -j -1
/usr/lib/java-ebuilder/meta.sh; ) > cache.0
+ popd > /dev/null
+ fi
+
+ # do the same to java overlay
+ if [[ ! -f "${CACHEDIR}"/cache.1 ]]; then
+ if [[ -n "${JAVA_OVERLAY_DIR}" ]]; then
+ [[ -f "${CACHEDIR}"/cache.raw1 ]] || \
+ java-ebuilder --refresh-cache -t "${JAVA_OVERLAY_DIR}"
--cache-file "${CACHEDIR}"/cache.raw1
+ pushd "${CACHEDIR}" > /dev/null
+ tail -n +2 cache.raw1 | parallel -j -1 scripts/meta.sh > cache.1
+ popd > /dev/null
+ else
+ touch "${CACHEDIR}"/cache.1
+ fi
+ fi
+
+ for M in ${MAVEN_ARTS}; do
+ /usr/lib/java-ebuilder/tree.sh ${M}
+ done
+}
+
+if [[ $# -gt 0 ]]; then
+ funcs=$@
+else
+ funcs=build
+fi
+
+for func in ${funcs}; do
+ ${func}
+done