Commit 7d45c32c authored by ben's avatar ben

Futher distribution file improvements


git-svn-id: http://svn.savannah.nongnu.org/svn/rdiff-backup@144 2b77aa54-bcbc-44c9-a7ec-4f6cf2b41109
parent e8c4b1c7
#!/usr/bin/env python #!/usr/bin/env python
import os, re, shutil, time import os, re, shutil, time, sys
SourceDir = "src" SourceDir = "src"
DistDir = "dist" DistDir = "dist"
...@@ -8,14 +8,7 @@ DistDir = "dist" ...@@ -8,14 +8,7 @@ DistDir = "dist"
# Various details about the files must also be specified by the rpm # Various details about the files must also be specified by the rpm
# spec template. # spec template.
spec_template = "dist/rdiff-backup.spec" spec_template = "dist/rdiff-backup.spec"
redhat_spec_template = "dist/rdiff-backup.rh7x.spec" #redhat_spec_template = "dist/rdiff-backup.rh7x.spec"
def GetVersion():
"""Return version string by reading in ./rdiff-backup"""
fp = open("rdiff-backup", "r")
match = re.search("Version (.*?) ", fp.read())
fp.close()
return match.group(1)
def CopyMan(destination, version): def CopyMan(destination, version):
"""Create updated man page at the specified location""" """Create updated man page at the specified location"""
...@@ -65,64 +58,77 @@ def MakeFAQ(): ...@@ -65,64 +58,77 @@ def MakeFAQ():
html_fp.write("\n</body></html>") html_fp.write("\n</body></html>")
html_fp.close() html_fp.close()
def MakeTar(version): def VersionedCopy(source, dest):
"""Copy source to dest, substituting $version with version"""
fin = open(source, "rb")
inbuf = fin.read()
assert not fin.close()
outbuf = re.sub("\$version", Version, inbuf, 1)
if outbuf == inbuf: assert 0, "No $version string replaced"
assert not re.search("\$version", outbuf), \
"Two $version strings found in the same file %s" % (source,)
fout = open(dest, "wb")
fout.write(outbuf)
assert not fout.close()
def MakeTar():
"""Create rdiff-backup tar file""" """Create rdiff-backup tar file"""
tardir = "rdiff-backup-%s" % version tardir = "rdiff-backup-%s" % Version
tarfile = "rdiff-backup-%s.tar.gz" % version tarfile = "rdiff-backup-%s.tar.gz" % Version
try: try:
os.lstat(tardir) os.lstat(tardir)
os.system("rm -rf " + tardir) os.system("rm -rf " + tardir)
except OSError: pass except OSError: pass
os.mkdir(tardir) os.mkdir(tardir)
for filename in ["rdiff-backup", "CHANGELOG", "COPYING", for filename in ["CHANGELOG", "COPYING", "README", "FAQ.html",
"README", "FAQ.html", SourceDir + "/cmodule.c", SourceDir + "/cmodule.c", DistDir + "/setup.py"]:
DistDir + "/setup.py"]:
assert not os.system("cp %s %s" % (filename, tardir)), filename assert not os.system("cp %s %s" % (filename, tardir)), filename
os.mkdir(tardir+"/rdiff_backup") os.mkdir(tardir+"/rdiff_backup")
for filename in ["connection.py", "destructive_stepping.py", for filename in ["connection.py", "destructive_stepping.py",
"FilenameMapping.py", "Globals.py", "Hardlink.py", "FilenameMapping.py", "Hardlink.py",
"highlevel.py", "increment.py", "__init__.py", "highlevel.py", "increment.py", "__init__.py",
"iterfile.py", "lazy.py", "log.py", "Main.py", "iterfile.py", "lazy.py", "log.py", "Main.py",
"manage.py", "MiscStats.py", "Rdiff.py", "restore.py", "manage.py", "MiscStats.py", "Rdiff.py",
"rlist.py", "robust.py", "rorpiter.py", "rpath.py", "restore.py", "rlist.py", "robust.py",
"selection.py", "SetConnections.py", "static.py", "rorpiter.py", "rpath.py", "selection.py",
"SetConnections.py", "static.py",
"statistics.py", "Time.py"]: "statistics.py", "Time.py"]:
assert not os.system("cp %s/%s %s/rdiff_backup" % assert not os.system("cp %s/%s %s/rdiff_backup" %
(SourceDir, filename, tardir)), filename (SourceDir, filename, tardir)), filename
VersionedCopy("%s/Globals.py" % (SourceDir,),
"%s/rdiff_backup/Globals.py" % (tardir,))
VersionedCopy("rdiff-backup", "%s/rdiff-backup" % (tardir,))
os.chmod(os.path.join(tardir, "setup.py"), 0755) os.chmod(os.path.join(tardir, "setup.py"), 0755)
os.chmod(os.path.join(tardir, "rdiff-backup"), 0755) os.chmod(os.path.join(tardir, "rdiff-backup"), 0755)
CopyMan(os.path.join(tardir, "rdiff-backup.1"), version) CopyMan(os.path.join(tardir, "rdiff-backup.1"), Version)
os.system("tar -cvzf %s %s" % (tarfile, tardir)) os.system("tar -cvzf %s %s" % (tarfile, tardir))
shutil.rmtree(tardir) shutil.rmtree(tardir)
return tarfile return tarfile
def MakeSpecFile(version): def MakeSpecFile():
"""Create spec file using spec template""" """Create spec file using spec template"""
def helper(spec_template, specfile): specfile = "rdiff-backup-%s-1.spec" % Version
"""Added now that there are special redhat rpms""" VersionedCopy(spec_template, specfile)
outfp = open(specfile, "w") return specfile
outfp.write("Version: %s\n" % version)
infp = open(spec_template, "r")
outfp.write(infp.read())
infp.close()
outfp.close()
specfile = "rdiff-backup-%s-1.spec" % version
redhat_specfile = "rdiff-backup-%s-1.rh7x.spec" % version
helper(spec_template, specfile)
helper(redhat_spec_template, redhat_specfile)
return (specfile, redhat_specfile)
def Main(): def Main():
version = GetVersion()
print "Making FAQ" print "Making FAQ"
MakeFAQ() MakeFAQ()
print "Processing version " + version print "Processing version " + Version
tarfile = MakeTar(version) tarfile = MakeTar()
print "Made tar file " + tarfile print "Made tar file " + tarfile
specfiles = MakeSpecFile(version) specfile = MakeSpecFile()
print "Made specfiles %s and %s" % specfiles print "Made specfile ", specfile
if __name__ == "__main__": Main() if __name__ == "__main__" and not globals().has_key('__no_execute__'):
if len(sys.argv) != 2:
print "Syntax: makedist [version_number]"
sys.exit(1)
Version = sys.argv[1]
Main()
Version: $version
Summary: Convenient and transparent local/remote incremental mirror/backup Summary: Convenient and transparent local/remote incremental mirror/backup
Name: rdiff-backup Name: rdiff-backup
Release: 1 Release: 1
...@@ -25,19 +26,17 @@ differences from the previous backup will be transmitted. ...@@ -25,19 +26,17 @@ differences from the previous backup will be transmitted.
%setup %setup
%build %build
./setup.py build python2 setup.py build
%install %install
./setup.py install --prefix=$RPM_BUILD_ROOT/usr python2 setup.py install --prefix=$RPM_BUILD_ROOT/usr
%clean %clean
%files %files
%defattr(-,root,root) %defattr(-,root,root)
%doc CHANGELOG COPYING README FAQ.html
/usr/lib/python2.2/site-packages/rdiff_backup
/usr/bin/rdiff-backup /usr/bin/rdiff-backup
/usr/share/man/man1/rdiff-backup.1.gz /usr/share/doc/rdiff-backup-%{version}
/usr/lib
%changelog %changelog
......
...@@ -3,17 +3,12 @@ ...@@ -3,17 +3,12 @@
import sys, os, getopt import sys, os, getopt
from distutils.core import setup, Extension from distutils.core import setup, Extension
version_string = "0.9.0" version_string = "$version"
if sys.version_info[:2] < (2,2): if sys.version_info[:2] < (2,2):
print "Sorry, rdiff-backup requires version 2.2 or later of python" print "Sorry, rdiff-backup requires version 2.2 or later of python"
sys.exit(1) sys.exit(1)
def install(cmd):
if os.system("install " + cmd) != 0:
print "Error running 'install %s'" % cmd
sys.exit(1)
setup(name="rdiff-backup", setup(name="rdiff-backup",
version=version_string, version=version_string,
description="Local/remote mirroring+incremental backup", description="Local/remote mirroring+incremental backup",
...@@ -21,27 +16,11 @@ setup(name="rdiff-backup", ...@@ -21,27 +16,11 @@ setup(name="rdiff-backup",
author_email="bescoto@stanford.edu", author_email="bescoto@stanford.edu",
url="http://rdiff-backup.stanford.edu", url="http://rdiff-backup.stanford.edu",
packages = ['rdiff_backup'], packages = ['rdiff_backup'],
ext_modules=[Extension("rdiff_backup.C", ["cmodule.c"])]) ext_modules = [Extension("rdiff_backup.C", ["cmodule.c"])],
scripts = ['rdiff-backup'],
copy_files = 0 data_files = [('share/man/man1', ['rdiff-backup.1']),
prefix = "/usr" ('share/doc/rdiff-backup-%s' % version_string,
for arg in sys.argv[1:]: # check for "install" and --prefix= arg ['CHANGELOG', 'COPYING', 'README', 'FAQ.html'])])
if arg == "install": copy_files = 1
elif arg.startswith("--prefix="): prefix = arg[len("--prefix="):]
if copy_files:
bindir = prefix + "/bin"
print "Copying rdiff-backup to " + bindir
install("-d " + bindir)
install("-m0755 rdiff-backup " + bindir)
mandir = prefix + "/share/man/man1"
print "Copying rdiff-backup.1 to " + mandir
install("-d " + mandir)
install("-m0644 rdiff-backup.1 " + mandir)
docdir = "%s/share/doc/rdiff-backup-%s" % (prefix, version_string)
print ("Copying CHANGELOG, COPYING, README, and FAQ.html to " + docdir)
install("-d " + docdir)
install("-m0644 CHANGELOG COPYING README FAQ.html " + docdir)
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment