Skip to content

Commit 7944370

Browse files
author
Richard Pospesel
committed
packages: added script to build debian source package
1 parent 091a44c commit 7944370

File tree

11 files changed

+194
-1
lines changed

11 files changed

+194
-1
lines changed

source/CMakeLists.txt

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -70,4 +70,5 @@ add_subdirectory(extern)
7070
add_subdirectory(test)
7171
add_subdirectory(pages)
7272
add_subdirectory(bindings)
73-
add_subdirectory(examples)
73+
add_subdirectory(examples)
74+
add_subdirectory(packages)

source/packages/CMakeLists.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
add_subdirectory(deb)

source/packages/deb/.gitignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
rules
2+
control

source/packages/deb/CMakeLists.txt

Lines changed: 57 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,57 @@
1+
find_program(TAR_EXECUTABLE NAMES tar)
2+
find_program(DPKG_SOURCE_EXECUTABLE NAMES dpkg-source)
3+
4+
if (NOT TAR_EXECUTABLE)
5+
message(WARNING "tar not found; will not build debian source package")
6+
elseif (NOT DPKG_SOURCE_EXECUTABLE)
7+
message(WARNING "dpkg-source not found; will not build debian source package")
8+
else()
9+
10+
# generate debian/rules file
11+
set(RULES_IN ${CMAKE_CURRENT_SOURCE_DIR}/debian/rules.in)
12+
set(RULES_OUT ${CMAKE_CURRENT_SOURCE_DIR}/debian/rules)
13+
configure_file(${RULES_IN} ${RULES_OUT} @ONLY)
14+
15+
# generate debian/control file
16+
set(CONTROL_IN ${CMAKE_CURRENT_SOURCE_DIR}/debian/control.in)
17+
set(CONTROL_OUT ${CMAKE_CURRENT_SOURCE_DIR}/debian/control)
18+
configure_file(${CONTROL_IN} ${CONTROL_OUT} @ONLY)
19+
20+
# Copy Rust source files and Cargo toml files into source tarball
21+
set(GOSLING_SOURCE "${CMAKE_SOURCE_DIR}/..")
22+
set(GOSLING_TARBALL_DIR "${CMAKE_CURRENT_BINARY_DIR}/gosling-${CGOSLING_VERSION}")
23+
set(GOSLING_TARBALL "${CMAKE_CURRENT_BINARY_DIR}/gosling_${CGOSLING_VERSION}.orig.tar.gz")
24+
add_custom_command(
25+
DEPENDS ${CMAKE_CURRENT_SOURCE_DIR}/debian
26+
OUTPUT
27+
${GOSLING_TARBALL}
28+
${CMAKE_CURRENT_BINARY_DIR}/gosling_${CGOSLING_VERSION}.debian.tar.xz
29+
${CMAKE_CURRENT_BINARY_DIR}/gosling_${CGOSLING_VERSION}.dsc
30+
# build source tree
31+
COMMAND ${CMAKE_COMMAND} -E rm -rf ${GOSLING_TARBALL_DIR}
32+
COMMAND ${CMAKE_COMMAND} -E make_directory ${GOSLING_TARBALL_DIR}
33+
COMMAND ${CMAKE_COMMAND} -E copy_directory ${CMAKE_SOURCE_DIR} ${GOSLING_TARBALL_DIR}/source
34+
COMMAND ${CMAKE_COMMAND} -E copy ${CMAKE_SOURCE_DIR}/../LICENSE.md ${GOSLING_TARBALL_DIR}/.
35+
COMMAND ${CMAKE_COMMAND} -E copy ${CMAKE_SOURCE_DIR}/../README.md ${GOSLING_TARBALL_DIR}/.
36+
COMMAND ${CMAKE_COMMAND} -E copy ${CMAKE_SOURCE_DIR}/../Makefile ${GOSLING_TARBALL_DIR}/.
37+
# delete optional submodules
38+
COMMAND ${CMAKE_COMMAND} -E rm -rf ${GOSLING_TARBALL_DIR}/source/extern/Catch2
39+
COMMAND ${CMAKE_COMMAND} -E rm -rf ${GOSLING_TARBALL_DIR}/source/extern/json
40+
41+
# create source tar
42+
COMMAND tar -czf gosling_${CGOSLING_VERSION}.orig.tar.gz gosling-${CGOSLING_VERSION}
43+
# copy debian directory
44+
COMMAND cp -aP ${CMAKE_CURRENT_SOURCE_DIR}/debian ${GOSLING_TARBALL_DIR}/debian
45+
COMMAND ${CMAKE_COMMAND} -E rm ${GOSLING_TARBALL_DIR}/debian/*.in
46+
47+
# build source package
48+
COMMAND dpkg-source -b ${GOSLING_TARBALL_DIR}
49+
)
50+
51+
add_custom_target(cgosling_debian_source_package_target ALL
52+
DEPENDS
53+
${GOSLING_TARBALL}
54+
${CMAKE_CURRENT_BINARY_DIR}/gosling_${CGOSLING_VERSION}.debian.tar.xz
55+
${CMAKE_CURRENT_BINARY_DIR}/gosling_${CGOSLING_VERSION}.dsc
56+
)
57+
endif()
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
gosling (0.2.1-1) unstable; urgency=low
2+
3+
* Initial release.
4+
5+
-- Richard Pospesel <richard@blueprintforfreespeech.net> Fri, 23 Feb 2024 00:00:00 +0000

source/packages/deb/debian/control

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
Source: gosling
2+
Priority: optional
3+
Maintainer: Richard Pospesel <richard@blueprintforfreespeech.net>
4+
Build-Depends: debhelper-compat (= 13), cmake (>= 3.17), rustc (>= 1.63), cargo
5+
Standards-Version: 4.5.1
6+
Homepage: https://gosling.technology
7+
Rules-Requires-Root: no
8+
9+
Package: libcgosling0
10+
Section: libs
11+
Architecture: any
12+
Multi-Arch: same
13+
Depends: ${misc:Depends}, ${shlibs:Depends}
14+
Suggests: tor
15+
Description: C bindings for Gosling crate
16+
Gosling is a library that allows developers to create
17+
applications which provide anonymous, secure, and
18+
private peer-to-peer functionality using Tor onion
19+
services.
20+
21+
Package: libcgosling-dev
22+
Section: libdevel
23+
Architecture: any
24+
Multi-Arch: same
25+
Depends: libcgosling0 (= ${binary:Version}), ${misc:Depends}
26+
Description: C bindings for Gosling crate (development files)
27+
Gosling is a library that allows developers to create
28+
applications which provide anonymous, secure, and
29+
private peer-to-peer functionality using Tor onion
30+
services.
31+
.
32+
This package contains headers necessary to compile third-party
33+
modules.
Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
Source: gosling
2+
Priority: optional
3+
Maintainer: Richard Pospesel <richard@blueprintforfreespeech.net>
4+
Build-Depends: debhelper-compat (= 13), cmake (>= 3.17), rustc (>= 1.63), cargo
5+
Standards-Version: 4.5.1
6+
Homepage: https://gosling.technology
7+
Rules-Requires-Root: no
8+
9+
Package: libcgosling@CGOSLING_MAJOR_VERSION@
10+
Section: libs
11+
Architecture: any
12+
Multi-Arch: same
13+
Depends: ${misc:Depends}, ${shlibs:Depends}
14+
Suggests: tor
15+
Description: C bindings for Gosling crate
16+
Gosling is a library that allows developers to create
17+
applications which provide anonymous, secure, and
18+
private peer-to-peer functionality using Tor onion
19+
services.
20+
21+
Package: libcgosling-dev
22+
Section: libdevel
23+
Architecture: any
24+
Multi-Arch: same
25+
Depends: libcgosling@CGOSLING_MAJOR_VERSION@ (= ${binary:Version}), ${misc:Depends}
26+
Description: C bindings for Gosling crate (development files)
27+
Gosling is a library that allows developers to create
28+
applications which provide anonymous, secure, and
29+
private peer-to-peer functionality using Tor onion
30+
services.
31+
.
32+
This package contains headers necessary to compile third-party
33+
modules.
Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
Format: https://www.debian.org/doc/packaging-manuals/copyright-format/1.0/
2+
Upstream-Name: Gosling
3+
Upstream-Contact: Richard Pospesel <richard@blueprintforfreespeech.net>
4+
Source: https://gosling.technology
5+
6+
Files: *
7+
Copyright: 2022-2024, Blueprint for Free Speech
8+
License: BSD-3-clause
9+
Redistribution and use in source and binary forms, with or without
10+
modification, are permitted provided that the following conditions
11+
are met:
12+
1. Redistributions of source code must retain the above copyright
13+
notice, this list of conditions and the following disclaimer.
14+
2. Redistributions in binary form must reproduce the above copyright
15+
notice, this list of conditions and the following disclaimer in the
16+
documentation and/or other materials provided with the distribution.
17+
3. The name of the author may not be used to endorse or promote products
18+
derived from this software without specific prior written permission.
19+
.
20+
THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
21+
IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
22+
OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
23+
IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
24+
INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
25+
NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
26+
DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
27+
THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
28+
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
29+
THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
#!/usr/bin/make -f
2+
3+
%:
4+
dh $@
5+
6+
override_dh_auto_build:
7+
$(MAKE) config-release
8+
$(MAKE) gosling_c_shared_bindings_target -C out/release
9+
$(MAKE) gosling_cpp_shared_bindings_target -C out/release
10+
11+
override_dh_auto_install:
12+
dh_auto_install
13+
14+
#
15+
# libcgosling0
16+
#
17+
mkdir -p debian/libcgosling@CGOSLING_MAJOR_VERSION@/usr/lib/$(DEB_HOST_MULTIARCH)
18+
cp out/release/bindings/c/lib/libcgosling.so.@CGOSLING_VERSION@ debian/libcgosling@CGOSLING_MAJOR_VERSION@/usr/lib/$(DEB_HOST_MULTIARCH)/.
19+
cp -P out/release/bindings/c/lib/libcgosling.so.@CGOSLING_MAJOR_VERSION@ debian/libcgosling@CGOSLING_MAJOR_VERSION@/usr/lib/$(DEB_HOST_MULTIARCH)/.
20+
21+
#
22+
# libcgosling-dev
23+
#
24+
mkdir -p debian/libcgosling-dev/usr/lib/$(DEB_HOST_MULTIARCH)
25+
cp -P out/release/bindings/c/lib/libcgosling.so debian/libcgosling-dev/usr/lib/$(DEB_HOST_MULTIARCH)/.
26+
27+
mkdir -p debian/libcgosling-dev/usr/include/$(DEB_HOST_MULTIARCH)
28+
cp out/release/bindings/c/include/* debian/libcgosling-dev/usr/include/$(DEB_HOST_MULTIARCH)/.
29+
cp out/release/bindings/cpp/include/* debian/libcgosling-dev/usr/include/$(DEB_HOST_MULTIARCH)/.
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
3.0 (quilt)

0 commit comments

Comments
 (0)