Skip to content

Commit 891b73a

Browse files
jruzicka-nicmichalvasko
authored andcommitted
distro FEATURE upstream RPM packaging
1 parent f079832 commit 891b73a

File tree

5 files changed

+99
-0
lines changed

5 files changed

+99
-0
lines changed

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
/pkg

distro/config/apkg.toml

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
[project]
2+
name = "libnetconf2"
3+
make_archive_script = "distro/scripts/make-archive.sh"
4+
5+
[upstream]
6+
archive_url = "https://github.com/CESNET/libnetconf2/archive/refs/tags/v{{ version }}.tar.gz"
7+
version_script = "distro/scripts/upstream-version.sh"
8+
9+
[apkg]
10+
compat = 1

distro/pkg/rpm/libnetconf2.spec

Lines changed: 66 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,66 @@
1+
Name: libnetconf2
2+
Version: {{ version }}
3+
Release: {{ release }}%{?dist}
4+
Summary: NETCONF protocol library
5+
Url: https://github.com/CESNET/libnetconf2
6+
Source: libnetconf2-%{version}.tar.gz
7+
License: BSD-3-Clause
8+
9+
BuildRequires: cmake
10+
BuildRequires: make
11+
BuildRequires: gcc
12+
BuildRequires: libssh-devel
13+
BuildRequires: libyang2-devel
14+
BuildRequires: openssl-devel
15+
16+
%package -n libnetconf2-devel
17+
Summary: Headers of libnetconf2 library
18+
Conflicts: libnetconf-devel
19+
Requires: %{name} = %{version}-%{release}
20+
21+
%description -n libnetconf2-devel
22+
Headers of libnetconf library.
23+
24+
%description
25+
libnetconf2 is a NETCONF library in C intended for building NETCONF clients and
26+
servers. NETCONF is the NETwork CONFiguration protocol introduced by IETF.
27+
28+
29+
%prep
30+
%setup -n libnetconf2-%{version}
31+
mkdir build
32+
33+
%build
34+
cd build
35+
cmake -DCMAKE_INSTALL_PREFIX:PATH=/usr \
36+
-DCMAKE_BUILD_TYPE:String="Release" \
37+
-DCMAKE_C_FLAGS="${RPM_OPT_FLAGS}" \
38+
-DCMAKE_CXX_FLAGS="${RPM_OPT_FLAGS}" \
39+
..
40+
make
41+
42+
%install
43+
cd build
44+
make DESTDIR=%{buildroot} install
45+
46+
%post -p /sbin/ldconfig
47+
48+
%postun -p /sbin/ldconfig
49+
50+
51+
%files
52+
%defattr(-,root,root)
53+
%{_libdir}/libnetconf2.so.2*
54+
55+
%files -n libnetconf2-devel
56+
%defattr(-,root,root)
57+
%{_libdir}/libnetconf2.so
58+
%{_libdir}/pkgconfig/libnetconf2.pc
59+
%{_includedir}/*.h
60+
%{_includedir}/libnetconf2/*.h
61+
%dir %{_includedir}/libnetconf2/
62+
63+
64+
%changelog
65+
* Fri Jul 09 2021 Jakub Ružička <[email protected]> - {{ version }}-{{ release }}
66+
- upstream package

distro/scripts/make-archive.sh

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
#!/bin/bash
2+
# create archive from current source using git
3+
4+
VERSION=$(git describe --tags --always)
5+
# skip "v" from start of version number (if it exists) and replace - with .
6+
VERSION=${VERSION#v}
7+
VERSION=${VERSION//[-]/.}
8+
9+
NAMEVER=libnetconf2-$VERSION
10+
ARCHIVE=$NAMEVER.tar.gz
11+
12+
git archive --format tgz --output $ARCHIVE --prefix $NAMEVER/ HEAD
13+
14+
# apkg expects stdout to list archive files
15+
echo $ARCHIVE

distro/scripts/upstream-version.sh

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
#!/bin/bash
2+
# get latest upstream libnetconf2 version from github
3+
4+
RLS_URL=https://api.github.com/repos/CESNET/libnetconf2/releases
5+
VERSION=$(curl -s $RLS_URL | grep tag_name | cut -d '"' -f 4 | sort --version-sort | tail -n 1)
6+
VERSION=${VERSION#v}
7+
echo $VERSION

0 commit comments

Comments
 (0)