Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 7 additions & 2 deletions build
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,7 @@ expand macros.d/macros.jpackage
expand macros.d/macros.fjava
expand macros.d/macros.javapackages-compat
expand java-utils/java-functions
expand java-utils/jp_binding.sh
expand depgenerators/maven.req
expand depgenerators/maven.prov
expand depgenerators/osgi.req
Expand All @@ -76,8 +77,12 @@ expand depgenerators/fileattrs/osgi.attr
expand depgenerators/fileattrs/maven.attr
expand depgenerators/fileattrs/javadoc.attr

while IFS== read -d' ' id path; do
echo "%java_home ${path}" >target/macros.fjava-"${id}"
while IFS== read -d' ' java_id java_home; do
expand macros.d/macros.javapackages-binding target/macros.java-"${java_id}"
sed -i \
-e "s|@{java_id}|${java_id}|g" \
-e "s|@{java_home}|${java_home}|g" \
target/macros.java-"${java_id}"
done <<<"${jvms}"

manpage abs2rel
Expand Down
1 change: 1 addition & 0 deletions configure
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,7 @@ jvmprivdir
jvmsysconfdir
mavenpomdir
ivyxmldir
jpbindingdir
pyinterpreter
abrtlibdir
"
Expand Down
1 change: 1 addition & 0 deletions expand.sh
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@ expand()
-e "s|@{javadir}|${javadir}|g" \
-e "s|@{jnidir}|${jnidir}|g" \
-e "s|@{jvmdir}|${jvmdir}|g" \
-e "s|@{jpbindingdir}|${jpbindingdir}|g" \
-e "s|@{m2home}|${m2home}|g" \
-e "s|@{prefix}|${prefix}|g" \
-e "s|@{rundir}|${rundir}|g" \
Expand Down
8 changes: 5 additions & 3 deletions install
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,7 @@ dir "${jnidir}"
dir "${javadocdir}"
dir "${mavenpomdir}"
dir "${ivyxmldir}"
dir "${jpbindingdir}"
dir "${datadir}/maven-metadata"
dir "${prefix}/lib/eclipse"
dir "${prefix}/lib/eclipse/features"
Expand Down Expand Up @@ -125,6 +126,7 @@ inst_config target/eclipse.conf "${javaconfdir}"

inst_data target/java-functions "${javadir}-utils"
inst_exec java-utils/java-wrapper "${javadir}-utils"
inst_exec target/jp_binding.sh "${javadir}-utils"

inst_data target/macros.jpackage "${rpmmacrodir}"

Expand All @@ -138,9 +140,9 @@ inst_data target/find-jar.1 "${mandir}/man1"
inst_data configs/configuration.xml "${m2home}"


while IFS== read -d' ' id path; do
exec >files-local-"${id}"
inst_data target/macros.fjava-"${id}" "${rpmmacrodir}"
while IFS== read -d' ' java_id java_path; do
exec >files-local-"${java_id}"
inst_data target/macros.java-"${java_id}" "${rpmmacrodir}"
done <<<"${jvms}"


Expand Down
226 changes: 226 additions & 0 deletions java-utils/jp_binding.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,226 @@
#!/bin/sh
# Copyright (c) 2024, Red Hat, Inc.
#
# All rights reserved.
#
# Redistribution and use in source and binary forms, with or without
# modification, are permitted provided that the following conditions
# are met:
#
# 1. Redistributions of source code must retain the above copyright
# notice, this list of conditions and the following disclaimer.
# 2. Redistributions in binary form must reproduce the above copyright
# notice, this list of conditions and the following disclaimer in the
# documentation and/or other materials provided with the
# distribution.
# 3. Neither the name of the Red Hat nor the names of its
# contributors may be used to endorse or promote products derived
# from this software without specific prior written permission.
#
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
# A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
# OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
# SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
# LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
# DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
# THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
#
# Authors: Mikolaj Izdebski <mizdebsk@redhat.com>

set -eu
jpbindingdir="@{jpbindingdir}"

if [ -z "${RPM_BUILD_ROOT:-}" ]; then
echo RPM_BUILD_ROOT env variable has not been set >&2
exit 1
fi
if [ -z "${RPM_SPECPARTS_DIR:-}" ]; then
echo RPM_BUILD_ROOT env variable has not been set >&2
exit 1
fi

