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
import os, re, shutil, time
import os, re, shutil, time, sys
SourceDir = "src"
DistDir = "dist"
......@@ -8,14 +8,7 @@ DistDir = "dist"
# Various details about the files must also be specified by the rpm
# spec template.
spec_template = "dist/rdiff-backup.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)
#redhat_spec_template = "dist/rdiff-backup.rh7x.spec"
def CopyMan(destination, version):
"""Create updated man page at the specified location"""
......@@ -65,64 +58,77 @@ def MakeFAQ():
html_fp.write("\n</body></html>")
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"""
tardir = "rdiff-backup-%s" % version
tarfile = "rdiff-backup-%s.tar.gz" % version
tardir = "rdiff-backup-%s" % Version
tarfile = "rdiff-backup-%s.tar.gz" % Version
try:
os.lstat(tardir)
os.system("rm -rf " + tardir)
except OSError: pass
os.mkdir(tardir)
for filename in ["rdiff-backup", "CHANGELOG", "COPYING",
"README", "FAQ.html", SourceDir + "/cmodule.c",
DistDir + "/setup.py"]:
for filename in ["CHANGELOG", "COPYING", "README", "FAQ.html",
SourceDir + "/cmodule.c", DistDir + "/setup.py"]:
assert not os.system("cp %s %s" % (filename, tardir)), filename
os.mkdir(tardir+"/rdiff_backup")
for filename in ["connection.py", "destructive_stepping.py",
"FilenameMapping.py", "Globals.py", "Hardlink.py",
"FilenameMapping.py", "Hardlink.py",
"highlevel.py", "increment.py", "__init__.py",
"iterfile.py", "lazy.py", "log.py", "Main.py",
"manage.py", "MiscStats.py", "Rdiff.py", "restore.py",
"rlist.py", "robust.py", "rorpiter.py", "rpath.py",
"selection.py", "SetConnections.py", "static.py",
"manage.py", "MiscStats.py", "Rdiff.py",
"restore.py", "rlist.py", "robust.py",
"rorpiter.py", "rpath.py", "selection.py",
"SetConnections.py", "static.py",
"statistics.py", "Time.py"]:
assert not os.system("cp %s/%s %s/rdiff_backup" %
(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, "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))
shutil.rmtree(tardir)
return tarfile
def MakeSpecFile(version):
def MakeSpecFile():
"""Create spec file using spec template"""
def helper(spec_template, specfile):
"""Added now that there are special redhat rpms"""
outfp = open(specfile, "w")
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)
specfile = "rdiff-backup-%s-1.spec" % Version
VersionedCopy(spec_template, specfile)
return specfile
def Main():
version = GetVersion()
print "Making FAQ"
MakeFAQ()
print "Processing version " + version
tarfile = MakeTar(version)
print "Processing version " + Version
tarfile = MakeTar()
print "Made tar file " + tarfile
specfiles = MakeSpecFile(version)
print "Made specfiles %s and %s" % specfiles
if __name__ == "__main__": Main()
specfile = MakeSpecFile()
print "Made specfile ", specfile
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
Name: rdiff-backup
Release: 1
......@@ -25,19 +26,17 @@ differences from the previous backup will be transmitted.
%setup
%build
./setup.py build
python2 setup.py build
%install
./setup.py install --prefix=$RPM_BUILD_ROOT/usr
python2 setup.py install --prefix=$RPM_BUILD_ROOT/usr
%clean
%files
%defattr(-,root,root)
%doc CHANGELOG COPYING README FAQ.html
/usr/lib/python2.2/site-packages/rdiff_backup
/usr/bin/rdiff-backup
/usr/share/man/man1/rdiff-backup.1.gz
/usr/share/doc/rdiff-backup-%{version}
/usr/lib
%changelog
......
......@@ -3,17 +3,12 @@
import sys, os, getopt
from distutils.core import setup, Extension
version_string = "0.9.0"
version_string = "$version"
if sys.version_info[:2] < (2,2):
print "Sorry, rdiff-backup requires version 2.2 or later of python"
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",
version=version_string,
description="Local/remote mirroring+incremental backup",
......@@ -21,27 +16,11 @@ setup(name="rdiff-backup",
author_email="bescoto@stanford.edu",
url="http://rdiff-backup.stanford.edu",
packages = ['rdiff_backup'],
ext_modules=[Extension("rdiff_backup.C", ["cmodule.c"])])
copy_files = 0
prefix = "/usr"
for arg in sys.argv[1:]: # check for "install" and --prefix= arg
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)
ext_modules = [Extension("rdiff_backup.C", ["cmodule.c"])],
scripts = ['rdiff-backup'],
data_files = [('share/man/man1', ['rdiff-backup.1']),
('share/doc/rdiff-backup-%s' % version_string,
['CHANGELOG', 'COPYING', 'README', 'FAQ.html'])])
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