aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRafael G. Martins <rafael@rafaelmartins.eng.br>2010-07-31 22:42:59 -0300
committerRafael G. Martins <rafael@rafaelmartins.eng.br>2010-07-31 22:42:59 -0300
commitb3ff807c469c8e64860228ae344b006ada38f738 (patch)
tree44b3588531ef5a35dd3b4910c92475bf269851d2 /g_octave
parentfixed the removing of forced strip on the Makefiles of the packages (diff)
downloadg-octave-b3ff807c469c8e64860228ae344b006ada38f738.tar.gz
g-octave-b3ff807c469c8e64860228ae344b006ada38f738.tar.bz2
g-octave-b3ff807c469c8e64860228ae344b006ada38f738.zip
removed the package g_octave.svn
Diffstat (limited to 'g_octave')
-rw-r--r--g_octave/svn/__init__.py0
-rw-r--r--g_octave/svn/client.py142
-rw-r--r--g_octave/svn/description.py34
-rw-r--r--g_octave/svn/revisions.py57
-rw-r--r--g_octave/svn/utils.py29
5 files changed, 0 insertions, 262 deletions
diff --git a/g_octave/svn/__init__.py b/g_octave/svn/__init__.py
deleted file mode 100644
index e69de29..0000000
--- a/g_octave/svn/__init__.py
+++ /dev/null
diff --git a/g_octave/svn/client.py b/g_octave/svn/client.py
deleted file mode 100644
index 46bb45a..0000000
--- a/g_octave/svn/client.py
+++ /dev/null
@@ -1,142 +0,0 @@
-# -*- coding: utf-8 -*-
-
-"""
- client.py
- ~~~~~~~~~
-
- This module implements a interface between g-octave and the octave-forge
- Subversion repository.
-
- :copyright: (c) 2010 by Rafael Goncalves Martins
- :license: GPL-2, see LICENSE for more details.
-"""
-
-from __future__ import print_function, absolute_import
-
-import os
-import pysvn
-import re
-import shutil
-import subprocess
-import sys
-
-from g_octave.compat import py3k
-
-if py3k:
- import urllib.request as url_request, urllib.error as url_error
-else:
- import urllib2
- url_request = urllib2
- url_error = urllib2
-
-from contextlib import closing
-
-from . import revisions
-from g_octave import config
-
-class SvnClient:
-
- url = 'https://octave.svn.sourceforge.net/svnroot/octave/trunk/octave-forge/'
- categories = ['main', 'extra', 'language', 'nonfree']
- exclude = ['CONTENTS', 'INDEX', 'Makefile', 'base']
-
- def __init__(self, create_revisions=True, verbose=False):
- self.conf = config.Config()
- json_file = os.path.join(self.conf.db, 'revisions.json')
- self._verbose = verbose
- self._client = pysvn.Client()
- self._revisions = revisions.Revisions(json_file)
- self.packages = {}
- if create_revisions and not os.path.exists(json_file):
- self.update_revisions()
- else:
- self.packages = self._revisions.get()
-
- def update_revisions(self):
- updated = []
- pkg_cache_dir = self.conf.pkg_cache
- try:
- pkg_cache = os.listdir(pkg_cache_dir)
- except:
- raise RuntimeError('Failed to list packages from the pkg_cache')
- for category in self.categories:
- self.packages[category] = self._list_packages(category)
- for category in self.packages:
- for package in self.packages[category]:
- old_revision = self._revisions.get(category, package)
- current_revision = self.packages[category][package]
- tarball_exist = False
- for package_c in pkg_cache:
- if re.match(r'%s\-[0-9\.]+' % package, package_c) is not None:
- tarball_exist = True
- if current_revision is None or old_revision is None or current_revision > old_revision or not tarball_exist:
- self._revisions.set(category, package, current_revision)
- updated.append((category, package))
- return updated
-
- def _list_packages(self, category):
- try:
- if self._verbose:
- print('Listing packages from: ' + category)
- pkg_list = self._client.list(
- self.url + '/' + category + '/',
- depth = pysvn.depth.immediates
- )
- except pysvn.ClientError as err:
- print('Error: ' + str(err), file=sys.stderr)
- tmp = {}
- for props, lock in pkg_list:
- filename = props.repos_path.split('/')[-1]
- if filename not in self.exclude and filename != category:
- tmp[filename] = props.created_rev.number
- return tmp
-
- def create_description_tree(self, dest, categories=['main', 'extra', 'language']):
- for category in categories:
- if category not in self.categories:
- continue
- for pkg, revision in self.packages[category]:
- current_dir = os.path.join(dest, category, pkg)
- os.makedirs(current_dir)
- try:
- if self._verbose:
- print('Fetching DESCRIPTION from: %s/%s' % (category, pkg))
- fp = url_request.urlopen(
- self.url + '/' + category + '/' + pkg + '/DESCRIPTION'
- )
- with open(os.path.join(current_dir, 'DESCRIPTION'), 'wb') as fp_:
- shutil.copyfileobj(fp, fp_)
- except url_error.URLError:
- pass
-
- def checkout_package(self, category, name, dest, stable=True):
- if stable:
- # get DESCRIPTION revision
- info = self._client.info2(
- self.url + '/' + category + '/' + name + '/DESCRIPTION'
- )
- revision = info[0][1].last_changed_rev
- self._client.checkout(
- self.url + '/' + category + '/' + name + '/',
- dest,
- revision = stable and revision or \
- pysvn.Revision(pysvn.opt_revision_kind.head)
- )
- makefile = os.path.join(dest, 'Makefile')
- configure = os.path.join(dest, 'configure')
- autogen = os.path.join(dest, 'src', 'autogen.sh')
- self.download_file('packages/package_Makefile.in', os.path.join(dest, 'Makefile'))
- self.download_file('packages/package_configure.in', configure)
- os.chmod(configure, 0o755)
- if os.path.exists(autogen):
- os.chmod(autogen, 0o755)
- if subprocess.call(
- 'cd %s && ./autogen.sh' % os.path.dirname(autogen),
- shell=True
- ) != os.EX_OK:
- raise RuntimeError('Failed to run autogen.sh')
-
- def download_file(self, src, dest):
- with closing(url_request.urlopen(self.url + '/' + src)) as fp:
- with open(dest, 'wb') as fp_:
- shutil.copyfileobj(fp, fp_)
diff --git a/g_octave/svn/description.py b/g_octave/svn/description.py
deleted file mode 100644
index 1cb760c..0000000
--- a/g_octave/svn/description.py
+++ /dev/null
@@ -1,34 +0,0 @@
-# -*- coding: utf-8 -*-
-
-"""
- description.py
- ~~~~~~~~~~~~~~
-
- This module implements a wrapper to the g_octave.description module,
- creating a description object from the SVN trunk DESCRIPTION file of
- a package.
-
- :copyright: (c) 2010 by Rafael Goncalves Martins
- :license: GPL-2, see LICENSE for more details.
-"""
-
-import os
-import tempfile
-
-from g_octave.svn import client
-from g_octave import description, exception
-
-class SvnDescription(description.Description):
-
- def __init__(self, category, package):
- self._svn = client.SvnClient(create_revisions=False)
- temp_desc = config_file = tempfile.mkstemp()[1]
- try:
- self._svn.download_file(
- category + '/' + package + '/DESCRIPTION',
- temp_desc
- )
- except:
- raise exception.DescriptionException('Failed to fetch DESCRIPTION file from SVN')
- description.Description.__init__(self, temp_desc, parse_sysreq=True)
- os.unlink(temp_desc)
diff --git a/g_octave/svn/revisions.py b/g_octave/svn/revisions.py
deleted file mode 100644
index 647756a..0000000
--- a/g_octave/svn/revisions.py
+++ /dev/null
@@ -1,57 +0,0 @@
-# -*- coding: utf-8 -*-
-
-"""
- revisions.py
- ~~~~~~~~~~~~
-
- This module implements a Python object with the revisions for each
- package fetched from the octave-forge SVN.
-
- :copyright: (c) 2010 by Rafael Goncalves Martins
- :license: GPL-2, see LICENSE for more details.
-"""
-
-import json
-
-from g_octave.compat import open
-
-class Revisions(object):
-
- def __init__(self, json_file):
- self._file = json_file
-
- def _load_json(self):
- revisions = {}
- try:
- with open(self._file) as fp:
- revisions = json.load(fp)
- except:
- return {}
- return revisions
-
- def _dump_json(self, revisions):
- try:
- with open(self._file, 'w') as fp:
- json.dump(revisions, fp)
- except:
- return False
- return True
-
- def get(self, category=None, package=None):
- revisions = self._load_json()
- if category is None:
- return revisions
- if category in revisions:
- if package is None:
- return revisions[category]
- if package in revisions[category]:
- return revisions[category][package]
- return None
-
- def set(self, category, package, value):
- revisions = self._load_json()
- if category not in revisions:
- revisions[category] = {}
- revisions[category][package] = value
- if not self._dump_json(revisions):
- raise RuntimeError('Failed to save JSON file.')
diff --git a/g_octave/svn/utils.py b/g_octave/svn/utils.py
deleted file mode 100644
index 83e32f9..0000000
--- a/g_octave/svn/utils.py
+++ /dev/null
@@ -1,29 +0,0 @@
-# -*- coding: utf-8 -*-
-
-"""
- utils.py
- ~~~~~~~~
-
- This module implements some helper functions to work with SVN packages.
-
- :copyright: (c) 2010 by Rafael Goncalves Martins
- :license: GPL-2, see LICENSE for more details.
-"""
-
-from __future__ import print_function
-
-import sys
-import tarfile
-
-from contextlib import closing
-
-def create_tarball(src_dir, tarball_file, arcname):
-
- def exclude(filename):
- return ('.svn' in filename) or ('autom4te.cache' in filename)
-
- try:
- with closing(tarfile.open(tarball_file, 'w:gz')) as tar:
- tar.add(src_dir, arcname=arcname, recursive=True, exclude=exclude)
- except tarfile.TarError as err:
- print('Failed to create the tarball: %s' % err, file=sys.stderr)