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

aur-update: Fix VCS vercmp, add glob ignoring #520

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 8 additions & 1 deletion aur-update/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,13 @@ List available updates from the Arch User Repository (AUR)

![](example.png)

Note: Logic depends on checking installed version against aurweb, so it doesn't
work well for VCS packages.
Instead, these need to run `makepkg --nodep -nobuild` on the actual `PKGBUILD`,
then either construct the version string via `makepkg --printsrcinfo` or parse
`makepkg --packagelist`, probably setting `PKG{DEST,EXT}` to controlled values
to make parsing more predictable.

## Setup / Usage

Example i3blocks configuration:
Expand Down Expand Up @@ -32,4 +39,4 @@ Usage of IPV4 can be forced using `FORCE_IPV4=1`. This is useful, because the AU

- python3 [requests library](http://docs.python-requests.org/en/master/)
- optional: libnotify/notify-send

- pyalpm
27 changes: 5 additions & 22 deletions aur-update/aur-update
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,9 @@
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.

import pyalpm
import re
import fnmatch
import json
import os
import requests
Expand Down Expand Up @@ -57,26 +60,6 @@ def version_in_aur(pkg):

return "NotFound"


def vcs_version(pkg, ver):
""" Try to find a sensible version for VSC packages

If pkg looks like a VCS package according to
https://wiki.archlinux.org/index.php/VCS_package_guidelines
try to extract a sensible (= comparable) version number.
"""

suffices = ['-cvs', '-svn', '-hg', '-darcs', '-bzr', '-git']
if not any(pkg.endswith(suffix) for suffix in suffices):
# does not look like a VCS package
return ver

if '.r' in ver:
# of the form RELEASE.rREVISION: only use the release
return ver.split('.r')[0]
# no base release to compare, just return None
return None

if args.force_ipv4:
# This is useful, because the AUR API often gets timeouts with
# IPV6 and the call does not return.
Expand Down Expand Up @@ -107,11 +90,11 @@ for pkg in packages.split('\n'):

updates = []
for pkg in installed_version.keys():
if pkg in args.ignore:
if any(re.match(fnmatch.translate(p), pkg) for p in args.ignore):
continue
v_aur = version_in_aur(pkg)
v_inst = installed_version[pkg]
if vcs_version(pkg, v_aur) != vcs_version(pkg, v_inst):
if pyalpm.vercmp(v_inst, v_aur) < 0:
updates.append(pkg + ' (%s -> %s)' % (v_inst, v_aur))

# create the message for the block
Expand Down