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

Fixes to failing mpm --pacman install <package_id> #766

Merged
merged 6 commits into from Sep 25, 2022

Conversation

dilawar
Copy link
Contributor

@dilawar dilawar commented Sep 24, 2022

Before this PR.

$ mpm --pacman install vim
Package manager order: pacman
warning: No vim package found on pacman.

After this PR, this works!

Fix

Fixes the parsing of the output of pacman search command.

Before this patch, the package_id would be extra/vim from the regex. After this patch, the package_id would be vim. extra/ is parsed as repo_id and ignored.

If pacman allows two packages with the same name but different repo e.g. foo/vim and bar/vim to co-exist then this PR is not a good solution.

Extra

Also adds a .gitlab-ci.yml file to test the package in an ArchLinux container. gitlab-runner exec docker pacman will run the tests inside an ArchLinux container. Can be used for #561? Unfortunately, requires installation of gitlab-runner. +1 that you can run the pipeline locally with gitlab-runner. Happy to drop these changes though.

@dilawar dilawar changed the title Fixes to failing mpm --pacman install vim Fixes to failing mpm --pacman install <package_id> Sep 24, 2022
@kdeldycke
Copy link
Owner

Thanks @dilawar for the PR!

As you pointed out, the unittest suite is not bullet-proof and quite fragile. 90% of the work on mpm is trying to make it pass on GitHub CI. So yes, any tentative alternative for a better test setup is welcome. I'll keep your Docker-based proposal around as I think it will be the way to go in the future. I hope I'll be able to revisit it soon.

I'll merge your PR as-is and trust you on pacman fix. I'll probably cut a release in a couple of days.

@kdeldycke kdeldycke added 🖥 platform: Linux Linux, Windows Subsystem for Linux v2 🐛 bug Something isn't working, or a fix is proposed 🤖 ci Continuous integration, tests, automation and management of the project 📦 manager: pacman-based pacaur, pacman, paru, yay labels Sep 25, 2022
@kdeldycke kdeldycke merged commit c4060a1 into kdeldycke:main Sep 25, 2022
@dilawar dilawar deleted the pacman branch September 25, 2022 05:26
@autinerd
Copy link
Contributor

autinerd commented Oct 5, 2022

I'm wondering why it didn't work before 🤔 Because pacman -Sy extra/vim should work as well.

@kdeldycke
Copy link
Owner

I'm not a pacman user so I blindly rely on you two to decide which is the better way. Adding more tests and making the test suite robust will help us go to the bottom of it. But I don't have a clue on how to cleanly integrate Docker with GitHub workflows. 😅

@dilawar
Copy link
Contributor Author

dilawar commented Oct 7, 2022

If I remember correctly, we never reached to pacman -S extra/vim execution. The search function could not match extra/vim with vim and declared that there is no package.

We still have a problem though. For example, if I have two packages from two different repos.

[dilawars@chutki meta-package-manager (post_766)]$ poetry run mpm --pacman search samtools
╭─────────────┬──────┬─────────┬────────────────╮
│ Package ID  │ Name │ Manager │ Latest version │
├─────────────┼──────┼─────────┼────────────────┤
│ r-rsamtools │      │ pacman  │ 2.12.0-4       │
│ samtools    │      │ pacman  │ 1.16-1         │
│ samtools    │      │ pacman  │ 1.16.1-1       │
╰─────────────┴──────┴─────────┴────────────────╯
3 packages total (pacman: 3).
[dilawars@chutki meta-package-manager (post_766)]$ poetry run mpm --pacman install samtools
Package manager order: pacman
Traceback (most recent call last):
  File "<string>", line 1, in <module>
  File "/home/dilawars/.cache/pypoetry/virtualenvs/meta-package-manager-fj-rdx---py3.10/lib/python3.10/site-packages/click/core.py", line 1130, in __call__
    return self.main(*args, **kwargs)
  File "/home/dilawars/.cache/pypoetry/virtualenvs/meta-package-manager-fj-rdx---py3.10/lib/python3.10/site-packages/click_extra/commands.py", line 142, in main
    super().main(*args, **kwargs)
  File "/home/dilawars/.cache/pypoetry/virtualenvs/meta-package-manager-fj-rdx---py3.10/lib/python3.10/site-packages/click/core.py", line 1055, in main
    rv = self.invoke(ctx)
  File "/home/dilawars/.cache/pypoetry/virtualenvs/meta-package-manager-fj-rdx---py3.10/lib/python3.10/site-packages/click_extra/commands.py", line 175, in invoke
    return super().invoke(ctx)
  File "/home/dilawars/.cache/pypoetry/virtualenvs/meta-package-manager-fj-rdx---py3.10/lib/python3.10/site-packages/click/core.py", line 1657, in invoke
    return _process_result(sub_ctx.command.invoke(sub_ctx))
  File "/home/dilawars/.cache/pypoetry/virtualenvs/meta-package-manager-fj-rdx---py3.10/lib/python3.10/site-packages/click/core.py", line 1404, in invoke
    return ctx.invoke(self.callback, **ctx.params)
  File "/home/dilawars/.cache/pypoetry/virtualenvs/meta-package-manager-fj-rdx---py3.10/lib/python3.10/site-packages/click/core.py", line 760, in invoke
    return __callback(*args, **kwargs)
  File "/home/dilawars/.cache/pypoetry/virtualenvs/meta-package-manager-fj-rdx---py3.10/lib/python3.10/site-packages/click/decorators.py", line 26, in new_func
    return f(get_current_context(), *args, **kwargs)
  File "/home/dilawars/Work/GITHUB/DILAWAR/meta-package-manager/meta_package_manager/cli.py", line 727, in install
    raise ValueError("Exact search returned multiple packages.")
