public inbox for gentoo-commits@lists.gentoo.org
 help / color / mirror / Atom feed
From: "Jauhien Piatlicki" <piatlicki@gmail.com>
To: gentoo-commits@lists.gentoo.org
Subject: [gentoo-commits] proj/g-sorcery:master commit in: gs_ctan/
Date: Thu, 18 Jul 2013 22:29:24 +0000 (UTC)	[thread overview]
Message-ID: <1374186547.01ba09173a010a2ac8d9b7f0a2d165ad3319b4e1.jauhien@gentoo> (raw)

commit:     01ba09173a010a2ac8d9b7f0a2d165ad3319b4e1
Author:     Jauhien Piatlicki (jauhien) <piatlicki <AT> gmail <DOT> com>
AuthorDate: Thu Jul 18 22:29:07 2013 +0000
Commit:     Jauhien Piatlicki <piatlicki <AT> gmail <DOT> com>
CommitDate: Thu Jul 18 22:29:07 2013 +0000
URL:        http://git.overlays.gentoo.org/gitweb/?p=proj/g-sorcery.git;a=commit;h=01ba0917

gs_ctan/ctan_db: generation of ebuild data implemented

---
 gs_ctan/ctan_db.py | 94 ++++++++++++++++++++++++++++++++++++++++++++++++------
 1 file changed, 85 insertions(+), 9 deletions(-)

diff --git a/gs_ctan/ctan_db.py b/gs_ctan/ctan_db.py
index a85488e..99c16c6 100644
--- a/gs_ctan/ctan_db.py
+++ b/gs_ctan/ctan_db.py
@@ -13,13 +13,30 @@
 
 import itertools
 import os
+import re
+import sys
 
+import portage
+
+from g_sorcery.g_collections import Dependency, Package, serializable_elist
+from g_sorcery.logger import Logger
 from g_sorcery.package_db import PackageDB
 from g_sorcery.exceptions import SyncError
 
 class CtanDB(PackageDB):
     def __init__(self, directory, repo_uri="", db_uri=""):
         super(CtanDB, self).__init__(directory, repo_uri, db_uri)
+        
+        logger = Logger()
+        gentoo_arch = portage.settings['ARCH']
+        self.arch = ""
+        if gentoo_arch == "x86":
+            self.arch = "i386-linux"
+        elif gentoo_arch == "amd64":
+            self.arch = "x86_64-linux"
+        else:
+            logger.warning("not supported arch: " + gentoo_arch)
+
 
     def get_download_uries(self):
         tlpdb_uri = self.repo_uri + "/tlpkg/texlive.tlpdb.xz"
@@ -44,7 +61,7 @@ class CtanDB(PackageDB):
         VALUE = 1
         FILES_LENGTH = len("files")
         
-        for entry in data:
+        for entry in data:     
             res_entry = {}
             previous_key = ""
             current_key = ""
@@ -71,16 +88,30 @@ class CtanDB(PackageDB):
                         res_entry[line[KEY]] = " ".join(line[VALUE:])
                         previous_key = line[KEY]
                         current_key = ""
+
+            parts = res_entry["name"].split(".")
+            if len(parts) > 1:
+                if parts[1] != self.arch:
+                    continue
+
             result.append(res_entry)
         
         return result
 
     def process_data(self, data):
+        
+        category = "dev-tex"
+        
+        self.add_category(category)
+
+        ARCH_LENGTH = len("ARCH")
 
-        self.add_category('dev-tex')
+        data = data["texlive.tlpdb"]
 
-        for entry in data["texlive.tlpdb"]:
+        self.number_of_packages = len(data)
+        self.written_number = 0
 
+        for entry in data:
             realname = entry["name"]
             
             #todo: work on common data vars processing: external deps, filtering etc.
@@ -103,6 +134,10 @@ class CtanDB(PackageDB):
 
             if "catalogue-version" in entry:
                 version = entry["catalogue-version"]
+                #todo better version checking and processing
+                match_object = re.match("^[0-9\.]+[a-z]?$", version)
+                if not match_object:
+                    version = entry["revision"]
             else:
                 version = entry["revision"]
 
@@ -121,9 +156,50 @@ class CtanDB(PackageDB):
                 base_src_uri = "http://mirror.ctan.org/systems/texlive/tlnet/archive"
                 catalogue = ""
 
-            print("dev-tex/" + realname + "-" + version)
-            print("    license: " + license)
-            print("    " + description)
-            print
-            print("    " + longdescription)
-            print
+            dependencies = serializable_elist(separator="\n\t")
+
+            if "depend" in entry:
+                for dependency in entry["depend"]:
+                    if dependency[-ARCH_LENGTH:] == "ARCH":
+                        dependency = dependency[:-ARCH_LENGTH] + self.arch
+                    dependencies.append(Dependency(category, dependency))
+
+            ebuild_data = {"realname" : realname,
+                           "description" : description,
+                           "homepage" : "http://tug.org/texlive/",
+                           "license" : license,
+                           "source_type" : source_type,
+                           "base_src_uri" : base_src_uri,
+                           "catalogue" : catalogue,
+                           "dependencies" : dependencies,
+                           "depend" : dependencies,
+                           "rdepend" : dependencies,
+            #eclass entry
+            #'eclasses' : ['gs-ctan'],
+            #metadata entries
+                          'maintainer' : [{'email' : 'piatlicki@gmail.com',
+                                           'name' : 'Jauhien Piatlicki'}],
+                          'longdescription' : longdescription
+                          }
+
+            self.add_package(Package(category, realname, version), ebuild_data)
+
+        logger = Logger()
+        logger.info("writing database")
+
+    def additional_write_version(self, category, package, version):
+        chars = ['-','\\','|','/']
+        show = chars[self.written_number % 4]
+        percent = (self.written_number * 100)/self.number_of_packages
+        length = 20
+        progress = (percent * 20)/100
+        blank = 20 - progress
+        
+        sys.stdout.write("\r %s [%s%s] %s%%" % (show, "#" * progress, " " * blank, percent))
+        sys.stdout.flush()
+        self.written_number += 1
+
+    def additional_write_category(self, category):
+        sys.stdout.write("\r %s [%s] %s%%" % ("-", "#" * 20, 100))
+        sys.stdout.flush()
+        print("")


             reply	other threads:[~2013-07-18 22:29 UTC|newest]

Thread overview: 12+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-07-18 22:29 Jauhien Piatlicki [this message]
  -- strict thread matches above, loose matches on Subject: below --
2013-08-01 15:58 [gentoo-commits] proj/g-sorcery:master commit in: gs_ctan/ Jauhien Piatlicki
2013-07-31 23:29 Jauhien Piatlicki
2013-07-22 16:57 Jauhien Piatlicki
2013-07-19 16:56 Jauhien Piatlicki
2013-07-19 11:23 Jauhien Piatlicki
2013-07-19 11:10 Jauhien Piatlicki
2013-07-19  8:36 Jauhien Piatlicki
2013-07-18  0:12 Jauhien Piatlicki
2013-07-18  0:12 Jauhien Piatlicki
2013-07-17 23:19 Jauhien Piatlicki
2013-07-17 17:05 Jauhien Piatlicki

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=1374186547.01ba09173a010a2ac8d9b7f0a2d165ad3319b4e1.jauhien@gentoo \
    --to=piatlicki@gmail.com \
    --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