diff options
Diffstat (limited to 'RepSys')
-rw-r--r-- | RepSys/__init__.py | 19 | ||||
-rw-r--r-- | RepSys/log.py | 6 | ||||
-rw-r--r-- | RepSys/rpmutil.py | 4 |
3 files changed, 24 insertions, 5 deletions
diff --git a/RepSys/__init__.py b/RepSys/__init__.py index c371e7a..c394746 100644 --- a/RepSys/__init__.py +++ b/RepSys/__init__.py @@ -1,9 +1,28 @@ #!/usr/bin/python +import re +import os import ConfigParser + config = ConfigParser.Config() del ConfigParser class Error(Exception): pass +class RepSysTree: + """ + This class just hold methods that abstract all the not-so-explicit + rules about the directory structure of a repsys repository. + """ + def fixpath(cls, url): + return re.sub("/+$", "", url) + fixpath = classmethod(fixpath) + + def pkgname(cls, pkgdirurl): + # we must remove trailling slashes in the package path because + # os.path.basename could return "" from URLs ending with "/" + fixedurl = cls.fixpath(pkgdirurl) + return os.path.basename(fixedurl) + pkgname = classmethod(pkgname) + # vim:et:ts=4:sw=4 diff --git a/RepSys/log.py b/RepSys/log.py index 62a290d..cf913f8 100644 --- a/RepSys/log.py +++ b/RepSys/log.py @@ -1,5 +1,5 @@ #!/usr/bin/python -from RepSys import Error, config +from RepSys import Error, config, RepSysTree from RepSys.svn import SVN from RepSys.util import execcmd @@ -52,7 +52,7 @@ def getrelease(pkgdirurl, rev=None): svn = SVN(baseurl=pkgdirurl) tmpdir = tempfile.mktemp() try: - pkgname = os.path.basename(pkgdirurl) + pkgname = RepSysTree.pkgname(pkgdirurl) pkgcurrenturl = os.path.join(pkgdirurl, "current") specurl = os.path.join(pkgcurrenturl, "SPECS") if svn.ls(specurl, noerror=1): @@ -394,7 +394,7 @@ def specfile_svn2rpm(pkgdirurl, specfile, rev=None, size=None, svn = SVN(baseurl=pkgdirurl) tmpdir = tempfile.mktemp() try: - pkgname = os.path.basename(pkgdirurl) + pkgname = RepSysTree.pkgname(pkgdirurl) pkgoldurl = os.path.join(oldurl, pkgname) if svn.ls(pkgoldurl, noerror=1): svn.export(pkgoldurl, tmpdir, rev=rev) diff --git a/RepSys/rpmutil.py b/RepSys/rpmutil.py index e35639d..ac54046 100644 --- a/RepSys/rpmutil.py +++ b/RepSys/rpmutil.py @@ -1,5 +1,5 @@ #!/usr/bin/python -from RepSys import Error, config +from RepSys import Error, config, RepSysTree from RepSys.svn import SVN from RepSys.rpm import SRPM from RepSys.log import specfile_svn2rpm @@ -223,7 +223,7 @@ def create_package(pkgdirurl, log="", verbose=0): svn = SVN(baseurl=pkgdirurl) tmpdir = tempfile.mktemp() try: - basename = os.path.basename(pkgdirurl) + basename = RepSysTree.pkgname(pkgdirurl) if verbose: print "Creating package directory...", sys.stdout.flush() |