-
Notifications
You must be signed in to change notification settings - Fork 175
Identify the correct binary for DNF4 #2936
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
base: main
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -15,6 +15,7 @@ | |
| # You should have received a copy of the GNU General Public License | ||
| # along with kiwi. If not, see <http://www.gnu.org/licenses/> | ||
| # | ||
| import os | ||
| import re | ||
| from typing import ( | ||
| List, Dict | ||
|
|
@@ -88,6 +89,31 @@ def request_package_exclusion(self, name: str) -> None: | |
| """ | ||
| self.exclude_requests.append(name) | ||
|
|
||
| def _get_dnf4_binary_name(self, root=None): | ||
| """ | ||
| Identify whether dnf is 'dnf4' or 'dnf-3' | ||
|
|
||
| :param str root: lookup binary name below this root directory | ||
|
|
||
| :return: name of dnf4 command | ||
|
|
||
| :rtype: str | ||
| """ | ||
| dnf4_binary = 'dnf-3' | ||
| dnf4_search_env = { | ||
| 'PATH': os.sep.join([root, 'usr', 'bin']) | ||
| } if root else None | ||
|
|
||
| # Python interpreter specific path | ||
| if Path.which( | ||
| filename='dnf4', | ||
| custom_env=dnf4_search_env, | ||
| access_mode=os.X_OK | ||
| ): | ||
| dnf4_binary = 'dnf4' | ||
|
Comment on lines
+102
to
+113
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I think you can change this to dnf_binary = 'dnf-4' if Path.which(
filename='dnf4', access_mode=os.X_OK, root_dir=root
) else 'dnf-3'
return dnf_binary
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. It actually means that we are using
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. If the idea was to lookup PATH (host) and in $root then the code needs to run two lookup calls, because the first call would be happy if there is just one hit in the given PATH
Member
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This is the exact implementation we used in the old yum one: https://github.com/OSInside/kiwi/blob/v9.16.36/kiwi/package_manager/yum.py#L89-L110
Member
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. At least with all the current supported distributions, the
Member
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. We just can't check for |
||
|
|
||
| return dnf4_binary | ||
|
|
||
| def setup_repository_modules( | ||
| self, collection_modules: Dict[str, List[str]] | ||
| ) -> None: | ||
|
|
@@ -109,7 +135,7 @@ def setup_repository_modules( | |
| } | ||
| """ | ||
| dnf_module_command = [ | ||
| 'dnf' | ||
| self._get_dnf4_binary_name() | ||
| ] + self.dnf_args + [ | ||
| '--installroot', self.root_dir, | ||
| f'--releasever={self.release_version}' | ||
|
|
@@ -147,6 +173,7 @@ def process_install_requests_bootstrap( | |
|
|
||
| :rtype: namedtuple | ||
| """ | ||
| dnf4 = self._get_dnf4_binary_name() | ||
| exclude_args = [] | ||
| if self.exclude_requests: | ||
| # For DNF, excluding a package means removing it from | ||
|
|
@@ -156,12 +183,12 @@ def process_install_requests_bootstrap( | |
| for package in self.exclude_requests: | ||
| exclude_args.append('--exclude=' + package) | ||
| Command.run( | ||
| ['dnf'] + self.dnf_args + [ | ||
| [dnf4] + self.dnf_args + [ | ||
| f'--releasever={self.release_version}' | ||
| ] + ['makecache'] | ||
| ) | ||
| dnf_command = [ | ||
| 'dnf' | ||
| dnf4 | ||
| ] + self.dnf_args + [ | ||
| '--installroot', self.root_dir, | ||
| f'--releasever={self.release_version}' | ||
|
|
@@ -181,6 +208,7 @@ def process_install_requests(self) -> CommandCallT: | |
|
|
||
| :rtype: namedtuple | ||
| """ | ||
| dnf4 = self._get_dnf4_binary_name(self.root_dir) | ||
| exclude_args = [] | ||
| if self.exclude_requests: | ||
| # For DNF, excluding a package means removing it from | ||
|
|
@@ -193,7 +221,7 @@ def process_install_requests(self) -> CommandCallT: | |
| self.root_dir, self.dnf_args | ||
| ) | ||
| dnf_command = [ | ||
| 'chroot', self.root_dir, 'dnf' | ||
| 'chroot', self.root_dir, dnf4 | ||
| ] + chroot_dnf_args + [ | ||
| f'--releasever={self.release_version}' | ||
| ] + self.custom_args + exclude_args + [ | ||
|
|
@@ -240,9 +268,10 @@ def process_delete_requests(self, force: bool = False) -> CommandCallT: | |
| self.command_env | ||
| ) | ||
| else: | ||
| dnf4 = self._get_dnf4_binary_name(self.root_dir) | ||
| chroot_dnf_args = Path.move_to_root(self.root_dir, self.dnf_args) | ||
| dnf_command = [ | ||
| 'chroot', self.root_dir, 'dnf' | ||
| 'chroot', self.root_dir, dnf4 | ||
| ] + chroot_dnf_args + [ | ||
| f'--releasever={self.release_version}' | ||
| ] + self.custom_args + [ | ||
|
|
@@ -261,10 +290,11 @@ def update(self) -> CommandCallT: | |
|
|
||
| :rtype: namedtuple | ||
| """ | ||
| dnf4 = self._get_dnf4_binary_name(self.root_dir) | ||
| chroot_dnf_args = Path.move_to_root(self.root_dir, self.dnf_args) | ||
| return Command.call( | ||
| [ | ||
| 'chroot', self.root_dir, 'dnf' | ||
| 'chroot', self.root_dir, dnf4 | ||
| ] + chroot_dnf_args + [ | ||
| f'--releasever={self.release_version}' | ||
| ] + self.custom_args + [ | ||
|
|
||
Uh oh!
There was an error while loading. Please reload this page.