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

refactor: minor optimization to not fetch qemu packages if they are already installed #393

Merged

Conversation

pendo324
Copy link
Member

@pendo324 pendo324 commented May 5, 2023

Issue #, if available: N/A

Description of changes:

  • Check if executables are already present before trying to install packages. Saves a potentially useless and costly dnf cache refresh.

Testing done:

  • local testing

  • I've reviewed the guidance in CONTRIBUTING.md

License Acceptance

By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 license.

@pendo324 pendo324 added the enhancement New feature or request label May 5, 2023
@pendo324 pendo324 self-assigned this May 5, 2023
fi

if [[ $qemu_pkgs ]]; then
dnf install -y --setopt=install_weak_deps=False ${qemu_pkgs}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: I think the current solution should be 100% fine for this current case, but I think it'd be a little safer to have qemu_pkgs be an array, e.g.

qemu_pkgs=()
qemu_pkgs=("${qemu_pkgs[@]}" "qemu-user-static-aarch64")
dnf install -y --setopt=install_weak_deps=False "${qemu_pkgs[@]}"

just because it allows us to quote the variable expansion.

@@ -154,7 +154,18 @@ func toggleUserModeEmulationInstallationScript(limaCfg *limayaml.LimaYAML, enabl
Mode: "system",
Script: fmt.Sprintf(`%s
#!/bin/bash
dnf install -y --setopt=install_weak_deps=False qemu-user-static-aarch64 qemu-user-static-arm qemu-user-static-x86
qemu_pkgs=""
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

we have repeat this section multiple times in other files. Is it possible to create as bash function. something like
https://unix.stackexchange.com/questions/599604/create-reusable-functions-bash
Btw, i am not sure whether this is even doable in your case.

@pendo324
Copy link
Member Author

pendo324 commented May 8, 2023

Thanks for the comments. Will see if I can incorporate these recommendations in a future PR.

@pendo324 pendo324 enabled auto-merge (squash) May 8, 2023 22:48
@pendo324 pendo324 disabled auto-merge May 8, 2023 22:48
@pendo324 pendo324 merged commit 688f315 into runfinch:main May 8, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants