Fixed g-pypi to replace dots in package name.
authorJesus Rivero <jesus.riveroa@gmail.com>
Fri, 1 Aug 2008 01:11:14 +0000 (01:11 +0000)
committerJesus Rivero <jesus.riveroa@gmail.com>
Fri, 1 Aug 2008 01:11:14 +0000 (01:11 +0000)
git-svn-id: http://g-pypi.googlecode.com/svn/trunk@15 118783bc-b352-0410-bbc3-0f610f6f7ae8

g_pypi/cli.py
g_pypi/ebuild.py
g_pypi/enamer.py

index f9e0da3ea97923ff07f897d59c1d55a50db2ec2c..047452d1fbe7c49ef05a4c9195568832fc3b1fdd 100755 (executable)
@@ -251,6 +251,7 @@ class GPyPI(object):
         download_url = self.get_uri()
         try:
             ebuild = Ebuild(self.package_name, self.version, download_url)
+
         except portage_exception.InvalidVersionString:
             self.logger.error("Can't determine PV, use -v to set it: %s-%s" % \
                     (self.package_name, self.version))
index cde41eec0dd0c01aecb9189dba0be650aa51887c..e56e3a4d6253e462761b6f840e8b7cf9f3864aa4 100755 (executable)
@@ -99,12 +99,20 @@ class Ebuild:
             self.options.pv = "9999"
             self.vars['esvn_repo_uri'] = download_url
             self.add_inherit("subversion")
+
+       if up_pn.find('.') > -1:
+           self.vars['python_modname'] = self.options.my_pn = up_pn
+           up_pn = self.filter_pkgname(up_pn)
+           self.options.pn = up_pn
+
         ebuild_vars = enamer.get_vars(download_url, up_pn, up_pv, self.options.pn,
-                self.options.pv, self.options.my_pn, self.options.my_pv)
+                self.options.pv, self.options.my_pn, self.options.my_pv, self.options.my_p)
+
         for key in ebuild_vars.keys():
             if not self.vars.has_key(key):
                 self.vars[key] = ebuild_vars[key]
-        self.vars['p'] = '%s-%s' % (self.vars['pn'], self.vars['pv'])
+
+       self.vars['p'] = '%s-%s' % (self.vars['pn'], self.vars['pv'])
 
     def set_metadata(self, metadata):
         """Set metadata"""
@@ -141,6 +149,7 @@ class Ebuild:
             self.vars['my_pn'] = ebuild_vars['my_pn']
         else:
             self.vars['my_pn'] = ''
+
         if ebuild_vars.has_key('my_pv'):
             self.vars['my_pv'] = ebuild_vars['my_pv']
         else:
@@ -287,7 +296,7 @@ class Ebuild:
             pkg_name = req.project_name.lower()
             if not len(req.specs):
                 self.add_setuptools_depend(req)
-                self.add_rdepend("dev-python/%s" % pkg_name)
+                self.add_rdepend("dev-python/%s" % self.filter_pkgname(pkg_name))
                 added_dep = True
                 #No version of requirement was specified so we only add
                 #dev-python/pkg_name
@@ -306,29 +315,29 @@ class Ebuild:
                         #for turbogears has >=2.2,<3.0 which would translate to
                         #portage's =dev-python/cherrypy-2.2*
                         self.logger.warn(" **** Requirement %s has multi-specs ****" % req)
-                        self.add_rdepend("dev-python/%s" % pkg_name)
+                        self.add_rdepend("dev-python/%s" % self.filter_pkgname(pkg_name))
                         break
                 #Requirement.specs is a list of (comparator,version) tuples
                 if comparator == "==":
                     comparator = "="
                 if valid_cpn("%sdev-python/%s-%s" % (comparator, pkg_name, ver)):