rpmname=""
basepkg=""
pkg=""
ghost=""
target=""
variant=""
provides=""
requires=""
recommends=""
with_meta_requires=true
description=""
with_description=true
summary=""
with_summary=true
with_files=true
with_package=true
with_install=true
verbose=false

while [ $# -gt 0 ]; do
case "$1" in
--rpm-name)
rpmname="$2"
shift
;;
--base-pkg)
basepkg="$2"
shift
;;
--binding-pkg)
pkg="$2"
shift
;;
--ghost)
ghost="$2"
shift
;;
--target)
target="$2"
shift
;;
--variant)
variant="$2"
shift
;;
--provides)
provides="${provides}
Provides: $2"
shift
;;
--requires)
requires="${requires}
Requires: $2"
shift
;;
--recommends)
recommends="${recommends}
Recommends: $2"
shift
;;
--no-meta-requires)
with_meta_requires=false
;;
--description)
description="$2"
shift
;;
--no-description)
with_description=false
;;
--summary)
summary="$2"
shift
;;
--no-summary)
with_summary=false
;;
--no-files)
with_files=false
;;
--no-package)
with_package=false
;;
--no-install)
with_install=false
;;
--verbose)
verbose=true
;;
*)
echo "Unknown option $1" >&2
exit 1
esac
shift
done

debug()
{
if ${verbose}; then
echo "$@" >&2
fi
}

if [ -z "${basepkg}" ]; then
if [ -n "${rpmname}" ]; then
basepkg="${rpmname}"
debug "Assuming default --base-pkg ${basepkg}"
else
echo "Missing required option --base-pkg" >&2
exit 1
fi
fi

if [ -z "${ghost}" ]; then
echo "Missing required option --ghost" >&2
exit 1
fi

if [ -z "${target}" ]; then
echo "Missing required option --target" >&2
exit 1
fi

if [ -z "${variant}" ]; then
echo "Missing required option --variant" >&2
exit 1
fi

if [ -z "${pkg}" ]; then
pkg="${basepkg}-${variant}"
debug "Assuming default --binding-pkg ${pkg}"
fi

if [ -z "${summary}" ]; then
summary="${basepkg} binding for ${variant}"
fi

if [ -z "${description}" ]; then
description="Configures ${basepkg} to work with ${variant}."
fi

sp=${RPM_SPECPARTS_DIR}/${pkg}.specpart
: >${sp}

if ${with_package}; then
echo "%package -n ${pkg}" >>${sp}
if ${with_summary}; then
echo "Summary: ${summary}" >>${sp}
fi
echo "${provides}" >>${sp}
echo "${requires}" >>${sp}
echo "${recommends}" >>${sp}
echo "Requires: javapackages-tools" >>${sp}
if ${with_meta_requires}; then
echo "Requires(meta): ${basepkg}" >>${sp}
fi
echo "" >>${sp}
fi

if ${with_description}; then
echo "%description -n ${pkg}" >>${sp}
echo "${description}" | fold >>${sp}
echo "" >>${sp}
fi

if ${with_files}; then
echo "%files -n ${pkg}" >>${sp}
echo "%ghost ${jpbindingdir}/${ghost}" >>${sp}
echo "%dir ${jpbindingdir}/${ghost}.d" >>${sp}
echo "${jpbindingdir}/${ghost}.d/${variant}" >>${sp}
fi

if ${verbose}; then
debug "Added the following package:"
sed 's/./ :: &/' ${sp} >&2
fi

if ${with_install}; then
install -d -m 755 ${RPM_BUILD_ROOT}${jpbindingdir}/${ghost}.d/
ln -sf ${target} ${RPM_BUILD_ROOT}${jpbindingdir}/${ghost}.d/${variant}
fi
41 changes: 33 additions & 8 deletions javapackages-tools.spec
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@

%global maven_home %{_usr}/share/xmvn

%global _jpbindingdir %{_datadir}/jpbinding

Name: javapackages-tools
Version: [...]
Release: %autorelease
Expand All @@ -19,8 +21,6 @@ BuildArch: noarch

