make_srpm 2.84 KB
Newer Older
Anders Blomdell's avatar
Anders Blomdell committed
1
2
3
4
#!/bin/sh

spec() {
cat << 'EOF'
Anders Blomdell's avatar
Anders Blomdell committed
5
Name:      labcomm__SUFFIX__
Anders Blomdell's avatar
Anders Blomdell committed
6
7
8
9
10
11
12
13
14
15
16
17
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
18
BuildRequires: python2-devel
Anders Blomdell's avatar
Anders Blomdell committed
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47

%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 -d ${RPM_BUILD_ROOT}/%{_includedir}/labcomm
Anders Blomdell's avatar
Anders Blomdell committed
48
install lib/c/2006/*h ${RPM_BUILD_ROOT}/%{_includedir}/labcomm
Anders Blomdell's avatar
Anders Blomdell committed
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65

#
# java 
#
install -d ${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/labcomm2006.jar ${RPM_BUILD_ROOT}/usr/lib

install -d ${RPM_BUILD_ROOT}/%{_bindir}
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
Anders Blomdell's avatar
Anders Blomdell committed
66
install -m u=r,g=r,o=r lib/csharp/labcomm2006.dll ${RPM_BUILD_ROOT}/usr/lib
Anders Blomdell's avatar
Anders Blomdell committed
67
68
69
70

#
# Python
#
71
72
install -d ${RPM_BUILD_ROOT}/%{python2_sitelib}/labcomm2006
install lib/python/labcomm2006/* ${RPM_BUILD_ROOT}/%{python2_sitelib}/labcomm2006
Anders Blomdell's avatar
Anders Blomdell committed
73
74
75
76
77
78
79
80
81
82
83

%files
%defattr (-, root, root)
%exclude /usr/lib/debug
%exclude /usr/lib/labcomm2006_compiler.jar
/usr/lib/*
%{_libdir}/*

%files devel
%defattr (-, root, root)
/usr/lib/labcomm2006_compiler.jar
Anders Blomdell's avatar
Anders Blomdell committed
84
%{_includedir}/labcomm/*
Anders Blomdell's avatar
Anders Blomdell committed
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
%{_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/')
Anders Blomdell's avatar
Anders Blomdell committed
101
102
SUFFIX=$(echo ${DESCRIBE} | sed -e 's/^\([^.]*\)[.].*$/\1/g')
VERSION=$(echo ${DESCRIBE} | sed -e 's/^[^.]*[.]\(.*\)/\1/g;s/-/./g')
Anders Blomdell's avatar
Anders Blomdell committed
103
104
105
COMMIT=$(git rev-parse HEAD)
(
    spec | \
Anders Blomdell's avatar
Anders Blomdell committed
106
        sed -e "s/__SUFFIX__/${SUFFIX}/g" | \
Anders Blomdell's avatar
Anders Blomdell committed
107
108
109
110
111
112
113
114
115
        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" \
116
         -bs rpmbuild/SPECS/labcomm.spec 2>&1 | sed -e 's|rpmbuild/SRPMS/||g'
Anders Blomdell's avatar
Anders Blomdell committed
117
mv rpmbuild/SRPMS/* .