Skip to content

Commit b725ee8

Browse files
committed
packages CHANGE scripts refactored to be more generic
1 parent 402ab07 commit b725ee8

13 files changed

+137
-164
lines changed

CMakeLists.txt

Lines changed: 3 additions & 73 deletions
Original file line numberDiff line numberDiff line change
@@ -107,8 +107,6 @@ set(GEN_JAVA_BINDINGS 0 CACHE BOOL "Enable Java bindings.")
107107

108108
find_package(FLEX)
109109
find_package(BISON)
110-
find_program(DEB_BUILDER NAMES debuild)
111-
find_program(RPM_BUILDER NAMES rpmbuild)
112110
find_program(SED_TOOL NAMES sed)
113111

114112
if(NOT BISON_FOUND)
@@ -130,77 +128,6 @@ else()
130128
)
131129
endif()
132130

133-
if (NOT DEFINED ENV{TRAVIS_BRANCH})
134-
execute_process(COMMAND "git" "rev-parse" "--abbrev-ref" "HEAD"
135-
OUTPUT_VARIABLE GIT_BRANCH
136-
OUTPUT_STRIP_TRAILING_WHITESPACE
137-
ERROR_QUIET
138-
)
139-
if (NOT GIT_BRANCH)
140-
set(ENV{TRAVIS_BRANCH} "master")
141-
else()
142-
if (GIT_BRANCH MATCHES "master|devel")
143-
set(ENV{TRAVIS_BRANCH} ${GIT_BRANCH})
144-
else()
145-
set(ENV{TRAVIS_BRANCH} "master")
146-
endif()
147-
endif()
148-
set(GIT_BRANCH $ENV{TRAVIS_BRANCH})
149-
endif()
150-
151-
if ($ENV{TRAVIS_BRANCH} STREQUAL "master")
152-
set(PACKAGE_NAME "libyang")
153-
set(PACKAGE_PART_NAME "")
154-
set(BRANCH "master")
155-
set(BUILD_TYPE "Package")
156-
set(CONFLICT_PACKAGE_NAME "libyang-experimental")
157-
else ()
158-
set(PACKAGE_NAME "libyang-experimental")
159-
set(PACKAGE_PART_NAME "-experimental")
160-
set(BRANCH "devel")
161-
set(BUILD_TYPE "debug")
162-
set(CONFLICT_PACKAGE_NAME "libyang")
163-
endif()
164-
165-
# setup package build
166-
configure_file(${PROJECT_SOURCE_DIR}/packages/libyang.spec.in ${PROJECT_BINARY_DIR}/build-packages/libyang.spec)
167-
configure_file(${PROJECT_SOURCE_DIR}/packages/libyang.dsc.in ${PROJECT_BINARY_DIR}/build-packages/libyang.dsc)
168-
configure_file(${PROJECT_SOURCE_DIR}/packages/debian.control.in ${PROJECT_BINARY_DIR}/build-packages/debian.control @ONLY)
169-
configure_file(${PROJECT_SOURCE_DIR}/packages/debian.rules.in ${PROJECT_BINARY_DIR}/build-packages/debian.rules)
170-
configure_file(${PROJECT_SOURCE_DIR}/packages/debian.libyang-cpp-dev.install
171-
${PROJECT_BINARY_DIR}/build-packages/debian.libyang-cpp${PACKAGE_PART_NAME}-dev.install COPYONLY)
172-
configure_file(${PROJECT_SOURCE_DIR}/packages/debian.libyang-cpp.install
173-
${PROJECT_BINARY_DIR}/build-packages/debian.libyang-cpp${PACKAGE_PART_NAME}.install COPYONLY)
174-
configure_file(${PROJECT_SOURCE_DIR}/packages/debian.libyang-dev.install
175-
${PROJECT_BINARY_DIR}/build-packages/debian.libyang${PACKAGE_PART_NAME}-dev.install COPYONLY)
176-
configure_file(${PROJECT_SOURCE_DIR}/packages/debian.libyang.install
177-
${PROJECT_BINARY_DIR}/build-packages/debian.libyang${PACKAGE_PART_NAME}.install COPYONLY)
178-
configure_file(${PROJECT_SOURCE_DIR}/packages/debian.python3-yang.install
179-
${PROJECT_BINARY_DIR}/build-packages/debian.python3-yang${PACKAGE_PART_NAME}.install COPYONLY)
180-
181-
if (NOT DEB_BUILDER)
182-
message(WARNING "Missing tools (devscripts, debhelper package) for building deb package.\nYou won't be able to generate deb package from source code.\nCompiling libyang should still works fine.")
183-
else ()
184-
# target for local build deb package
185-
add_custom_target(build-deb
186-
WORKING_DIRECTORY ${PROJECT_BINARY_DIR}
187-
COMMAND build-packages/local-deb.sh
188-
)
189-
configure_file(${PROJECT_SOURCE_DIR}/packages/local-deb.sh.in ${PROJECT_BINARY_DIR}/build-packages/local-deb.sh @ONLY)
190-
endif()
191-
192-
if (NOT RPM_BUILDER)
193-
message(WARNING "Missing tools (rpm package) for building rpm package. \nYou won't be able to generate rpm package from source code.\nCompiling libyang should still works fine.")
194-
else ()
195-
# target for local build rpm package
196-
string(REPLACE ${PROJECT_SOURCE_DIR} "." EXCLUDE_BUILD_DIR ${PROJECT_BINARY_DIR})
197-
add_custom_target(build-rpm
198-
WORKING_DIRECTORY ${PROJECT_BINARY_DIR}
199-
COMMAND build-packages/local-rpm.sh
200-
)
201-
configure_file(${PROJECT_SOURCE_DIR}/packages/local-rpm.sh.in ${PROJECT_BINARY_DIR}/build-packages/local-rpm.sh @ONLY)
202-
endif()
203-
204131
# by default build shared library
205132
# static build requires static libpcre library
206133
option(ENABLE_STATIC "Build static (.a) library" OFF)
@@ -422,6 +349,9 @@ install(FILES ${PROJECT_SOURCE_DIR}/tools/re/yangre.1 DESTINATION ${CMAKE_INSTAL
422349
# yang2yin
423350
add_executable(yang2yin ${yang2yinsrc})
424351

352+
# packages
353+
add_subdirectory(packages)
354+
425355
# uninstall
426356
add_custom_target(uninstall "${CMAKE_COMMAND}" -P "${CMAKE_MODULE_PATH}/uninstall.cmake")
427357

packages/CMakeLists.txt

Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,51 @@
1+
set(PACKAGE "libyang")
2+
set(CPP_PACKAGE "libyang-cpp")
3+
set(PYTHON_PACKAGE "python-yang")
4+
5+
find_program(DEB_BUILDER NAMES debuild)
6+
find_program(RPM_BUILDER NAMES rpmbuild)
7+
8+
# setup package build
9+
configure_file(${PROJECT_SOURCE_DIR}/packages/${PACKAGE}.spec.in ${PROJECT_BINARY_DIR}/build-packages/${PACKAGE}.spec)
10+
configure_file(${PROJECT_SOURCE_DIR}/packages/${PACKAGE}.dsc.in ${PROJECT_BINARY_DIR}/build-packages/${PACKAGE}.dsc)
11+
configure_file(${PROJECT_SOURCE_DIR}/packages/debian.control.in ${PROJECT_BINARY_DIR}/build-packages/debian.control @ONLY)
12+
configure_file(${PROJECT_SOURCE_DIR}/packages/debian.rules.in ${PROJECT_BINARY_DIR}/build-packages/debian.rules)
13+
configure_file(${PROJECT_SOURCE_DIR}/packages/${PACKAGE}.rpmlintrc
14+
${PROJECT_BINARY_DIR}/build-packages/${PACKAGE}.rpmlintrc COPYONLY)
15+
configure_file(${PROJECT_SOURCE_DIR}/packages/${PACKAGE}.compat
16+
${PROJECT_BINARY_DIR}/build-packages/${PACKAGE}.compat COPYONLY)
17+
configure_file(${PROJECT_SOURCE_DIR}/packages/debian.${PACKAGE}.install
18+
${PROJECT_BINARY_DIR}/build-packages/debian.${PACKAGE}.install COPYONLY)
19+
configure_file(${PROJECT_SOURCE_DIR}/packages/debian.${PACKAGE}-dev.install
20+
${PROJECT_BINARY_DIR}/build-packages/debian.${PACKAGE}-dev.install COPYONLY)
21+
configure_file(${PROJECT_SOURCE_DIR}/packages/debian.${CPP_PACKAGE}.install
22+
${PROJECT_BINARY_DIR}/build-packages/debian.${CPP_PACKAGE}.install COPYONLY)
23+
configure_file(${PROJECT_SOURCE_DIR}/packages/debian.${CPP_PACKAGE}-dev.install
24+
${PROJECT_BINARY_DIR}/build-packages/debian.${CPP_PACKAGE}-dev.install COPYONLY)
25+
configure_file(${PROJECT_SOURCE_DIR}/packages/debian.${PYTHON_PACKAGE}.install
26+
${PROJECT_BINARY_DIR}/build-packages/debian.${PYTHON_PACKAGE}.install COPYONLY)
27+
28+
if (NOT DEB_BUILDER)
29+
message(STATUS "Missing tools (devscripts, debhelper package) for building DEB package.")
30+
else ()
31+
# target for local build deb package
32+
message(STATUS "To build local DEB package, use \"build-deb\" target.")
33+
add_custom_target(build-deb
34+
WORKING_DIRECTORY ${PROJECT_BINARY_DIR}
35+
COMMAND build-packages/local-deb.sh
36+
)
37+
configure_file(${PROJECT_SOURCE_DIR}/packages/local-deb.sh.in ${PROJECT_BINARY_DIR}/build-packages/local-deb.sh @ONLY)
38+
endif()
39+
40+
if (NOT RPM_BUILDER)
41+
message(STATUS "Missing tools (rpm package) for building RPM package.")
42+
else ()
43+
# target for local build rpm package
44+
message(STATUS "To build local RPM package, use \"build-rpm\" target.")
45+
string(REPLACE ${PROJECT_SOURCE_DIR} "." EXCLUDE_BUILD_DIR ${PROJECT_BINARY_DIR})
46+
add_custom_target(build-rpm
47+
WORKING_DIRECTORY ${PROJECT_BINARY_DIR}
48+
COMMAND build-packages/local-rpm.sh
49+
)
50+
configure_file(${PROJECT_SOURCE_DIR}/packages/local-rpm.sh.in ${PROJECT_BINARY_DIR}/build-packages/local-rpm.sh @ONLY)
51+
endif()

packages/create-package.sh

Lines changed: 15 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
#!/usr/bin/env bash
22

3+
package="libyang"
4+
35
if [ "$TRAVIS_PULL_REQUEST" == "true" -o "$TRAVIS_EVENT_TYPE" != "cron" ] ; then
46
exit 0
57
fi
@@ -15,43 +17,37 @@ fi
1517
# fill username and password for opensuse build and downlaod last package information
1618
echo -e "[general]\napiurl = https://api.opensuse.org\n\n[https://api.opensuse.org]\nuser = ${osb_user}\npass = ${osb_pass}" >~/.oscrc
1719
cd ./build
18-
if [ $TRAVIS_BRANCH == "devel" ]; then
19-
package="home:liberouter/libyang-experimental"
20-
name="libyang-experimental"
21-
else
22-
package="home:liberouter/libyang"
23-
name="libyang"
24-
fi
20+
2521
osc checkout home:liberouter
26-
cp $package/libyang.spec $package/debian.changelog home:liberouter
27-
cp build-packages/* $package
28-
cd $package
22+
cp home:liberouter/$package/$package.spec home:liberouter/$package/debian.changelog home:liberouter
23+
cp build-packages/debian* build-packages/$package* home:liberouter/$package
24+
cd home:liberouter/$package
2925

3026
# check versions
31-
VERSION=$(cat libyang.spec | grep "Version: " | awk '{print $NF}')
32-
OLDVERSION=$(cat ../libyang.spec | grep "Version: " | awk '{print $NF}')
27+
VERSION=$(cat $package.spec | grep "Version: " | awk '{print $NF}')
28+
OLDVERSION=$(cat ../$package.spec | grep "Version: " | awk '{print $NF}')
3329
if [ -z "$FORCEVERSION" -a "$VERSION" == "$OLDVERSION" ]; then
3430
exit 0
3531
fi
3632

3733
# create new changelog and paste old changelog
3834
if [ "$VERSION" != "$OLDVERSION" ]; then
3935
logtime=$(git log -i --grep="VERSION .* $OLDVERSION" | grep "Date: " | sed 's/Date:[ ]*//')
40-
echo -e "$name ($VERSION) stable; urgency=low\n" >debian.changelog
36+
echo -e "$package ($VERSION) stable; urgency=low\n" >debian.changelog
4137
git log --since="$logtime" --pretty=format:" * %s (%aN)%n" | grep "BUGFIX\|CHANGE\|FEATURE" >>debian.changelog
4238
git log -1 --pretty=format:"%n -- %aN <%aE> %aD%n" >>debian.changelog
4339
echo -e "\n" >>debian.changelog
4440
cat ../debian.changelog >>debian.changelog
4541
fi
4642

4743
if [ "$VERSION" != "$OLDVERSION" ]; then
48-
git log -1 --date=format:'%a %b %d %Y' --pretty=format:"* %ad %aN <%aE>" | tr -d "\n" >>libyang.spec
49-
echo " $VERSION" >>libyang.spec
50-
git log --since="$logtime" --pretty=format:"- %s (%aN)" | grep "BUGFIX\|CHANGE\|FEATURE" >>libyang.spec
51-
echo -e "\n" >>libyang.spec
44+
git log -1 --date=format:'%a %b %d %Y' --pretty=format:"* %ad %aN <%aE>" | tr -d "\n" >>$package.spec
45+
echo " $VERSION" >>$package.spec
46+
git log --since="$logtime" --pretty=format:"- %s (%aN)" | grep "BUGFIX\|CHANGE\|FEATURE" >>$package.spec
47+
echo -e "\n" >>$package.spec
5248
fi
53-
cat ../libyang.spec | sed -e '1,/%changelog/d' >>libyang.spec
49+
cat ../$package.spec | sed -e '1,/%changelog/d' >>$package.spec
5450

5551
# download source and update to opensuse build
56-
wget "https://github.com/CESNET/libyang/archive/$TRAVIS_BRANCH.tar.gz" -O $TRAVIS_BRANCH.tar.gz
52+
wget "https://github.com/CESNET/libyang/archive/master.tar.gz" -O master.tar.gz
5753
osc commit -m travis-update

packages/debian.control.in

Lines changed: 19 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -1,55 +1,54 @@
1-
Source: @PACKAGE_NAME@
2-
Maintainer: CESNET <rkrejci@cesnet.cz>
1+
Source: @PACKAGE@
2+
Maintainer: CESNET <mvasko@cesnet.cz>
33
Priority: extra
44
Standards-Version: 3.8.2
55
Build-Depends: debhelper (>= 9), gcc
66
Homepage: https://github.com/CESNET/libyang
77

8-
Package: @PACKAGE_NAME@
8+
Package: @PACKAGE@
99
Depends: libpcre3, ${shlibs:Depends}
10-
Conflicts: @CONFLICT_PACKAGE_NAME@ (= @LIBYANG_MAJOR_VERSION@.@LIBYANG_MINOR_VERSION@)
1110
Section: libs
1211
Architecture: any
1312
Description: Libyang is YANG data modelling language parser and toolkit written (and providing API) in C.
1413

15-
Package: @PACKAGE_NAME@-dev
16-
Depends: libpcre3-dev, @PACKAGE_NAME@ (=@LIBYANG_VERSION@)
14+
Package: @PACKAGE@-dev
15+
Depends: libpcre3-dev, @PACKAGE@ (=@LIBYANG_VERSION@)
1716
Section: libdevel
1817
Architecture: any
1918
Description: Headers of libyang library.
2019

21-
Package: @PACKAGE_NAME@-dbg
22-
Depends: @PACKAGE_NAME@ (=@LIBYANG_VERSION@)
20+
Package: @PACKAGE@-dbg
21+
Depends: @PACKAGE@ (=@LIBYANG_VERSION@)
2322
Section: debug
2423
Architecture: any
2524
Description: Debug symbols of libyang library.
2625

27-
Package: libyang-cpp@PACKAGE_PART_NAME@
28-
Depends: @PACKAGE_NAME@ (=@LIBYANG_VERSION@)
26+
Package: @CPP_PACKAGE@
27+
Depends: @PACKAGE@ (=@LIBYANG_VERSION@)
2928
Section: libs
3029
Architecture: any
3130
Description: Bindings of libyang library to C++ language.
3231

33-
Package: libyang-cpp@PACKAGE_PART_NAME@-dev
34-
Depends: libpcre3-dev, libyang-cpp@PACKAGE_PART_NAME@ (=@LIBYANG_VERSION@)
32+
Package: @CPP_PACKAGE@-dev
33+
Depends: libpcre3-dev, @CPP_PACKAGE@ (=@LIBYANG_VERSION@)
3534
Section: libdevel
3635
Architecture: any
37-
Description: Headers of bindings to c++ language libyang library.
36+
Description: Headers of bindings to C++ language libyang library.
3837

39-
Package: libyang-cpp@PACKAGE_PART_NAME@-dbg
40-
Depends: libyang-cpp@PACKAGE_PART_NAME@ (=@LIBYANG_VERSION@)
38+
Package: @CPP_PACKAGE@-dbg
39+
Depends: @CPP_PACKAGE@ (=@LIBYANG_VERSION@)
4140
Section: debug
4241
Architecture: any
43-
Description: Debug symbols of c++ bidings of libyang library.
42+
Description: Debug symbols of C++ bidings of libyang library.
4443

45-
Package: python3-yang@PACKAGE_PART_NAME@
46-
Depends: @PACKAGE_NAME@ (=@LIBYANG_VERSION@), libyang-cpp@PACKAGE_PART_NAME@ (=@LIBYANG_VERSION@)
44+
Package: @PYTHON_PACKAGE@
45+
Depends: @PACKAGE@ (=@LIBYANG_VERSION@), @CPP_PACKAGE@ (=@LIBYANG_VERSION@)
4746
Section: libs
4847
Architecture: any
4948
Description: Bindings of libyang library to python3 language.
5049

51-
Package: python3-yang@PACKAGE_PART_NAME@-dbg
52-
Depends: python3-yang@PACKAGE_PART_NAME@ (=@LIBYANG_VERSION@)
50+
Package: @PYTHON_PACKAGE@-dbg
51+
Depends: @PYTHON_PACKAGE@ (=@LIBYANG_VERSION@)
5352
Section: debug
5453
Architecture: any
5554
Description: Debug symbols of python3 bidings of libyang library.
File renamed without changes.

packages/debian.rules.in

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -7,12 +7,12 @@ export DH_VERBOSE=1
77
dh $@
88

99
override_dh_strip:
10-
dh_strip -plibyang@PACKAGE_PART_NAME@ --dbg-package=libyang@PACKAGE_PART_NAME@-dbg
11-
dh_strip -plibyang-cpp@PACKAGE_PART_NAME@ --dbg-package=libyang-cpp@PACKAGE_PART_NAME@-dbg
12-
dh_strip -ppython3-yang@PACKAGE_PART_NAME@ --dbg-package=python3-yang@PACKAGE_PART_NAME@-dbg
10+
dh_strip -p@PACKAGE@ --dbg-package=@PACKAGE@-dbg
11+
dh_strip -p@CPP_PACKAGE@ --dbg-package=@CPP_PACKAGE@-dbg
12+
dh_strip -p@PYTHON_PACKAGE@ --dbg-package=@PYTHON_PACKAGE@-dbg
1313

1414
override_dh_auto_configure:
15-
cmake -DCMAKE_INSTALL_PREFIX=/usr -DFORCE_INSRC_BUILD=ON -DCMAKE_BUILD_TYPE="@BUILD_TYPE@" -DENABLE_LYD_PRIV=ON \
15+
cmake -DCMAKE_INSTALL_PREFIX=/usr -DFORCE_INSRC_BUILD=ON -DCMAKE_BUILD_TYPE="Package" -DENABLE_LYD_PRIV=ON \
1616
-DGEN_LANGUAGE_BINDINGS=ON .
1717

1818
override_dh_auto_test:

packages/libyang.compat

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

packages/libyang.dsc.in

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
Format: 3.0 (quilt)
2-
Source: @PACKAGE_NAME@
3-
Binary: @PACKAGE_NAME@, @PACKAGE_NAME@-dbg, @PACKAGE_NAME@-dev, libyang-cpp@PACKAGE_PART_NAME@, libyang-cpp@PACKAGE_PART_NAME@-dev, libyang-cpp@PACKAGE_PART_NAME@-dbg, python3-yang@PACKAGE_PART_NAME@, python3-yang@PACKAGE_PART_NAME@-dbg
4-
Maintainer: CESNET <rkrejci@cesnet.cz>
2+
Source: @PACKAGE@
3+
Binary: @PACKAGE@, @PACKAGE@-dbg, @PACKAGE@-dev, @CPP_PACKAGE@, @CPP_PACKAGE@-dev, @CPP_PACKAGE@-dbg, @PYTHON_PACKAGE@, @PYTHON_PACKAGE@-dbg
4+
Maintainer: CESNET <mvasko@cesnet.cz>
55
Version: @LIBYANG_VERSION@
66
Architecture: any
77
Standards-Version: 3.8.2

packages/libyang.rpmlintrc

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
addFilter("E: shlib-policy-name-error")

0 commit comments

Comments
 (0)