#!/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)