Skip to content

Commit

Permalink
packages: added script to build debian source package
Browse files Browse the repository at this point in the history
  • Loading branch information
Richard Pospesel committed Feb 28, 2024
1 parent 19aa374 commit f20d823
Show file tree
Hide file tree
Showing 12 changed files with 210 additions and 1 deletion.
3 changes: 2 additions & 1 deletion source/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -70,4 +70,5 @@ add_subdirectory(extern)
add_subdirectory(test)
add_subdirectory(pages)
add_subdirectory(bindings)
add_subdirectory(examples)
add_subdirectory(examples)
add_subdirectory(packages)
1 change: 1 addition & 0 deletions source/packages/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
add_subdirectory(deb)
2 changes: 2 additions & 0 deletions source/packages/deb/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
rules
control
57 changes: 57 additions & 0 deletions source/packages/deb/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
find_program(TAR_EXECUTABLE NAMES tar)
find_program(DPKG_SOURCE_EXECUTABLE NAMES dpkg-source)

if (NOT TAR_EXECUTABLE)
message(WARNING "tar not found; will not build debian source package")
elseif (NOT DPKG_SOURCE_EXECUTABLE)
message(WARNING "dpkg-source not found; will not build debian source package")
else()

# generate debian/rules file
set(RULES_IN ${CMAKE_CURRENT_SOURCE_DIR}/debian/rules.in)
set(RULES_OUT ${CMAKE_CURRENT_SOURCE_DIR}/debian/rules)
configure_file(${RULES_IN} ${RULES_OUT} @ONLY)

set(CONTROL_IN ${CMAKE_CURRENT_SOURCE_DIR}/debian/control.in)
set(CONTROL_OUT ${CMAKE_CURRENT_SOURCE_DIR}/debian/control)
configure_file(${CONTROL_IN} ${CONTROL_OUT} @ONLY)

