From: "André Erdmann" <dywi@mailerd.de>
To: gentoo-commits@lists.gentoo.org
Subject: [gentoo-commits] proj/R_overlay:master commit in: roverlay/portage/
Date: Fri, 15 Jun 2012 20:34:31 +0000 (UTC) [thread overview]
Message-ID: <1339792217.9cf67df4fbd056c1699cea990dbca118ead03285.dywi@gentoo> (raw)
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 --
next reply other threads:[~2012-06-15 20:35 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2012-06-15 20:34 André Erdmann [this message]
-- strict thread matches above, loose matches on Subject: below --
2012-06-15 20:34 [gentoo-commits] proj/R_overlay:master commit in: roverlay/portage/ André Erdmann
2012-06-15 20:34 André Erdmann
2012-06-15 20:34 André Erdmann
2012-06-13 16:34 André Erdmann
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1339792217.9cf67df4fbd056c1699cea990dbca118ead03285.dywi@gentoo \
--to=dywi@mailerd.de \
--cc=gentoo-commits@lists.gentoo.org \
--cc=gentoo-dev@lists.gentoo.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox