Initial import of Jigawatts for RHEL 9.

Rewrite to use autotools build system, avoiding need for Maven dependencies missing in RHEL 9.
This also ensures use of the standard build flags and installs the jar in the expected location.

Resolves: rhbz#1972029
This commit is contained in:
Andrew Hughes 2021-08-16 18:23:30 +01:00
parent e86d2e89b7
commit c368530e92
4 changed files with 152 additions and 0 deletions

1
.gitignore vendored
View File

@ -0,0 +1 @@
/e814e2f0a9390b19a4073b074d43de8a0d121b8d.zip

92
jigawatts.spec Normal file
View File

@ -0,0 +1,92 @@
%global uname jigawatts
%global uversion e814e2f0a9390b19a4073b074d43de8a0d121b8d
%global dversion %(echo %{uversion} | sed s/-/_/)
%global aarch64 aarch64 arm64 armv8
%global shortcommit %(c=%{uversion}; echo ${c:0:7})
%global commitdate 20210802
Name: %{uname}
Version: 0.2
Release: 0.3.%{commitdate}%{shortcommit}%{?dist}
Summary: Java CRIU helper
License: GPLv2 with exceptions
URL: https://github.com/chflood/%{uname}
Source0: https://github.com/gnu-andrew/jigawatts/archive/%{uversion}.zip
Patch0: load_library.patch
BuildRequires: java-devel
BuildRequires: criu-devel
BuildRequires: gcc
BuildRequires: gcc-c++
BuildRequires: autoconf
BuildRequires: automake
Requires: java-headless
# criu is only available on these architectures
# https://bugzilla.redhat.com/show_bug.cgi?id=902875
ExclusiveArch: x86_64 %{arm} ppc64le aarch64 s390x
%description
CRIU is a Linux utility that allows the checkpointing and restoring
of processes.You can read more about CRIU at criu.org. CRIU for
Java is a package which makes it more convenient to use CRIU from
Java.
%package javadoc
Summary: Javadoc for %{name}
%description javadoc
Javadoc for %{name}
%prep
%setup -q -n %{uname}-%{uversion}
%patch0 -p1
./autogen.sh
%build
%configure
make
%install
rm -rf $RPM_BUILD_ROOT
%make_install
%files
%dir %{_pkgdocdir}
%doc %{_pkgdocdir}/README.md
%dir %{_defaultlicensedir}/%{name}
%license %{_defaultlicensedir}/%{name}/LICENSE.md
%dir %{_javadir}/%{name}
%{_javadir}/%{name}/jigawatt.jar
%{_libdir}/libJigawatts.so
%files javadoc
%{_javadocdir}/%{name}
%changelog
* Mon Aug 02 2021 Andrew Hughes <gnu.andrew@redhat.com> - 0.2-0.3.20210802a3007aa
- Rewrite to use autotools build system, avoiding need for Maven dependencies missing in RHEL 9.
- This also ensures use of the standard build flags and installs the jar in the expected location.
- Resolves: rhbz#1972029
* Thu Jul 22 2021 Fedora Release Engineering <releng@fedoraproject.org> - 0.2-0.2.20210701c15dd4c
- Rebuilt for https://fedoraproject.org/wiki/Fedora_35_Mass_Rebuild
* Thu Jul 01 2021 Jiri Vanek <jvanek@redhat.com> - 0.2-0.1.20210701c15dd4c
- criu-devel moved to BR
- now requires criu-libs
- enabled debuginfo generation
- excluded i686 build as criu is 64b only
- .so file moved out of jar. Required teo patches:
- added and applied patch0 output_loc.patch
- added and applied patch1 load_library.patch
- on aarch64 workarounded missing lib64 on /usr/LD_LIBRARY_PATH
* Wed Apr 14 2021 Jiri Vanek <jvanek@redhat.com> - 0.2-0.1.20210701c15dd4c
- initial build
- added requires of criu-devel

58
load_library.patch Normal file
View File

@ -0,0 +1,58 @@
diff --git a/src/main/java/org/openjdk/jigawatts/Jigawatts.java b/src/main/java/org/openjdk/jigawatts/Jigawatts.java
index f2766da..8257eeb 100644
--- a/src/main/java/org/openjdk/jigawatts/Jigawatts.java
+++ b/src/main/java/org/openjdk/jigawatts/Jigawatts.java
@@ -150,38 +150,26 @@ public class Jigawatts {
return Collections.unmodifiableList(crContext.restoreHooks);
}
- private static void copyLibrary(String library, String destDir) throws IOException {
-
- String libraryName = System.mapLibraryName(library);
- String libraryFile = destDir + "/" + libraryName;
-
- try (InputStream is = Jigawatts.class.getClassLoader().getResourceAsStream(libraryName);
- FileOutputStream os = new FileOutputStream(libraryFile)) {
-
- byte[] buf = new byte[1024];
-
- int bytesRead;
-
- while ((bytesRead = is.read(buf)) > 0) {
- os.write(buf, 0, bytesRead);
+ private static void loadLib(String library) {
+ String criuLib = System.mapLibraryName(library);
+ boolean success = false;
+ for (String path: System.getProperty("java.library.path").split(":")) {
+ try {
+ String libPath = path + File.separator + criuLib;
+ System.load(libPath);
+ success = true;
+ break;
+ } catch (UnsatisfiedLinkError e) {
+ continue;
}
+ };
+ if (!success) {
+ throw new RuntimeException(library + " library not found!");
}
}
static {
-
- String libDir = System.getProperty("java.io.tmpdir");
- String tmpLib = libDir+ "/" + System.mapLibraryName("Jigawatts");
-
- if (!Files.exists(Paths.get(tmpLib))) {
- try {
- copyLibrary("Jigawatts", libDir);
- } catch (IOException ex) {
- throw new RuntimeException("can't initialize Jigawatts",ex);
- }
- }
- System.load(tmpLib);
- System.loadLibrary("criu");
+ loadLib("Jigawatts");
checkpointHooks = new ArrayList<Hook>();
restoreHooks = new ArrayList<Hook>();

1
sources Normal file
View File

@ -0,0 +1 @@
SHA512 (e814e2f0a9390b19a4073b074d43de8a0d121b8d.zip) = 5ca78cb7a923a97075be8c61bf017bce56d68c6fb9e132e6474ddc877fbb51e9ef46d03cc2d3b3353c4b9385af7a0684e65377f61b32e9812423b991ee5391cf