Unattended-Upgrade升级失败求助:指定软件包未自动更新
Let’s walk through the most likely fixes for why these Microsoft SQL packages aren’t updating automatically, even after you ran a manual dist-upgrade:
1. Confirm Microsoft’s repo is allowed in Unattended-Upgrades config
Unattended-Upgrades only pulls updates from sources explicitly listed in its allowed origins. Since msodbcsql and mssql-tools come from Microsoft’s third-party repository, it’s probably missing from the default allowlist.
- Open your config file to check:
nano /etc/apt/apt.conf.d/50unattended-upgrades - Look for the
Unattended-Upgrade::Allowed-Originssection. To find the exact origin/suite string to add, run this command to inspect the package’s source details:
You’ll see lines likeapt-cache policy msodbcsqlOrigin: packages.microsoft.comandSuite: jammy-prod(the suite name matches your distro codename). Add this entry to the allowed origins list:"packages.microsoft.com:jammy-prod"; - Save the file, then run
unattended-upgrade -d(debug mode) to test if the auto-updater now recognizes the pending updates.
2. Check if the packages are marked as "held"
If a package is marked as held, Unattended-Upgrades will skip it completely. Verify this with:
apt-mark showhold
If you see msodbcsql or mssql-tools in the output, unhold them using:
apt-mark unhold msodbcsql mssql-tools
3. Inspect Unattended-Upgrades’ dedicated logs
The history.log only tracks manual upgrade actions—Unattended-Upgrades has its own detailed logs that will tell you exactly why it skipped these packages. Check them with:
less /var/log/unattended-upgrades/unattended-upgrades.log
Look for lines referencing msodbcsql or mssql-tools—common issues here include:
- Unresolvable dependency conflicts that require user input
- Failed connections to Microsoft’s repository
- Configuration file prompts that the auto-updater is set to skip
If you spot config file conflicts, run dpkg --configure -a to resolve them manually, then re-test the unattended upgrade.
4. Validate Microsoft’s repository setup
Occasionally, Microsoft’s repo might be misconfigured or outdated, preventing updates from being detected. Check your repo file:
cat /etc/apt/sources.list.d/mssql-release.list
Ensure the URL matches your distro version (e.g., https://packages.microsoft.com/ubuntu/22.04/prod for Jammy). If it’s incorrect, update it, run apt update, and try again.
After working through these steps, run unattended-upgrade -d to simulate the auto-upgrade process and confirm the packages are now being processed correctly.
内容的提问来源于stack exchange,提问作者Sam

