Gentoo Archives: gentoo-commits

From: "Michał Górny" <mgorny@g.o>
To: gentoo-commits@l.g.o
Subject: [gentoo-commits] proj/pms-test-suite:master commit in: PMSTestSuite/repository/, PMSTestSuite/
Date: Wed, 01 Jun 2011 12:31:04
Message-Id: 67277bf31457d314b5e24a32477deb2ee9ed67b3.mgorny@gentoo
1 commit: 67277bf31457d314b5e24a32477deb2ee9ed67b3
2 Author: Michał Górny <mgorny <AT> gentoo <DOT> org>
3 AuthorDate: Wed Jun 1 11:40:26 2011 +0000
4 Commit: Michał Górny <mgorny <AT> gentoo <DOT> org>
5 CommitDate: Wed Jun 1 11:40:26 2011 +0000
6 URL: http://git.overlays.gentoo.org/gitweb/?p=proj/pms-test-suite.git;a=commit;h=67277bf3
7
8 Support creating a new ebuild repository. Write repo_name.
9
10 ---
11 PMSTestSuite/cli.py | 4 ++--
12 PMSTestSuite/repository/__init__.py | 24 +++++++++++++++++++++++-
13 2 files changed, 25 insertions(+), 3 deletions(-)
14
15 diff --git a/PMSTestSuite/cli.py b/PMSTestSuite/cli.py
16 index f7eb7ae..f6b56ab 100644
17 --- a/PMSTestSuite/cli.py
18 +++ b/PMSTestSuite/cli.py
19 @@ -9,7 +9,7 @@ from optparse import OptionParser
20
21 from PMSTestSuite import PV
22 from PMSTestSuite.library import load_library
23 -from PMSTestSuite.repository import EbuildRepository
24 +from PMSTestSuite.repository import NewEbuildRepository
25 from PMSTestSuite.pm import get_package_managers
26
27 class PMSTestSuiteCLI(object):
28 @@ -76,7 +76,7 @@ class PMSTestSuiteCLI(object):
29 self.pm.pm_options = shlex.split(opts.pmopts) if opts.pmopts else []
30
31 try:
32 - self.repository = EbuildRepository(opts.repo_path)
33 + self.repository = NewEbuildRepository(opts.repo_path, 'pms-test-suite')
34 except (OSError, IOError, ValueError) as e:
35 opt.error('Repository open failed: %s' % e)
36
37
38 diff --git a/PMSTestSuite/repository/__init__.py b/PMSTestSuite/repository/__init__.py
39 index 1895f48..cb5d0ac 100644
40 --- a/PMSTestSuite/repository/__init__.py
41 +++ b/PMSTestSuite/repository/__init__.py
42 @@ -2,7 +2,7 @@
43 # (c) 2011 Michał Górny <mgorny@g.o>
44 # Released under the terms of the 2-clause BSD license.
45
46 -import os.path
47 +import os, os.path
48
49 class EbuildRepository(object):
50 """
51 @@ -46,3 +46,25 @@ class EbuildRepository(object):
52 """ Remanifest files from <files> dict using <pm>. """
53 dirs = frozenset([os.path.join(self.path, os.path.dirname(f)) for f in files])
54 pm.remanifest(dirs)
55 +
56 +class NewEbuildRepository(EbuildRepository):
57 + """
58 + A subclass of EbuildRepository supporting creating a new repository
59 + for the test suite (i.e. not requiring repo_name to exist).
60 + """
61 +
62 + def __init__(self, path, repo_name):
63 + """
64 + Create a new ebuild repository in <path>. Name it <repo_name>.
65 + """
66 + self.path = path
67 + self.repo_name = repo_name
68 +
69 + rnpath = os.path.join(path, 'profiles', 'repo_name')
70 + dirpath = os.path.dirname(rnpath)
71 +
72 + if not os.path.isdir(dirpath): # XXX: poor
73 + os.makedirs(dirpath)
74 + f = open(rnpath, 'w')
75 + f.write(repo_name)
76 + f.close()