~ed.so/duplicity/reuse-passphrase-for-signing-fix

« back to all changes in this revision

Viewing changes to dist/makedist

  • Committer: bescoto
  • Date: 2002-10-29 01:49:46 UTC
  • Revision ID: vcs-imports@canonical.com-20021029014946-3m4rmm5plom7pl6q
Initial checkin

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
#!/usr/bin/env python
 
2
 
 
3
import os, re, shutil, time, sys
 
4
 
 
5
SourceDir = "src"
 
6
DistDir = "dist"
 
7
 
 
8
# Various details about the files must also be specified by the rpm
 
9
# spec template.
 
10
spec_template = "dist/duplicity.spec"
 
11
 
 
12
def CopyMan(input_name, destination, version):
 
13
        """Create updated man page at the specified location"""
 
14
        fp = open(destination, "w")
 
15
        date = time.strftime("%B %Y", time.localtime(time.time()))
 
16
        version = "Version "+version
 
17
        firstline = ('.TH RDIFFDIR 1 "%s" "%s" "User Manuals"\n' %
 
18
                                 (date, version))
 
19
        fp.write(firstline)
 
20
        infp = open(input_name, "r")
 
21
        infp.readline()
 
22
        fp.write(infp.read())
 
23
        fp.close()
 
24
        infp.close()
 
25
 
 
26
def MakeFAQ():
 
27
        """Create FAQ.html and FAQ.wml files from FAQ-body.html"""
 
28
        faqbody_fp = open("FAQ-body.html", "r")
 
29
        faqbody_string = faqbody_fp.read()
 
30
        faqbody_fp.close()
 
31
 
 
32
        wml_fp = open("FAQ.wml", "w")
 
33
        wml_fp.write(
 
34
"""#include 'template.wml' curpage=faq title="rdiff-backup: FAQ"
 
35
 
 
36
<divert body>
 
37
<p><h2>FAQ:</h2>
 
38
 
 
39
""")
 
40
        wml_fp.write(faqbody_string)
 
41
        wml_fp.write("\n</divert>\n")
 
42
        wml_fp.close()
 
43
 
 
44
        html_fp = open("FAQ.html", "w")
 
45
        html_fp.write(
 
46
"""<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
 
47
 
 
48
<html>
 
49
  <head>
 
50
    <title>rdiff-backup FAQ</title>
 
51
  </head>
 
52
 
 
53
  <body>
 
54
  <h1>rdiff-backup FAQ</h1>
 
55
""")
 
56
        html_fp.write(faqbody_string)
 
57
        html_fp.write("\n</body></html>")
 
58
        html_fp.close()
 
59
 
 
60
def VersionedCopy(source, dest):
 
61
        """Copy source to dest, substituting $version with version"""
 
62
        fin = open(source, "rb")
 
63
        inbuf = fin.read()
 
64
        assert not fin.close()
 
65
 
 
66
        outbuf = re.sub("\$version", Version, inbuf, 1)
 
67
        if outbuf == inbuf: assert 0, "No $version string replaced"
 
68
        assert not re.search("\$version", outbuf), \
 
69
                   "Two $version strings found in the same file %s" % (source,)
 
70
 
 
71
        fout = open(dest, "wb")
 
72
        fout.write(outbuf)
 
73
        assert not fout.close()
 
74
 
 
75
def MakeTar():
 
76
        """Create rdiff-backup tar file"""
 
77
        tardir = "duplicity-%s" % Version
 
78
        tarfile = "duplicity-%s.tar.gz" % Version
 
79
        try:
 
80
                os.lstat(tardir)
 
81
                os.system("rm -rf " + tardir)
 
82
        except OSError: pass
 
83
        os.mkdir(tardir)
 
84
        for filename in ["COPYING", "README", "CHANGELOG",
 
85
                                         SourceDir + "/_librsyncmodule.c",
 
86
                                         DistDir + "/setup.py"]:
 
87
                assert not os.system("cp %s %s" % (filename, tardir)), filename
 
88
 
 
89
        os.mkdir(tardir+"/src")
 
90
 
 
91
        for filename in ["backends.py", "collections.py", "commandline.py",
 
92
                                         "diffdir.py", "dup_temp.py", "dup_time.py",
 
93
                                         "file_naming.py", "globals.py",
 
94
                                         "GnuPGInterface.py", "gpg.py", "__init__.py",
 
95
                                         "lazy.py", "librsync.py", "log.py",
 
96
                                         "manifest.py", "misc.py", "patchdir.py",
 
97
                                         "path.py", "robust.py", "selection.py",
 
98
                                         "static.py", "tarfile.py"]:
 
99
                assert not os.system("cp %s/%s %s/src" %
 
100
                                                         (SourceDir, filename, tardir)), filename
 
101
 
 
102
        VersionedCopy("%s/globals.py" % (SourceDir,),
 
103
                                  "%s/src/globals.py" % (tardir,))
 
104
        VersionedCopy("duplicity-bin", "%s/duplicity" % (tardir,))
 
105
        VersionedCopy("rdiffdir", "%s/rdiffdir" % (tardir,))
 
106
        VersionedCopy(DistDir + "/setup.py", "%s/setup.py" % (tardir,))
 
107
 
 
108
        os.chmod(os.path.join(tardir, "setup.py"), 0755)
 
109
        os.chmod(os.path.join(tardir, "rdiffdir"), 0644)
 
110
        CopyMan("rdiffdir.1", os.path.join(tardir, "rdiffdir.1"), Version)
 
111
        CopyMan("duplicity.1", os.path.join(tardir, "duplicity.1"), Version)
 
112
        os.system("tar -cvzf %s %s" % (tarfile, tardir))
 
113
        shutil.rmtree(tardir)
 
114
        return tarfile
 
115
 
 
116
def MakeSpecFile():
 
117
        """Create spec file using spec template"""
 
118
        specfile = "duplicity-%s-1.spec" % Version
 
119
        VersionedCopy(spec_template, specfile)
 
120
        return specfile
 
121
 
 
122
def Main():
 
123
        #print "Making FAQ"
 
124
        #MakeFAQ()
 
125
        print "Processing version " + Version
 
126
        tarfile = MakeTar()
 
127
        print "Made tar file " + tarfile
 
128
        specfile = MakeSpecFile()
 
129
        print "Made specfile ", specfile
 
130
 
 
131
if __name__ == "__main__" and not globals().has_key('__no_execute__'):
 
132
        if len(sys.argv) != 2:
 
133
                print "Syntax: makedist [version_number]"
 
134
                sys.exit(1)
 
135
        Version = sys.argv[1]
 
136
        Main()
 
137