~vcs-imports/kupfer/master-new

« back to all changes in this revision

Viewing changes to wscript

  • Committer: Ulrik Sverdrup
  • Date: 2010-02-11 16:55:26 UTC
  • Revision ID: git-v1:d79fd019b3938a35b97bdda5dc274c1bd2bf4710
Create release tarballs with ./waf gitdist, implemented on top of git-archive

./waf gitdist creates a release tarball with git-archive, writing in
extra-dist files (waf and version stamp file) manually.

./waf dist  is the original waf dist process left untouched (for used
in tarball -> tarball packing).

Show diffs side-by-side

added added

removed removed

Lines of Context:
32
32
                global VERSION
33
33
                VERSION = version
34
34
 
 
35
def _write_git_version():
 
36
        """ Write the revision to a file called GIT_VERSION,
 
37
        to grab the current version number from git when
 
38
        generating the dist tarball."""
 
39
        version = _get_git_version()
 
40
        if not version:
 
41
                return False
 
42
        version_file = open("GIT_VERSION", "w")
 
43
        version_file.write(version + "\n")
 
44
        version_file.close()
 
45
        return True
 
46
 
 
47
 
35
48
_read_git_version()
36
49
 
37
 
VERSION_MAJOR_MINOR = ".".join(VERSION.split(".")[0:2])
38
 
 
39
50
# these variables are mandatory ('/' are converted automatically)
40
51
srcdir = '.'
41
52
blddir = 'build'
42
53
 
43
 
def dist_hook():
44
 
        """in the dist preparation dir, delete unwanted files"""
45
 
        DIST_GIT_IGNORE = """
46
 
                debug.py
47
 
                makedist.sh
48
 
                """.split()
49
 
 
50
 
        for ignfile in filter(os.path.exists, DIST_GIT_IGNORE):
51
 
                os.unlink(ignfile)
 
54
EXTRA_DIST = [
 
55
        "waf",
 
56
        "GIT_VERSION",
 
57
]
 
58
 
 
59
def _tarfile_append_as(tarname, filename, destname):
 
60
        import tarfile
 
61
        tf = tarfile.TarFile.open(tarname, "a")
 
62
        try:
 
63
                tf.add(filename, destname)
 
64
        finally:
 
65
                tf.close()
 
66
 
 
67
def gitdist(ctx):
 
68
        """Make the release tarball using git-archive"""
 
69
        import subprocess
 
70
        if not _write_git_version():
 
71
                raise Exception("No version")
 
72
        basename = "%s-%s" % (APPNAME, VERSION)
 
73
        outname = basename + ".tar"
 
74
        proc = subprocess.Popen(
 
75
                ["git", "archive", "--format=tar", "--prefix=%s/" % basename, "HEAD"],
 
76
                stdout=subprocess.PIPE)
 
77
        fd = os.open(outname, os.O_CREAT | os.O_EXCL | os.O_WRONLY, 0666)
 
78
        os.write(fd, proc.communicate()[0])
 
79
        os.close(fd)
 
80
        for distfile in EXTRA_DIST:
 
81
                _tarfile_append_as(outname, distfile, os.path.join(basename, distfile))
 
82
        subprocess.call(["gzip", outname])
 
83
        subprocess.call(["sha1sum", outname + ".gz"])
52
84
 
53
85
def dist():
54
 
        """Make the dist tarball and print its SHA-1 """
55
 
        def write_git_version():
56
 
                """ Write the revision to a file called GIT_VERSION,
57
 
                to grab the current version number from git when
58
 
                generating the dist tarball."""
59
 
                version = _get_git_version()
60
 
                if not version:
61
 
                        return False
62
 
                version_file = open("GIT_VERSION", "w")
63
 
                version_file.write(version + "\n")
64
 
                version_file.close()
65
 
                return True
66
 
 
 
86
        "The standard waf dist process"
67
87
        import Scripting
68
 
        write_git_version()
 
88
        _write_git_version()
69
89
        Scripting.g_gz = "gz"
70
90
        Scripting.dist(APPNAME, VERSION)
71
91
 
 
92
 
72
93
def set_options(opt):
73
94
        # options for disabling pyc or pyo compilation
74
95
        opt.tool_options("python")