-                    self.add_rdepend("%sdev-python/%s-%s" % (comparator, pkg_name, ver))
+                    self.add_rdepend("%sdev-python/%s-%s" % (comparator, self.filter_pkgname(pkg_name), ver))
                 else:
                     self.logger.info(\
                             "Invalid PV in dependency: (Requirement %s) %sdev-python/%s-%s" \
                             % (req, comparator, pkg_name, ver)
                             )
-                    installed_pv = get_installed_ver("dev-python/%s" % pkg_name)
+                    installed_pv = get_installed_ver("dev-python/%s" % self.filter_pkgname(pkg_name))
                     if installed_pv:
                         self.add_rdepend(">=dev-python/%s-%s" % \
-                                (pkg_name, installed_pv))
+                                (self.filter_pkgname(pkg_name), installed_pv))
                     else:
                         #If we have it installed, use >= installed version
                         #If package has invalid version and we don't have
                         #an ebuild in portage, just add PN to DEPEND, no 
                         #version. This means the dep ebuild will have to
                         #be created by adding --MY_? options using the CLI
-                        self.add_rdepend("dev-python/%s" % pkg_name)
+                        self.add_rdepend("dev-python/%s" % self.filter_pkgname(pkg_name))
                 added_dep = True
             if not added_dep:
                 self.add_warning("Couldn't determine dependency: %s" % req)
@@ -432,7 +441,6 @@ class Ebuild:
             #    not self.options.subversion:
             self.post_unpack() 
             functions['src_test'] = self.get_src_test() 
-            functions['src_install'] = self.get_docs()
         # *_f variables are formatted text ready for ebuild
         self.vars['depend_f'] = format_depend(self.vars['depend'])
         self.vars['rdepend_f'] = format_depend(self.vars['rdepend'])
@@ -573,6 +581,9 @@ class Ebuild:
 
             self.vars["s"] = "${WORKDIR}/%s" % unpacked_dir
 
+    def filter_pkgname(self, pkgname):
+       return pkgname.replace('.', '-')
+
 def get_portage_license(my_license):
     """
     Map defined classifier license to Portage license
@@ -654,3 +665,4 @@ def format_depend(dep_list):
             middle += "\t%s\n" % dep
         output += middle + "\t" + dep_list[-1]
     return output
+
index fc604a44d56d3150fd4571cafbf9e6910535930b..905a632830345f4554ed4236e408b9a18160dc17 100644 (file)
@@ -281,7 +281,7 @@ def sanitize_uri(uri):
     """
     return uri
 
-def get_vars(uri, up_pn, up_pv, pn="", pv="", my_pn="", my_pv=""):
+def get_vars(uri, up_pn, up_pv, pn="", pv="", my_pn="", my_pv="", my_p=""):
     """
     Determine P* and MY_* variables
 
@@ -343,11 +343,6 @@ def get_vars(uri, up_pn, up_pv, pn="", pv="", my_pn="", my_pv=""):
         pn = pn.lower()
     p = "%s-%s" % (pn, pv)
 
-    #Check if we need to use MY_P based on src's uri
-    if my_p:
-        src_uri, my_p_raw = get_myp(uri)
-    else:
-        src_uri, my_p, my_p_raw = get_src_uri(uri)
 
     #Make sure we have a valid P
     if not portage_dep.isvalidatom("=dev-python/%s-%s" % (pn, pv)):
@@ -372,6 +367,19 @@ def get_vars(uri, up_pn, up_pv, pn="", pv="", my_pn="", my_pv=""):
             my_p = my_p.replace(pn, "${PN}")
             my_p = my_p.replace(pv, "${PV}")
 
+    if my_pn and not my_p:
+       if my_pv:
+               my_p = '%s-%s' % (my_pn, my_pv)
+       elif not my_pv:
+               my_p = '%s-%s' % (my_pn, '${PV}')
+       my_pn = ''
+
+    #Check if we need to use MY_P based on src's uri
+    if my_p:
+        src_uri, my_p_raw = get_myp(uri)
+    else:
+        src_uri, my_p, my_p_raw = get_src_uri(uri)
+
     return {'pn': pn,
             'pv': pv,
             'p': p,