Skip to content

Commit

Permalink
api: correct bug with package_latest_version
Browse files Browse the repository at this point in the history
If a user has a residual config of a package that is no longer available (like with a manually installed package that has been removed and not purged), the resulting package_latest_version could be incorrect.

eg (a newer firejail was downloaded and manually installed and then removed, it still has a residual-config but can not be installed since it is not in the repos):
```
apt list -a firejail
Listing... Done
firejail/now 0.9.62-3ubuntu0.1 arm64 [residual-config]
firejail/bionic 0.9.52-2 arm64 [residual-config]
```
vs
```
apt-cache policy firejail
firejail:
  Installed: (none)
  Candidate: 0.9.52-2
  Version table:
     0.9.62-3ubuntu0.1 -1
        100 /var/lib/dpkg/status
     0.9.52-2 500
        500 http://ports.ubuntu.com bionic/universe arm64 Packages
```
this new change also takes 1/3 the time to execute as the other method as well

this caused `package_is_new_enough` to return incorrect output
  • Loading branch information
theofficialgman committed Jul 6, 2023
1 parent 0654568 commit aa488b7
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion api
Original file line number Diff line number Diff line change
Expand Up @@ -132,7 +132,7 @@ package_latest_version() { #returns the latest available versions of the specifi
[ -z "$package" ] && error "package_latest_version(): no package specified!"

# use slower but more accurate apt list command to get package version for current architecture
apt list -a "$package" 2>/dev/null | grep "$(dpkg --print-architecture)\|all" | awk '{print $2}' | sort -rV | head -n1
apt-cache policy "$package" 2>/dev/null | grep "Candidate: " | awk '{print $2}'
#grep -rx "Package: $package" /var/lib/apt/lists --exclude="lock" --exclude-dir="partial" --after 4 | grep -o 'Version: .*' | awk '{print $2}' | sort -rV | head -n1
}

Expand Down

0 comments on commit aa488b7

Please sign in to comment.