Menu

[r113]: / tools / create_packages_from_docs.py  Maximize  Restore  History

Download this file

104 lines (75 with data), 2.4 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
#!/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_docs(client, path):
""" Checkout from the tagged release. """
tag_url = "%s/docs" % root_url
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:
client = pysvn.Client()
path = os.path.join("/", "tmp", "cpp-netlib-docs")
checkout_docs(client, path)
create_tarball(path, "cpp-netlib-docs.tar.gz", "w:gz")
create_tarball(path, "cpp-netlib-docs.tar.bz2", "w:bz2")
create_zip(path, "cpp-netlib-docs.zip", "w")
except Exception, err:
print err
sys.exit(-1)