Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

How to handle different dependency names on differing distros? #124

Open
dmulder opened this issue Nov 7, 2024 · 3 comments
Open

How to handle different dependency names on differing distros? #124

dmulder opened this issue Nov 7, 2024 · 3 comments

Comments

@dmulder
Copy link

dmulder commented Nov 7, 2024

I'm trying to build RPMs for SUSE and Rocky, but the dependency names for some packages aren't the same. How am I supposed to handle this?

@cat-in-136
Copy link
Owner

See https://github.com/cat-in-136/cargo-generate-rpm#overwrite-configuration

As same as the original rpm, it is frequently possible to avoid explicitly specifying a dependent package names with automatic dependency resolution or so library names.

If not, use the configuration overwrite.

@dmulder
Copy link
Author

dmulder commented Nov 8, 2024

Ok, the documentation is vague on details, and everything I've tried doesn't actually work.
My problem is that I'm supplying an ssh configuration file, then adding a dependency on sshd (sshd in EL distros, openssh-server on SUSE distros).

My Cargo.toml looks like this:

[package]
name = "sshd-config"
description = "Himmelblau Required SSHD Configuration"
version.workspace = true
authors.workspace = true
rust-version.workspace = true
edition.workspace = true
license.workspace = true
homepage.workspace = true
repository.workspace = true

[lib]
path = "src/lib.rs"

[package.metadata.deb]
name = "himmelblau-sshd-config"
depends = ["openssh-server"]
assets = [
  ["../../platform/debian/sshd_config", "etc/ssh/sshd_config.d/himmelblau.conf", "644"],
]

[package.metadata.generate-rpm]
name = "himmelblau-sshd-config"
assets = [
  { source = "../../platform/el/sshd_config", dest = "/etc/ssh/sshd_config.d/himmelblau.conf", mode = "644" },
]

[package.metadata.generate-rpm.requires]
sshd = "*"

I've created a separate toml file for modifying the requires:

[package.metadata.generate-rpm.requires]
openssh-server = "*"

Then my build commands:
For EL:
cargo generate-rpm -p src/sshd-config
For SUSE:
cargo generate-rpm -p src/sshd-config --metadata-overwrite=src/sshd-config/openSUSEDepends.toml#package.metadata.generate-rpm.requires

The results:

# rpm -qpR packaging/himmelblau-sshd-config-0.8.0-1.x86_64-tumbleweed.rpm
/bin/sh
sshd
rpmlib(CompressedFileNames) = 3.0.4-1
rpmlib(FileDigests) = 4.6.0-1
rpmlib(PayloadFilesHavePrefix) = 4.0-1
rpmlib(PayloadIsZstd) = 5.4.18-1
# rpm -qpR packaging/himmelblau-sshd-config-0.8.0-1.x86_64-rocky9.rpm 
/bin/sh
sshd
rpmlib(CompressedFileNames) = 3.0.4-1
rpmlib(FileDigests) = 4.6.0-1
rpmlib(PayloadFilesHavePrefix) = 4.0-1
rpmlib(PayloadIsZstd) = 5.4.18-1

Clearly the --metadata-overwrite option is being ignored, unless I've made some mistake, but the documentation never explains clearly what should be provided here. I tried providing a full toml file, with just the requires changed. I tried supplying just the line openssh-server = "*" with #package.metadata.generate-rpm.requires on the command line (this throws an error).

Nothing I have tried works as you describe.

@cat-in-136
Copy link
Owner

As written README, it simply overwrites package.metadata.generate-rpm (not ....requires). No implementation to take care the context of the change.

See as following:

$ cat Cargo.toml                                                                                                                    /tmp/foobar (master)
[package]
name = "foobar"
description = "foobar"
license = "MIT"
version = "0.1.0"
edition = "2021"

[dependencies]

[package.metadata.generate-rpm]
name = "foobarbaz"
assets = [
  { source = "target/release/foobar", dest = "/usr/bin/foobar", mode = "755" },
]

[package.metadata.generate-rpm.requires]
sshd = "*"

#[package.metadata.generate-rpm.variants.suse.requires]
#openssh-server = "*"

$ cat openSUSEDepends.toml
[package.metadata.generate-rpm.requires]
openssh-server = "*"

$ cargo generate-rpm ; rpm -qpR target/generate-rpm/foobarbaz-0.1.0-1.x86_64.rpm | grep ssh
sshd
$ cargo generate-rpm --metadata-overwrite=openSUSEDepends.toml#package.metadata.generate-rpm ; rpm -qpR target/generate-rpm/foobarbaz-0.1.0-1.x86_64.rpm | grep ssh 
openssh-server

metadata-overwrite is muddled because it comprehensively supports a variety of requirements. For simple patching, comment out the Cargo.toml of above example and cargo generate-rpm --variant suse is simple and short.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants