[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[rdiff-backup-users] [PATCH] makedist on Windows
From: |
Josh Nisly |
Subject: |
[rdiff-backup-users] [PATCH] makedist on Windows |
Date: |
Sun, 22 Jun 2008 11:29:18 +0600 |
User-agent: |
Thunderbird 2.0.0.14 (X11/20080505) |
Here is another, simpler patch. This makes so that the makedist script
works on Windows, by using native python functions instead of unix programs.
The patch only uses the python functions if it's running on windows,
because some of the modules are not available in Python 2.2. When we
drop 2.2 support, I'd argue that the python functions should be used all
the time.
Thanks,
JoshN
--- dist/makedist 12 Nov 2006 07:24:36 -0000 1.28
+++ dist/makedist 12 Apr 2008 19:20:30 -0000
@@ -93,10 +93,10 @@
def MakeTar(specfiles):
"""Create rdiff-backup tar file"""
tardir = "rdiff-backup-%s" % Version
- tarfile = "rdiff-backup-%s.tar.gz" % Version
+ tarfile_ = "rdiff-backup-%s.tar.gz" % Version
try:
os.lstat(tardir)
- os.system("rm -rf " + tardir)
+ shutil.rmtree(tardir)
except OSError: pass
os.mkdir(tardir)
for filename in ["CHANGELOG", "COPYING", "README",
@@ -104,7 +104,8 @@
SourceDir + "/cmodule.c",
SourceDir + "/_librsyncmodule.c",
DistDir + "/setup.py"] + specfiles:
- assert not os.system("cp %s %s" % (filename, tardir)), filename
+ shutil.copyfile(filename,
+ os.path.join(tardir,
os.path.basename(filename)))
os.mkdir(tardir+"/rdiff_backup")
for filename in ["eas_acls.py", "backup.py", "connection.py",
"compare.py",
@@ -118,8 +118,8 @@
"SetConnections.py", "static.py",
"statistics.py", "TempFile.py",
"Time.py",
"user_group.py"]:
- assert not os.system("cp %s/%s %s/rdiff_backup" %
- (SourceDir, filename,
tardir)), filename
+ shutil.copyfile(os.path.join(SourceDir, filename),
+ os.path.join(tardir,
"rdiff_backup", filename))
VersionedCopy("%s/Globals.py" % (SourceDir,),
"%s/rdiff_backup/Globals.py" % (tardir,))
@@ -132,9 +132,17 @@
os.chmod(os.path.join(tardir, "rdiff-backup"), 0644)
CopyMan(os.path.join(tardir, "rdiff-backup.1"), Version)
CopyMan(os.path.join(tardir, "rdiff-backup-statistics.1"), Version)
- os.system("tar -cvzf %s %s" % (tarfile, tardir))
+ if os.name != 'nt':
+ os.system("tar -cvzf %s %s" % (tarfile_, tardir))
+ else:
+ import tarfile
+ tar = tarfile.open(tarfile_, 'w:gz')
+ for path in os.listdir(tardir):
+ tar.add(os.path.join(tardir, path))
+ tar.close()
+
shutil.rmtree(tardir)
- return tarfile
+ return tarfile_
def MakeSpecFile():
"""Create spec file using spec template"""
- [rdiff-backup-users] [PATCH] makedist on Windows,
Josh Nisly <=