summaryrefslogtreecommitdiff
path: root/cpp/makedist.py
diff options
context:
space:
mode:
Diffstat (limited to 'cpp/makedist.py')
-rwxr-xr-xcpp/makedist.py197
1 files changed, 119 insertions, 78 deletions
diff --git a/cpp/makedist.py b/cpp/makedist.py
index d0bdc5ae3ef..532927cf90b 100755
--- a/cpp/makedist.py
+++ b/cpp/makedist.py
@@ -14,13 +14,11 @@ import os, sys, shutil, fnmatch, re, glob
# Program usage.
#
def usage():
- print "Usage: " + sys.argv[0] + " [options] [tag]"
+ print "Usage: " + sys.argv[0] + " [options]"
print
print "Options:"
print "-h Show this message."
print "-v Be verbose."
- print
- print "If no tag is specified, HEAD is used."
#
# Find files matching a pattern.
@@ -195,7 +193,6 @@ def fixVersion(files, version, mmversion):
#
# Check arguments
#
-tag = "HEAD"
verbose = 0
for x in sys.argv[1:]:
if x == "-h":
@@ -208,9 +205,11 @@ for x in sys.argv[1:]:
print
usage()
sys.exit(1)
- else:
- tag = x
+if os.path.exists("../.git"):
+ print "ERROR: Unable to run in repository! Exiting..."
+ sys.exit(1)
+
#
# Remove any existing "dist" directory and create a new one.
#
@@ -218,77 +217,117 @@ distdir = "dist"
if os.path.exists(distdir):
shutil.rmtree(distdir)
os.mkdir(distdir)
-os.mkdir(os.path.join(distdir, "ice"))
-#
-# Export sources from git.
-#
-print "Checking out " + tag + "..."
if verbose:
- quiet = "-v"
+ quiet = "v"
else:
quiet = ""
-os.system("git archive " + quiet + " " + tag + " . | (cd dist/ice && tar xf -)")
-
-os.chdir(distdir)
#
# Get Ice version.
#
-config = open(os.path.join("ice", "include", "IceUtil", "Config.h"), "r")
+config = open(os.path.join("include", "IceUtil", "Config.h"), "r")
version = re.search("ICE_STRING_VERSION \"([0-9\.b]*)\"", config.read()).group(1)
mmversion = re.search("([0-9]+\.[0-9b]+)[\.0-9]*", version).group(1)
-print "Fixing version in various files..."
-fixVersion(find("ice", "README*"), version, mmversion)
-fixVersion(find("ice", "INSTALL*"), version, mmversion)
-fixVersion(find("ice/config", "glacier2router.cfg"), version, mmversion)
-fixVersion(find("ice/config", "icegridregistry.cfg"), version, mmversion)
-fixVersion(find("ice/install/rpm", "*.conf"), version, mmversion)
-
print "Creating Ice-rpmbuild..."
-rpmbuildver = "Ice-rpmbuild-" + version
-if verbose:
- quiet = "v"
-else:
- quiet = ""
-os.system("tar c" + quiet + "f " + rpmbuildver + ".tar " +
- "-C ice/install -C rpm {icegridregistry,icegridnode,glacier2router}.{conf,suse,redhat} README.RPM " +
- "-C ../unix THIRD_PARTY_LICENSE.Linux README.Linux-RPM SOURCES.Linux " +
- "-C ../thirdparty/php ice.ini")
-os.system("gzip -9 " + rpmbuildver + ".tar")
+rpmbuildver = os.path.join("dist", "Ice-rpmbuild-" + version)
+fixVersion(find(os.path.join("install", "rpm"), "icegridregistry.*"), version, mmversion)
+fixVersion(find(os.path.join("install", "rpm"), "icegridnode.*"), version, mmversion)
+fixVersion(find(os.path.join("install", "rpm"), "glacier2router.*"), version, mmversion)
+fixVersion(find(os.path.join("install", "rpm"), "README.RPM"), version, mmversion)
+fixVersion(find(os.path.join("install", "unix"), "THIRD_PARTY_LICENSE.Linux"), version, mmversion)
+fixVersion(find(os.path.join("install", "unix"), "README.Linux-RPM"), version, mmversion)
+fixVersion(find(os.path.join("install", "unix"), "SOURCES.Linux"), version, mmversion)
+
+if os.system("tar c" + quiet + "f " + rpmbuildver + ".tar " +
+ "-C .. `[ -e RELEASE_NOTES.txt ] && echo ""RELEASE_NOTES.txt""` " +
+ "-C cpp/install -C rpm {icegridregistry,icegridnode,glacier2router}.{conf,suse,redhat} README.RPM " +
+ "-C ../unix THIRD_PARTY_LICENSE.Linux README.Linux-RPM SOURCES.Linux " +
+ "-C ../thirdparty/php ice.ini"):
+ print >> sys.stderr, "ERROR: Archiving failed"
+ sys.exit(1)
+
+if os.system("gzip -9 " + rpmbuildver + ".tar"):
+ print >> sys.stderr, "ERROR: Archiving failed"
+ sys.exit(1)
+
#
-# Remove files.
+# Create archives.
#
-print "Removing unnecessary files..."
+print "Creating distribution..."
+icever = "Ice-" + version
+
+print "Creating exclusion file..."
filesToRemove = [ \
- os.path.join("ice", "makedist.py"), \
- os.path.join("ice", "makebindist.py"), \
- os.path.join("ice", "iceemakedist.py"), \
- os.path.join("ice", "RPMTools.py"), \
- os.path.join("ice", "fixCopyright.py"), \
- os.path.join("ice", "fixVersion.py"), \
- os.path.join("ice", "icee.dsw"), \
- os.path.join("ice", "icee.dsp"), \
- os.path.join("ice", "src", "icecpp", "icecppe.dsp"), \
- os.path.join("ice", "src", "IceUtil", "iceutile.dsp"), \
- os.path.join("ice", "src", "Slice", "slicee.dsp"), \
+ "makedist.py", \
+ "makebindist.py", \
+ "iceemakedist.py", \
+ "RPMTools.py", \
+ "fixCopyright.py", \
+ "fixVersion.py", \
+ "icee.dsw", \
+ "icee.dsp", \
+ "allDemos.py", \
+ os.path.join("config", "makegitignore.py"), \
+ os.path.join("src", "icecpp", "icecppe.dsp"), \
+ os.path.join("src", "IceUtil", "iceutile.dsp"), \
+ os.path.join("src", "Slice", "slicee.dsp"), \
+ "dist", \
+ "install", \
+ os.path.join("src", "slice2cppe"), \
+ os.path.join("src", "slice2javae"), \
+ os.path.join("exclusions")
]
-filesToRemove.extend(find("ice", ".gitignore"))
+
+filesToRemove.extend(find(".", ".gitignore"))
+filesToRemove.extend(find(".", "expect.py"))
+
+exclusionFile = open("exclusions", "w")
for x in filesToRemove:
- if os.path.exists(x):
- os.remove(x)
-shutil.rmtree(os.path.join("ice", "install"))
-shutil.rmtree(os.path.join("ice", "src", "slice2cppe"))
-shutil.rmtree(os.path.join("ice", "src", "slice2javae"))
+ exclusionFile.write("%s\n" % x)
+exclusionFile.close()
+os.mkdir(os.path.join("dist", icever))
+if os.system("tar c" + quiet + " -X exclusions . | ( cd " + os.path.join("dist", icever) + " && tar xf - )"):
+ print >> sys.stderr, "ERROR: demo script archive caused errors"
+ sys.exit(1)
+os.remove("exclusions")
+os.chdir("dist")
+
+if os.system("chmod -R u+rw,go+r-w %s " % icever):
+ print >> sys.stderr, "ERROR: unable to set directory permissions"
+ sys.exit(1)
+
+#
+# Printing warnings here instead of exiting because these probably
+# are not errors per-se but may reflect an unnecessary operation.
+#
+if os.system("find %s \\( -name \"*.h\" -or -name \"*.cpp\" -or -name \"*.ice\" \\) -exec chmod a-x {} \\;" % icever):
+ print >> sys.stderr, "WARNING: find returned non-zero result"
+if os.system("find %s \\( -name \"README*\" -or -name \"INSTALL*\" \\) -exec chmod a-x {} \\;" % icever):
+ print >> sys.stderr, "WARNING: find returned non-zero result"
+if os.system("find %s \\( -name \"*.xml\" -or -name \"*.mc\" \\) -exec chmod a-x {} \\;" % icever):
+ print >> sys.stderr, "WARNING: find returned non-zero result"
+if os.system("find %s \\( -name \"Makefile\" -or -name \"*.dsp\" \\) -exec chmod a-x {} \\;" % icever):
+ print >> sys.stderr, "WARNING: find returned non-zero result"
+if os.system("find %s -type d -exec chmod a+x {} \\;" % icever):
+ print >> sys.stderr, "WARNING: find returned non-zero result"
+if os.system("find %s -perm +111 -exec chmod a+x {} \\;" % icever):
+ print >> sys.stderr, "WARNING: find returned non-zero result"
+
+print "Fixing version in various files..."
+fixVersion(find(icever, "README*"), version, mmversion)
+fixVersion(find(icever, "INSTALL*"), version, mmversion)
+fixVersion(find(os.path.join(icever, "config"), "glacier2router.cfg"), version, mmversion)
+fixVersion(find(os.path.join(icever, "config"), "icegridregistry.cfg"), version, mmversion)
#
# Generate bison files.
#
print "Generating bison files..."
cwd = os.getcwd()
-grammars = find("ice", "*.y")
+grammars = find(icever, "*.y")
for x in grammars:
#
# Change to the directory containing the file.
@@ -303,10 +342,13 @@ for x in grammars:
quiet = ""
else:
quiet = "-s"
+ result = 0
if file == "cexp.y":
- os.system("gmake " + quiet + " cexp.c")
+ result = os.system("gmake " + quiet + " cexp.c")
else:
- os.system("gmake " + quiet + " " + base + ".cpp")
+ result = os.system("gmake " + quiet + " " + base + ".cpp")
+ if result:
+ print
#
# Edit the Makefile to comment out the grammar rules.
#
@@ -324,7 +366,7 @@ for x in grammars:
# Generate flex files.
#
print "Generating flex files..."
-scanners = find("ice", "*.l")
+scanners = find(icever, "*.l")
for x in scanners:
#
# Change to the directory containing the file.
@@ -339,7 +381,9 @@ for x in scanners:
quiet = ""
else:
quiet = "-s"
- os.system("gmake " + quiet + " " + base + ".cpp")
+ if os.system("gmake " + quiet + " " + base + ".cpp"):
+ print>>sys.stderr, "Generating flex files failed."
+ sys.exit(1)
#
# Edit the Makefile to comment out the flex rules.
#
@@ -353,37 +397,34 @@ for x in scanners:
fixProject(p, file)
os.chdir(cwd)
+if verbose:
+ quiet = "v"
+else:
+ quiet = ""
+
#
# Comment out the implicit parser and scanner rules in
# config/Make.rules.
#
print "Fixing makefiles..."
-fixMakeRules(os.path.join("ice", "config", "Make.rules"))
+fixMakeRules(os.path.join(icever, "config", "Make.rules"))
+
+if os.system("tar c" + quiet + "f %s.tar %s" % (icever, icever)):
+ print>>sys.stderr, "ERROR: tar command failed"
+ sys.exit(1)
+
+if os.system("gzip -9 " + icever + ".tar"):
+ print>>sys.stderr, "ERROR: gzip command failed"
+ sys.exit(1)
-#
-# Create archives.
-#
-print "Creating distribution..."
-icever = "Ice-" + version
-os.rename("ice", icever)
-if verbose:
- quiet = "v"
-else:
- quiet = ""
-os.system("chmod -R u+rw,go+r-w . " + icever)
-os.system("find " + icever + " \\( -name \"*.h\" -or -name \"*.cpp\" -or -name \"*.ice\" \\) -exec chmod a-x {} \\;")
-os.system("find " + icever + " \\( -name \"README*\" -or -name \"INSTALL*\" \\) -exec chmod a-x {} \\;")
-os.system("find " + icever + " \\( -name \"*.xml\" -or -name \"*.mc\" \\) -exec chmod a-x {} \\;")
-os.system("find " + icever + " \\( -name \"Makefile\" -or -name \"*.dsp\" \\) -exec chmod a-x {} \\;")
-os.system("find " + icever + " -type d -exec chmod a+x {} \\;")
-os.system("find " + icever + " -perm +111 -exec chmod a+x {} \\;")
-os.system("tar c" + quiet + "f " + icever + ".tar " + icever)
-os.system("gzip -9 " + icever + ".tar")
if verbose:
quiet = ""
else:
quiet = "q"
-os.system("zip -9r" + quiet + " " + icever + ".zip " + icever)
+
+if os.system("zip -9r" + quiet + " " + icever + ".zip " + icever):
+ print>>sys.stderr, "ERROR: zip command failed"
+ sys.exit(1)
#
# Copy CHANGES