maketarball.py 6.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181
  1. #!/usr/bin/python
  2. ########################################################################
  3. ##
  4. ##
  5. ## This script builds the panda source tarballs and zip-files
  6. ##
  7. ## usage: maketarball [version] [more options]
  8. ##
  9. ## The source tarball contains most of what is in CVS, but some of the
  10. ## control files (like the CVS directories themselves) are stripped out.
  11. ##
  12. ## The source tarball contains an rpmbuild 'spec' file so that you can
  13. ## easily build a binary RPM: rpmbuild -tb panda3d-version.tar.GZ
  14. ##
  15. ## The 'spec' file included in the tarball uses the 'makepanda' build
  16. ## system to compile panda.
  17. ##
  18. ##
  19. ########################################################################
  20. import sys,os,time,stat,string,re,getopt,cPickle
  21. def oscmd(cmd):
  22. print cmd
  23. sys.stdout.flush()
  24. if (os.system(cmd)): sys.exit("Failed")
  25. def writefile(dest,desiredcontents):
  26. print "Generating file: "+dest
  27. sys.stdout.flush()
  28. try:
  29. wfile = open(dest, 'wb')
  30. wfile.write(desiredcontents)
  31. wfile.close();
  32. except: sys.exit("Cannot write to "+dest)
  33. ########################################################################
  34. #
  35. # Locate the root of the panda tree
  36. #
  37. ########################################################################
  38. PANDASOURCE=os.path.dirname(os.path.abspath(sys.path[0]))
  39. if ((os.path.exists(os.path.join(PANDASOURCE,"makepanda/makepanda.py"))==0) or
  40. (os.path.exists(os.path.join(PANDASOURCE,"dtool","src","dtoolbase","dtoolbase.h"))==0) or
  41. (os.path.exists(os.path.join(PANDASOURCE,"panda","src","pandabase","pandabase.h"))==0)):
  42. sys.exit("I am unable to locate the root of the panda source tree.")
  43. os.chdir(PANDASOURCE)
  44. ########################################################################
  45. ##
  46. ## Read the default version number from dtool/PandaVersion.pp
  47. ##
  48. ## Parse the command-line arguments.
  49. ##
  50. ########################################################################
  51. def printUsage():
  52. sys.exit("usage: maketarball [version]")
  53. if (len(sys.argv)>=2):
  54. VERSION = sys.argv[1]
  55. if (len(VERSION.split(".")) != 3): printUsage()
  56. elif (len(sys.argv)==1):
  57. VERSION="0.0.0"
  58. try:
  59. f = file("dtool/PandaVersion.pp","r")
  60. pattern = re.compile('^[ \t]*[#][ \t]*define[ \t]+PANDA_VERSION[ \t]+([0-9]+)[ \t]+([0-9]+)[ \t]+([0-9]+)')
  61. for line in f:
  62. match = pattern.match(line,0)
  63. if (match):
  64. VERSION = match.group(1)+"."+match.group(2)+"."+match.group(3)
  65. break
  66. f.close()
  67. except: sys.exit("Cannot read version number from dtool/PandaVersion.pp")
  68. else: printUsage()
  69. ########################################################################
  70. ##
  71. ## Build the Zip-file and Tar-File
  72. ##
  73. ########################################################################
  74. TARDIR="panda3d-"+VERSION
  75. oscmd("rm -rf "+TARDIR)
  76. oscmd("mkdir -p "+TARDIR)
  77. oscmd("mkdir -p "+TARDIR+"/thirdparty")
  78. oscmd("ln -sf ../dtool "+TARDIR+"/dtool")
  79. oscmd("ln -sf ../panda "+TARDIR+"/panda")
  80. oscmd("ln -sf ../direct "+TARDIR+"/direct")
  81. oscmd("ln -sf ../pandaapp "+TARDIR+"/pandaapp")
  82. oscmd("ln -sf ../pandatool "+TARDIR+"/pandatool")
  83. oscmd("ln -sf ../ppremake "+TARDIR+"/ppremake")
  84. oscmd("ln -sf ../SceneEditor "+TARDIR+"/SceneEditor")
  85. oscmd("ln -sf ../dmodels "+TARDIR+"/dmodels")
  86. oscmd("ln -sf ../models "+TARDIR+"/models")
  87. oscmd("ln -sf ../samples "+TARDIR+"/samples")
  88. oscmd("ln -sf ../doc "+TARDIR+"/doc")
  89. oscmd("ln -sf ../makepanda "+TARDIR+"/makepanda")
  90. oscmd("ln -sf ../../thirdparty/linux-libs-a "+TARDIR+"/thirdparty/linux-libs-a")
  91. oscmd("ln -sf ../../thirdparty/Pmw "+TARDIR+"/thirdparty/Pmw")
  92. writefile(TARDIR+'/panda3d.spec',SPEC)
  93. oscmd("tar --exclude CVS -chzf "+TARDIR+".tar.gz "+TARDIR)
  94. oscmd("rm -rf "+TARDIR)
  95. oscmd("mkdir -p "+TARDIR)
  96. oscmd("mkdir -p "+TARDIR+"/thirdparty")
  97. oscmd("ln -sf ../dtool "+TARDIR+"/dtool")
  98. oscmd("ln -sf ../panda "+TARDIR+"/panda")
  99. oscmd("ln -sf ../direct "+TARDIR+"/direct")
  100. oscmd("ln -sf ../pandaapp "+TARDIR+"/pandaapp")
  101. oscmd("ln -sf ../pandatool "+TARDIR+"/pandatool")
  102. oscmd("ln -sf ../ppremake "+TARDIR+"/ppremake")
  103. oscmd("ln -sf ../SceneEditor "+TARDIR+"/SceneEditor")
  104. oscmd("ln -sf ../dmodels "+TARDIR+"/dmodels")
  105. oscmd("ln -sf ../models "+TARDIR+"/models")
  106. oscmd("ln -sf ../samples "+TARDIR+"/samples")
  107. oscmd("ln -sf ../doc "+TARDIR+"/doc")
  108. oscmd("ln -sf ../makepanda "+TARDIR+"/makepanda")
  109. oscmd("ln -sf ../../thirdparty/win-libs-vc7 "+TARDIR+"/thirdparty/win-libs-vc7")
  110. oscmd("ln -sf ../../thirdparty/win-python "+TARDIR+"/thirdparty/win-python")
  111. oscmd("ln -sf ../../thirdparty/win-util "+TARDIR+"/thirdparty/win-util")
  112. oscmd("ln -sf ../../thirdparty/win-nsis "+TARDIR+"/thirdparty/win-nsis")
  113. oscmd("ln -sf ../../thirdparty/win-extras "+TARDIR+"/thirdparty/win-extras")
  114. oscmd("ln -sf ../../thirdparty/Pmw "+TARDIR+"/thirdparty/Pmw")
  115. oscmd("zip -rq "+TARDIR+".zip "+TARDIR+" -x '*/CVS/*'")
  116. oscmd("rm -rf "+TARDIR)
  117. oscmd("mkdir -p "+TARDIR)
  118. oscmd("mkdir -p "+TARDIR+"/thirdparty")
  119. oscmd("ln -sf ../dtool "+TARDIR+"/dtool")
  120. oscmd("ln -sf ../panda "+TARDIR+"/panda")
  121. oscmd("ln -sf ../direct "+TARDIR+"/direct")
  122. oscmd("ln -sf ../pandaapp "+TARDIR+"/pandaapp")
  123. oscmd("ln -sf ../pandatool "+TARDIR+"/pandatool")
  124. oscmd("ln -sf ../ppremake "+TARDIR+"/ppremake")
  125. oscmd("ln -sf ../SceneEditor "+TARDIR+"/SceneEditor")
  126. oscmd("ln -sf ../dmodels "+TARDIR+"/dmodels")
  127. oscmd("ln -sf ../models "+TARDIR+"/models")
  128. oscmd("ln -sf ../doc "+TARDIR+"/doc")
  129. oscmd("ln -sf ../makepanda "+TARDIR+"/makepanda")
  130. oscmd("zip -rq "+TARDIR+"-sourceforge.zip "+TARDIR+" -x '*/CVS/*'")
  131. oscmd("rm -rf "+TARDIR)
  132. oscmd("mkdir -p "+TARDIR)
  133. oscmd("ln -sf ../samples "+TARDIR+"/samples")
  134. oscmd("zip -rq "+TARDIR+"-samples.zip "+TARDIR+" -x '*/CVS/*'")
  135. oscmd("rm -rf "+TARDIR)
  136. oscmd("mkdir -p "+TARDIR)
  137. oscmd("mkdir -p "+TARDIR+"/thirdparty")
  138. oscmd("ln -sf ../../thirdparty/linux-libs-a "+TARDIR+"/thirdparty/linux-libs-a")
  139. oscmd("ln -sf ../../thirdparty/Pmw "+TARDIR+"/thirdparty/Pmw")
  140. oscmd("zip -rq "+TARDIR+"-tools-linux.zip "+TARDIR+" -x '*/CVS/*'")
  141. oscmd("rm -rf "+TARDIR)
  142. oscmd("mkdir -p "+TARDIR)
  143. oscmd("mkdir -p "+TARDIR+"/thirdparty")
  144. oscmd("ln -sf ../../thirdparty/win-libs-vc7 "+TARDIR+"/thirdparty/win-libs-vc7")
  145. oscmd("ln -sf ../../thirdparty/win-python "+TARDIR+"/thirdparty/win-python")
  146. oscmd("ln -sf ../../thirdparty/win-util "+TARDIR+"/thirdparty/win-util")
  147. oscmd("ln -sf ../../thirdparty/win-nsis "+TARDIR+"/thirdparty/win-nsis")
  148. oscmd("ln -sf ../../thirdparty/win-extras "+TARDIR+"/thirdparty/win-extras")
  149. oscmd("ln -sf ../../thirdparty/Pmw "+TARDIR+"/thirdparty/Pmw")
  150. oscmd("zip -rq "+TARDIR+"-tools-win32.zip "+TARDIR+" -x '*/CVS/*'")
  151. oscmd("rm -rf "+TARDIR)
  152. oscmd("mkdir -p "+TARDIR)
  153. oscmd("ln -sf ../thirdparty "+TARDIR+"/thirdparty")
  154. oscmd("zip -rq "+TARDIR+"-tools-all.zip "+TARDIR+" -x '*/CVS/*'")
  155. oscmd("rm -rf "+TARDIR)