8000
Skip to content

Use sudo when invoking apt-get to install packages#17071

Merged
tomponline merged 3 commits intocanonical:mainfrom
simondeziel:install-packages
Nov 26, 2025
Merged

Use sudo when invoking apt-get to install packages#17071
tomponline merged 3 commits intocanonical:mainfrom
simondeziel:install-packages

Conversation

@simondeziel
Copy link
Copy Markdown
Member
@simondeziel simondeziel commented Nov 25, 2025

This should fix actions/install-lxd-runtimedeps that was otherwise missing sudo (see here):

 Installing optional runtime dependencies
+ echo 'Installing optional runtime dependencies'
+ . test/includes/check.sh
+ . test/includes/setup.sh
+ install_instance_drivers
+ '[' 1 = 0 ']'
+ local UNAME
+ local QEMU_SYSTEM
++ uname -m
+ UNAME=x86_64
+ '[' x86_64 = x86_64 ']'
+ QEMU_SYSTEM=qemu-system-x86
+ check_dependencies qemu-img qemu-system-x86_64 sgdisk make-bcache /usr/lib/qemu/virtiofsd
+ local dep missing
+ missing=
+ for dep in "$@"
+ command -v qemu-img
+ '[' -n '' ']'
+ missing=qemu-img
+ for dep in "$@"
+ command -v qemu-system-x86_64
+ '[' -n qemu-img ']'
+ missing='qemu-img qemu-system-x86_64'
+ for dep in "$@"
+ command -v sgdisk
+ for dep in "$@"
+ command -v make-bcache
+ for dep in "$@"
+ command -v /usr/lib/qemu/virtiofsd
+ '[' -n 'qemu-img qemu-system-x86_64' ']'
+ missing='qemu-img qemu-system-x86_64 /usr/lib/qemu/virtiofsd'
+ '[' -n 'qemu-img qemu-system-x86_64 /usr/lib/qemu/virtiofsd' ']'
+ echo 'Missing dependencies: qemu-img qemu-system-x86_64 /usr/lib/qemu/virtiofsd'
Missing dependencies: qemu-img qemu-system-x86_64 /usr/lib/qemu/virtiofsd
+ return 1
+ command -v apt-get
+ grep -qxF 'VERSION_ID="22.04"' /etc/os-release
+ apt-get install --no-install-recommends -y gdisk ovmf qemu-block-extra qemu-system-x86 qemu-utils qemu-system-modules-spice virtiofsd bcache-tools
E: Could not open lock file /var/lib/dpkg/lock-frontend - open (13: Permission denied)
E: Unable to acquire the dpkg frontend lock (/var/lib/dpkg/lock-frontend), are you root?

Signed-off-by: Simon Deziel <simon.deziel@canonical.com>
Signed-off-by: Simon Deziel <simon.deziel@canonical.com>
Signed-off-by: Simon Deziel <simon.deziel@canonical.com>
Copy link
Copy Markdown
Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

This PR fixes a permission issue where apt-get install was being invoked without sudo, causing failures in the actions/install-lxd-runtimedeps GitHub Actions workflow. The fix introduces a centralized install_packages() helper function that properly uses sudo when installing packages.

Key changes:

  • Adds new install_packages() helper function that wraps apt-get install with sudo
  • Refactors all direct apt-get install calls to use the new helper function
  • Simplifies conditional logic by removing redundant command -v apt-get checks

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated no comments.

File Description
test/includes/setup.sh Adds install_packages() helper function and refactors install_tools(), install_storage_driver_tools(), and install_instance_drivers() to use it
test/suites/container_devices_tpm.sh Replaces direct apt-get install call with install_packages() helper

@simondeziel simondeziel marked this pull request as ready for review November 25, 2025 22:21
@tomponline tomponline merged commit 6caa729 into canonical:main Nov 26, 2025
138 of 140 checks passed
@simondeziel simondeziel deleted the install-packages branch November 26, 2025 13:11
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

Successfully merging this pull request may close these issues.

3 participants

0