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

Directory next to PKGBUILD causes paru to fail #1135

Closed
fynzhak opened this issue Feb 15, 2024 · 5 comments
Closed

Directory next to PKGBUILD causes paru to fail #1135

fynzhak opened this issue Feb 15, 2024 · 5 comments

Comments

@fynzhak
Copy link

fynzhak commented Feb 15, 2024

Affected Version

paru v2.0.1 - libalpm v13.0.2

Description

It looks like the print_dir() function in install.rs fails if there is a directory next to the PKGBUILD. This causes print_dir() to return an Err and prevent any subsequent packages from installing.
turbovnc is one such package that causes the failure.

Here's a test you can throw into install.rs to see the failure in action:

#[cfg(test)]
mod tests {
    use std::path::Path;

    use crate::config::Config;

    use super::print_dir;

    #[test]
    fn test_print_dir() {
        let config = Config::default();
        let path = Path::new("testdata/clone/auracle-git");
        let mut printed = Vec::new();
        let mut buf = Vec::new();
        let bat = false;
        let recurse = 2;

        print_dir(&config, &path, &mut printed, &mut buf, bat, recurse).unwrap();
    }
}

The idea that comes to mind for a fix is if you detect a directory in the file processing loop, unconditionally "continue" if you detect a directory.
Perhaps something like:

@@ -1594,10 +1594,10 @@ fn print_dir(
                 continue;
             }
             if file.file_type()?.is_dir() {
-                if recurse == 0 {
-                    continue;
+                if recurse > 0 {
+                    print_dir(config, &file.path(), stdin, buf, bat, recurse - 1)?;
                 }
-                print_dir(config, &file.path(), stdin, buf, bat, recurse - 1)?;
+                    continue;

Since I've only just started looking at the code I just want to make sure the intent is correct and that this is a legitimate failure.

Thanks!

@soloturn
Copy link
Contributor

@fynzhak this makes it work for you?

@PlasticSoup
Copy link

Are you sure this is a paru issue directly? The turbovnc package builds and installs normally on my systems. Also when paru clones a pakage directory to ~/.cache/paru/clone a .git directory is created. Shouldn't all packages be affected then? Or am I misunderstanding something.

@fynzhak
Copy link
Author

fynzhak commented Feb 25, 2024

@soloturn , indeed this does fix it for me. My test passes and I'm able to build turbovnc with paru. All other tests seem to to pass as well.

@PlasticSoup , it looks like .git is specifically filtered out when looping through files.
It's curious that turbovnc works for you. I just tried it again in case something has changed, and it still fails for me. It's possible I have some configuration that's causing the failure to be more catastrophic for me.
Were you able to try running that little test I wrote?

To add a bit more detail, for me the test (and the turbovnc package) is failing with an error "Is a directory (os error 21)" when the print_dir() function does it's "pkgbbuild.read_to_end(buf)". The pkgbbuild variable in this case is a File representing the directory we are currently in. I think the assumption is that when we get to this point, we should just be looking at the PKGBUILD file?

@PlasticSoup
Copy link

I did not run the test, just because I only know the basics of programing and I'm not sure exactly where to put the code in the file and how to run the test. 🤷‍♂️

However, I did find out why the package builds on my systems. It appeared that the error happens very early in the process and that something expects a file but finds a directory. I remembered that by default at the PKGBUILD review paru pipes the files through a pager. I configure paru to use midnight commander with the FileManager option in paru.conf instead. When I changed that back to default the issue also occurred for me. So it looks like paru tries to pipe all objects through the pager and the directory causes the process to hang.

For now I moved the asc file into the root directory for turbovnc. I would think that other packages could be affected too since putting the asc files in keys/pgp is the standard in the repos.

@fynzhak
Copy link
Author

fynzhak commented Feb 26, 2024

Wow, thanks for updating the turbovnc package! It does build for me now via paru.

I'm glad you were able to reproduce the issue too!

If this is standard practice then I imagine there are other packages that will trigger the issue. We do have a test repo right in Paru that triggers it. 😄

Morganamilo added a commit that referenced this issue Mar 7, 2024
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

3 participants