From 260111a914ba0f1d698c248e2f19001d43243cde Mon Sep 17 00:00:00 2001 From: Juliusz Sosinowicz Date: Wed, 19 Oct 2022 20:09:55 +0200 Subject: [PATCH] Initial rpm package support --- .gitignore | 4 ++++ makefile.linux | 51 ++++++++++++++++++++++++++++++++++++++++++++++++++ rpm/spec.in | 47 ++++++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 102 insertions(+) create mode 100644 rpm/spec.in diff --git a/.gitignore b/.gitignore index 3dc4ac6..ac6a1fc 100644 --- a/.gitignore +++ b/.gitignore @@ -9,3 +9,7 @@ docs/ # Code signing key/alias info file codeSigning.properties +# rpm package files +rpm/spec +*.rpm +wolfcrypt*.tar.gz diff --git a/makefile.linux b/makefile.linux index 2fe9ce4..3fb5918 100644 --- a/makefile.linux +++ b/makefile.linux @@ -2,6 +2,26 @@ OUT_PATH = lib SRC_PATH = jni INC_PATH = $(SRC_PATH)/include +NAME = wolfcrypt-jni +VERSION = $(shell grep 'name="implementation.version"' build.xml | sed -re 's/.*value="(.+)".*/\1/') + +ifneq ($(PREFIX),) + INSTALL_DIR = $(DESTDIR)$(PREFIX) +else + INSTALL_DIR = $(DESTDIR)/usr/local +endif + +ifeq ($(LIBDIR),) + LIBDIR=lib +endif + +ifeq ($(INSTALL),) + INSTALL=install +endif + +DIST_FILES = AUTHORS build.xml COPYING examples jni LICENSING makefile makefile.linux makefile.macosx \ + pom.xml README_JCE.md README.md rpm src + OBJ_LIST = jni_fips.o jni_native_struct.o jni_aes.o jni_des3.o jni_md5.o \ jni_sha.o jni_hmac.o jni_rng.o jni_rsa.o jni_dh.o jni_ecc.o \ jni_ed25519.o jni_curve25519.o jni_chacha.o jni_error.o jni_asn.o \ @@ -24,6 +44,37 @@ $(OUT_PATH)/%.o: $(SRC_PATH)/%.c @mkdir -p $(OUT_PATH) $(CC) $(CCFLAGS) -c -o $@ $< +dist: + mkdir -p "$(NAME)-$(VERSION)" + cp -pr $(DIST_FILES) "$(NAME)-$(VERSION)" + tar -zcf "$(NAME)-$(VERSION).tar.gz" "$(NAME)-$(VERSION)" + rm -rf "$(NAME)-$(VERSION)" + +rpm: dist + @env + @rm -f *.rpm + rpmdev-setuptree + find ~/rpmbuild/RPMS ~/rpmbuild/SRPMS -name "$(PACKAGE)-$(VERSION)*.rpm" | xargs rm -f + @cp "$(NAME)-$(VERSION).tar.gz" ~/rpmbuild/SOURCES/ + @cp rpm/spec.in rpm/spec + @sed -i rpm/spec -e "s/@NAME@/$(NAME)/g" + @sed -i rpm/spec -e "s/@VERSION@/$(VERSION)/g" + JUNIT_HOME=lib rpmbuild -ba --clean rpm/spec + @cp ~/rpmbuild/RPMS/*/$(NAME)-$(VERSION)*.rpm . + @cp ~/rpmbuild/SRPMS/$(NAME)-$(VERSION)*.rpm . + +lib/wolfcrypt-jni.jar: + ant build-jni-release + +install: all lib/wolfcrypt-jni.jar + $(INSTALL) -d $(INSTALL_DIR)/$(LIBDIR) + $(INSTALL) lib/libwolfcryptjni.so $(INSTALL_DIR)/$(LIBDIR) + $(INSTALL) lib/wolfcrypt-jni.jar $(INSTALL_DIR)/$(LIBDIR) + +uninstall: + rm -f $(INSTALL_DIR)/$(LIBDIR)/libwolfcryptjni.so + rm -f $(INSTALL_DIR)/$(LIBDIR)/wolfcrypt-jni.jar + .PHONY: clean clean: diff --git a/rpm/spec.in b/rpm/spec.in new file mode 100644 index 0000000..1ad169f --- /dev/null +++ b/rpm/spec.in @@ -0,0 +1,47 @@ +Name: @NAME@ +Version: @VERSION@ +Release: 1 +Summary: wolfCrypt JCE provider and JNI wrapper + +License: GPLv2 +URL: http://www.wolfssl.com/ +Source0: @NAME@-@VERSION@.tar.gz + +BuildRequires: ant + +# Don't add wolfSSL to dependency list. User may want to +# use a version outside of RPM. +%global __requires_exclude ^libwolfssl.*$ + + +%description +This package contains the libraries for %{name}. + +# Don't generate the debug sources +%define debug_package %{nil} + +%prep +%autosetup + + +%build +%make_build + + +%install +%make_install LIBDIR=%{_lib} PREFIX=%{_prefix} + +%clean +%{__rm} -rf %{buildroot} + + +%files +%{_libdir}/libwolfcryptjni.so +%{_libdir}/wolfcrypt-jni.jar + + + +%changelog +* Wed Oct 19 2022 Juliusz Sosinowicz +- Initial package +-