* [gentoo-commits] proj/R_overlay:master commit in: roverlay/portage/
@ 2012-06-13 16:34 André Erdmann
0 siblings, 0 replies; 5+ messages in thread
From: André Erdmann @ 2012-06-13 16:34 UTC (permalink / raw
To: gentoo-commits
commit: a1ebcb962993c32941056bb6820266b6d7c7e449
Author: André Erdmann <dywi <AT> mailerd <DOT> de>
AuthorDate: Wed Jun 13 16:30:38 2012 +0000
Commit: André Erdmann <dywi <AT> mailerd <DOT> de>
CommitDate: Wed Jun 13 16:30:38 2012 +0000
URL: http://git.overlays.gentoo.org/gitweb/?p=proj/R_overlay.git;a=commit;h=a1ebcb96
roverlay/portage, ebuild
* shallow-copy the ebuild header instead of modifying it which results in
useless ebuilds when creating more than one
* make Ebuild's has_rsuggests bool instance-wide
modified: roverlay/portage/ebuild.py
modified: roverlay/portage/ebuildjob.py
---
roverlay/portage/ebuild.py | 10 +++++++---
roverlay/portage/ebuildjob.py | 3 +++
2 files changed, 10 insertions(+), 3 deletions(-)
diff --git a/roverlay/portage/ebuild.py b/roverlay/portage/ebuild.py
index fdef01c..00620f0 100644
--- a/roverlay/portage/ebuild.py
+++ b/roverlay/portage/ebuild.py
@@ -2,8 +2,11 @@
# Copyright 2006-2012 Gentoo Foundation
# Distributed under the terms of the GNU General Public License v2
+import copy
+
import roverlay.config
+
class Ebuild ( object ):
EBUILD_INDENT = roverlay.config.get ( 'EBUILD.indent', '\t' )
@@ -37,6 +40,7 @@ class Ebuild ( object ):
self._data = dict ()
self._ebuild_lines = None
self._ebuild_name = None
+ self.has_rsuggests = False
# --- end of __init__ (...) ---
@@ -217,7 +221,7 @@ class Ebuild ( object ):
"""
# have suggests if they're set and not empty
- have_suggests = bool (
+ self.has_rsuggests = bool (
'R_SUGGESTS' in self._data and self._data ['R_SUGGESTS']
)
@@ -237,7 +241,7 @@ class Ebuild ( object ):
ret [kw].append ( self._data [kw] )
- if have_suggests:
+ if self.has_rsuggests:
ret ['R_SUGGESTS'] = self._data ['R_SUGGESTS']
# +R_SUGGESTS, -R_SUGGESTS?
@@ -353,7 +357,7 @@ class Ebuild ( object ):
ebuild_lines = []
if 'ebuild_header' in self._data:
- ebuild_lines = self._data ['ebuild_header']
+ ebuild_lines = copy.copy ( self._data ['ebuild_header'] )
ebuild_lines.append ( "" )
add_easyvar ( ebuild_lines, "PKG_FILE" )
diff --git a/roverlay/portage/ebuildjob.py b/roverlay/portage/ebuildjob.py
index 825607b..ff8278a 100644
--- a/roverlay/portage/ebuildjob.py
+++ b/roverlay/portage/ebuildjob.py
@@ -248,6 +248,9 @@ class EbuildJob ( object ):
## finalize self.ebuild: forced text creation + make it readonly
if ebuild.prepare ( True, True ):
self.ebuild = ebuild
+ # update package info
+ self.package_info ['has_suggests'] = ebuild.has_rsuggests
+
except Exception as any_exception:
^ permalink raw reply related [flat|nested] 5+ messages in thread
* [gentoo-commits] proj/R_overlay:master commit in: roverlay/portage/
@ 2012-06-15 20:34 André Erdmann
0 siblings, 0 replies; 5+ messages in thread
From: André Erdmann @ 2012-06-15 20:34 UTC (permalink / raw
To: gentoo-commits
commit: 6ebe883df9965402931a3138db21353e2758e880
Author: André Erdmann <dywi <AT> mailerd <DOT> de>
AuthorDate: Thu Jun 14 18:55:40 2012 +0000
Commit: André Erdmann <dywi <AT> mailerd <DOT> de>
CommitDate: Thu Jun 14 18:55:40 2012 +0000
URL: http://git.overlays.gentoo.org/gitweb/?p=proj/R_overlay.git;a=commit;h=6ebe883d
Manifest creation
* using the ebuild interface
new file: roverlay/portage/manifest.py
---
roverlay/portage/manifest.py | 145 ++++++++++++++++++++++++++++++++++++++++++
1 files changed, 145 insertions(+), 0 deletions(-)
diff --git a/roverlay/portage/manifest.py b/roverlay/portage/manifest.py
new file mode 100644
index 0000000..a74226b
--- /dev/null
+++ b/roverlay/portage/manifest.py
@@ -0,0 +1,145 @@
+# R Overlay -- Manifest creation for ebuilds
+# Copyright 2006-2012 Gentoo Foundation
+# Distributed under the terms of the GNU General Public License v2
+
+
+# TODO (in future): could use portage api directly, namely
+# '/usr/lib/portage/pym/portage/package/ebuild/doebuild.py'
+# instead of using '/usr/bin/ebuild'
+
+import os
+import copy
+import logging
+import subprocess
+
+
+from roverlay import config, util
+
+EBUILD_PROG = config.get ( 'TOOLS.EBUILD.prog', '/usr/bin/ebuild' )
+EBUILD_TARGET = config.get ( 'TOOLS.EBUILD.target', 'manifest' )
+
+LOGGER = logging.getLogger ( 'ManifestCreation' )
+
+_MANIFEST_ENV = [ None, None ]
+
+def _get_manifest_env ( filter_env=True ):
+ """Creates an environment suitable for an "ebuild <ebuild> digest|manifest"
+ call (or uses an already existing env).
+ Returns a shallow copy of this env which can then be locally modified
+ (setting DISTDIR).
+ TODO/FIXME: DISTDIR is per repo, so use one env per repo!
+
+ arguments:
+ * filter_env -- if True: start with an empty env and copy vars
+ from os.environ selectively
+ else : start with os.environ as env
+ """
+
+ mindex = 0 if filter_env else 1
+
+ if _MANIFEST_ENV [mindex] is None:
+ # ((lock this if required))
+
+ if filter_env:
+
+ # selectively import os.environ
+ # FIXME: keep EBUILD_DEFAULT_OPTS?
+ our_env = util.keepenv (
+ ( 'PATH', '' ),
+ 'LANG',
+ 'PWD',
+ 'EBUILD_DEFAULT_OPTS'
+ )
+ else:
+ # copy os.environ
+ our_env = dict ( os.environ )
+
+ # -- common env part
+
+ # set FEATURES
+ # * digest -- needed? (works without it)
+ # * assume-digests --
+ # * unknown-features-warn -- should FEATURES ever change
+ # * noauto -- should prevent ebuild from adding additional actions,
+ # it still tries to download source packages, which is just wrong here
+ # 'cause it is expected that the R package file exists when calling
+ # this function, so FETCHCOMMAND/RESUMECOMMAND will be set
+ # to /bin/true if possible.
+ # * distlocks -- disabled if FETCHCOMMAND/RESUMECOMMAND set to no-op
+ #
+ our_env ['FEATURES'] = \
+ "noauto digest assume-digests unknown-features-warn"
+
+ # try to prevent src fetching
+ for nop in ( '/bin/true', '/bin/echo' ):
+ if os.path.isfile ( nop ):
+ fetch_nop = "%s \${DISTDIR} \${FILE} \${URI}" % nop
+ our_env ['FETCHCOMMAND'] = fetch_nop
+ our_env ['RESUMECOMMAND'] = fetch_nop
+ our_env ['FEATURES'] += " -distlocks"
+ break
+
+ # set PORDIR_OVERLAY
+ our_env ['PORTDIR_OVERLAY'] = config.get_or_fail ( [ 'OVERLAY', 'dir' ] )
+
+ _MANIFEST_ENV [mindex] = our_env
+ # -- end if
+ return copy.copy ( _MANIFEST_ENV [mindex] )
+# --- end of _get_manifest_env (...) ---
+
+def create_manifest ( package_info ):
+
+ my_env = _get_manifest_env ( filter_env=True )
+
+ # using util for reading package info
+ my_env ['DISTDIR'] = util.get_extra_packageinfo (
+ package_info, 'PKG_DISTDIR'
+ )
+
+ ebuild_file = util.get_extra_packageinfo ( package_info, 'EBUILD_FILE' )
+
+ ebuild_call = subprocess.Popen (
+ (
+ EBUILD_PROG,
+ '--debug',
+ ebuild_file,
+ EBUILD_TARGET
+ ),
+ stdin=None,
+ stdout=subprocess.PIPE,
+ stderr=subprocess.PIPE,
+ env=my_env
+ )
+
+
+
+ output = ebuild_call.communicate()
+ # necessary? (probably not, FIXME/TODO)
+ ebuild_call.wait()
+
+ # log stdout?
+ #for line in util.pipe_lines ( output [0] ):
+ # LOGGER.debug ( line )
+
+ # log stderr
+ for line in util.pipe_lines ( output [1], use_filter=True ):
+ LOGGER.warning ( line )
+
+ if ebuild_call.returncode == 0:
+ return True
+ else:
+ LOGGER.error ( "Cannot create Manifest for %s!" % ebuild_file )
+ return False
+# --- end of create_manifest (...) ---
+
+def try_manifest ( package_info ):
+ try:
+ return create_manifest ( package_info )
+ except Exception as any_exception:
+ LOGGER.exception ( any_exception )
+ return False
+# --- end of try_manifest (...) ---
+
+t = try_manifest
+
+
^ permalink raw reply related [flat|nested] 5+ messages in thread
* [gentoo-commits] proj/R_overlay:master commit in: roverlay/portage/
@ 2012-06-15 20:34 André Erdmann
0 siblings, 0 replies; 5+ messages in thread
From: André Erdmann @ 2012-06-15 20:34 UTC (permalink / raw
To: gentoo-commits
commit: 2e3c050d5712b079611af4d21b9869817fba05b7
Author: André Erdmann <dywi <AT> mailerd <DOT> de>
AuthorDate: Fri Jun 15 09:53:21 2012 +0000
Commit: André Erdmann <dywi <AT> mailerd <DOT> de>
CommitDate: Fri Jun 15 09:53:21 2012 +0000
URL: http://git.overlays.gentoo.org/gitweb/?p=proj/R_overlay.git;a=commit;h=2e3c050d
manifest creation
* real implementation in manifesthelpers.py,
easy access via manifest.py->creat_manifest()
modified: roverlay/portage/manifest.py
new file: roverlay/portage/manifesthelpers.py
---
roverlay/portage/manifest.py | 145 +++----------------------
roverlay/portage/manifesthelpers.py | 207 +++++++++++++++++++++++++++++++++++
2 files changed, 223 insertions(+), 129 deletions(-)
diff --git a/roverlay/portage/manifest.py b/roverlay/portage/manifest.py
index a74226b..79e241c 100644
--- a/roverlay/portage/manifest.py
+++ b/roverlay/portage/manifest.py
@@ -3,143 +3,30 @@
# Distributed under the terms of the GNU General Public License v2
-# TODO (in future): could use portage api directly, namely
-# '/usr/lib/portage/pym/portage/package/ebuild/doebuild.py'
-# instead of using '/usr/bin/ebuild'
-
-import os
-import copy
import logging
-import subprocess
-
-from roverlay import config, util
+import roverlay.portage.manifesthelpers
-EBUILD_PROG = config.get ( 'TOOLS.EBUILD.prog', '/usr/bin/ebuild' )
-EBUILD_TARGET = config.get ( 'TOOLS.EBUILD.target', 'manifest' )
+_MANIFEST_IMPLEMENTATION = \
+ roverlay.portage.manifesthelpers.ExternalManifestCreation
-LOGGER = logging.getLogger ( 'ManifestCreation' )
-_MANIFEST_ENV = [ None, None ]
+def create_manifest ( package_info, nofail=False ):
+ """Creates a Manifest for package_info, using the <<best>> implementation
+ available.
-def _get_manifest_env ( filter_env=True ):
- """Creates an environment suitable for an "ebuild <ebuild> digest|manifest"
- call (or uses an already existing env).
- Returns a shallow copy of this env which can then be locally modified
- (setting DISTDIR).
- TODO/FIXME: DISTDIR is per repo, so use one env per repo!
+ current implementation: ExternalManifestCreation (using ebuild(1))
arguments:
- * filter_env -- if True: start with an empty env and copy vars
- from os.environ selectively
- else : start with os.environ as env
+ * package_info --
+ * nofail -- catch exceptions and return False
"""
-
- mindex = 0 if filter_env else 1
-
- if _MANIFEST_ENV [mindex] is None:
- # ((lock this if required))
-
- if filter_env:
-
- # selectively import os.environ
- # FIXME: keep EBUILD_DEFAULT_OPTS?
- our_env = util.keepenv (
- ( 'PATH', '' ),
- 'LANG',
- 'PWD',
- 'EBUILD_DEFAULT_OPTS'
- )
+ try:
+ return _MANIFEST_IMPLEMENTATION.do ( package_info )
+ except Exception as e:
+ logging.exception ( e )
+ if nofail:
+ return False
else:
- # copy os.environ
- our_env = dict ( os.environ )
-
- # -- common env part
-
- # set FEATURES
- # * digest -- needed? (works without it)
- # * assume-digests --
- # * unknown-features-warn -- should FEATURES ever change
- # * noauto -- should prevent ebuild from adding additional actions,
- # it still tries to download source packages, which is just wrong here
- # 'cause it is expected that the R package file exists when calling
- # this function, so FETCHCOMMAND/RESUMECOMMAND will be set
- # to /bin/true if possible.
- # * distlocks -- disabled if FETCHCOMMAND/RESUMECOMMAND set to no-op
- #
- our_env ['FEATURES'] = \
- "noauto digest assume-digests unknown-features-warn"
-
- # try to prevent src fetching
- for nop in ( '/bin/true', '/bin/echo' ):
- if os.path.isfile ( nop ):
- fetch_nop = "%s \${DISTDIR} \${FILE} \${URI}" % nop
- our_env ['FETCHCOMMAND'] = fetch_nop
- our_env ['RESUMECOMMAND'] = fetch_nop
- our_env ['FEATURES'] += " -distlocks"
- break
-
- # set PORDIR_OVERLAY
- our_env ['PORTDIR_OVERLAY'] = config.get_or_fail ( [ 'OVERLAY', 'dir' ] )
-
- _MANIFEST_ENV [mindex] = our_env
- # -- end if
- return copy.copy ( _MANIFEST_ENV [mindex] )
-# --- end of _get_manifest_env (...) ---
-
-def create_manifest ( package_info ):
-
- my_env = _get_manifest_env ( filter_env=True )
-
- # using util for reading package info
- my_env ['DISTDIR'] = util.get_extra_packageinfo (
- package_info, 'PKG_DISTDIR'
- )
-
- ebuild_file = util.get_extra_packageinfo ( package_info, 'EBUILD_FILE' )
-
- ebuild_call = subprocess.Popen (
- (
- EBUILD_PROG,
- '--debug',
- ebuild_file,
- EBUILD_TARGET
- ),
- stdin=None,
- stdout=subprocess.PIPE,
- stderr=subprocess.PIPE,
- env=my_env
- )
-
-
-
- output = ebuild_call.communicate()
- # necessary? (probably not, FIXME/TODO)
- ebuild_call.wait()
-
- # log stdout?
- #for line in util.pipe_lines ( output [0] ):
- # LOGGER.debug ( line )
-
- # log stderr
- for line in util.pipe_lines ( output [1], use_filter=True ):
- LOGGER.warning ( line )
-
- if ebuild_call.returncode == 0:
- return True
- else:
- LOGGER.error ( "Cannot create Manifest for %s!" % ebuild_file )
- return False
+ raise
# --- end of create_manifest (...) ---
-
-def try_manifest ( package_info ):
- try:
- return create_manifest ( package_info )
- except Exception as any_exception:
- LOGGER.exception ( any_exception )
- return False
-# --- end of try_manifest (...) ---
-
-t = try_manifest
-
-
diff --git a/roverlay/portage/manifesthelpers.py b/roverlay/portage/manifesthelpers.py
new file mode 100644
index 0000000..f3874d1
--- /dev/null
+++ b/roverlay/portage/manifesthelpers.py
@@ -0,0 +1,207 @@
+# R Overlay -- Manifest creation for ebuilds
+# Copyright 2006-2012 Gentoo Foundation
+# Distributed under the terms of the GNU General Public License v2
+
+
+# TODO (in future): could use portage api directly, namely
+# '/usr/lib/portage/pym/portage/package/ebuild/doebuild.py'
+# instead of using '/usr/bin/ebuild'
+
+import os
+import copy
+import logging
+import subprocess
+
+
+from roverlay import config, util
+
+
+class ManifestCreation ( object ):
+ """This is the base class for Manifest file creation."""
+
+ static_instance = None
+
+ def __init__ ( self ):
+ self.logger = logging.getLogger ( 'ManifestCreation' )
+ # --- end of __init__ (...) ---
+
+ def create_for ( self, package_info ):
+ """Creates a Manifest file for the ebuild of the given package_info."""
+ raise Exception ( "method stub" )
+ # --- end of create_for (...) ---
+
+ @classmethod
+ def do ( cls, package_info ):
+ """Class/static access to Manifest creation."""
+ if cls.static_instance is None:
+ cls.static_instance = cls()
+
+ return cls.static_instance.create_for ( package_info )
+ # --- end of do (...) ---
+
+
+class ExternalManifestCreation ( ManifestCreation ):
+ """This class implements Manifest creation using the low level ebuild
+ interface, ebuild(1), which is called in a filtered environment.
+ """
+
+ def __init__ ( self ):
+ super ( ExternalManifestCreation, self ) . __init__ ()
+ self.manifest_env = ManifestEnv ( filter_env=True )
+ self.ebuild_prog = config.get ( 'TOOLS.EBUILD.prog', '/usr/bin/ebuild' )
+ # ebuild <ebuild_file> <target>, where target is:
+ self.ebuild_tgt = config.get ( 'TOOLS.EBUILD.target', 'manifest' )
+ # --- end of __init__ (...) ---
+
+ def create_for ( self, package_info ):
+ """See ManifestCreation.create_for.
+ Calls ebuild, returns True on success else False.
+
+ raises: *passes Exceptions from failed config lookups
+ """
+
+
+ my_env = self.manifest_env [ package_info ['origin'] ]
+
+ ebuild_file = util.get_extra_packageinfo ( package_info, 'EBUILD_FILE' )
+
+ ebuild_call = subprocess.Popen (
+ (
+ self.ebuild_prog,
+ ebuild_file,
+ self.ebuild_tgt
+ ),
+ stdin=None,
+ stdout=subprocess.PIPE,
+ stderr=subprocess.PIPE,
+ env=my_env
+ )
+
+
+ output = ebuild_call.communicate()
+ # necessary? (probably not, FIXME/TODO)
+ ebuild_call.wait()
+
+ # log stdout?
+ #for line in util.pipe_lines ( output [0] ):
+ # LOGGER.debug ( line )
+
+ # log stderr
+ for line in util.pipe_lines ( output [1], use_filter=True ):
+ self.logger.warning ( line )
+
+ if ebuild_call.returncode == 0:
+ return True
+ else:
+ self.logger.error ( "Couldn't create Manifest for %s!" % ebuild_file )
+ return False
+ # --- end of create_for (...) ---
+
+
+class ManifestEnv ( object ):
+ """per-repo environment container for Manifest creation using ebuild."""
+
+ def __init__ ( self, filter_env=True ):
+ """Initializes a ManifestEnv.
+
+ arguments:
+ * filter_env -- if True: start with an empty env and copy vars
+ from os.environ selectively
+ else : start with os.environ as env
+ """
+ self.filter_env = filter_env
+ self._manenv = dict()
+ self.logger = logging.getLogger ( 'ManifestEnv' )
+ self._common_env = None
+ # --- end of __init__ (...) ---
+
+ def get_env ( self, repo_name ):
+ """Returns an env dict for repo_name.
+
+ arguments:
+ * repo_name --
+ """
+ if not repo_name in self._manenv:
+ repo_env = self._get_common_manifest_env()
+ repo_env ['DISTDIR'] = util.get_distdir ( repo_name )
+ self._manenv [repo_name] = repo_env
+
+ return self._manenv [repo_name]
+ # --- end of get_env (...) ---
+
+ # x = ManifestEnv(); env = x [repo] etc.
+ __getitem__ = get_env
+
+ def _get_common_manifest_env ( self, noret=False ):
+ """Creates an environment suitable for an
+ "ebuild <ebuild> digest|manifest" call (or uses an already existing env).
+ Returns a shallow copy of this env which can then be locally modified
+ (setting DISTDIR).
+
+ arguments:
+ * noret -- do not return copied env if True
+ """
+
+ if self._common_env is None:
+ # ((lock this if required))
+
+ if self.filter_env:
+
+ # selectively import os.environ
+ # FIXME: keep EBUILD_DEFAULT_OPTS?
+ our_env = util.keepenv (
+ ( 'PATH', '' ),
+ 'LANG',
+ 'PWD',
+ 'EBUILD_DEFAULT_OPTS'
+ )
+ else:
+ # copy os.environ
+ our_env = dict ( os.environ )
+
+ # -- common env part
+
+ # set FEATURES
+ # * digest -- needed? (works without it)
+ # * assume-digests --
+ # * unknown-features-warn -- should FEATURES ever change
+ #
+ # * noauto -- should prevent ebuild from adding additional actions,
+ # it still tries to download source packages, which is just wrong
+ # here 'cause it is expected that the R package file exists when
+ # calling this function, so FETCHCOMMAND/RESUMECOMMAND will be set
+ # to /bin/true if possible.
+ #
+ # * distlocks -- disabled if FETCHCOMMAND/RESUMECOMMAND set to no-op
+ #
+ our_env ['FEATURES'] = \
+ "noauto digest assume-digests unknown-features-warn"
+
+ # try to prevent src fetching
+ for nop in ( '/bin/true', '/bin/echo' ):
+ if os.path.isfile ( nop ):
+ self.logger.debug (
+ '%s disables/replaces FETCHCOMMAND/RESUMECOMMAND' % nop
+ )
+ fetch_nop = "%s \${DISTDIR} \${FILE} \${URI}" % nop
+ our_env ['FETCHCOMMAND'] = fetch_nop
+ our_env ['RESUMECOMMAND'] = fetch_nop
+ our_env ['FEATURES'] += " -distlocks"
+ break
+
+ # set PORDIR_OVERLAY
+ our_env ['PORTDIR_OVERLAY'] = config.get_or_fail (
+ [ 'OVERLAY', 'dir' ]
+ )
+
+ self._common_env = our_env
+ # -- end if
+ if noret:
+ return None
+ else:
+ return copy.copy ( self._common_env )
+ # --- end of _get_common_manifest_env (...) ---
+
+
+
+
^ permalink raw reply related [flat|nested] 5+ messages in thread
* [gentoo-commits] proj/R_overlay:master commit in: roverlay/portage/
@ 2012-06-15 20:34 André Erdmann
0 siblings, 0 replies; 5+ messages in thread
From: André Erdmann @ 2012-06-15 20:34 UTC (permalink / raw
To: gentoo-commits
commit: 9cf67df4fbd056c1699cea990dbca118ead03285
Author: André Erdmann <dywi <AT> mailerd <DOT> de>
AuthorDate: Fri Jun 15 20:30:17 2012 +0000
Commit: André Erdmann <dywi <AT> mailerd <DOT> de>
CommitDate: Fri Jun 15 20:30:17 2012 +0000
URL: http://git.overlays.gentoo.org/gitweb/?p=proj/R_overlay.git;a=commit;h=9cf67df4
ebuild creation: use PackageInfo, create metadata
modified: roverlay/portage/ebuildcreator.py
modified: roverlay/portage/ebuildjob.py
---
roverlay/portage/ebuildcreator.py | 27 +++++++-
roverlay/portage/ebuildjob.py | 117 +++++++++++++++++++++++++-----------
2 files changed, 104 insertions(+), 40 deletions(-)
diff --git a/roverlay/portage/ebuildcreator.py b/roverlay/portage/ebuildcreator.py
index 334295f..aee45e1 100644
--- a/roverlay/portage/ebuildcreator.py
+++ b/roverlay/portage/ebuildcreator.py
@@ -2,6 +2,7 @@
# Copyright 2006-2012 Gentoo Foundation
# Distributed under the terms of the GNU General Public License v2
+import time
import logging
import threading
@@ -12,10 +13,10 @@ except ImportError:
import Queue as queue
-from roverlay import config
-from roverlay.depres import depresolver
-from roverlay.depres.channels import EbuildJobChannel
-from roverlay.portage.ebuildjob import EbuildJob
+from roverlay import config
+from roverlay.depres import depresolver
+from roverlay.depres.channels import EbuildJobChannel
+from roverlay.portage.ebuildjob import EbuildJob
class EbuildCreator ( object ):
@@ -37,6 +38,10 @@ class EbuildCreator ( object ):
self.logger = logging.getLogger ( 'EbuildCreator' )
+ # this topic to change FIXME/TODO
+ # metadata [<ebuild_name>] = MetadataJob instance
+ self.metadata = dict()
+
# --- end of init (...) ---
def add_package ( self, package_file ):
@@ -93,6 +98,7 @@ class EbuildCreator ( object ):
# already running
return True
+ start = time.time()
jobcount = EbuildCreator.NUMTHREADS
@@ -117,6 +123,19 @@ class EbuildCreator ( object ):
self._threads = None
+ stop = time.time()
+ self.logger.info ( 'done after %f seconds' % ( stop - start ) )
+
+ # make metadata, topic to change... FIXME/TODO
+ for ejob in self.ebuild_jobs_done:
+ if ejob.get_ebuild() is None: continue
+
+ edir = ejob.package_info ['ebuild_dir']
+ if not edir in self.metadata:
+ self.metadata [edir] = ejob.feed_metadata ( create=True )
+ else:
+ ejob.feed_metadata ( metadata=self.metadata [edir] )
+
self.runlock.release()
# --- end of start (...) ---
diff --git a/roverlay/portage/ebuildjob.py b/roverlay/portage/ebuildjob.py
index ff8278a..6ad2738 100644
--- a/roverlay/portage/ebuildjob.py
+++ b/roverlay/portage/ebuildjob.py
@@ -7,6 +7,8 @@ import re
from roverlay import config, util
from roverlay.portage.ebuild import Ebuild
+from roverlay.portage.packageinfo import PackageInfo
+from roverlay.portage.metadata.creation import MetadataJob
from roverlay.rpackage.descriptionreader import DescriptionReader
@@ -47,7 +49,8 @@ class EbuildJob ( object ):
dep resolver 'communication channel', status codes etc.
"""
- self.package_info = util.get_packageinfo ( package_file )
+ self.package_info = PackageInfo ( filepath=package_file )
+ self.package_info.set_readonly()
try:
self.logger = EbuildJob.LOGGER.getChild (
@@ -75,6 +78,39 @@ class EbuildJob ( object ):
# --- end of __init__ (...) ---
+ def feed_metadata ( self, create=False, metadata=None ):
+ """Feeds metadata, either a existing MetadataJob instance or a new one.
+
+ arguments:
+ * create -- if True: create new metadata, "function mode",
+ requires bool (metadata) == False
+ * metadata -- if not None: metadata to update, "method mode",
+ requires bool (create) == False
+
+ returns: created metadata if in function mode (create is True) else
+ None (implicit)
+
+ raises: Exception if (create <=> metadata)
+ """
+ if not create and not metadata:
+ raise Exception ( "either create or metadata" )
+ elif create and metadata:
+ raise Exception ( "either create or metadata" )
+ elif create:
+ metadata = MetadataJob (
+ self.package_info,
+ self.logger.getChild ( 'metadata' )
+ )
+
+
+ metadata.update (
+ self.description_reader.get_desc ( run_if_unset=False ),
+ self.package_info
+ )
+
+ if create: return metadata
+ # --- end of feed_metadata (...) ---
+
def get_resolver ( self, dependency_type ):
# comment TODO
if not dependency_type in self._depres:
@@ -99,7 +135,8 @@ class EbuildJob ( object ):
whether to current status matches the expected one.
arguments:
- * expected_status -- if not None: check if this job's state is expected_status
+ * expected_status -- if not None: check if this job's state
+ is expected_status
"""
if not expected_status is None:
return bool ( self.status == expected_status )
@@ -115,17 +152,16 @@ class EbuildJob ( object ):
# --- end of done_success (...) ---
def run ( self ):
- """Tells this EbuildJob to run. This means that it reads the package file,
- resolves dependencies using its resolver (TODO) and creates
- an Ebuild object that is ready to be written into a file.
+ """Tells this EbuildJob to run.
+ This means that it reads the package file, resolves dependencies
+ using its resolver and creates an Ebuild object that is ready
+ to be written into a file.
"""
# TODO move hardcoded entries to config/const
- # TODO metadata.xml creation (long DESCRIPTION should go into metadata, not the ebuild)
try:
-
- # set status or return
+ # enforcing BRANCHMAP status control: set status or return
if not self._set_status ( 'BUSY', True ): return
desc = self.description_reader.get_desc ( True )
@@ -134,15 +170,16 @@ class EbuildJob ( object ):
self.logger.info ( 'Cannot create an ebuild for this package.' )
- fileinfo = self.package_info
-
ebuild = Ebuild ( self.logger.getChild ( "Ebuild" ) )
- ebuild.add ( 'pkg_name', fileinfo ['package_name'] )
+ ebuild.add ( 'pkg_name', self.package_info ['package_name'] )
+
# TODO move regex to config/const
- ebuild.add ( 'pkg_version',
- re.sub ( '[-]{1,}', '.', fileinfo ['package_version'] )
- )
+ ebuild.add (
+ 'pkg_version',
+ re.sub ( '[-]{1,}', '.', self.package_info ['package_version'] )
+ )
+ ebuild.add ( 'PKG_FILE', self.package_info ['package_file'] )
have_description = False
@@ -152,24 +189,27 @@ class EbuildJob ( object ):
have_description = True
if 'Description' in desc:
- ebuild.add ( 'DESCRIPTION', ( '// ' if have_description else '' ) + desc ['Description'] )
- #have_description=True
+ ebuild.add (
+ 'DESCRIPTION',
+ ( '// ' if have_description else '' ) + desc ['Description']
+ )
+ del have_description
- # origin is todo (sync module knows the package origin)
- # could calculate SRC_URI in the eclass depending on origin
- ##ebuild.add ( 'PKG_ORIGIN', 'CRAN/BIOC/... TODO!' )
- ebuild.add ( 'SRC_URI', 'where? TODO!' )
- ebuild.add ( 'PKG_FILE', fileinfo ['package_file'] )
+ ebuild.add ( 'SRC_URI', self.package_info ['package_url'] )
## default ebuild header, could use some const here (eclass name,..)
- ebuild.add ( 'ebuild_header',
- EbuildJob.DEFAULT_EBUILD_HEADER,
- False
- )
+ # TODO use a single string as ebuild header instead of joining it
+ # for every ebuild
+ ebuild.add (
+ 'ebuild_header',
+ EbuildJob.DEFAULT_EBUILD_HEADER,
+ False
+ )
if not self.request_resolver is None:
+ # dependency resolution is enabled
dep_type = desc_field = None
@@ -206,7 +246,8 @@ class EbuildJob ( object ):
if not self._set_status ( 'BUSY' ): return
if not resolved:
- # ebuild is not creatable, set status to FAIL and close dep resolvers
+ # ebuild is not creatable,
+ # set status to FAIL and close dep resolvers
self.logger.info (
"Failed to resolve dependencies for this package."
)
@@ -223,13 +264,14 @@ class EbuildJob ( object ):
if deplist is None:
## FIXME: false positive: "empty" channel
- raise Exception (
- 'dep_resolver is broken: '
- 'lookup() returns None but satisfy_request() says ok.'
- )
+ raise Exception (
+ 'dep_resolver is broken: '
+ 'lookup() returns None but satisfy_request() says ok.'
+ )
+
elif isinstance ( deplist, ( list, set ) ):
# add dependencies in no_append/override mode
- self.logger.debug ( "adding %s to %s", str (deplist), dep_type )
+ self.logger.debug ( "adding %s to %s", deplist, dep_type )
ebuild.add ( dep_type, deplist, False )
else:
@@ -238,7 +280,6 @@ class EbuildJob ( object ):
)
# --- end for
-
# tell the dep resolver channels that we're done
for r in self._depres.values(): r.close ()
@@ -248,21 +289,25 @@ class EbuildJob ( object ):
## finalize self.ebuild: forced text creation + make it readonly
if ebuild.prepare ( True, True ):
self.ebuild = ebuild
+
# update package info
- self.package_info ['has_suggests'] = ebuild.has_rsuggests
+ self.package_info.set_writeable()
+ self.package_info.update ( ebuild=ebuild )
+ self.package_info.set_readonly()
- except Exception as any_exception:
+ except Exception as e:
# any exception means failure
self._set_status ( 'FAIL' )
+ self.logger.exception ( e )
raise
# --- end of run (...) ---
def _set_status ( self, new_status, ignore_invalid=False ):
- """Changes the status of this job. May refuse to do that if invalid change
- requested (e.g. 'FAIL' -> 'SUCCESS').
+ """Changes the status of this job. May refuse to do that
+ if invalid change requested (e.g. 'FAIL' -> 'SUCCESS').
arguments:
new_status --
^ permalink raw reply related [flat|nested] 5+ messages in thread
* [gentoo-commits] proj/R_overlay:master commit in: roverlay/portage/
@ 2012-06-15 20:34 André Erdmann
0 siblings, 0 replies; 5+ messages in thread
From: André Erdmann @ 2012-06-15 20:34 UTC (permalink / raw
To: gentoo-commits
commit: d4019f10979a2d10c2fb85ae5a5bf02cd44a07a2
Author: André Erdmann <dywi <AT> mailerd <DOT> de>
AuthorDate: Fri Jun 15 20:29:37 2012 +0000
Commit: André Erdmann <dywi <AT> mailerd <DOT> de>
CommitDate: Fri Jun 15 20:29:37 2012 +0000
URL: http://git.overlays.gentoo.org/gitweb/?p=proj/R_overlay.git;a=commit;h=d4019f10
Ebuild.py: fixes and cut long DESCRIPTION values
modified: roverlay/portage/ebuild.py
---
roverlay/portage/ebuild.py | 139 +++++++++++++++++++++++++++++--------------
1 files changed, 94 insertions(+), 45 deletions(-)
diff --git a/roverlay/portage/ebuild.py b/roverlay/portage/ebuild.py
index 00620f0..a435f5c 100644
--- a/roverlay/portage/ebuild.py
+++ b/roverlay/portage/ebuild.py
@@ -6,6 +6,8 @@ import copy
import roverlay.config
+from roverlay.util import shorten_str
+
class Ebuild ( object ):
EBUILD_INDENT = roverlay.config.get ( 'EBUILD.indent', '\t' )
@@ -168,10 +170,12 @@ class Ebuild ( object ):
def suggest_dir_name ( self ):
"""Suggests a direcory name for this Ebuild."""
- if 'pkg_name' in self._data:
+ if self._data is None:
+ return self._ebuild_name.partition ( '-' ) [0]
+ elif 'pkg_name' in self._data:
return self._data ['pkg_name']
else:
- return self.suggest_name().partition ( '-' )
+ return self.suggest_name().partition ( '-' ) [0]
# --- end of suggest_dir_name (...) ---
def suggest_name ( self, fallback_name='' ):
@@ -253,23 +257,30 @@ class Ebuild ( object ):
# --- end of get_dep_and_use () ---
- def make_var ( varname, value=None, oneline_list=True, indent_list=True, indent_level=0 ):
+ def make_var (
+ varname,
+ value=None, oneline_list=True, indent_list=True, indent_level=0
+ ):
"""Creates a <name>=<value> statement for ebuilds.
arguments:
- * varname -- name of the variable
- * value -- value of the variable. This has to be either None (the default),
- str, or list of str.
- * oneline_list -- if value is a list: controls whether its components should be
- put into one line (True) or multiple (False). Defaults to True.
- * indent_list -- if value is a list and not oneline_list:
- controls whether each value line should be indentend
- (by indent_level + 1) or not ("by 0"). Defaults to True.
+ * varname -- name of the variable
+ * value -- value of the variable.
+ This has to be either None (the default), str,
+ or list of str.
+ * oneline_list -- if value is a list: controls whether its components
+ should be put into one line (True) or multiple.
+ Defaults to True.
+ * indent_list -- if value is a list and not oneline_list:
+ controls whether each value line should be
+ indentend (by indent_level + 1) or not ("by 0").
+ Defaults to True.
* indent_level -- current indentation level, defaults to 0
"""
- # assumption: value is either None, scalar with str representation or list of str
+ # assumption: value is either None,
+ # scalar with str representation or list of str
var_value = None
if not value:
@@ -288,16 +299,37 @@ class Ebuild ( object ):
else:
var_value = str ( value )
- return indent_level * Ebuild.EBUILD_INDENT + varname + '="' + var_value + '"'
+
+ # (TODO)
+ # fixing ebuild var values here
+
+ # cut DESCRIPTION line if too long
+ if varname == 'DESCRIPTION':
+ var_value = shorten_str ( var_value, 45, '... (see metadata)' )
+
+
+ ret ='%s%s="%s"' % (
+ indent_level * Ebuild.EBUILD_INDENT,
+ varname,
+ var_value
+ )
+
+ # (TODO)
+ # fixing ebuild var lines here
+
+ return ret
# --- end of make_var (...) ---
def remove_newlines ( line_list ):
- """
- Removes leading, ending and repeated empty/whitespace lines in line_list.
+ """Removes leading, ending and repeated blank lines in line_list.
arguments:
- * line_list
+ * line_list --
+
+ returns: filtered lines
+
+ TODO: check if a filter function could be used for this
"""
lines = []
line = None
@@ -325,26 +357,38 @@ class Ebuild ( object ):
# --- end of remove_newlines (...) ---
- def add_easyvar ( ebuild_content, varname, value_key=None, add_newline=False):
- """Adds a 'simple' variable to the ebuild lines. This means that it
- can directly be taken from self._data [value_key]. This method assumes
- that value_key exists in self._data, any exceptions (KeyError) will be passed.
+ def add_easyvar (
+ ebuild_content, varname,
+ value_key=None, add_newline=False
+ ):
+ """Adds a 'simple' variable to the ebuild lines.
+ This means that it can directly be taken from self._data [value_key].
+ This method assumes that value_key exists in self._data,
+ any exceptions (KeyError) will be passed.
arguments:
- * ebuild_content -- list of ebuild text lines, will be modified directly,
- so copy it before calling addvar if you need the original list.
- * varname -- name of the variable. Nothing happens if this is None.
- * value_key -- key of the value, defaults to varname if it is None
- * add_newline -- adds a newline after the var statement, defaults to False
-
- Returns given list (ebuild_content), which will then have been modified.
+ * ebuild_content -- list of ebuild text lines, will be modified
+ directly, so copy it before calling addvar if
+ you need the original list.
+ * varname -- name of the variable.
+ Nothing happens if this is None.
+ * value_key -- key of the value,
+ defaults to varname if it is None
+ * add_newline -- adds a newline after the var statement,
+ defaults to False
+
+ returns: given+modified list (ebuild_content)
"""
if not varname is None:
if value_key is None:
- ebuild_content.append ( make_var ( varname, self._data [varname] ) )
+ ebuild_content.append (
+ make_var ( varname, self._data [varname] )
+ )
else:
- ebuild_content.append ( make_var ( varname, self._data [value_key] ) )
+ ebuild_content.append (
+ make_var ( varname, self._data [value_key] )
+ )
if add_newline:
ebuild_content.append ( "" )
@@ -353,6 +397,7 @@ class Ebuild ( object ):
# --- end of add_easyvar (...) ---
+ # -- actual start of _make_ebuild_lines (...) --
try:
ebuild_lines = []
@@ -366,42 +411,46 @@ class Ebuild ( object ):
ebuild_lines.append ( "" )
+ # TODO/FIXME: this makes DESCRIPTION mandatory, maybe check with
+ # >if 'DESCRIPTION' in self._data<
add_easyvar ( ebuild_lines, "DESCRIPTION" )
- if 'SRC_URI' in self._data:
- add_easyvar ( ebuild_lines, "SRC_URI" )
- else:
- # > calculate SRC_URI using self._data ['origin'] -- either here or in eclass
- ebuild_lines.append ( make_var ( "SRC_URI" , None ) )
- # (temporary, todo) setting restrict to fetch
- ebuild_lines.append ( make_var ( "RESTRICT" , "fetch" ) )
-
- ebuild_lines.append ( "" )
+ add_easyvar ( ebuild_lines, "SRC_URI", add_newline=True )
- # LICENSE ?
+ # FIXME/TODO: LICENSE?
dep_and_use = get_dep_and_use ()
- # check that IUSE has more than one element, don't write IUSE="${IUSE:-}" etc.
+ # check that IUSE has more than one element,
+ # don't write IUSE="${IUSE:-}" etc.
if len ( dep_and_use ['IUSE'] ) > 1:
- ebuild_lines.append ( make_var ( "IUSE", dep_and_use ['IUSE'], True ) )
+ ebuild_lines.append (
+ make_var ( "IUSE", dep_and_use ['IUSE'], True )
+ )
if 'R_SUGGESTS' in dep_and_use:
- ebuild_lines.append ( make_var ( "R_SUGGESTS", dep_and_use ['R_SUGGESTS'], False ) )
+ ebuild_lines.append (
+ make_var ( "R_SUGGESTS", dep_and_use ['R_SUGGESTS'], False )
+ )
# see IUSE
if len ( dep_and_use ['DEPEND'] ) > 1:
- ebuild_lines.append ( make_var ( "DEPEND", dep_and_use ['DEPEND'], False ) )
+ ebuild_lines.append (
+ make_var ( "DEPEND", dep_and_use ['DEPEND'], False )
+ )
# see IUSE
if len ( dep_and_use ['RDEPEND'] ) > 1:
- ebuild_lines.append ( make_var ( "RDEPEND", dep_and_use ['RDEPEND'], False ) )
+ ebuild_lines.append (
+ make_var ( "RDEPEND", dep_and_use ['RDEPEND'], False )
+ )
del dep_and_use
return remove_newlines ( ebuild_lines )
except ( ValueError, KeyError, NameError ) as err:
- self.logger.error ( "Cannot create ebuild text lines. The error message was %s.", str ( err ) )
+ self.logger.exception ( err )
+ self.logger.error ( "Cannot create ebuild text lines." )
return None
# --- end of make_ebuild_lines (...) ---
^ permalink raw reply related [flat|nested] 5+ messages in thread
end of thread, other threads:[~2012-06-15 20:35 UTC | newest]
Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2012-06-13 16:34 [gentoo-commits] proj/R_overlay:master commit in: roverlay/portage/ André Erdmann
-- strict thread matches above, loose matches on Subject: below --
2012-06-15 20:34 André Erdmann
2012-06-15 20:34 André Erdmann
2012-06-15 20:34 André Erdmann
2012-06-15 20:34 André Erdmann
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox