debian: Add cargo and configure it

So a couple of things to consider here:

 - We need to `cargo vendor` and then bundle the `vendor` directory
   into a tarball, otherwise the tarball creation on Launchpad will
   remove `.gitignore` files and other mis-identified files, thus
   breaking the checksum checks in `cargo build` later.
 - Cargo likes to write metadata into its home, so provide us with a
   suitable scratch directory for that
 - The `cln-grpc` crate requires a protobuf compiler
This commit is contained in:
Christian Decker 2022-10-11 11:48:21 +02:00
parent 7192259c4d
commit 2b0780bd95
4 changed files with 12 additions and 3 deletions

5
.cargo/config.toml Normal file
View File

@ -0,0 +1,5 @@
[source.crates-io]
replace-with = "vendored-sources"
[source.vendored-sources]
directory = "vendor"

View File

@ -348,7 +348,7 @@ endif
RUST_PROFILE ?= debug
ifneq ($(RUST_PROFILE),debug)
CARGO_OPTS := --profile=$(RUST_PROFILE) --quiet
CARGO_OPTS := --profile=$(RUST_PROFILE) --quiet --offline
else
CARGO_OPTS := --quiet
endif

2
debian/control vendored
View File

@ -3,7 +3,7 @@ Source: lightningd
Section: net
Priority: optional
Maintainer: Christian Decker <decker.christian@gmail.com>
Build-Depends: debhelper (>=9),autotools-dev,build-essential,pkg-config,libsqlite3-dev,git,libtool,libgmp-dev,libsqlite3-dev,python3,net-tools,zlib1g-dev,python3-pip,autoconf,automake,python3-mako,gettext,libpq-dev,python3-mako
Build-Depends: debhelper (>=9),autotools-dev,build-essential,pkg-config,libsqlite3-dev,git,libtool,libgmp-dev,libsqlite3-dev,python3,net-tools,zlib1g-dev,python3-pip,autoconf,automake,python3-mako,gettext,libpq-dev,python3-mako,cargo,rustfmt,protobuf-compiler
Depends: libsqlite3-0
Standards-Version: 3.9.6
Homepage: https://github.com/ElementsProject/lightning

6
debian/rules vendored
View File

@ -19,11 +19,15 @@ export DH_VERBOSE = 1
override_dh_auto_build:
make
# Trick cargo into not writing stuff to our non-existent $HOME
mkdir /tmp/home
CARGO_HOME=/tmp/home cargo build --all --release --offline
CARGO_HOME=/tmp/home RUST_PROFILE=release make
# dh_make generated override targets
# This is example for Cmake (See https://bugs.debian.org/641051 )
override_dh_auto_configure:
tar -xvjf vendor.tar.bz2
# PYTHON_VERSION is required for libwally's ./configure script so it
# doesn't fall back on the deprecated (and removed) version 2
PYTHON_VERSION=3 ./configure CC=gcc --disable-developer --disable-valgrind --prefix=/usr