[Pkg-rust-maintainers] wanted: guidance on building a binary package from a crate when the default featureset is insufficient

Daniel Kahn Gillmor dkg at fifthhorseman.net
Wed Feb 2 06:47:35 GMT 2022


Hi Debian rust folks--

I'm trying to upgrade sequoia-sop in debian from 0.22.2 to 0.25.0.  I'm
failing because it wants to build a binary crate, but the binary target
depends on a non-default feature of the crate itself.

in 0.22.2, this was a simple crate with a single binary package.  Build
worked fine.

in 0.23.0, upstream added a library crate with several possible
features, and now the binary crate needs one of the non-default features
to build.

Upstream's Cargo.toml these days has:

```
[lib]

[[bin]]
name = "sqop"
path = "src/main.rs"
required-features = ["cli"]

[features]
default = ["sequoia-openpgp/default"]
cli = ["sop/cli"]
crypto-nettle = ["sequoia-openpgp/crypto-nettle"]
crypto-cng = ["sequoia-openpgp/crypto-cng"]
compression = ["sequoia-openpgp/compression"]
compression-deflate = ["sequoia-openpgp/compression-deflate"]
compression-bzip2 = ["sequoia-openpgp/compression-bzip2"]
```

When i try to build it with the standard debian rust packaging workflow,
i end up with the following error (dependency build stages omitted for
brevity):

