ppatcher.py 3.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101
  1. #! /usr/bin/env python
  2. usageText = """
  3. This script generates the patches required to support incremental
  4. download of Panda3D packages. It can be run as a post-process on a
  5. directory hierarchy created by ppackage; it will examine the directory
  6. hierarchy, and create any patches that appear to be missing.
  7. You may run ppackage on the same directory hierarchy as many times as
  8. you like, without creating patches. You may then download and test
  9. the resulting files--users connecting to the tree without fresh
  10. patches will be forced to download the entire file, instead of making
  11. an incremental download, but the entire process will work otherwise.
  12. When you are satisfied that all of the files are ready to be released,
  13. you may run ppackage on the directory hierarchy to generate the
  14. required patches.
  15. Generating the patches just before final release is a good idea to
  16. limit the number of trivially small patches that are created. Each
  17. time this script is run, a patch is created from the previous version,
  18. and these patches daisy-chain together to define a complete update
  19. sequence. If you run this script on internal releases, you will
  20. generate a long chain of small patches that your users must download;
  21. this is pointless if there is no possibility of anyone having
  22. downloaded one of the intervening versions.
  23. You can also generate patches with the -p option to ppackage, but that
  24. only generates patches for the specific packages built by that
  25. invocation of ppackage. If you use the ppatcher script instead, it
  26. will generate patches for all packages (or the set of packages that
  27. you name specifically).
  28. This script is actually a wrapper around Panda's PatchMaker.py.
  29. Usage:
  30. %(prog)s [opts] [packageName1 .. packageNameN]
  31. Parameters:
  32. packageName1 .. packageNameN
  33. Specify the names of the package(s) you wish to generate patches
  34. for. This allows you to build patches for only a subset of the
  35. packages found in the tree. If you omit these parameters, patches
  36. are built for all packages that require them.
  37. Options:
  38. -i install_dir
  39. The full path to the install directory. This should be the same
  40. directory named by the -i parameter to ppackage.
  41. -h
  42. Display this help
  43. """
  44. import sys
  45. import getopt
  46. import os
  47. from direct.p3d.PatchMaker import PatchMaker
  48. from panda3d.core import Filename
  49. def usage(code, msg = ''):
  50. sys.stderr.write(usageText % {'prog' : os.path.split(sys.argv[0])[1]})
  51. sys.stderr.write(msg + '\n')
  52. sys.exit(code)
  53. try:
  54. opts, args = getopt.getopt(sys.argv[1:], 'i:h')
  55. except getopt.error as msg:
  56. usage(1, msg)
  57. installDir = None
  58. for opt, arg in opts:
  59. if opt == '-i':
  60. installDir = Filename.fromOsSpecific(arg)
  61. elif opt == '-h':
  62. usage(0)
  63. else:
  64. print('illegal option: ' + arg)
  65. sys.exit(1)
  66. packageNames = args
  67. if not installDir:
  68. installDir = Filename('install')
  69. if not packageNames:
  70. # "None" means all packages.
  71. packageNames = None
  72. pm = PatchMaker(installDir)
  73. pm.buildPatches(packageNames = packageNames)
  74. # An explicit call to exit() is required to exit the program, when
  75. # this module is packaged in a p3d file.
  76. sys.exit(0)