#!/usr/bin/python #Checks the aur version and compares it to the /data/dev/linhes_pkgbuild/linhes directory. import os,sys import shutil import urllib.request, urllib.error, urllib.parse import re import subprocess import glob def getArchVer(): try: archVer = subprocess.check_output(["package-query", "-A", "-i", "-f %v", "--nocolor", currDirName]) archVer = archVer.strip().decode('utf-8') return archVer except: return "None" def getLHVer(): pkgfile = currDir + "/PKGBUILD" if not os.path.isfile(pkgfile): print(currDirName + " version in LH PKGBUILD is: Unknown") print(" Can't find",pkgfile) #sys.exit(2) else: LHVer="" variables=["pkgbase", "pkgname", "pkgver", "pkgrel", "epoch"] # Loop over contents to get our variables # Use bash to do it because PKGBUILDs are very loose with their format for item in variables: v = subprocess.Popen(['/bin/bash','-c', 'source ' + pkgfile + '; echo ${' + item + '[@]}'], stdout = subprocess.PIPE,) value = v.communicate()[0].strip(b'\n') value = value.decode('utf-8') if item == "pkgbase": pkgbase = value elif item == "pkgname": pkgname = value pkglist = list(value.split()) elif item == "epoch": if value: epoch = "%s:" %value LHVer=epoch elif item == "pkgver": pkgver = value elif item == "pkgrel": pkgrel = value LHVer=LHVer + pkgver + "-" + pkgrel return LHVer # print(currDirName + " version in LH PKGBUILD is: " + LHVer) def main(): global currDirName global currDir LHdir="/data/dev/linhes_pkgbuild/linhes/*" for currDir in glob.glob(LHdir): if os.path.isdir(currDir): currDirName = os.path.basename(currDir) if currDirName == "mythtv": continue archVer = getArchVer() if archVer == "None": continue #print("Searching for " + currDirName + " on archlinux.org...") #print("AUR:",archVer) LHVer = getLHVer() #print("LH:",LHVer) archNewer = subprocess.run(['/bin/vercmp', archVer , LHVer], capture_output=True, text=True) if archNewer.stdout == "1\n": print(currDirName,"needs update: [AUR]:",archVer,"[LH]:",LHVer) if __name__ == "__main__": print("--------------------------") main() print("--------------------------")