ValueError: Exact search returned multiple packages.
[dilawars@chutki meta-package-manager (post_766)]$ poetry run mpm --pacman search bioarchlinux/samtools
0 package total (pacman: 0).
[dilawars@chutki meta-package-manager (post_766)]$ poetry run mpm --pacman search samtools
╭───────────────────────────────┬─────────────┬─────────┬────────────────╮
│ Package ID                    │ Name        │ Manager │ Latest version │
├───────────────────────────────┼─────────────┼─────────┼────────────────┤
│ bioarchlinux/package_name     │ r-rsamtools │ pacman  │ 2.12.0-4       │
│ bioarchlinux/package_name     │ samtools    │ pacman  │ 1.16.1-1       │
│ home_subcom_Arch/package_name │ samtools    │ pacman  │ 1.16-1         │
╰───────────────────────────────┴─────────────┴─────────┴────────────────╯
3 packages total (pacman: 3).
[dilawars@chutki meta-package-manager (post_766)]$ poetry run mpm --pacman install samtools
Package manager order: pacman
Traceback (most recent call last):
  File "<string>", line 1, in <module>
  File "/home/dilawars/.cache/pypoetry/virtualenvs/meta-package-manager-fj-rdx---py3.10/lib/python3.10/site-packages/click/core.py", line 1130, in __call__
    return self.main(*args, **kwargs)
  File "/home/dilawars/.cache/pypoetry/virtualenvs/meta-package-manager-fj-rdx---py3.10/lib/python3.10/site-packages/click_extra/commands.py", line 142, in main
    super().main(*args, **kwargs)
  File "/home/dilawars/.cache/pypoetry/virtualenvs/meta-package-manager-fj-rdx---py3.10/lib/python3.10/site-packages/click/core.py", line 1055, in main
    rv = self.invoke(ctx)
  File "/home/dilawars/.cache/pypoetry/virtualenvs/meta-package-manager-fj-rdx---py3.10/lib/python3.10/site-packages/click_extra/commands.py", line 175, in invoke
    return super().invoke(ctx)
  File "/home/dilawars/.cache/pypoetry/virtualenvs/meta-package-manager-fj-rdx---py3.10/lib/python3.10/site-packages/click/core.py", line 1657, in invoke
    return _process_result(sub_ctx.command.invoke(sub_ctx))
  File "/home/dilawars/.cache/pypoetry/virtualenvs/meta-package-manager-fj-rdx---py3.10/lib/python3.10/site-packages/click/core.py", line 1404, in invoke
    return ctx.invoke(self.callback, **ctx.params)
  File "/home/dilawars/.cache/pypoetry/virtualenvs/meta-package-manager-fj-rdx---py3.10/lib/python3.10/site-packages/click/core.py", line 760, in invoke
    return __callback(*args, **kwargs)
  File "/home/dilawars/.cache/pypoetry/virtualenvs/meta-package-manager-fj-rdx---py3.10/lib/python3.10/site-packages/click/decorators.py", line 26, in new_func
    return f(get_current_context(), *args, **kwargs)
  File "/home/dilawars/Work/GITHUB/DILAWAR/meta-package-manager/meta_package_manager/cli.py", line 728, in install
    raise ValueError(f"Exact search returned multiple packages: {pkg_list}")
ValueError: Exact search returned multiple packages: ['bioarchlinux/samtools', 'home_subcom_Arch/samtools']

Above are my old notes before submitting the PR.

I feel that forcing only a single match by raising exceptions if there are multiple matches is a bit more strict IMO. We can print a warning and continue with the first match?! But I also appreciate that things are explicit. Maybe we can have --strict/--no-strict args that switch between two behaviors: on multiple matches, we throw error in --strict and we print a warning and continue with the best match (difflib.SequenceMatcher?) with --no-strict. Default being --strict.

@autinerd
Copy link
Contributor

autinerd commented Oct 7, 2022

If I remember correctly, we never reached to pacman -S extra/vim execution. The search function could not match extra/vim with vim and declared that there is no package.

Interesting. When I use pacman with "exact" search, it shows me this:

$ sudo pacman -Ss "^vim$"
extra/gvim 9.0.0354-1 [Installiert]
    Vi Improved, a highly configurable, improved version of the vi text editor
    (with advanced features, such as a GUI)
extra/vim 9.0.0354-1
    Vi Improved, a highly configurable, improved version of the vi text editor

(gvim as well because gvim provides vim)

And yeah, because a package can exist in multiple repos (the most famous being testing for versions before going to extra etc.), the repo name should be part of the package name.

The only problem is, that you can't search for "repo/package" in pacman. To check if a package exists (with repo name), you have to use pacman -Si "extra/vim" for this. Maybe this would be a new extension for mpm, implementing "get details about package" for the package managers.

@github-actions
Copy link
Contributor

github-actions bot commented Jan 9, 2023

This pull request has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Jan 9, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
🐛 bug Something isn't working, or a fix is proposed 🤖 ci Continuous integration, tests, automation and management of the project 📦 manager: pacman-based pacaur, pacman, paru, yay 🖥 platform: Linux Linux, Windows Subsystem for Linux v2
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants