You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

package-diff.py 4.5KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140
  1. #!/usr/bin/python
  2. import sys,os,re
  3. from sets import Set
  4. ################################################################################
  5. # Configuration
  6. ################################################################################
  7. downloadsite = "http://vaadin.com/download"
  8. latestfile = "/release/6.8/LATEST"
  9. JAPIZE = "japize"
  10. JAPICOMPAT = "japicompat"
  11. ################################################################################
  12. # Utility Functions
  13. ################################################################################
  14. def command(cmd, dryrun=0):
  15. if not dryrun:
  16. if os.system(cmd):
  17. print "Command '%s' failed, exiting." % (cmd)
  18. sys.exit(1)
  19. else:
  20. print "Dry run - not executing."
  21. ################################################################################
  22. # Difference of two lists of files
  23. ################################################################################
  24. def diffFiles(a, b):
  25. diff = Set(a).difference(Set(b))
  26. difffiles = []
  27. for item in diff:
  28. difffiles.append(item)
  29. difffiles.sort()
  30. return difffiles
  31. ################################################################################
  32. # Lists files inside a Zip file (a JAR)
  33. ################################################################################
  34. def listJarFiles(jarfile):
  35. # Read the jar content listing
  36. pin = os.popen("unzip -ql %s" % jarfile, "r")
  37. lines = map(lambda x: x[:-1], pin.readlines())
  38. pin.close()
  39. # Determine the position of file names
  40. namepos = lines[0].find("Name")
  41. files = []
  42. for i in xrange(2, len(lines)-2):
  43. filename = lines[i][namepos:]
  44. files.append(filename)
  45. return files
  46. ################################################################################
  47. # JAPI - Java API Differences
  48. ################################################################################
  49. def japize(version, jarfile):
  50. cmd = "%s as %s apis %s +com.vaadin, $JAVA_HOME/jre/lib/rt.jar 2>/dev/null" % (JAPIZE, version, jarfile)
  51. command (cmd)
  52. return "%s.japi.gz" % (version)
  53. def japicompat(japi1, japi2):
  54. cmd = "%s -q %s %s" % (JAPICOMPAT, japi1, japi2)
  55. pin = os.popen(cmd, "r")
  56. lines = "".join(pin.readlines())
  57. pin.close()
  58. return lines
  59. ################################################################################
  60. #
  61. ################################################################################
  62. # Download the installation package of the latest version
  63. wgetcmd = "wget -q -O - %s" % (downloadsite+latestfile)
  64. pin = os.popen(wgetcmd, "r")
  65. latestdata = pin.readlines()
  66. pin.close()
  67. latestversion = latestdata[0].strip()
  68. latestpath = latestdata[1].strip()
  69. latestURL = downloadsite + "/" + latestpath + "/"
  70. latestfilename = "vaadin-%s.jar" % (latestversion)
  71. latestpackage = latestURL + latestfilename
  72. locallatestpackage = "/tmp/%s" % (latestfilename)
  73. print "Latest version: %s" % (latestversion)
  74. print "Latest version path: %s" % (latestpath)
  75. print "Latest version URL: %s" % (latestURL)
  76. # Check if it already exists
  77. try:
  78. os.stat(locallatestpackage)
  79. print "Latest package already exists in %s" % (locallatestpackage)
  80. # File exists
  81. except OSError:
  82. # File does not exist, get it.
  83. print "Downloading latest release package %s to %s" % (latestpackage, locallatestpackage)
  84. wgetcmd = "wget -q -O %s %s" % (locallatestpackage, latestpackage)
  85. command (wgetcmd)
  86. # List files in built version.
  87. builtversion = sys.argv[1]
  88. builtpackage = "build/result/vaadin-%s/WebContent/WEB-INF/lib/vaadin-%s.jar" % (builtversion, builtversion)
  89. # Report differences
  90. print "\n--------------------------------------------------------------------------------\nVaadin JAR differences"
  91. latestJarFiles = listJarFiles(locallatestpackage)
  92. builtJarFiles = listJarFiles(builtpackage)
  93. # New files
  94. newfiles = diffFiles(builtJarFiles, latestJarFiles)
  95. print "\n%d new files:" % (len(newfiles))
  96. for item in newfiles:
  97. print item
  98. # Removed files
  99. removed = diffFiles(latestJarFiles, builtJarFiles)
  100. print "\n%d removed files:" % (len(removed))
  101. for item in removed:
  102. print item
  103. print "\n--------------------------------------------------------------------------------\nVaadin API differences"
  104. oldjapi = japize(latestversion, locallatestpackage)
  105. newjapi = japize(builtversion, builtpackage)
  106. print "\n--------------------------------------------------------------------------------\nLost API features\n"
  107. japidiff1 = japicompat(oldjapi, newjapi)
  108. print japidiff1
  109. print "\n--------------------------------------------------------------------------------\nNew API features\n"
  110. japidiff2 = japicompat(newjapi, oldjapi)
  111. print japidiff2
  112. # Purge downloaded package
  113. command("rm %s" % (locallatestpackage))