From cda634f8a1b84c0486b08528171c36f26f5cb11d Mon Sep 17 00:00:00 2001 From: Anders Blomdell <anders.blomdell@control.lth.se> Date: Fri, 20 Feb 2015 16:21:54 +0100 Subject: [PATCH] Added .src.rpm generation --- Makefile | 12 +++-- compiler/Makefile | 16 +++++- compiler/labcomm | 2 + compiler/labcomm2006 | 2 + compiler/labcomm2014 | 2 + packaging/.gitignore | 2 + packaging/Makefile | 18 +++++++ packaging/make_srpm | 125 +++++++++++++++++++++++++++++++++++++++++++ 8 files changed, 173 insertions(+), 6 deletions(-) create mode 100755 compiler/labcomm create mode 100755 compiler/labcomm2006 create mode 100755 compiler/labcomm2014 create mode 100644 packaging/.gitignore create mode 100644 packaging/Makefile create mode 100755 packaging/make_srpm diff --git a/Makefile b/Makefile index fd5f226..77f3305 100644 --- a/Makefile +++ b/Makefile @@ -1,12 +1,12 @@ -SUBDIRS=compiler lib test examples +SUBDIRS=compiler lib test examples packaging export LABCOMM_JAR=$(shell pwd)/compiler/labcomm_compiler.jar export LABCOMM=java -jar $(LABCOMM_JAR) .PHONY: all -all: $(SUBDIRS:%=make-%) +all: $(SUBDIRS:%=all-%) -.PHONY: make-% -make-%: +.PHONY: all-% +all-%: LD_LIBRARY_PATH=`pwd`/lib/c $(MAKE) -C $* .PHONY: test @@ -29,3 +29,7 @@ distclean: clean $(SUBDIRS:%=distclean-%) .PHONY: distclean-% distclean-%: $(MAKE) -C $* distclean + +.PHONY: srpm +srpm: + make -C packaging $@ diff --git a/compiler/Makefile b/compiler/Makefile index 2444440..f935342 100644 --- a/compiler/Makefile +++ b/compiler/Makefile @@ -1,4 +1,16 @@ -all: +.PHONY: all +all: ant-all -%: +.PHONY: test +test: ant-test + +.PHONY: clean +clean: ant-clean + rm -f *~ + +.PHONY: distclean +distclean: clean + +.PHONY: ant-% +ant-%: ant $* diff --git a/compiler/labcomm b/compiler/labcomm new file mode 100755 index 0000000..604b83a --- /dev/null +++ b/compiler/labcomm @@ -0,0 +1,2 @@ +#!/bin/sh +java -jar /lib/labcomm_compiler.jar "$@" diff --git a/compiler/labcomm2006 b/compiler/labcomm2006 new file mode 100755 index 0000000..77c38e8 --- /dev/null +++ b/compiler/labcomm2006 @@ -0,0 +1,2 @@ +#!/bin/sh +java -jar /lib/labcomm2006_compiler.jar "$@" diff --git a/compiler/labcomm2014 b/compiler/labcomm2014 new file mode 100755 index 0000000..901a413 --- /dev/null +++ b/compiler/labcomm2014 @@ -0,0 +1,2 @@ +#!/bin/sh +java -jar /lib/labcomm2014_compiler.jar "$@" diff --git a/packaging/.gitignore b/packaging/.gitignore new file mode 100644 index 0000000..9f87b19 --- /dev/null +++ b/packaging/.gitignore @@ -0,0 +1,2 @@ +labcomm-*.src.rpm +rpmbuild diff --git a/packaging/Makefile b/packaging/Makefile new file mode 100644 index 0000000..0c15aeb --- /dev/null +++ b/packaging/Makefile @@ -0,0 +1,18 @@ +.PHONY: all +all: + +.PHONY: test +test: + +.PHONY: clean +clean: + rm -rf rpmbuild + rm -f *~ + +.PHONY: distclean +distclean: clean + rm -f labcomm-*.src.rpm + +.PHONY: srpm +srpm: + ./make_srpm diff --git a/packaging/make_srpm b/packaging/make_srpm new file mode 100755 index 0000000..3468367 --- /dev/null +++ b/packaging/make_srpm @@ -0,0 +1,125 @@ +#!/bin/sh + +spec() { +cat << 'EOF' +Name: labcomm +Version: __VERSION__ +Release: 1 +Summary: LabComm communication protocol +License: GPLv3 + +# https://gitlab.control.lth.se/anders_blomdell/labcomm/repository/archive.tar.gz?__COMMIT__ +Source0: labcomm.__DESCRIBE__.tar.gz + +BuildRequires: gcc +BuildRequires: ant +BuildRequires: java +BuildRequires: mono-core + +%description +LabComm communication protocol + +%package devel +Summary: LabComm communication protocol +Requires: %{name} = %{version}-%{release} + +%description devel +LabComm communication protocol + +% +%prep +%setup -q -c -a 0 + +%build +pwd +make + +%install + +# +# C +# +install -d ${RPM_BUILD_ROOT}/%{_libdir} +install lib/c/liblabcomm2006.a ${RPM_BUILD_ROOT}/%{_libdir}/ +install lib/c/liblabcomm2006.so.1 ${RPM_BUILD_ROOT}/%{_libdir}/liblabcomm2006.so.__VERSION__ +ln -s liblabcomm2006.so.__VERSION__ ${RPM_BUILD_ROOT}/%{_libdir}/liblabcomm2006.so +install lib/c/liblabcomm2014.a ${RPM_BUILD_ROOT}/%{_libdir}/ +install lib/c/liblabcomm2014.so.1 ${RPM_BUILD_ROOT}/%{_libdir}/liblabcomm2014.so.__VERSION__ +ln -s liblabcomm2014.so.__VERSION__ ${RPM_BUILD_ROOT}/%{_libdir}/liblabcomm2014.so +install -d ${RPM_BUILD_ROOT}/%{_includedir}/labcomm +install lib/c/2014/*h ${RPM_BUILD_ROOT}/%{_includedir}/labcomm +install -d ${RPM_BUILD_ROOT}/%{_includedir}/labcomm2006 +install lib/c/2006/*h ${RPM_BUILD_ROOT}/%{_includedir}/labcomm2006 + +# +# java +# +install -d ${RPM_BUILD_ROOT}/usr/lib +install -m u=r,g=r,o=r compiler/labcomm2014_compiler.jar ${RPM_BUILD_ROOT}/usr/lib +install -m u=r,g=r,o=r compiler/labcomm2006_compiler.jar ${RPM_BUILD_ROOT}/usr/lib +install -m u=r,g=r,o=r lib/java/labcomm2014.jar ${RPM_BUILD_ROOT}/usr/lib +install -m u=r,g=r,o=r lib/java/labcomm2006.jar ${RPM_BUILD_ROOT}/usr/lib + +install -d ${RPM_BUILD_ROOT}/%{_bindir} +install -m u=rx,g=rx,o=rx \ + compiler/labcomm2014 ${RPM_BUILD_ROOT}/%{_bindir}/labcomm2014 +install -m u=rx,g=rx,o=rx \ + compiler/labcomm2006 ${RPM_BUILD_ROOT}/%{_bindir}/labcomm2006 +ls -l ${RPM_BUILD_ROOT}/%{_bindir} + +# +# C# +# +install -d ${RPM_BUILD_ROOT}/usr/lib +install -m u=r,g=r,o=r lib/csharp/labcomm.dll ${RPM_BUILD_ROOT}/usr/lib + +# +# Python +# +install -d ${RPM_BUILD_ROOT}/%{python_sitelib}/labcomm +install lib/python/labcomm/* ${RPM_BUILD_ROOT}/%{python_sitelib}/labcomm + +%files +%defattr (-, root, root) +%exclude /usr/lib/debug +%exclude /usr/lib/labcomm2014_compiler.jar +%exclude /usr/lib/labcomm2006_compiler.jar +/usr/lib/* +%{_libdir}/* + +%files devel +%defattr (-, root, root) +/usr/lib/labcomm2014_compiler.jar +/usr/lib/labcomm2006_compiler.jar +%{_includedir}/* +%{_bindir}/* + +EOF +} + +# Create a suitable directory for rpmbuild +rm -rf rpmbuild +mkdir -p rpmbuild/BUILD +mkdir -p rpmbuild/SPECS +mkdir -p rpmbuild/RPMS +mkdir -p rpmbuild/SRPMS +mkdir -p rpmbuild/SOURCES +rm -rf rpmbuild/SOURCES/* + +# Create spec and .tar.gz +DESCRIBE=$(git describe | sed -e 's/^v\(.*\)/\1/') +VERSION=$(echo ${DESCRIBE} | sed -e 's/-/./g') +COMMIT=$(git rev-parse HEAD) +( + spec | \ + sed -e "s/__VERSION__/${VERSION}/g" | \ + sed -e "s/__DESCRIBE__/${DESCRIBE}/g" | \ + sed -e "s/__COMMIT__/${COMMIT}/g" \ +) > rpmbuild/SPECS/labcomm.spec +( + cd $(git rev-parse --show-toplevel) + git archive --format tar HEAD +) > rpmbuild/SOURCES/labcomm.${DESCRIBE}.tar.gz +rpmbuild --define "_topdir $(pwd)/rpmbuild" \ + -bs rpmbuild/SPECS/labcomm.spec +mv rpmbuild/SRPMS/* . -- GitLab