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

Update rpm, migrate to clap and add source_date_epoch flag #83

Merged
merged 11 commits into from
Aug 8, 2023

Conversation

newpavlov
Copy link
Contributor

@newpavlov newpavlov commented Jun 2, 2023

While clap-based code is somewhat heavier than getopts, it's more powerful and results in cleaner and easier to maintain code.

This PR also fixes a bunch of Clippy warnings and introduces the source-date flag necessary for reproducible builds.

I am not completely sure I got the extra metadata stuff correctly, so it's better to double check it.

Closes #82

@newpavlov newpavlov force-pushed the clap branch 2 times, most recently from 413e677 to 8c99d56 Compare June 5, 2023 11:06
@newpavlov
Copy link
Contributor Author

@cat-in-136
I would appreciate if you will give feedback on this PR before I spend time on resolving the conflicts.

@cat-in-136
Copy link
Owner

cat-in-136 commented Jun 18, 2023

@newpavlov To resolve #82, the prerequisite is that the next version of rpm-rs/rpm have been released so that the git path does not have to be written to the Cargo.toml dependency. Other than that, some trivial work is required, such as updating README.md. In other words, there is still some work to be done.

On the other hand, if you remove the "source_date_epoch flag" and "closes #82" from this PR / branch, it is thought to be almost ready to merge.

What you do with it is up to you. Because you are a committer of rpm-rs/rpm.


Your clap branch cargo-generate-rpm works differently between cargo-generate-rpm and cargo generate-rpm. You can see this in the behavior of cargo-generate-rpm --help and cargo generate-rpm --help.

Some other cargo subcommands actually have this behavior, but I'd like to stick with it for compatibility with previous behavior and because it works properly with cargo tauri (which uses clap).

@newpavlov
Copy link
Contributor Author

I guess rpm v0.12 will be released only after rpm-rs/rpm#159 gets resolved, so it will take a bit of time.

Your clap branch cargo-generate-rpm works differently between cargo-generate-rpm and cargo generate-rpm.

Do you have suggestions how it can be fixed? Personally, I dislike the subcommand workaround as well, but I couldn't find an easy way to fix it.

@cat-in-136
Copy link
Owner

Do you have suggestions how it can be fixed? Personally, I dislike the subcommand workaround as well, but I couldn't find an easy way to fix it.

@newpavlov Here is the short snippet to do same thing as cargo-tauri does.

use clap::Parser;

#[derive(Debug, Parser)]
#[command(name = "cargo")]
#[command(bin_name = "cargo")]
enum CargoCli {
    Foobarbaz(FoobarbazArgs),
}

#[derive(Debug, Parser)]//<--- instead of clap::Args, use clap::Parser derive.
#[command(name = "cargo-foobarbaz")]
#[command(bin_name = "cargo-foobarbaz")]
#[command(author, version, about, long_about = None)]
struct FoobarbazArgs {
    #[arg(long)]
    foo: Option<String>,
}

fn main() {
    let args = if let Some("foobarbaz") = std::env::args().nth(1).as_deref() {
        CargoCli::parse()
    } else {
        CargoCli::Foobarbaz(FoobarbazArgs::parse())
    };
    println!("{args:?}");
}

@newpavlov newpavlov marked this pull request as ready for review July 14, 2023 16:39
@newpavlov
Copy link
Contributor Author

@cat-in-136
rpm v0.12 was published, so this PR is ready for review/merge.

@cat-in-136 cat-in-136 linked an issue Jul 22, 2023 that may be closed by this pull request
@cat-in-136
Copy link
Owner

@newpavlov Can you check my review comment above?

@newpavlov
Copy link
Contributor Author

Do you mean the difference between calling cargo-generate-rpm and cargo generate-rpm? I think I've already fixed it. Or have I missed something?

src/config/file_info.rs Outdated Show resolved Hide resolved
src/main.rs Outdated Show resolved Hide resolved
@cat-in-136
Copy link
Owner

I have already confirmed that the issue of cargo-generate-rpm and cargo generate-rpm is resolved in following code.

    let mut args = std::env::args();
    let args = if let Some("generate-rpm") = args.nth(1).as_deref() {
        let CargoWrapper::GenerateRpm(args) = CargoWrapper::parse();
        args
    } else {
        Cli::parse()
    };

@cat-in-136 cat-in-136 merged commit 750bbaa into cat-in-136:master Aug 8, 2023
1 check passed
@cat-in-136
Copy link
Owner

Thanks a lot.

@newpavlov newpavlov deleted the clap branch August 8, 2023 14:14
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

Successfully merging this pull request may close these issues.

RPM is not readable by rpmlint Reproducible builds
2 participants