distro FEATURE apkg-powered upstream rpm packaging
Using this .spec file originally provided by Martin Winter with some
modifications and apkg magic, I'm able to build both source package
libyang2-2.0.0.9.gf60c0dbf-1.fc34.src.rpm
and native RPM packages
libyang2-2.0.0.9.gf60c0dbf-1.fc34.x86_64.rpm
libyang2-devel-2.0.0.9.gf60c0dbf-1.fc34.x86_64.rpm
libyang2-tools-2.0.0.9.gf60c0dbf-1.fc34.x86_64.rpm
libyang2-debuginfo-2.0.0.9.gf60c0dbf-1.fc34.x86_64.rpm
libyang2-debugsource-2.0.0.9.gf60c0dbf-1.fc34.x86_64.rpm
libyang2-tools-debuginfo-2.0.0.9.gf60c0dbf-1.fc34.x86_64.rpm
by running
apkg build -i
on this commit. It should work on any RPM-based distro including SUSE.
I was able to install resulting packages on each testing system.
I've tested this on:
* Fedora 33 VM
* Fedora 34 docker container (fedora:34)
* openSUSE 15 docker container (opensuse/leap)
distro/README.md contains (3 lines of) instructions on howto test this
using apkg in a VM/container/machine of your choice.
diff --git a/distro/pkg/rpm/libyang2.spec b/distro/pkg/rpm/libyang2.spec
new file mode 100644
index 0000000..7fc3cd0
--- /dev/null
+++ b/distro/pkg/rpm/libyang2.spec
@@ -0,0 +1,87 @@
+Name: libyang2
+Version: {{ version }}
+Release: {{ release }}%{?dist}
+Summary: YANG data modeling language library
+Url: https://github.com/CESNET/libyang
+Source: libyang-%{version}.tar.gz
+License: BSD-3-Clause
+
+BuildRequires: cmake
+BuildRequires: doxygen
+BuildRequires: gcc
+BuildRequires: libcmocka-devel
+BuildRequires: make
+BuildRequires: pcre2-devel
+
+%if "x%{?suse_version}" == "x"
+Requires: pcre2
+%else
+Requires: libpcre2-posix2
+%endif
+
+%package -n libyang2-devel
+Summary: Headers of libyang library
+Conflicts: libyang-devel
+Requires: %{name} = %{version}-%{release}
+Requires: pcre2-devel
+
+%package -n libyang2-tools
+Summary: Helper Tools and examples for libyang library
+Conflicts: libyang
+Provides: libyang-tools
+Requires: %{name} = %{version}-%{release}
+
+%description -n libyang2-devel
+Headers of libyang library.
+
+%description -n libyang2-tools
+Helper Tools and examples for libyang library.
+
+%description
+libyang is a YANG data modelling language parser and toolkit
+written (and providing API) in C.
+
+%prep
+%setup -n libyang-%{version}
+mkdir build
+
+%build
+cd build
+cmake -DCMAKE_INSTALL_PREFIX:PATH=/usr \
+ -DCMAKE_BUILD_TYPE:String="Release" \
+ -DCMAKE_C_FLAGS="${RPM_OPT_FLAGS}" \
+ -DCMAKE_CXX_FLAGS="${RPM_OPT_FLAGS}" \
+ ..
+make
+
+%check
+cd build
+ctest --output-on-failure
+
+%install
+cd build
+make DESTDIR=%{buildroot} install
+
+%post -p /sbin/ldconfig
+
+%postun -p /sbin/ldconfig
+
+%files
+%defattr(-,root,root)
+%{_libdir}/libyang.so.2*
+
+%files -n libyang2-devel
+%defattr(-,root,root)
+%{_libdir}/libyang.so
+%{_libdir}/pkgconfig/libyang.pc
+%{_includedir}/libyang/*.h
+%dir %{_includedir}/libyang/
+
+%files -n libyang2-tools
+%{_bindir}/yanglint
+%{_bindir}/yangre
+%{_mandir}/man1/yanglint.1.gz
+
+%changelog
+* Fri Apr 30 2021 Jakub Ružička <jakub.ruzicka@nic.cz> - {{ version }}-{{ release }}
+- upstream package