-
Notifications
You must be signed in to change notification settings - Fork 25
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
Support for building rpms on the fly #193
Comments
Where was that the case? The interface is mostly unchanged |
here is some code using the old RPMBuilder api, https://github.com/Lunarequest/sddm2rpm/blob/mistress/src/rpm_build.rs#L43-L55 it was possible to iterate over and add files to the rpm. which the new Packagebuild this isn't possible |
It's possible in exactly the same way though? This code (copied from your example & slightly simplified / corrected for new idioms) compiles and executes fine use rpm;
use std::env;
use std::path::Path;
use std::process::exit;
use walkdir;
fn main() {
let mut pkg = rpm::PackageBuilder::new(
"test",
"0.0.1",
"GPLv2",
"noarch",
"autogenrated sddm theme rpm",
)
.compression(rpm::CompressionType::Zstd)
.requires(rpm::Dependency::any("sddm"));
let info = "suse";
if info.contains("suse") {
pkg = pkg.requires(rpm::Dependency::any("kf5-plasma"))
.requires(rpm::Dependency::any("libqt5-qtquickcontrols"))
.requires(rpm::Dependency::any("libqt5-qtvirtualkeyboard"));
} else if info.contains("Fedora Linux") {
pkg = pkg.requires(rpm::Dependency::any("libKF5Plasma5"))
.requires(rpm::Dependency::any("qt5-qtquickcontrols"))
.requires(rpm::Dependency::any("desktop-backgrounds-compat"));
} else {
eprintln!("unsupported distro falling back to common package names\nNote: this may not be all dependencies");
}
for entry in walkdir::WalkDir::new("./src/")
.into_iter()
.filter_map(|e| e.ok())
{
let file = entry.path();
if Path::new(&file.as_os_str()).is_file() {
let dest = file
.to_string_lossy()
.replace("./", "/usr/share/sddm/themes/");
let options = rpm::FileOptions::new(dest);
pkg = pkg.with_file(file, options).expect("Error");
}
}
let package = pkg.build().unwrap();
let name = "test";
let mut f = std::fs::File::create(format!("{}.rpm", name)).unwrap();
match package.write(&mut f) {
Ok(()) => println!("created {name}.rpm"),
Err(e) => {
eprintln!("Failed to synathsize rpm {e}");
exit(1);
}
};
} Don't close your PR because it may still be a worthwhile addition, but I'm not sure any aspect of this is currently impossible? |
Thats strange rust was refusing to allow this in another project saying PackageBuilder does not implement copy |
Maybe the issue is that |
Closing the issue. The PR is still valid though, as mentioned before. |
Currently I'm working on a tool that generates rpms from yaml part of the issue is that I will never know the files in the final rpm until the build is completed. Currently with
PackageBuilder
does not implement Copy which means it's impossible to generate a rpm on the fly using a loop. the old package rpm-rs while having a clunkier interface supported this. the two solutions i can see area) add the copy trait to
PackageBuilder
, this may cause issues we can not foresee.b) implement a .with_files which takes a vec of tuples with (source, options)
The text was updated successfully, but these errors were encountered: