From 57030343bac8c2ba89a59e02e5fbb2a415fe1668 Mon Sep 17 00:00:00 2001
From: Mikolaj Izdebski <mizdebsk@redhat.com>
Date: Mon, 30 Nov 2020 18:43:43 +0100
Subject: [PATCH] Make package layout more easily configurable

---
 javapackages-bootstrap.spec | 26 +++++++++++++++++---------
 1 file changed, 17 insertions(+), 9 deletions(-)

diff --git a/javapackages-bootstrap.spec b/javapackages-bootstrap.spec
index e1e3df7..dc0e79a 100644
--- a/javapackages-bootstrap.spec
+++ b/javapackages-bootstrap.spec
@@ -6,6 +6,11 @@
 %global         __requires_exclude_from \\.jar$
 %global         __provides_exclude_from \\.jar$
 
+%global mavenHomePath %{_datadir}/%{name}
+%global metadataPath %{mavenHomePath}/maven-metadata
+%global artifactsPath %{_javadir}
+%global launchersPath %{mavenHomePath}/bin
+
 Name:           javapackages-bootstrap
 Version:        1.0.0
 Release:        1%{?dist}
@@ -312,25 +317,26 @@ export LC_ALL=C.utf8
 
 %install
 ./mbi.j dist \
+  -basePackageName=%{name} \
   -installRoot=%{buildroot} \
-  -mavenHomePath=%{_datadir}/%{name} \
-  -metadataPath=%{_datadir}/%{name}/maven-metadata \
-  -artifactsPath=%{_javadir}/%{name} \
-  -launchersPath=%{_datadir}/%{name}/bin \
+  -mavenHomePath=%{mavenHomePath} \
+  -metadataPath=%{metadataPath} \
+  -artifactsPath=%{artifactsPath} \
+  -launchersPath=%{launchersPath} \
 
 # fix permissions
 for f in mvn mvnDebug mvnyjp
 do
-  chmod +x "%{buildroot}%{_datadir}/%{name}/bin/${f}"
+  chmod +x "%{buildroot}%{mavenHomePath}/bin/${f}"
 done
 
 for f in ant cup jflex xmvn-install xmvn-resolve xmvn-subst
 do
-  chmod g-w "%{buildroot}%{_datadir}/%{name}/bin/${f}"
+  chmod g-w "%{buildroot}%{launchersPath}/${f}"
 done
 
 # remove zero-size files
-find %{buildroot}%{_javadir}/%{name} -type f -size 0 -delete
+find %{buildroot}%{artifactsPath} -type f -size 0 -delete
 
 # install license files
 license_directory="%{buildroot}%{_licensedir}/%{name}"
@@ -401,8 +407,10 @@ install_license xbean NOTICE
 install_license xmvn NOTICE
 
 %files
-%{_datadir}/%{name}
-%{_javadir}/%{name}/*
+%{mavenHomePath}
+%{metadataPath}/*
+%{artifactsPath}/*
+%{launchersPath}/*
 
 %license %{_licensedir}/%{name}
 %doc README.md