```
   dh_auto_install -O--buildsystem=cargo
debian cargo wrapper: options, profiles, parallel: ['parallel=4'] [] ['-j4']
debian cargo wrapper: rust_type, gnu_type: x86_64-unknown-linux-gnu, x86_64-linux-gnu
debian cargo wrapper: installing into destdir 'debian/sqop' prefix '/usr'
debian cargo wrapper: running subprocess (['env', 'RUST_BACKTRACE=1', 'CARGO_TARGET_DIR=/tmp/cdtemp.Z7OOMz/rust-sequoia-sop-0.25.0/target', '/usr/bin/cargo', '-Zavoid-dev-deps', 'install', '--verbose', '--verbose', '-j4', '--target', 'x86_64-unknown-linux-gnu', '--path', '/tmp/cdtemp.Z7OOMz/rust-sequoia-sop-0.25.0', '--root', 'debian/sqop/usr'],) {'check': True}
  Installing sequoia-sop v0.25.0 (/tmp/cdtemp.Z7OOMz/rust-sequoia-sop-0.25.0)
[…]
     Running `CARGO=/usr/bin/cargo CARGO_CRATE_NAME=sequoia_sop CARGO_MANIFEST_DIR=/tmp/cdtemp.Z7OOMz/rust-sequoia-sop-0.25.0 CARGO_PKG_AUTHORS='Justus Winter <justus at sequoia-pgp.org>' CARGO_PKG_DESCRIPTION='An implementation of the Stateless OpenPGP Interface using Sequoia' CARGO_PKG_HOMEPAGE='https://sequoia-pgp.org/' CARGO_PKG_LICENSE=GPL-2.0-or-later CARGO_PKG_LICENSE_FILE='' CARGO_PKG_NAME=sequoia-sop CARGO_PKG_REPOSITORY='https://gitlab.com/sequoia-pgp/sequoia-sop' CARGO_PKG_VERSION=0.25.0 CARGO_PKG_VERSION_MAJOR=0 CARGO_PKG_VERSION_MINOR=25 CARGO_PKG_VERSION_PATCH=0 CARGO_PKG_VERSION_PRE='' CARGO_PRIMARY_PACKAGE=1 LD_LIBRARY_PATH='/tmp/cdtemp.Z7OOMz/rust-sequoia-sop-0.25.0/target/release/deps:/usr/lib' OUT_DIR=/tmp/cdtemp.Z7OOMz/rust-sequoia-sop-0.25.0/target/x86_64-unknown-linux-gnu/release/build/sequoia-sop-3f5d260b44ff208a/out rustc --crate-name sequoia_sop --edition=2018 src/lib.rs --error-format=json --json=diagnostic-rendered-ansi --crate-type lib --emit=dep-info,metadata,link -C opt-level=3 -C embed-bitcode=no --cfg 'feature="default"' -C metadata=17d3292440b8f990 -C extra-filename=-17d3292440b8f990 --out-dir /tmp/cdtemp.Z7OOMz/rust-sequoia-sop-0.25.0/target/x86_64-unknown-linux-gnu/release/deps --target x86_64-unknown-linux-gnu -L dependency=/tmp/cdtemp.Z7OOMz/rust-sequoia-sop-0.25.0/target/x86_64-unknown-linux-gnu/release/deps -L dependency=/tmp/cdtemp.Z7OOMz/rust-sequoia-sop-0.25.0/target/release/deps --extern anyhow=/tmp/cdtemp.Z7OOMz/rust-sequoia-sop-0.25.0/target/x86_64-unknown-linux-gnu/release/deps/libanyhow-b38df66aae14183b.rmeta --extern sequoia_openpgp=/tmp/cdtemp.Z7OOMz/rust-sequoia-sop-0.25.0/target/x86_64-unknown-linux-gnu/release/deps/libsequoia_openpgp-c5868d1f0e4f5f54.rmeta --extern sop=/tmp/cdtemp.Z7OOMz/rust-sequoia-sop-0.25.0/target/x86_64-unknown-linux-gnu/release/deps/libsop-ffa2524c1f3ac0d0.rmeta -C debuginfo=2 --cap-lints warn -C linker=x86_64-linux-gnu-gcc -C link-arg=-Wl,-z,relro --remap-path-prefix /tmp/cdtemp.Z7OOMz/rust-sequoia-sop-0.25.0=/usr/share/cargo/registry/sequoia-sop-0.25.0 -L native=/usr/lib/gcc/x86_64-linux-gnu/11/ -L native=/usr/lib/x86_64-linux-gnu -L native=/usr/lib/x86_64-linux-gnu -L native=/usr/lib/x86_64-linux-gnu -L native=/usr/lib/x86_64-linux-gnu`
warning: `sequoia-openpgp` (lib) generated 10 warnings
    Finished release [optimized] target(s) in 6m 45s
error: no binaries are available for install using the selected features
Traceback (most recent call last):
  File "/usr/share/cargo/bin/cargo", line 231, in <module>
    sys.exit(main(*sys.argv[1:]))
  File "/usr/share/cargo/bin/cargo", line 221, in main
    return install(os.getenv("DESTDIR", ""),
  File "/usr/share/cargo/bin/cargo", line 127, in install
    logrun(["env", "RUST_BACKTRACE=1",
  File "/usr/share/cargo/bin/cargo", line 76, in logrun
    return subprocess.run(*args, **kwargs)
  File "/usr/lib/python3.9/subprocess.py", line 528, in run
    raise CalledProcessError(retcode, process.args,
subprocess.CalledProcessError: Command '['env', 'RUST_BACKTRACE=1', 'CARGO_TARGET_DIR=/tmp/cdtemp.Z7OOMz/rust-sequoia-sop-0.25.0/target', '/usr/bin/cargo', '-Zavoid-dev-deps', 'install', '--verbose', '--verbose', '-j4', '--target', 'x86_64-unknown-linux-gnu', '--path', '/tmp/cdtemp.Z7OOMz/rust-sequoia-sop-0.25.0', '--root', 'debian/sqop/usr']' returned non-zero exit status 101.
dh_auto_install: error: env DESTDIR=debian/sqop /usr/share/cargo/bin/cargo install returned exit code 1
make: *** [debian/rules:3: binary] Error 25
dpkg-buildpackage: error: debian/rules binary subprocess returned exit status 2
```

as far as i can tell, the problem is related to this argument to cargo:

     --cfg 'feature="default"'

Which of course will not build the binary, since the binary depends on
the non-default "cli" feature.

There's kind of a twisty maze of things i might need to look at to
figure out how to adjust this to include a different featureset, and
none of the places i've looked has proved fruitful.

I've looked at:

- debcargo sources

- dh-cargo sources

- source for the /usr/share/cargo/bin/cargo wrapper from the cargo
  package
 
- trawled the debcargo-conf repo looking for an example other package
  with similar constraints

If this is a bug in our toolchain, i don't even know where to file it.

Any suggestions or pointers?

    --dkg
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 227 bytes
Desc: not available
URL: <http://alioth-lists.debian.net/pipermail/pkg-rust-maintainers/attachments/20220202/657aa0d5/attachment.sig>


More information about the Pkg-rust-maintainers mailing list