Menu

[r224]: / tools / create_packages_from_release.py  Maximize  Restore  History

Download this file

117 lines (85 with data), 2.8 kB

  1
  2
  3
  4
  5
  6
  7
  8
  9
 10
 11
 12
 13
 14
 15
 16
 17
 18
 19
 20
 21
 22
 23
 24
 25
 26
 27
 28
 29
 30
 31
 32
 33
 34
 35
 36
 37
 38
 39
 40
 41
 42
 43
 44
 45
 46
 47
 48
 49
 50
 51
 52
 53
 54
 55
 56
 57
 58
 59
 60
 61
 62
 63
 64
 65
 66
 67
 68
 69
 70
 71
 72
 73
 74
 75
 76
 77
 78
 79
 80
 81
 82
 83
 84
 85
 86
 87
 88
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
#!/usr/bin/python
#
# Copyright Glyn Matthews 2008.
# Distributed under the Boost Software License, Version 1.0.
# (See accompanying file LICENSE_1_0.txt or copy at
# http://www.boost.org/LICENSE_1_0.txt)
#
"""
Creates a set of archives for the given release.
"""
__author__ = 'Glyn Matthews'
import os
import pysvn
# constants
root_url = "https://cpp-netlib.svn.sourceforge.net/svnroot/cpp-netlib"
def checkout_release(client, version, path):
""" Checkout from the tagged release. """
tag_url = "%s/tags/release/%s" % (root_url, version)
client.checkout(url=tag_url, path=path)
def create_tarball(path, filename, mode):
""" Create tarball. """
import tarfile
tar = tarfile.open(filename, mode)
cwd = os.getcwd()
os.chdir(path)
try:
for root, dirs, files in os.walk('.'):
if '.svn' in dirs:
dirs.remove('.svn')
if 'bin' in dirs:
dirs.remove('bin')
if 'bin.v2' in dirs:
dirs.remove('bin.v2')
for fil in files:
tar.add(os.path.join(root, fil))
except Exception, err:
print err
tar.close()
os.chdir(cwd)
def create_zip(path, filename, mode):
""" Create zip archive. """
import zipfile
zip = zipfile.ZipFile(filename, mode)
cwd = os.getcwd()
os.chdir(path)
try:
for root, dirs, files in os.walk('.'):
if '.svn' in dirs:
dirs.remove('.svn')
if 'bin' in dirs:
dirs.remove('bin')
if 'bin.v2' in dirs:
dirs.remove('bin.v2')
for fil in files:
zip.write(os.path.join(root, fil))
except Exception, err:
print err
zip.close()
os.chdir(cwd)
def usage():
""" """
print "Usage: python create_packages_from_release.py --major=<major> --minor<minor>"
if __name__ == '__main__':
import sys
import getopt
try:
opts, args = getopt.getopt(sys.argv[1:], "", ["major=", "minor="])
for name, value in opts:
if name == '--major':
major = int(value)
elif name == '--minor':
minor = int(value)
if major is None or minor is None:
usage()
sys.exit(-1)
version = "%d.%d" % (major, minor)
client = pysvn.Client()
path = os.path.join("/", "tmp", "cpp-netlib")
checkout_release(client, version, path)
create_tarball(path, "cpp-netlib.tar.gz", "w:gz")
create_tarball(path, "cpp-netlib.tar.bz2", "w:bz2")
create_zip(path, "cpp-netlib.zip", "w")
except Exception, err:
print err
sys.exit(-1)