Gentoo Websites Logo
Go to: Gentoo Home Documentation Forums Lists Bugs Planet Store Wiki Get Gentoo!
Bug 926061 - app-portage/nattka-0.4.1-r1: make-package-list command crashes without git checkout
Summary: app-portage/nattka-0.4.1-r1: make-package-list command crashes without git ch...
Status: RESOLVED INVALID
Alias: None
Product: Gentoo Linux
Classification: Unclassified
Component: Current packages (show other bugs)
Hardware: All Linux
: Normal enhancement
Assignee: Michał Górny
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2024-03-03 01:42 UTC by A Schenck
Modified: 2024-03-04 07:54 UTC (History)
1 user (show)

See Also:
Package list:
Runtime testing required: ---


Attachments
Patch to remove git dependency for 'make-package-list' command (make_package_list_without_git.patch,7.71 KB, patch)
2024-03-03 01:42 UTC, A Schenck
Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description A Schenck 2024-03-03 01:42:31 UTC
Created attachment 886568 [details, diff]
Patch to remove git dependency for 'make-package-list' command

Tried using NATTkA while fumbling around trying to figure out how to file a keywordreq. The wiki page for NATTkA is a stub but it has a sample command for keywording, the results of which were:
```
rockpro64 /var/db/repos/gentoo # nattka --repo . make-package-list -a '~arm64' rsnapshot
Traceback (most recent call last):
  File "/usr/lib/python-exec/python3.11/nattka", line 8, in <module>
    sys.exit(setuptools_main())
             ^^^^^^^^^^^^^^^^^
  File "/usr/lib/python3.11/site-packages/nattka/__main__.py", line 1066, in setuptools_main
    sys.exit(main(sys.argv[1:]))
             ^^^^^^^^^^^^^^^^^^
  File "/usr/lib/python3.11/site-packages/nattka/__main__.py", line 1056, in main
    return getattr(cmd, args.command.replace('-', '_'))()
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/lib/python3.11/site-packages/nattka/__main__.py", line 395, in make_package_list
    repo, git_repo = self.get_git_repository()
                     ^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/lib/python3.11/site-packages/nattka/__main__.py", line 190, in get_git_repository
    git_repo = GitWorkTree(repo.location)
               ^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/lib/python3.11/site-packages/nattka/git.py", line 119, in __init__
    raise GitRepositoryNotFound(
nattka.git.GitRepositoryNotFound: No repository found in /var/db/repos/gentoo
```

From reading the help, 'make-package-list' didn't seem like it would need to do any git commands, and looking at the code supported that conclusion. So this is a quickly whipped up patch from the main machine, which when placed in /etc/portage/patches/app-portage/nattka/ results in the following output instead:
```
rockpro64 /var/db/repos/gentoo # nattka --repo . make-package-list -a '~arm64' app-backup/rsnapshot
INFO:nattka:Iteration 1: running pkgcheck ...
gentoo -- updating profiles cache: arm64
INFO:nattka:New packages: dev-perl/Lchown
INFO:nattka:Iteration 1: verifying ...
INFO:nattka:Iteration 2: running pkgcheck ...
INFO:nattka:Time elapsed: 0:00:05.921201
INFO:nattka:Target CC: arm64@gentoo.org
INFO:nattka:Package list follows:
app-backup/rsnapshot ~arm64
dev-perl/Lchown ^
```
Comment 1 Sam James archtester Gentoo Infrastructure gentoo-dev Security 2024-03-03 01:45:46 UTC
Per /usr/lib/python3.11/site-packages/nattka/git.py, it needs a git repo to be able to reset the state after, I think?
Comment 2 A Schenck 2024-03-03 03:21:41 UTC
(In reply to Sam James from comment #1)
> Per /usr/lib/python3.11/site-packages/nattka/git.py, it needs a git repo to
> be able to reset the state after, I think?

Ahh, so it is actually a destructive action because it defers to pkgcheck to do the scanning and that requires the ebuild(s) to be updated on disk. That is unfortunate but makes a bit of sense. For this one command the only writes seem to come from keyword.update_keywords_in_file which could return the original content if it changed, and an alternate context manager implementation could write that back. But that would be more work and be much more likely to closed "won't fix".
Syncing from rsync keeps a clean original copy to verify the manifest before writing the updates to the repository, which would be a reasonable approach here but it's taking a while to read the sync code to see how that works.
Or the changed ebuilds could be written to an overlay instead of over the existing files if pkgcheck supports overlays.

So many options but they require time to look into.