"fedpkg local" builds fail for rust packages

2024-04-03 Thread pfed--- via devel
Hi all,

I like using `fedpkg local` builds to speed up testing of packaging, but
now encountered a problem trying to package a rust program for the first
time. It turns out a local build fails in the install step for all rust
packages (that I tried out) with an error like

error: 152 files in the working directory contain changes that were not yet 
committed into git:
[ ... file list ... ]
to proceed despite this and include the uncommitted changes, pass the 
`--allow-dirty` flag

The problem is the line

/usr/bin/env CARGO_HOME=.cargo RUSTC_BOOTSTRAP=1 RUSTFLAGS='-Copt-level=3 
-Cdebuginfo=2 -Ccodegen-units=1 -Cstrip=none -Cforce-frame-pointers=yes 
-Clink-arg=-specs=/usr/lib/rpm/redhat/redhat-package-notes --cap-lints=warn' 
/usr/bin/cargo package -l | grep -w -E -v 'Cargo.(lock|toml.orig)' | xargs -d 
'\n' /usr/bin/cp --parents -a -t $REG_DIR

coming from the `%cargo_install` macro, where `cargo package -l` is used
to generate the file list. Now, since `fedpkg local` builds inside a
subdirectory of the package repo, `cargo package` sees that it's
operating inside a git repo and issues the above warning, exiting
non-zero.

I know to work around this by using rpmbuild manually or testing with
mock builds all the time, but I think it would be great if local builds
would work, too.

Maybe we could add the `--allow-dirty` to the `%cargo_install` macro -
from the top of my head this should not break anything, but I'm not
sure. There does not seem to be a general "ignore-git" option for cargo.

Or are there other ways to get this to work?

Greetings,
Philip Matura
--
___
devel mailing list -- devel@lists.fedoraproject.org
To unsubscribe send an email to devel-le...@lists.fedoraproject.org
Fedora Code of Conduct: 
https://docs.fedoraproject.org/en-US/project/code-of-conduct/
List Guidelines: https://fedoraproject.org/wiki/Mailing_list_guidelines
List Archives: 
https://lists.fedoraproject.org/archives/list/devel@lists.fedoraproject.org
Do not reply to spam, report it: 
https://pagure.io/fedora-infrastructure/new_issue


Re: "fedpkg local" builds fail for rust packages

2024-04-04 Thread pfed--- via devel
On Thu, Apr 04, 2024 at 09:51:31AM +0200, Fabio Valentini wrote:
> > > The short answer is: No, "fedpkg local" is not expected to work for
> > > Rust packages, and probably won't ever work as expected for Rust
> > > packages.
> > >
> > > I am not really interested in adding the "--allow-dirty" flag (not
> > > sure if it would even work in this case), since building Rust packages
> > > with "fedpkg local" is not working for other reasons. Primarily,
> > > "fedpkg local" does not support dynamically generated BuildRequires -
> > > this is only supported when building in mock.
> 
> > I don't know what you mean? For me after patching the macro locally
> > local builds work as expected. Maybe I'm overlooking something?
> 
> You might be lucky and just tried to package a Rust crate with no
> dependencies?
> Dependencies on other Rust crates are only resolved dynamically at build
> time, which "fedpkg local" does not support. So it works "by accident" for
> Rust crates with no crate dependencies, but in general, it can't work.

That would have been extremely lucky, but no, I'm building crates with
dependencies. And the build generates the requires list just fine.

What is not possible is installing build dependencies directly from a
spec file from a fresh clone, if that is what you mean? But in this case
running a local build generates a `.buildreqs.nosrc.rpm` file with the
correct dependencies, which can be passed to `dnf builddep`.

And since a local build does not manage build dependencies themselves,
rather relies on them just being there, I don't really see an issue in
that?

Philip Matura
--
___
devel mailing list -- devel@lists.fedoraproject.org
To unsubscribe send an email to devel-le...@lists.fedoraproject.org
Fedora Code of Conduct: 
https://docs.fedoraproject.org/en-US/project/code-of-conduct/
List Guidelines: https://fedoraproject.org/wiki/Mailing_list_guidelines
List Archives: 
https://lists.fedoraproject.org/archives/list/devel@lists.fedoraproject.org
Do not reply to spam, report it: 
https://pagure.io/fedora-infrastructure/new_issue