diff options
author | Smoked Cheese <root@ubuntology.ru> | 2018-01-15 14:23:33 +0300 |
---|---|---|
committer | GitHub <noreply@github.com> | 2018-01-15 14:23:33 +0300 |
commit | 402664f58d3b076a3715ddf0fdb6bb49c70c57b4 (patch) | |
tree | ada04209d97dbf9800d48e8e29490dc3c4b2c94d | |
parent | e16d3894c5979fcfe1c57bf7dadc455ce690baf9 (diff) |
update rpm spec and use variables in cmake instead of hardcoded paths (#624)
-rw-r--r-- | .gitignore | 1 | ||||
-rw-r--r-- | CMakeLists.txt | 12 | ||||
-rw-r--r-- | circle.yml | 2 | ||||
-rw-r--r-- | cmake/ModulePackage.cmake | 12 | ||||
-rw-r--r-- | other/pkgconfig/toxcore.pc.in | 4 | ||||
-rw-r--r-- | other/rpm/Makefile | 32 | ||||
-rw-r--r-- | other/rpm/tox-bootstrapd.service | 17 | ||||
-rw-r--r-- | other/rpm/toxcore.spec.in | 126 |
8 files changed, 197 insertions, 9 deletions
@@ -16,6 +16,7 @@ Thumbs.db | |||
16 | CMakeCache.txt | 16 | CMakeCache.txt |
17 | CMakeFiles | 17 | CMakeFiles |
18 | Makefile | 18 | Makefile |
19 | !/other/rpm/Makefile | ||
19 | cmake_install.cmake | 20 | cmake_install.cmake |
20 | install_manifest.txt | 21 | install_manifest.txt |
21 | tags | 22 | tags |
diff --git a/CMakeLists.txt b/CMakeLists.txt index bc846554..d6302051 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt | |||
@@ -54,9 +54,13 @@ message("SOVERSION: ${SOVERSION}") | |||
54 | 54 | ||
55 | include(AddCompilerFlag) | 55 | include(AddCompilerFlag) |
56 | include(ApiDsl) | 56 | include(ApiDsl) |
57 | include(MacRpath) | ||
58 | include(ModulePackage) | 57 | include(ModulePackage) |
59 | include(StrictAbi) | 58 | include(StrictAbi) |
59 | include(GNUInstallDirs) | ||
60 | |||
61 | if(APPLE) | ||
62 | include(MacRpath) | ||
63 | endif() | ||
60 | 64 | ||
61 | enable_testing() | 65 | enable_testing() |
62 | 66 | ||
@@ -374,9 +378,9 @@ endforeach() | |||
374 | # Make version script (on systems that support it) to limit symbol visibility. | 378 | # Make version script (on systems that support it) to limit symbol visibility. |
375 | make_version_script(toxcore ${toxcore_API_HEADERS}) | 379 | make_version_script(toxcore ${toxcore_API_HEADERS}) |
376 | 380 | ||
377 | # Generate pkg-config file, install library to "lib" and install headers to | 381 | # Generate pkg-config file, install library to "${CMAKE_INSTALL_LIBDIR}" and install headers to |
378 | # "include/tox". | 382 | # "${CMAKE_INSTALL_INCLUDEDIR}/tox". |
379 | install_module(toxcore DESTINATION "include/tox") | 383 | install_module(toxcore DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}/tox) |
380 | 384 | ||
381 | ################################################################################ | 385 | ################################################################################ |
382 | # | 386 | # |
@@ -20,6 +20,8 @@ dependencies: | |||
20 | - sudo bash -c "echo '::1 localhost ipv6-localhost ipv6-loopback' >> /etc/hosts" # ipv6 localhost entry | 20 | - sudo bash -c "echo '::1 localhost ipv6-localhost ipv6-loopback' >> /etc/hosts" # ipv6 localhost entry |
21 | # ------------ network_test requires that "localhost" resolves to ::1 ------------ | 21 | # ------------ network_test requires that "localhost" resolves to ::1 ------------ |
22 | 22 | ||
23 | - sudo bash -c "echo /usr/local/lib/x86_64-linux-gnu > /etc/ld.so.conf.d/fix685519.conf" # fix https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=685519 | ||
24 | |||
23 | - java -version ; exit 0 | 25 | - java -version ; exit 0 |
24 | - gcc --version ; exit 0 | 26 | - gcc --version ; exit 0 |
25 | - clang --version ; exit 0 | 27 | - clang --version ; exit 0 |
diff --git a/cmake/ModulePackage.cmake b/cmake/ModulePackage.cmake index c38e7de0..7a96abcf 100644 --- a/cmake/ModulePackage.cmake +++ b/cmake/ModulePackage.cmake | |||
@@ -89,10 +89,10 @@ function(install_module lib) | |||
89 | VERSION ${SOVERSION} | 89 | VERSION ${SOVERSION} |
90 | SOVERSION ${SOVERSION_MAJOR} | 90 | SOVERSION ${SOVERSION_MAJOR} |
91 | ) | 91 | ) |
92 | install(TARGETS ${lib}_shared DESTINATION "lib") | 92 | install(TARGETS ${lib}_shared DESTINATION ${CMAKE_INSTALL_LIBDIR}) |
93 | endif() | 93 | endif() |
94 | if(ENABLE_STATIC) | 94 | if(ENABLE_STATIC) |
95 | install(TARGETS ${lib}_static DESTINATION "lib") | 95 | install(TARGETS ${lib}_static DESTINATION ${CMAKE_INSTALL_LIBDIR}) |
96 | endif() | 96 | endif() |
97 | 97 | ||
98 | string(REPLACE ";" " " ${lib}_PKGCONFIG_LIBS "${${lib}_PKGCONFIG_LIBS}") | 98 | string(REPLACE ";" " " ${lib}_PKGCONFIG_LIBS "${${lib}_PKGCONFIG_LIBS}") |
@@ -104,9 +104,15 @@ function(install_module lib) | |||
104 | @ONLY | 104 | @ONLY |
105 | ) | 105 | ) |
106 | 106 | ||
107 | configure_file( | ||
108 | "${toxcore_SOURCE_DIR}/other/rpm/${lib}.spec.in" | ||
109 | "${CMAKE_BINARY_DIR}/${lib}.spec" | ||
110 | @ONLY | ||
111 | ) | ||
112 | |||
107 | install(FILES | 113 | install(FILES |
108 | ${CMAKE_BINARY_DIR}/${lib}.pc | 114 | ${CMAKE_BINARY_DIR}/${lib}.pc |
109 | DESTINATION "lib/pkgconfig") | 115 | DESTINATION ${CMAKE_INSTALL_LIBDIR}/pkgconfig) |
110 | 116 | ||
111 | foreach(sublib ${${lib}_API_HEADERS}) | 117 | foreach(sublib ${${lib}_API_HEADERS}) |
112 | string(REPLACE "^" ";" sublib ${sublib}) | 118 | string(REPLACE "^" ";" sublib ${sublib}) |
diff --git a/other/pkgconfig/toxcore.pc.in b/other/pkgconfig/toxcore.pc.in index 55b3b10a..b53fa48c 100644 --- a/other/pkgconfig/toxcore.pc.in +++ b/other/pkgconfig/toxcore.pc.in | |||
@@ -1,6 +1,6 @@ | |||
1 | prefix=@CMAKE_INSTALL_PREFIX@ | 1 | prefix=@CMAKE_INSTALL_PREFIX@ |
2 | libdir=${prefix}/lib | 2 | libdir=${prefix}/@CMAKE_INSTALL_LIBDIR@ |
3 | includedir=${prefix}/include | 3 | includedir=${prefix}/@CMAKE_INSTALL_INCLUDEDIR@ |
4 | 4 | ||
5 | Name: toxcore | 5 | Name: toxcore |
6 | Description: Tox protocol library | 6 | Description: Tox protocol library |
diff --git a/other/rpm/Makefile b/other/rpm/Makefile new file mode 100644 index 00000000..5e164717 --- /dev/null +++ b/other/rpm/Makefile | |||
@@ -0,0 +1,32 @@ | |||
1 | PROJECT_NAME = toxcore | ||
2 | PROJECT_FULL_NAME = c-$(PROJECT_NAME) | ||
3 | PROJECT_VERSION = $(shell git describe | sed -e 's/^v//' -e 's/-/_/g') | ||
4 | PROJECT_COMMIT_ID = $(shell git rev-parse HEAD) | ||
5 | PROJECT_COMMIT_ID_SHORT = $(shell git rev-parse --short HEAD) | ||
6 | PROJECT_GIT_ROOT = $(shell git rev-parse --show-toplevel) | ||
7 | |||
8 | all: | ||
9 | @echo available targets: spec srpm clean | ||
10 | |||
11 | spec: toxcore.spec | ||
12 | |||
13 | toxcore.spec: | ||
14 | sed -r \ | ||
15 | -e 's#@PROJECT_NAME@#$(PROJECT_NAME)#g' \ | ||
16 | -e 's#@PROJECT_VERSION@#$(PROJECT_VERSION)#' \ | ||
17 | -e 's#^(%define commit )0$$#\1$(PROJECT_COMMIT_ID)#' \ | ||
18 | toxcore.spec.in > toxcore.spec | ||
19 | |||
20 | $(PROJECT_FULL_NAME)-$(PROJECT_COMMIT_ID_SHORT).tar.gz: | ||
21 | ( \ | ||
22 | cd $(PROJECT_GIT_ROOT); \ | ||
23 | git archive --prefix '$(PROJECT_FULL_NAME)-$(PROJECT_COMMIT_ID_SHORT)/' -o other/rpm/$(PROJECT_FULL_NAME)-$(PROJECT_COMMIT_ID_SHORT).tar.gz $(PROJECT_COMMIT_ID) \ | ||
24 | ) | ||
25 | |||
26 | srpm: toxcore.spec $(PROJECT_FULL_NAME)-$(PROJECT_COMMIT_ID_SHORT).tar.gz | ||
27 | rpmbuild --define "_sourcedir ." --define "_srcrpmdir ." -bs toxcore.spec | ||
28 | |||
29 | clean: | ||
30 | rm -f toxcore.spec *.tar.gz *.rpm | ||
31 | |||
32 | .PHONY = clean srpm spec | ||
diff --git a/other/rpm/tox-bootstrapd.service b/other/rpm/tox-bootstrapd.service new file mode 100644 index 00000000..227c4497 --- /dev/null +++ b/other/rpm/tox-bootstrapd.service | |||
@@ -0,0 +1,17 @@ | |||
1 | [Unit] | ||
2 | Description=Tox DHT Bootstrap Daemon | ||
3 | After=network.target | ||
4 | |||
5 | [Service] | ||
6 | Type=forking | ||
7 | RuntimeDirectory=tox-bootstrapd | ||
8 | RuntimeDirectoryMode=750 | ||
9 | PIDFile=/var/run/tox-bootstrapd/tox-bootstrapd.pid | ||
10 | WorkingDirectory=/var/lib/tox-bootstrapd | ||
11 | ExecStart=/usr/bin/tox-bootstrapd --config /etc/tox-bootstrapd.conf | ||
12 | User=tox-bootstrapd | ||
13 | Group=tox-bootstrapd | ||
14 | #CapabilityBoundingSet=CAP_NET_BIND_SERVICE | ||
15 | |||
16 | [Install] | ||
17 | WantedBy=multi-user.target | ||
diff --git a/other/rpm/toxcore.spec.in b/other/rpm/toxcore.spec.in new file mode 100644 index 00000000..4c5132ce --- /dev/null +++ b/other/rpm/toxcore.spec.in | |||
@@ -0,0 +1,126 @@ | |||
1 | %define full_name c-@PROJECT_NAME@ | ||
2 | %define commit 0 | ||
3 | %if "${commit}" != "0" | ||
4 | %define shortcommit %(c=%{commit}; echo ${c:0:7}) | ||
5 | %endif | ||
6 | |||
7 | Name: @PROJECT_NAME@ | ||
8 | Version: @PROJECT_VERSION@ | ||
9 | Release: 1%{?dist} | ||
10 | Summary: All-in-one secure communication platform | ||
11 | |||
12 | License: GPLv3 | ||
13 | URL: https://github.com/TokTok/%{full_name} | ||
14 | %if "%{commit}" == "0" | ||
15 | Source0: https://github.com/TokTok/%{full_name}/archive/v%{version}.tar.gz | ||
16 | %else | ||
17 | Source0: https://github.com/TokTok/%{full_name}/archive/%{commit}/%{full_name}-%{shortcommit}.tar.gz | ||
18 | %endif | ||
19 | |||
20 | BuildRequires: cmake | ||
21 | BuildRequires: libvpx-devel | ||
22 | BuildRequires: opus-devel | ||
23 | BuildRequires: libsodium-devel | ||
24 | BuildRequires: libconfig-devel | ||
25 | BuildRequires: systemd-units | ||
26 | |||
27 | %description | ||
28 | With the rise of governmental monitoring programs, Tox, a FOSS initiative, aims | ||
29 | to be an easy to use, all-in-one communication platform that ensures their users | ||
30 | full privacy and secure message delivery. | ||
31 | |||
32 | %package devel | ||
33 | Summary: Development files for @PROJECT_NAME@ | ||
34 | Requires: %{name} = %{version}-%{release} | ||
35 | |||
36 | %description devel | ||
37 | Development package for @PROJECT_NAME@ | ||
38 | |||
39 | %package static | ||
40 | Summary: @PROJECT_NAME@ static libraries | ||
41 | Requires: %{name}-devel = %{version}-%{release} | ||
42 | |||
43 | %description static | ||
44 | @PROJECT_NAME@ static libraries | ||
45 | |||
46 | %package -n tox-bootstrapd | ||
47 | Summary: Tox DHT bootstrap daemon. | ||
48 | Requires: %{name} = %{version}-%{release} | ||
49 | Requires(pre): shadow-utils | ||
50 | Requires(post): systemd-units | ||
51 | Requires(preun): systemd-units | ||
52 | Requires(postun): systemd-units | ||
53 | |||
54 | %description -n tox-bootstrapd | ||
55 | Tox DHT bootstrap daemon. | ||
56 | |||
57 | %prep | ||
58 | %if "%{commit}" == "0" | ||
59 | %setup -q -n %{full_name}-%{version} | ||
60 | %else | ||
61 | %setup -q -n %{full_name}-%{commit} | ||
62 | %endif | ||
63 | |||
64 | %build | ||
65 | %cmake | ||
66 | %{__make} %{?_smp_mflags} | ||
67 | |||
68 | %install | ||
69 | %make_install | ||
70 | mkdir -p %{buildroot}%{_unitdir} | ||
71 | install -m 0644 other/rpm/tox-bootstrapd.service %{buildroot}%{_unitdir}/tox-bootstrapd.service | ||
72 | install -d "%{buildroot}%{_sharedstatedir}/tox-bootstrapd" | ||
73 | mkdir -p %{buildroot}%{_sysconfdir} | ||
74 | install -m 0644 other/bootstrap_daemon/tox-bootstrapd.conf %{buildroot}%{_sysconfdir}/tox-bootstrapd.conf | ||
75 | |||
76 | %check | ||
77 | %{__make} %{?_smp_mflags} test | ||
78 | |||
79 | %pre -n tox-bootstrapd | ||
80 | getent group tox-bootstrapd >/dev/null || groupadd -r tox-bootstrapd | ||
81 | getent passwd tox-bootstrapd >/dev/null || \ | ||
82 | useradd -r -g tox-bootstrapd -d /var/lib/tox-bootstrapd -s /sbin/nologin \ | ||
83 | -c "Account to run Tox's DHT bootstrap daemon" tox-bootstrapd | ||
84 | |||
85 | %post -p /sbin/ldconfig | ||
86 | |||
87 | %postun -p /sbin/ldconfig | ||
88 | |||
89 | %post -n tox-bootstrapd | ||
90 | %systemd_post tox-bootstrapd.service | ||
91 | |||
92 | %postun -n tox-bootstrapd | ||
93 | %systemd_postun_with_restart tox-bootstrapd.service | ||
94 | |||
95 | %preun -n tox-bootstrapd | ||
96 | %systemd_preun tox-bootstrapd.service | ||
97 | |||
98 | %files | ||
99 | %defattr(-, root, root) | ||
100 | %doc COPYING README.md CHANGELOG.md | ||
101 | %{_libdir}/libtoxcore.so* | ||
102 | |||
103 | %files devel | ||
104 | %defattr(-, root, root) | ||
105 | %{_includedir}/tox/ | ||
106 | %{_libdir}/pkgconfig/toxcore.pc | ||
107 | |||
108 | %files static | ||
109 | %defattr(-, root, root) | ||
110 | %{_libdir}/libtoxcore.a | ||
111 | |||
112 | %files -n tox-bootstrapd | ||
113 | %defattr(-, root, root) | ||
114 | %{_bindir}/tox-bootstrapd | ||
115 | %{_unitdir}/tox-bootstrapd.service | ||
116 | %{_sharedstatedir}/tox-bootstrapd | ||
117 | %attr(-,tox-bootstrapd,tox-bootstrapd) %{_sharedstatedir}/tox-bootstrapd/ | ||
118 | %config(noreplace) %{_sysconfdir}/tox-bootstrapd.conf | ||
119 | |||
120 | |||
121 | %changelog | ||
122 | * Sat Nov 25 2017 SmokedCheese <root@ubuntology.ru> - 0.0.0-2 | ||
123 | - Rewrite spec file | ||
124 | |||
125 | * Tue Mar 3 2015 Sergey 'Jin' Bostandzhyan <jin@mediatomb.cc> - 0.0.0-1 | ||
126 | - initial package | ||