Paul Bichis has uploaded this change for review. (
https://gerrit.osmocom.org/c/libosmo-abis/+/40833?usp=email )
Change subject: Create rpm make targets and add libosmo-abis.spec.in
......................................................................
Create rpm make targets and add libosmo-abis.spec.in
Change-Id: I86c2c621887d1d9352f3ddfa1270c1379cf50fd9
---
M Makefile.am
A contrib/libosmo-abis.spec.in
2 files changed, 196 insertions(+), 0 deletions(-)
git pull ssh://gerrit.osmocom.org:29418/libosmo-abis refs/changes/33/40833/1
diff --git a/Makefile.am b/Makefile.am
index 790d055..054465e 100644
--- a/Makefile.am
+++ b/Makefile.am
@@ -20,8 +20,102 @@
EXTRA_DIST = \
.version \
README.md \
+ contrib/libosmo-abis.spec.in \
debian \
git-version-gen \
$(NULL)
@RELMAKE@
+
+# RPM packaging support with proper Git version handling
+EXTRA_DIST += contrib/libosmo-abis.spec
+
+# Git version variables
+PKGNAME := libosmo-abis
+VERSION := 1.6
+RELEASE := 1
+TARNAME := $(PKGNAME)-$(VERSION)-$(RELEASE)
+TARFILE := $(TARNAME).tar.gz
+SRPMDIR := $(HOME)/rpmbuild/SRPMS
+GITTAG := $(shell LANG=C LC_MESSAGES=C git tag 2>/dev/null | tail -n 1)
+GIT_HASH := $(shell LANG=C LC_MESSAGES=C git rev-list -n1 HEAD 2>tmp.txt)
+GIT_ERR := $(shell LANG=C LC_MESSAGES=C cat tmp.txt 2>/dev/null; rm -f tmp.txt
2>/dev/null )
+SUFFIX :=
+RPMOPT :=
+
+.PHONY: rpm srpm rpm-clean tarball check-gittag check-githash srpm-git build-git
build-srpm rpm-head srpm-head
+
+tarball: clean
+ @echo "Creating tarball..."
+ @mkdir -p tarballs
+ @wd=`pwd|sed 's,^.*/,,'`; \
+ mkdir -p tarballs; cd ..; \
+ find $$wd -name .git >>$$wd/tarballs/tar-exclude; \
+ find $$wd -name '.gitignore' >>$$wd/tarballs/tar-exclude; \
+ find $$wd -name '*~' >>$$wd/tarballs/tar-exclude; \
+ find $$wd -name '*.o' >>$$wd/tarballs/tar-exclude; \
+ find $$wd -name '*.lo' >>$$wd/tarballs/tar-exclude; \
+ find $$wd -name '.libs' >>$$wd/tarballs/tar-exclude; \
+ find $$wd -name '.deps' >>$$wd/tarballs/tar-exclude; \
+ tar czf $$wd/tarballs/$(TARFILE) --exclude $$wd/Makefile.local --exclude $$wd/tarballs
-X $$wd/tarballs/tar-exclude --transform "s,^$$wd,$(PKGNAME)-$(VERSION)," $$wd;
\
+ rm $$wd/tarballs/tar-exclude; \
+ echo "Created tarballs/$(TARFILE)"
+
+rpm: tarball
+ rpmbuild -tb --define 'tarname $(TARNAME)' --define 'revision $(if
$(SUFFIX),$(SUFFIX),%{nil})' $(RPMOPT) tarballs/$(TARFILE)
+
+srpm: tarball
+ rpmbuild -ta --define 'tarname $(TARNAME)' --define 'revision $(if
$(SUFFIX),$(SUFFIX),%{nil})' $(RPMOPT) tarballs/$(TARFILE)
+
+# build packages from GIT HEAD
+rpm-head: check-githash tarball
+ rpmbuild -tb --define 'tarname $(TARNAME)' --define 'revision
_$(GIT_HASH)git' $(RPMOPT) tarballs/$(TARFILE)
+
+srpm-head: check-githash tarball
+ rpmbuild -ta --define 'tarname $(TARNAME)' --define 'revision
_$(GIT_HASH)git' $(RPMOPT) tarballs/$(TARFILE)
+
+# build packages with tagged version
+srpm-git: check-gittag tarball
+ rpmbuild -ta --define 'tarname $(TARNAME)' --define 'revision
_t$(GITTAG)$(SUFFIX)' $(RPMOPT) tarballs/$(TARFILE)
+
+check-gittag: check-githash
+ @tag_hash=""; \
+ if [ "" != "$(GITTAG)" ]; then \
+ tag_hash=`LANG=C LC_MESSAGES=C git rev-list -n1 $(GITTAG) 2>/dev/null`; \
+ else \
+ echo "No available GIT tag"; \
+ exit 1; \
+ fi; \
+ if [ "x$(GIT_HASH)" != "x$$tag_hash" ]; then \
+ echo "Current commit hash $(GIT_HASH) different from expected hash for tag
$(GITTAG) ($$tag_hash)"; \
+ exit 1; \
+ fi;
+
+check-githash:
+ @if [ "x" = "x$(GIT_HASH)" ]; then \
+ echo "Could not obtain last GIT commit hash. GIT Error:"; \
+ echo "$(GIT_ERR)"; \
+ exit 1; \
+ fi;
+
+build-git: check-gittag
+ @for f in "$(SRPMDIR)/$(TARNAME)_t$(GITTAG)$(SUFFIX)."*.src.rpm ; do \
+ if [ -s "$$f" ]; then \
+ echo "Already having $$f"; \
+ exit; \
+ fi \
+ done ; \
+ $(MAKE) srpm-git
+
+build-srpm:
+ @for f in "$(SRPMDIR)/$(TARNAME)$(SUFFIX)."*.src.rpm ; do \
+ if [ -s "$$f" ]; then \
+ echo "Already having $$f"; \
+ exit; \
+ fi \
+ done ; \
+ $(MAKE) srpm
+
+rpm-clean:
+ @echo "Cleaning RPM build directories..."
+ @rm -rf rpm tarballs tmp.txt
diff --git a/contrib/libosmo-abis.spec.in b/contrib/libosmo-abis.spec.in
new file mode 100644
index 0000000..56e1a0c
--- /dev/null
+++ b/contrib/libosmo-abis.spec.in
@@ -0,0 +1,102 @@
+# libosmo-abis.spec
+
+%{!?dist:%define dist %{?distsuffix:%distsuffix%{?product_version}}}
+%{!?distribution: %define distribution %(sed -E 's/ Linux release / /'
/etc/redhat-release)}
+%define systemd %(test -x /usr/bin/systemctl && echo 1 || echo 0)
+%{!?_unitdir:%define _unitdir /usr/lib/systemd/system}
+%define buildnum 1
+%{!?tarname:%define tarname %{name}-%{version}-%{buildnum}}
+
+
+Name: libosmo-abis
+Version: 1.6.0
+Release: %{buildnum}%{?revision}%{?dist}
+Summary: Osmocom ABIS library
+License: GPL-2.0-or-later
+Group: Productivity/Telephony/Utilities
+URL:
https://github.com/yremora/osmo/tree/main/libosmo-abis
+Source: %{tarname}.tar.gz
+BuildRequires: automake
+BuildRequires: libtool >= 2
+BuildRequires: pkgconfig >= 0.20
+BuildRequires: pkgconfig(libosmocore) >= 1.11.0
+BuildRequires: pkgconfig(libosmogsm) >= 1.11.0
+BuildRequires: pkgconfig(libosmocodec) >= 1.11.0
+BuildRequires: pkgconfig(libosmovty) >= 1.11.0
+BuildRequires: pkgconfig(libosmo-netif) >= 1.6.0
+
+%description
+ABIS interface handling library for yREMORA telecom projects.
+
+%package -n libosmoabis15
+Summary: Osmocom ABIS library
+License: AGPL-3.0-or-later
+Group: System/Libraries
+
+%description -n libosmoabis15
+ABIS interface handling library for yREMORA telecom projects.
+
+%package -n libosmotrau11
+Summary: Osmocom TRAU library
+License: AGPL-3.0-or-later
+Group: System/Libraries
+
+%description -n libosmotrau11
+TRAU (Transcoding and Rate Adaptation Unit) library for yREMORA telecom projects.
+
+%package -n libosmo-abis-devel
+Summary: Development files for the Osmocom ABIS library
+License: AGPL-3.0-or-later
+Group: Development/Libraries/C and C++
+Requires: libosmoabis15 = %{version}
+Requires: libosmotrau11 = %{version}
+
+%description -n libosmo-abis-devel
+ABIS interface handling library for yREMORA telecom projects.
+
+This subpackage contains libraries and header files for developing
+applications that want to make use of libosmo-abis.
+
+%prep
+%setup -q
+
+%build
+echo "%{version}" >.tarball-version
+autoreconf -fiv
+%configure --enable-shared --disable-static
--includedir="%{_includedir}/%{name}"
+make %{?_smp_mflags}
+
+%install
+%make_install
+find %{buildroot} -type f -name "*.la" -delete -print
+
+%check
+make %{?_smp_mflags} check || (find . -name testsuite.log -exec cat {} +)
+
+%post -n libosmoabis15 -p /sbin/ldconfig
+%postun -n libosmoabis15 -p /sbin/ldconfig
+
+%post -n libosmotrau11 -p /sbin/ldconfig
+%postun -n libosmotrau11 -p /sbin/ldconfig
+
+%files -n libosmoabis15
+%{_libdir}/libosmoabis.so.15*
+
+%files -n libosmotrau11
+%{_libdir}/libosmotrau.so.11*
+
+%files -n libosmo-abis-devel
+%license COPYING
+%dir %{_includedir}/%{name}
+%dir %{_includedir}/%{name}/osmocom
+%{_includedir}/%{name}/osmocom/abis/
+%{_includedir}/%{name}/osmocom/trau/
+%{_libdir}/libosmoabis.so
+%{_libdir}/libosmotrau.so
+%{_libdir}/pkgconfig/libosmoabis.pc
+%{_libdir}/pkgconfig/libosmotrau.pc
+
+%changelog
+* %(date "+%%a %%b %%d %%Y") Paul Bichis <paul(a)afk.ro> -
%{version}-%{release}
+- Initial RPM package for %{name} packaged for %{distribution}
+- Added proper RPM packaging with BuildRequires and Requires
--
To view, visit
https://gerrit.osmocom.org/c/libosmo-abis/+/40833?usp=email
To unsubscribe, or for help writing mail filters, visit
https://gerrit.osmocom.org/settings?usp=email
Gerrit-MessageType: newchange
Gerrit-Project: libosmo-abis
Gerrit-Branch: master
Gerrit-Change-Id: I86c2c621887d1d9352f3ddfa1270c1379cf50fd9
Gerrit-Change-Number: 40833
Gerrit-PatchSet: 1
Gerrit-Owner: Paul Bichis <paul(a)afk.ro>