Skip to content

[FIX]Handle dpkg lock and interrupted state on fresh installs#921

Merged
rquidute merged 4 commits into2.14.1+winter2026from
fix/919_pi-setup-dpkg-lock-and-repair
Mar 18, 2026
Merged

[FIX]Handle dpkg lock and interrupted state on fresh installs#921
rquidute merged 4 commits into2.14.1+winter2026from
fix/919_pi-setup-dpkg-lock-and-repair

Conversation

@rquidute
Copy link
Copy Markdown
Contributor

What changed

Improve the robustness of the Pi setup installation script by handling two common failure scenarios on fresh Ubuntu installs: background package manager locks and interrupted dpkg state.

  • scripts/pi-setup/install-pi-dependencies.sh

    • Added a new step "Wait for automatic system updates to complete" that polls three dpkg/apt lock files (/var/lib/dpkg/lock-frontend,
      /var/lib/apt/lists/lock, /var/cache/apt/archives/lock) every 10 seconds before proceeding. Waits up to 5 minutes; exits with a clear warning message
      if locks persist beyond that.
    • Added a new step "Check and repair dpkg state if interrupted" that runs dpkg --audit to detect any partially configured packages, and automatically
      invokes dpkg --configure -a to repair them. Exits with an actionable error message if the repair fails.

    Both steps are inserted before the "Upgrade OS" step, where these issues would otherwise cause the script to fail.

Related Issue

#919

Testing

@rquidute rquidute self-assigned this Mar 17, 2026
@gemini-code-assist
Copy link
Copy Markdown

Summary of Changes

Hello, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed!

This pull request significantly enhances the robustness of the Raspberry Pi setup installation script. It introduces proactive measures to address common issues encountered on fresh Ubuntu installations, specifically by waiting for background package manager operations to complete and automatically repairing any inconsistent dpkg states. These improvements aim to prevent script failures and provide a more reliable and smoother installation experience.

Highlights

  • Package Manager Lock Handling: Implemented a waiting mechanism that polls dpkg and apt lock files for up to 5 minutes, preventing script failures due to background package manager activity on fresh installs. If locks persist, a warning is issued and the script exits.
  • Dpkg State Repair: Added a step to detect and automatically repair interrupted dpkg states using dpkg --audit and dpkg --configure -a, ensuring package consistency before further operations. If repair fails, an actionable error message is provided.

🧠 New Feature in Public Preview: You can now enable Memory to help Gemini Code Assist learn from your team's feedback. This makes future code reviews more consistent and personalized to your project's style. Click here to enable Memory in your admin console.

Changelog
  • scripts/pi-setup/install-pi-dependencies.sh
    • Added a new section to wait for automatic system updates to complete by polling dpkg and apt lock files, with a 5-minute timeout.
    • Introduced a new section to check and repair the dpkg state if it's interrupted, using dpkg --audit and dpkg --configure -a.
Activity
  • No human activity (comments, reviews, progress) has been recorded on this pull request yet.
Using Gemini Code Assist

The full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips.

Invoking Gemini

You can request assistance from Gemini at any point by creating a comment using either /gemini <command> or @gemini-code-assist <command>. Below is a summary of the supported commands on the current page.

Feature Command Description
Code Review /gemini review Performs a code review for the current pull request in its current state.
Pull Request Summary /gemini summary Provides a summary of the current pull request in its current state.
Comment @gemini-code-assist Responds in comments when explicitly tagged, both in pull request comments and review comments.
Help /gemini help Displays a list of available commands.

Customization

To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a .gemini/ folder in the base of the repository. Detailed instructions can be found here.

Limitations & Feedback

Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for GitHub and other Google products, sign up here.

You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension.

Footnotes

  1. Review the Privacy Notices, Generative AI Prohibited Use Policy, Terms of Service, and learn how to configure Gemini Code Assist in GitHub here. Gemini can make mistakes, so double check it and use code with caution.

Copy link
Copy Markdown

@gemini-code-assist gemini-code-assist bot left a comment

Choose a reason for hiding this comment

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

Code Review

This pull request improves the robustness of the Pi setup script by adding checks for package manager locks and interrupted dpkg states. The implementation is solid. I've added one suggestion to improve the shell scripting style and robustness in the lock-waiting loop. Overall, this is a valuable addition to prevent common failures on fresh installations.

@rquidute rquidute marked this pull request as ready for review March 18, 2026 11:53
Copy link
Copy Markdown
Contributor

@antonio-amjr antonio-amjr left a comment

Choose a reason for hiding this comment

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

I have some comments below:

@rquidute rquidute merged commit 10ba29f into 2.14.1+winter2026 Mar 18, 2026
3 checks passed
@rquidute rquidute deleted the fix/919_pi-setup-dpkg-lock-and-repair branch March 18, 2026 14:15
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