Skip to content

Commit 10c0d11

Browse files
committed
Merge branch 'PavolVican-devel' into devel
2 parents 9305fbb + 7c0fbb4 commit 10c0d11

12 files changed

Lines changed: 322 additions & 2 deletions

.travis-deps-linux.sh

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ sudo apt-get install -y zlib1g-dev
66
sudo apt-get install -y libssl-dev
77
sudo apt-get install -y libval-dev
88
sudo apt-get install -y valgrind
9+
sudo apt-get install -y osc
910

1011
echo -n | openssl s_client -connect scan.coverity.com:443 | sed -ne '/-BEGIN CERTIFICATE-/,/-END CERTIFICATE-/p' | sudo tee -a /etc/ssl/certs/ca-certificates.crt
1112

.travis.yml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@ script:
3232
- cd $TRAVIS_BUILD_DIR && mkdir build_ssh && cd build_ssh ; cmake $OPENSSLFLAGS -DENABLE_TLS=OFF -DENABLE_SSH=ON -DENABLE_DNSSEC=OFF .. && make -j2 && ctest -V
3333
- cd $TRAVIS_BUILD_DIR && mkdir build_ssh_tls && cd build_ssh_tls ; cmake $OPENSSLFLAGS -DENABLE_TLS=ON -DENABLE_SSH=ON -DENABLE_DNSSEC=OFF .. && make -j2 && ctest -V
3434
- cd $TRAVIS_BUILD_DIR && mkdir build_all && cd build_all ; cmake $OPENSSLFLAGS -DENABLE_TLS=ON -DENABLE_SSH=ON -DENABLE_DNSSEC=ON .. && make -j2 && ctest -V
35+
- cd -
3536

3637
after_success:
37-
- if [ "$TRAVIS_OS_NAME" = "linux" -a "$CC" = "gcc" ]; then codecov; fi
38+
- if [ "$TRAVIS_OS_NAME" = "linux" -a "$CC" = "gcc" ]; then codecov; ./packages/create-package.sh; fi

CMakeLists.txt

Lines changed: 66 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@ endif()
2323

2424
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Wall -Wextra -fvisibility=hidden")
2525
set(CMAKE_C_FLAGS_RELEASE "-O2 -DNDEBUG")
26+
set(CMAKE_C_FLAGS_PACKAGE "-g -O2 -DNDEBUG")
2627
set(CMAKE_C_FLAGS_DEBUG "-g -O0")
2728

2829
# set version
@@ -46,6 +47,70 @@ if(ENABLE_DNSSEC AND NOT ENABLE_SSH)
4647
set(ENABLE_DNSSEC OFF)
4748
endif()
4849

50+
# package options
51+
find_program (DEB_BUILDER NAMES debuild)
52+
find_program (RPM_BUILDER NAMES rpmbuild)
53+
54+
if (NOT DEFINED ENV{TRAVIS_BRANCH})
55+
execute_process(COMMAND "git" "rev-parse" "--abbrev-ref" "HEAD"
56+
OUTPUT_VARIABLE GIT_BRANCH
57+
OUTPUT_STRIP_TRAILING_WHITESPACE
58+
ERROR_QUIET
59+
)
60+
if (NOT GIT_BRANCH)
61+
set(ENV{TRAVIS_BRANCH} "master")
62+
else()
63+
if (GIT_BRANCH MATCHES "master|devel")
64+
set(ENV{TRAVIS_BRANCH} ${GIT_BRANCH})
65+
else()
66+
set(ENV{TRAVIS_BRANCH} "master")
67+
endif()
68+
endif()
69+
set(GIT_BRANCH $ENV{TRAVIS_BRANCH})
70+
endif()
71+
72+
if ($ENV{TRAVIS_BRANCH} STREQUAL "master")
73+
set(PACKAGE_NAME "libnetconf2")
74+
set(BRANCH "master")
75+
set(BUILD_TYPE "Package")
76+
set(CONFLICT_PACKAGE_NAME "libnetconf2-experimental")
77+
set(COMPAT_PACKAGES "")
78+
else ()
79+
set(PACKAGE_NAME "libnetconf2-experimental")
80+
set(BRANCH "devel")
81+
set(BUILD_TYPE "debug")
82+
set(CONFLICT_PACKAGE_NAME "libnetconf2")
83+
set(COMPAT_PACKAGES "-experimental")
84+
endif()
85+
# change version in config files
86+
configure_file(${PROJECT_SOURCE_DIR}/packages/libnetconf2.spec.in ${PROJECT_BINARY_DIR}/build-packages/libnetconf2.spec)
87+
configure_file(${PROJECT_SOURCE_DIR}/packages/libnetconf2.dsc.in ${PROJECT_BINARY_DIR}/build-packages/libnetconf2.dsc)
88+
configure_file(${PROJECT_SOURCE_DIR}/packages/debian.control.in ${PROJECT_BINARY_DIR}/build-packages/debian.control @ONLY)
89+
configure_file(${PROJECT_SOURCE_DIR}/packages/debian.rules.in ${PROJECT_BINARY_DIR}/build-packages/debian.rules)
90+
91+
if (NOT DEB_BUILDER)
92+
message(WARNING "Missing tools (devscripts, debhelper package) for building deb package.\nYou won't be able to generate deb package from source code.\nCompiling libnetconf2 should still works fine.")
93+
else ()
94+
# target for local build deb package
95+
add_custom_target(build-deb
96+
WORKING_DIRECTORY ${PROJECT_BINARY_DIR}
97+
COMMAND build-packages/local-deb.sh
98+
)
99+
configure_file(${PROJECT_SOURCE_DIR}/packages/local-deb.sh.in ${PROJECT_BINARY_DIR}/build-packages/local-deb.sh @ONLY)
100+
endif()
101+
102+
if (NOT RPM_BUILDER)
103+
message(WARNING "Missing tools (rpm package) for building rpm package. \nYou won't be able to generate rpm package from source code.\nCompiling libnetconf2 should still works fine.")
104+
else ()
105+
# target for local build rpm package
106+
string(REPLACE ${PROJECT_SOURCE_DIR} "." EXCLUDE_BUILD_DIR ${PROJECT_BINARY_DIR})
107+
add_custom_target(build-rpm
108+
WORKING_DIRECTORY ${PROJECT_BINARY_DIR}
109+
COMMAND build-packages/local-rpm.sh
110+
)
111+
configure_file(${PROJECT_SOURCE_DIR}/packages/local-rpm.sh.in ${PROJECT_BINARY_DIR}/build-packages/local-rpm.sh @ONLY)
112+
endif()
113+
49114
include_directories(${PROJECT_BINARY_DIR}/src)
50115

51116
# source files
@@ -88,7 +153,7 @@ set(headers
88153
add_library(netconf2 SHARED ${libsrc})
89154
set_target_properties(netconf2 PROPERTIES VERSION ${LIBNETCONF2_VERSION} SOVERSION ${LIBNETCONF2_SOVERSION})
90155

91-
if(CMAKE_BUILD_TYPE STREQUAL debug)
156+
if((CMAKE_BUILD_TYPE STREQUAL debug) OR (CMAKE_BUILD_TYPE STREQUAL Package))
92157
option(ENABLE_BUILD_TESTS "Build tests" ON)
93158
option(ENABLE_VALGRIND_TESTS "Build tests with valgrind" ON)
94159
else()

packages/create-package.sh

Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
#!/usr/bin/env bash
2+
3+
if [ "$TRAVIS_PULL_REQUEST" == "true" -o "$TRAVIS_EVENT_TYPE" != "cron" ] ; then
4+
exit 0
5+
fi
6+
# check osb_user and osb_pass
7+
if [ -z "${osb_user}" -o -z "${osb_pass}" ]; then
8+
exit 0
9+
fi
10+
11+
# fill username and password for opensuse build and downlaod last package information
12+
echo -e "[general]\napiurl = https://api.opensuse.org\n\n[https://api.opensuse.org]\nuser = ${osb_user}\npass = ${osb_pass}" >~/.oscrc
13+
cd ./build_all
14+
if [ $TRAVIS_BRANCH == "devel" ]; then
15+
package="home:liberouter/libnetconf2-experimental"
16+
name="libnetconf2-experimental"
17+
else
18+
package="home:liberouter/libnetconf2"
19+
name="libnetconf2"
20+
fi
21+
osc checkout home:liberouter
22+
cp $package/libnetconf2.spec $package/debian.changelog home:liberouter
23+
cp build-packages/* $package
24+
cd $package
25+
26+
# check versions
27+
VERSION=$(cat libnetconf2.spec | grep "Version: " | awk '{print $NF}')
28+
OLDVERSION=$(cat ../libnetconf2.spec | grep "Version: " | awk '{print $NF}')
29+
if [ "$VERSION" == "$OLDVERSION" ]; then
30+
exit 0
31+
fi
32+
33+
# create new changelog and paste old changelog
34+
logtime=$(git log -i --grep="VERSION .* $OLDVERSION" | grep "Date: " | sed 's/Date:[ ]*//')
35+
echo -e "$name ($VERSION) stable; urgency=low\n" >debian.changelog
36+
git log --since="$logtime" --pretty=format:" * %s (%aN)%n" | grep "BUGFIX\|CHANGE\|FEATURE" >>debian.changelog
37+
git log -1 --pretty=format:"%n -- %aN <%aE> %aD%n" >>debian.changelog
38+
echo -e "\n" >>debian.changelog
39+
cat ../debian.changelog >>debian.changelog
40+
git log -1 --date=format:'%a %b %d %Y' --pretty=format:"* %ad %aN <%aE>" | tr -d "\n" >>libnetconf2.spec
41+
echo " $VERSION" >>libnetconf2.spec
42+
git log --since="$logtime" --pretty=format:"- %s (%aN)" | grep "BUGFIX\|CHANGE\|FEATURE" >>libnetconf2.spec
43+
echo -e "\n" >>libnetconf2.spec
44+
cat ../libnetconf2.spec | sed -e '1,/%changelog/d' >>libnetconf2.spec
45+
46+
# download source and update to opensuse build
47+
wget "https://github.com/CESNET/libnetconf2/archive/$TRAVIS_BRANCH.tar.gz" -O $TRAVIS_BRANCH.tar.gz
48+
osc commit -m travis-update

packages/debian.control.in

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
Source: @PACKAGE_NAME@
2+
Maintainer: CESNET <rkrejci@cesnet.cz>
3+
Priority: extra
4+
Standards-Version: 3.8.2
5+
Build-Depends: debhelper (>= 9), gcc
6+
Homepage: https://github.com/CESNET/libnetconf2
7+
8+
Package: @PACKAGE_NAME@
9+
Depends: libyang@COMPAT_PACKAGES@, libssh-4 (>= 0.7.1), ${shlibs:Depends}
10+
Conflicts: @CONFLICT_PACKAGE_NAME@
11+
Section: libs
12+
Architecture: any
13+
Description: Libnetconf2 is a NETCONF library in C intended for building NETCONF clients and servers.
14+
15+
Package: @PACKAGE_NAME@-dev
16+
Depends: libyang@COMPAT_PACKAGES@-dev
17+
Section: libdevel
18+
Architecture: any
19+
Description: Headers for libnetconf2 library.
20+
21+
Package: @PACKAGE_NAME@-dbg
22+
Depends: @PACKAGE_NAME@ (= @LIBNETCONF2_VERSION@)
23+
Section: debug
24+
Architecture: any
25+
Description: Debug symbols for libnetconf2 library.
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
usr/lib/*/libnetconf2.so
2+
usr/lib/*/pkgconfig/libnetconf2.pc
3+
usr/include/libnetconf2/*
4+
usr/include/nc_client.h
5+
usr/include/nc_server.h
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
usr/share/libnetconf2/*
2+
usr/lib/*/libnetconf2.so.*

packages/debian.rules.in

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
#!/usr/bin/make -f
2+
# -*- makefile -*-
3+
# Uncomment this to turn on verbose mode.
4+
export DH_VERBOSE=1
5+
6+
%:
7+
dh $@
8+
9+
override_dh_strip:
10+
dh_strip --dbg-package=@PACKAGE_NAME@-dbg
11+
12+
override_dh_auto_configure:
13+
cmake -DCMAKE_INSTALL_PREFIX:PATH=/usr -D CMAKE_BUILD_TYPE:String="@BUILD_TYPE@" .
14+
15+
override_dh_auto_test:
16+
ctest --output-on-failure

packages/libnetconf2.dsc.in

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
Format: 3.0 (quilt)
2+
Source: @PACKAGE_NAME@
3+
Binary: @PACKAGE_NAME@, @PACKAGE_NAME@-dbg, @PACKAGE_NAME@-dev
4+
Maintainer: CESNET <rkrejci@cesnet.cz>
5+
Version: @LIBNETCONF2_VERSION@
6+
Architecture: any
7+
Standards-Version: 3.8.2
8+
Homepage: https://github.com/CESNET/libnetconf2
9+
Vcs-Git: https://github.com/CESNET/libnetconf2
10+
Build-Depends: debhelper (>= 9), make, gcc, cmake, pkg-config, libcmocka-dev, libyang@COMPAT_PACKAGES@-dev, libssh-dev (>= 0.7.1), openssl

packages/libnetconf2.spec.in

Lines changed: 114 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,114 @@
1+
Name: libnetconf2-experimental
2+
Version: @LIBNETCONF2_VERSION@
3+
Release: 0
4+
Summary: Libnetconf2 library
5+
Url: https://github.com/CESNET/libnetconf2
6+
Source: %{url}/archive/@BRANCH@.tar.gz
7+
License: BSD-3-Clause
8+
BuildRoot: %{_tmppath}/%{name}-%{version}-%{release}
9+
10+
%define debug_package %{nil}
11+
12+
Requires: libnetconf2-@LIBNETCONF2_MAJOR_VERSION@_@LIBNETCONF2_MINOR_VERSION@ = %{version}-%{release}
13+
BuildRequires: libyang@COMPAT_PACKAGES@-devel
14+
BuildRequires: libssh-devel >= 0.7.1
15+
BuildRequires: openssl-devel
16+
BuildRequires: valgrind
17+
BuildRequires: libcmocka-devel
18+
BuildRequires: gcc
19+
%if 0%{?suse_version}
20+
BuildRequires: timezone
21+
%endif
22+
23+
%package debuginfo
24+
Summary: Debug symbol for libnetnconf2 library
25+
Requires: %{name} = %{version}-%{release}
26+
27+
%if 0%{?suse_version}
28+
%package debugsource
29+
Summary: Debug information for libnetnconf2 library
30+
Requires: %{name} = %{version}-%{release}
31+
32+
%description debugsource
33+
This package provides debug information for package libnetconf2. Debug information is useful when developing applications that use this package or when debugging this package.
34+
35+
%endif
36+
37+
%package -n libnetconf2-@LIBNETCONF2_MAJOR_VERSION@_@LIBNETCONF2_MINOR_VERSION@
38+
Summary: Libnetconf2 library
39+
Requires: libyang
40+
41+
%package devel
42+
Summary: Headers of libnetconf2 library
43+
Requires: %{name} = %{version}-%{release}
44+
Requires: libssh-devel
45+
46+
%description -n libnetconf2-@LIBNETCONF2_MAJOR_VERSION@_@LIBNETCONF2_MINOR_VERSION@
47+
Libnetconf2 is a NETCONF library in C intended for building NETCONF clients and servers.
48+
49+
%description devel
50+
Headers of libnetconf2 library.
51+
52+
%description debuginfo
53+
This package provides debug information for package libnetconf2. Debug information is useful when developing applications that use this package or when debugging this package.
54+
55+
%description
56+
Libnetconf2 is a NETCONF library in C intended for building NETCONF clients and servers.
57+
58+
%prep
59+
%setup -n libnetconf2-@BRANCH@
60+
61+
%build
62+
cmake -DCMAKE_INSTALL_PREFIX:PATH=/usr -D CMAKE_BUILD_TYPE:String="@BUILD_TYPE@" .
63+
make
64+
65+
%check
66+
ctest --output-on-failure
67+
68+
%install
69+
make DESTDIR=%{buildroot} install
70+
/usr/lib/rpm/find-debuginfo.sh
71+
72+
%post -n libnetconf2-@LIBNETCONF2_MAJOR_VERSION@_@LIBNETCONF2_MINOR_VERSION@ -p /sbin/ldconfig
73+
74+
%postun -n libnetconf2-@LIBNETCONF2_MAJOR_VERSION@_@LIBNETCONF2_MINOR_VERSION@ -p /sbin/ldconfig
75+
76+
%files
77+
%{_datadir}/libnetconf2/*
78+
%dir %{_datadir}/libnetconf2/
79+
80+
%files -n libnetconf2-@LIBNETCONF2_MAJOR_VERSION@_@LIBNETCONF2_MINOR_VERSION@
81+
%defattr(-,root,root)
82+
%{_libdir}/libnetconf2.so.*
83+
84+
%files devel
85+
%defattr(-,root,root)
86+
%{_libdir}/libnetconf2.so
87+
%{_libdir}/pkgconfig/libnetconf2.pc
88+
%{_includedir}/libnetconf2/*
89+
%{_includedir}/nc_client.h
90+
%{_includedir}/nc_server.h
91+
%dir %{_includedir}/libnetconf2/
92+
93+
%if 0%{?suse_version}
94+
%files debuginfo
95+
%defattr(-,root,root)
96+
%{_prefix}/lib/debug/*
97+
%{_prefix}/lib/debug/.build-id/*
98+
%{_usrsrc}/debug/*
99+
100+
%files debugsource
101+
%defattr(-,root,root)
102+
%{_usrsrc}/debug/*
103+
104+
%else
105+
%files debuginfo
106+
%defattr(-,root,root)
107+
%{_prefix}/lib/debug/*
108+
%{_prefix}/lib/debug/.build-id/*
109+
%{_usrsrc}/debug/*
110+
111+
%endif
112+
113+
%changelog
114+

0 commit comments

Comments
 (0)