summaryrefslogtreecommitdiffstats
path: root/linhes/linhes-dev/chk_aur_pkg.py
diff options
context:
space:
mode:
Diffstat (limited to 'linhes/linhes-dev/chk_aur_pkg.py')
-rwxr-xr-xlinhes/linhes-dev/chk_aur_pkg.py79
1 files changed, 79 insertions, 0 deletions
diff --git a/linhes/linhes-dev/chk_aur_pkg.py b/linhes/linhes-dev/chk_aur_pkg.py
new file mode 100755
index 0000000..6dc7fa5
--- /dev/null
+++ b/linhes/linhes-dev/chk_aur_pkg.py
@@ -0,0 +1,79 @@
+#!/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)
+ if archVer != LHVer:
+ print(currDirName,"needs update: [AUR]:",archVer,"[LH]:",LHVer)
+
+if __name__ == "__main__":
+ print("--------------------------")
+ main()
+ print("--------------------------")