Source: https://github.com/fedora-java/javapackages/archive/%{version}.tar.gz

Source21: toolchains-openjdk21.xml

BuildRequires: coreutils
BuildRequires: make
BuildRequires: rubygem-asciidoctor
Expand Down Expand Up @@ -48,12 +48,12 @@ install their content.

%package -n maven-local-openjdk21
Summary: Macros and scripts for Maven packaging support
RemovePathPostfixes: -openjdk21
Requires: java-21-openjdk-devel
Provides: maven-local = %{version}-%{release}
Requires: %{name} = %{version}-%{release}
Requires: javapackages-local-openjdk21 = %{version}-%{release}
Requires: xmvn-minimal
Requires: xmvn-toolchain-openjdk21
Requires: mvn(org.fedoraproject.xmvn:xmvn-mojo)
# Common Maven plugins required by almost every build. It wouldn't make
# sense to explicitly require them in every package built with Maven.
Expand Down Expand Up @@ -147,9 +147,6 @@ rm -rf %{buildroot}%{_sysconfdir}/ivy
rm -rf %{buildroot}%{_sysconfdir}/ant.d
%endif

mkdir -p %{buildroot}%{maven_home}/conf/
cp -p %{SOURCE21} %{buildroot}%{maven_home}/conf/toolchains.xml-openjdk21

%if 0%{?flatpak}
# make both /app (runtime deps) and /usr (build-only deps) builds discoverable
sed -e '/^JAVA_LIBDIR=/s|$|:/usr/share/java|' \
Expand All @@ -170,6 +167,36 @@ ln -s %{_datadir}/java-utils %{buildroot}%{_usr}/share/java-utils
%check
./check

%transfiletriggerin -- %{_jpbindingdir}
shopt -s nullglob
grep -E '^%{_jpbindingdir}/.*\.d/' | sed 's|%{_jpbindingdir}/\(.*\)/\(.*\)|\1 \2|' | while read dir tgt; do
lnk=${dir/%.d}
ln -sf "$dir/$tgt" %{_jpbindingdir}/"$lnk"
done

%transfiletriggerun -- %{_jpbindingdir}
shopt -s nullglob
grep -E '^%{_jpbindingdir}/.*\.d/' | sed 's|%{_jpbindingdir}/\(.*\)/\(.*\)|\1 \2|' | while read dir tgt; do
lnk=${dir/%.d}
was=$(readlink %{_jpbindingdir}/"$lnk" || :)
if [[ "$was" = "$dir/$tgt" ]]; then
unlink %{_jpbindingdir}/"$lnk"
fi
done

%transfiletriggerpostun -- %{_jpbindingdir}
shopt -s nullglob
for bindd in %{_jpbindingdir}/*.d/; do
lnk=${bindd/%.d\/}
if ! [[ -e "$lnk" ]]; then
for ftgt in "$bindd"*; do
tgt=$(realpath -m -s --relative-to=%{_jpbindingdir} "$ftgt")
ln -sf "$tgt" "$lnk"
break
done
fi
done

%files -f files-tools
%if 0%{?flatpak}
%{_usr}/bin/build-classpath
Expand All @@ -185,8 +212,6 @@ ln -s %{_datadir}/java-utils %{buildroot}%{_usr}/share/java-utils
%files -n javapackages-local-openjdk21 -f files-local-openjdk21

%files -n maven-local-openjdk21
%dir %{maven_home}/conf
%{maven_home}/conf/toolchains.xml-openjdk21

%if %{with ivy}
%files -n ivy-local -f files-ivy
Expand Down
2 changes: 2 additions & 0 deletions macros.d/macros.javapackages-binding
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
# Home directory for Java @{java_id}
%java_home @{java_home}
6 changes: 6 additions & 0 deletions macros.d/macros.javapackages-filesystem
Original file line number Diff line number Diff line change
Expand Up @@ -80,3 +80,9 @@
# Directory for Ivy XML files
#
%_ivyxmldir %{_datadir}/ivy-xmls

#
# Directory containing binding symlinks
# EXPERIMENTAL, subject to change or removal
#
%_jpbindingdir %{_datadir}/jpbinding
Loading