# Copy Rust source files and Cargo toml files into source tarball
set(GOSLING_SOURCE "${CMAKE_SOURCE_DIR}/..")
set(GOSLING_TARBALL_DIR "${CMAKE_CURRENT_BINARY_DIR}/gosling-${CGOSLING_VERSION}")
set(GOSLING_TARBALL "${CMAKE_CURRENT_BINARY_DIR}/gosling_${CGOSLING_VERSION}.orig.tar.gz")
add_custom_command(
DEPENDS ${CMAKE_CURRENT_SOURCE_DIR}/debian
OUTPUT
${GOSLING_TARBALL}
${CMAKE_CURRENT_BINARY_DIR}/gosling_${CGOSLING_VERSION}.debian.tar.xz
${CMAKE_CURRENT_BINARY_DIR}/gosling_${CGOSLING_VERSION}.dsc
# build source tree
COMMAND ${CMAKE_COMMAND} -E rm -rf ${GOSLING_TARBALL_DIR}
COMMAND ${CMAKE_COMMAND} -E make_directory ${GOSLING_TARBALL_DIR}
COMMAND ${CMAKE_COMMAND} -E copy_directory ${CMAKE_SOURCE_DIR} ${GOSLING_TARBALL_DIR}/source
COMMAND ${CMAKE_COMMAND} -E copy ${CMAKE_SOURCE_DIR}/../LICENSE.md ${GOSLING_TARBALL_DIR}/.
COMMAND ${CMAKE_COMMAND} -E copy ${CMAKE_SOURCE_DIR}/../README.md ${GOSLING_TARBALL_DIR}/.
COMMAND ${CMAKE_COMMAND} -E copy ${CMAKE_SOURCE_DIR}/../Makefile ${GOSLING_TARBALL_DIR}/.
# delete optional submodules
COMMAND ${CMAKE_COMMAND} -E rm -rf ${GOSLING_TARBALL_DIR}/source/extern/Catch2
COMMAND ${CMAKE_COMMAND} -E rm -rf ${GOSLING_TARBALL_DIR}/source/extern/json

# create source tar
COMMAND tar -czf gosling_${CGOSLING_VERSION}.orig.tar.gz gosling-${CGOSLING_VERSION}
# copy debian directory
COMMAND cp -aP ${CMAKE_CURRENT_SOURCE_DIR}/debian ${GOSLING_TARBALL_DIR}/debian
COMMAND ${CMAKE_COMMAND} -E rm ${GOSLING_TARBALL_DIR}/debian/*.in

# build source package
COMMAND dpkg-source -b ${GOSLING_TARBALL_DIR}
)

add_custom_target(cgosling_debian_source_package_target ALL
DEPENDS
${GOSLING_TARBALL}
${CMAKE_CURRENT_BINARY_DIR}/gosling_${CGOSLING_VERSION}.debian.tar.xz
${CMAKE_CURRENT_BINARY_DIR}/gosling_${CGOSLING_VERSION}.dsc
)
add_dependencies(cgosling_debian_source_package_target gosling_cpp_bindings_target)
endif()
5 changes: 5 additions & 0 deletions source/packages/deb/debian/changelog
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
gosling (0.2.1-1) unstable; urgency=low

* Initial release.

-- Richard Pospesel <richard@blueprintforfreespeech.net> Fri, 23 Feb 2024 00:00:00 +0000
33 changes: 33 additions & 0 deletions source/packages/deb/debian/control
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
Source: gosling
Priority: optional
Maintainer: Richard Pospesel <richard@blueprintforfreespeech.net>
Build-Depends: debhelper-compat (= 13), cmake (>= 3.17), rustc (>= 1.63), cargo
Standards-Version: 4.5.1
Homepage: https://gosling.technology
Rules-Requires-Root: no

Package: libcgosling0
Section: libs
Architecture: any
Multi-Arch: same
Depends: ${misc:Depends}, ${shlibs:Depends}
Suggests: tor
Description: C bindings for Gosling crate
Gosling is a library that allows developers to create
applications which provide anonymous, secure, and
private peer-to-peer functionality using Tor onion
services.

Package: libcgosling-dev
Section: libdevel
Architecture: any
Multi-Arch: same
Depends: libcgosling0 (= ${binary:Version}), ${misc:Depends}
Description: C bindings for Gosling crate (development files)
Gosling is a library that allows developers to create
applications which provide anonymous, secure, and
private peer-to-peer functionality using Tor onion
services.
.
This package contains headers necessary to compile third-party
modules.
33 changes: 33 additions & 0 deletions source/packages/deb/debian/control.in
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
Source: gosling
Priority: optional
Maintainer: Richard Pospesel <richard@blueprintforfreespeech.net>
Build-Depends: debhelper-compat (= 13), cmake (>= 3.17), rustc (>= 1.63), cargo
Standards-Version: 4.5.1
Homepage: https://gosling.technology
Rules-Requires-Root: no

Package: libcgosling@CGOSLING_MAJOR_VERSION@
Section: libs
Architecture: any
Multi-Arch: same
Depends: ${misc:Depends}, ${shlibs:Depends}
Suggests: tor
Description: C bindings for Gosling crate
Gosling is a library that allows developers to create
applications which provide anonymous, secure, and
private peer-to-peer functionality using Tor onion
services.

Package: libcgosling-dev
Section: libdevel
Architecture: any
Multi-Arch: same
Depends: libcgosling@CGOSLING_MAJOR_VERSION@ (= ${binary:Version}), ${misc:Depends}
Description: C bindings for Gosling crate (development files)
Gosling is a library that allows developers to create
applications which provide anonymous, secure, and
private peer-to-peer functionality using Tor onion
services.
.
This package contains headers necessary to compile third-party
modules.
29 changes: 29 additions & 0 deletions source/packages/deb/debian/copyright
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
Format: https://www.debian.org/doc/packaging-manuals/copyright-format/1.0/
Upstream-Name: Gosling
Upstream-Contact: Richard Pospesel <richard@blueprintforfreespeech.net>
Source: https://gosling.technology

Files: *
Copyright: 2022-2024, Blueprint for Free Speech
License: BSD-3-clause
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions
are met:
1. Redistributions of source code must retain the above copyright
notice, this list of conditions and the following disclaimer.
2. Redistributions in binary form must reproduce the above copyright
notice, this list of conditions and the following disclaimer in the
documentation and/or other materials provided with the distribution.
3. The name of the author may not be used to endorse or promote products
derived from this software without specific prior written permission.
.
THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
29 changes: 29 additions & 0 deletions source/packages/deb/debian/rules.in
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
#!/usr/bin/make -f

%:
dh $@

override_dh_auto_build:
$(MAKE) config-release
$(MAKE) gosling_c_shared_bindings_target -C out/release
$(MAKE) gosling_cpp_shared_bindings_target -C out/release

override_dh_auto_install:
dh_auto_install

#
# libcgosling0
#
mkdir -p debian/libcgosling@CGOSLING_MAJOR_VERSION@/usr/lib/$(DEB_HOST_MULTIARCH)
cp out/release/bindings/c/lib/libcgosling.so.@CGOSLING_VERSION@ debian/libcgosling@CGOSLING_MAJOR_VERSION@/usr/lib/$(DEB_HOST_MULTIARCH)/.
cp -P out/release/bindings/c/lib/libcgosling.so.@CGOSLING_MAJOR_VERSION@ debian/libcgosling@CGOSLING_MAJOR_VERSION@/usr/lib/$(DEB_HOST_MULTIARCH)/.

#
# libcgosling-dev
#
mkdir -p debian/libcgosling-dev/usr/lib/$(DEB_HOST_MULTIARCH)
cp -P out/release/bindings/c/lib/libcgosling.so debian/libcgosling-dev/usr/lib/$(DEB_HOST_MULTIARCH)/.

mkdir -p debian/libcgosling-dev/usr/include/$(DEB_HOST_MULTIARCH)
cp out/release/bindings/c/include/* debian/libcgosling-dev/usr/include/$(DEB_HOST_MULTIARCH)/.
cp out/release/bindings/cpp/include/* debian/libcgosling-dev/usr/include/$(DEB_HOST_MULTIARCH)/.
1 change: 1 addition & 0 deletions source/packages/deb/debian/source/format
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
3.0 (quilt)
16 changes: 16 additions & 0 deletions source/packages/deb/debian/upstream/metadata
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
#
# DEP-12: Per-package machine-readable metadata about Upstream
# Please check * https://dep-team.pages.debian.net/deps/dep12/
# * https://wiki.debian.org/UpstreamMetadata
Reference:
Author: <please use full names and separate multiple author by the keyword "and">
Title:
Journal:
Year:
Volume:
Number:
Pages:
DOI:
PMID:
URL:
eprint:
2 changes: 2 additions & 0 deletions source/packages/deb/debian/watch
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
# You must remove unused comment lines for the released package.
version=3

0 comments on commit f20d823

Please sign in to comment.