[zpkg] SVN: zpkgtools/trunk/zpkgtools/ - try to be more careful
about getting the right permissions in generated tar
Fred L. Drake, Jr.
fdrake at gmail.com
Mon Sep 19 11:31:34 EDT 2005
Log message for revision 38520:
- try to be more careful about getting the right permissions in generated tar
files, based on a suggestion from Brian Sutherland
- add a test that makes sure a tar file of the expected name is actually
generated on non-Windows systems
Changed:
U zpkgtools/trunk/zpkgtools/app.py
U zpkgtools/trunk/zpkgtools/tests/test_app.py
-=-
Modified: zpkgtools/trunk/zpkgtools/app.py
===================================================================
--- zpkgtools/trunk/zpkgtools/app.py 2005-09-19 15:21:08 UTC (rev 38519)
+++ zpkgtools/trunk/zpkgtools/app.py 2005-09-19 15:31:33 UTC (rev 38520)
@@ -311,13 +311,24 @@
"""
pwd = os.getcwd()
os.chdir(self.tmpdir)
- cmdline = ("tar", "czf", self.target_file, self.target_name)
+ cmdline1 = ("tar", "czf", self.target_file,
+ "--owner=0", "--group=0", "--mode=a+r",
+ self.target_name)
+ cmdline2 = ("tar", "czf", self.target_file, self.target_name)
# The os.spawn?p*() functions are not available on Windows, so
# we need to search the PATH ourselves:
- cmdpath = runlog.find_command(cmdline[0])
- runlog.report_command(" ".join(cmdline))
+ cmdpath = runlog.find_command(cmdline1[0])
+ runlog.report_command(" ".join(cmdline1))
try:
- rc = os.spawnv(os.P_WAIT, cmdpath, cmdline)
+ rc = os.spawnv(os.P_WAIT, cmdpath, cmdline1)
+ if os.WIFEXITED(rc) and os.WEXITSTATUS(rc) == 2:
+ # didn't like the command line; maybe not GNU tar?
+ if os.path.exists(self.target_file):
+ os.unlink(self.target_file)
+ cmdpath = runlog.find_command(cmdline2[0])
+ runlog.report_exit_code(rc)
+ runlog.report_command(" ".join(cmdline2))
+ rc = os.spawnv(os.P_WAIT, cmdpath, cmdline2)
finally:
os.chdir(pwd)
runlog.report_exit_code(rc)
Modified: zpkgtools/trunk/zpkgtools/tests/test_app.py
===================================================================
--- zpkgtools/trunk/zpkgtools/tests/test_app.py 2005-09-19 15:21:08 UTC (rev 38519)
+++ zpkgtools/trunk/zpkgtools/tests/test_app.py 2005-09-19 15:31:33 UTC (rev 38520)
@@ -403,7 +403,7 @@
def createApplication(self, args):
options = app.parse_args([CMD] + args)
- self.app = DelayedCleanupBuilderApplication(options)
+ self.app = DelayedCleanupNonBuilderApplication(options)
return self.app
def createPackageMap(self):
@@ -421,6 +421,20 @@
# convert package_map to URL so relative names are resolved properly
return "file://" + urllib.pathname2url(package_map)
+ def test_create_tarball(self):
+ # This builds a package and checks that the distribution
+ # archive was created. This only works if 'tar' is available,
+ # so we skip this on Windows.
+ if sys.platform[:3].lower() == "win":
+ return
+ package_map = self.createPackageMap()
+ options = app.parse_args(
+ [CMD, "-f", "-m", package_map, "-v", "1.2.3", "package"])
+ application = DelayedCleanupBuilderApplication(options)
+ application.run()
+ self.failUnless(os.path.isfile("package-1.2.3.tgz"))
+ os.unlink("package-1.2.3.tgz")
+
def test_creating_complete_exclude_resources_list(self):
config = os.path.join(os.path.dirname(os.path.abspath(__file__)),
"input", "exclude.cfg")
@@ -592,9 +606,6 @@
class DelayedCleanupBuilderApplication(app.BuilderApplication):
- def create_tarball(self):
- pass
-
def cleanup(self):
pass
@@ -602,7 +613,13 @@
app.BuilderApplication.cleanup(self)
+class DelayedCleanupNonBuilderApplication(DelayedCleanupBuilderApplication):
+ def create_tarball(self):
+ pass
+
+
+
def isfile(path, *args):
if args:
path = os.path.join(path, *args)
More information about the zpkg
mailing list