find-packages-not-compiled-in-farm 2.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120
  1. #!/usr/bin/python
  2. # -*- coding: utf-8 -*-
  3. #
  4. # find which packages were not compiled in farm
  5. # usage: scriptname svnindex pisiindex
  6. #
  7. import os
  8. import sys
  9. import urllib2
  10. import bz2
  11. import lzma
  12. import piksemel
  13. pisirepouri = "http://ciftlik.pisilinux.org/2.0-Beta.1/pisi-index.xml.xz"
  14. svnrepouri = "https://github.com/ertugerata/core/raw/master/pisi-index.xml.xz"
  15. def getIndex(uri):
  16. try:
  17. if "://" in uri:
  18. rawdata = urllib2.urlopen(uri).read()
  19. else:
  20. rawdata = open(uri, "r").read()
  21. except IOError:
  22. print "could not fetch %s" % uri
  23. return None
  24. if uri.endswith("bz2"):
  25. data = bz2.decompress(rawdata)
  26. elif uri.endswith("xz") or uri.endswith("lzma"):
  27. data = lzma.decompress(rawdata)
  28. else:
  29. data = rawdata
  30. return data
  31. def parseRepo(repoURI):
  32. pkgdict = {}
  33. rawData = getIndex(repoURI)
  34. doc = piksemel.parseString(rawData)
  35. hasSpecFile = doc.getTag("SpecFile")
  36. if hasSpecFile:
  37. for parent in doc.tags("SpecFile"):
  38. pkgname = parent.getTag("Source").getTagData("Name")
  39. srcname = pkgname
  40. partof = parent.getTag("Source").getTagData("PartOf")
  41. lastRelease = parent.getTag("History").tags("Update").next()
  42. release = lastRelease.getAttribute("release")
  43. pkgdict[srcname] = [partof, release]
  44. else:
  45. for parent in doc.tags("Package"):
  46. pkgname = parent.getTagData("Name")
  47. srcname = parent.getTag("Source").getTagData("Name")
  48. partof = parent.getTagData("PartOf")
  49. lastRelease = parent.getTag("History").tags("Update").next()
  50. release = lastRelease.getAttribute("release")
  51. pkgdict[srcname] = [partof, release]
  52. return pkgdict
  53. if __name__ == "__main__":
  54. pkgmissing = []
  55. pkgdifferent = []
  56. if len(sys.argv) > 1:
  57. svnrepouri = sys.argv[1]
  58. if len(sys.argv) > 2:
  59. pisirepouri = sys.argv[2]
  60. print
  61. print "* working on %s" % svnrepouri
  62. svnrepo = parseRepo(svnrepouri)
  63. print "* working on %s" % pisirepouri
  64. pisirepo = parseRepo(pisirepouri)
  65. pkglist = svnrepo.keys()
  66. pkglist.sort()
  67. for i in pkglist:
  68. if not i in pisirepo:
  69. partof = svnrepo[i][0]
  70. pkgmissing.append("%s/%s" % (partof.replace(".", "/"), i))
  71. elif svnrepo[i][1] != pisirepo[i][1]:
  72. partof = svnrepo[i][0]
  73. pkgdifferent.append("%s/%s" % (partof.replace(".", "/"), i))
  74. pkgmissing.sort()
  75. pkgdifferent.sort()
  76. if len(pkgmissing):
  77. print
  78. print "* Packages missing in %s" % pisirepouri
  79. for p in pkgmissing:
  80. print " %s" % p
  81. if len(pkgdifferent):
  82. print
  83. print "* Packages that needs compiling"
  84. for p in pkgdifferent:
  85. i = p.split("/")[-1]
  86. print " %s (%s > %s)" % (p, svnrepo[i][1], pisirepo[i][1])
  87. print