public inbox for gentoo-commits@lists.gentoo.org
 help / color / mirror / Atom feed
* [gentoo-commits] proj/g-sorcery:master commit in: g_sorcery/, gs_elpa/data/, g_sorcery/data/, gs_elpa/
@ 2013-08-29  1:12 Jauhien Piatlicki
  0 siblings, 0 replies; only message in thread
From: Jauhien Piatlicki @ 2013-08-29  1:12 UTC (permalink / raw
  To: gentoo-commits

commit:     c4fedcc829ef955b8e8e1e2c4cad7ed62ab58d99
Author:     Jauhien Piatlicki (jauhien) <piatlicki <AT> gmail <DOT> com>
AuthorDate: Thu Aug 29 01:03:20 2013 +0000
Commit:     Jauhien Piatlicki <piatlicki <AT> gmail <DOT> com>
CommitDate: Thu Aug 29 01:03:20 2013 +0000
URL:        http://git.overlays.gentoo.org/gitweb/?p=proj/g-sorcery.git;a=commit;h=c4fedcc8

refactoring of eclasses

---
 g_sorcery/data/g-sorcery.eclass                | 49 ++++++++++++++++++++++++++
 g_sorcery/eclass.py                            | 32 +++++++++--------
 gs_elpa/data/{g-elpa.eclass => gs-elpa.eclass} | 41 ++++++---------------
 gs_elpa/ebuild.py                              |  4 +--
 gs_elpa/elpa_db.py                             |  2 +-
 5 files changed, 80 insertions(+), 48 deletions(-)

diff --git a/g_sorcery/data/g-sorcery.eclass b/g_sorcery/data/g-sorcery.eclass
new file mode 100644
index 0000000..68635e0
--- /dev/null
+++ b/g_sorcery/data/g-sorcery.eclass
@@ -0,0 +1,49 @@
+# Copyright 1999-2013 Gentoo Foundation
+# Distributed under the terms of the GNU General Public License v2
+# $Header: $
+# automatically generated by g-sorcery
+# please do not edit this file
+#
+# Original Author: Jauhien Piatlicki <piatlicki@gmail.com>
+# Purpose: base routines for g-sorcery backends' eclasses
+#
+# Bugs to piatlicki@gmail.com
+#
+# @ECLASS: g-sorcery.eclass
+#
+# @ECLASS-VARIABLE: REPO_URI
+# @DESCRIPTION: address of a repository with sources
+#
+# @ECLASS-VARIABLE: DIGEST_SOURCES
+# @DESCRIPTION: whether manifest for sources exists
+#
+# @ECLASS-VARIABLE: SOURCEFILE
+# @DESCRIPTION: source file name
+#
+# @ECLASS-VARIABLE: GSORCERY_STORE_DIR
+# @DESCRIPTION: store location for downloaded sources
+GSORCERY_STORE_DIR="${PORTAGE_ACTUAL_DISTDIR:-${DISTDIR}}"
+#
+# @ECLASS-VARIABLE: GSORCERY_FETCH_CMD
+# @DESCRIPTION: fetch command
+GSORCERY_FETCH_CMD="wget"
+
+EXPORT_FUNCTIONS src_unpack
+
+g-sorcery_fetch() {
+	addwrite "${GSORCERY_STORE_DIR}"
+	pushd "${GSORCERY_STORE_DIR}" >/dev/null || die "can't chdir to ${GSORCERY_STORE_DIR}"
+	if [[ ! -f "${SOURCEFILE}" ]]; then
+		$GSORCERY_FETCH_CMD ${REPO_URI}${SOURCEFILE} || die
+	fi
+	popd >/dev/null || die
+}
+
+g-sorcery_src_unpack() {
+	if [[ x${DIGEST_SOURCES} = x ]]; then
+		g-sorcery_fetch
+	fi
+
+	cp ${GSORCERY_STORE_DIR}/${SOURCEFILE} . || die
+	unpack ./${SOURCEFILE}
+}

diff --git a/g_sorcery/eclass.py b/g_sorcery/eclass.py
index 5fe2f6f..0ebaf6c 100644
--- a/g_sorcery/eclass.py
+++ b/g_sorcery/eclass.py
@@ -15,6 +15,7 @@ import glob
 import os
 
 from .exceptions import EclassError
+from .fileutils import get_pkgpath
 
 class EclassGenerator(object):
     """
@@ -35,10 +36,13 @@ class EclassGenerator(object):
             List of all eclasses with string entries.
         """
         result = []
-        if self.eclass_dir:
-            for f_name in glob.iglob(os.path.join(self.eclass_dir, '*.eclass')):
-                result.append(os.path.basename(f_name)[:-7])
-        return result
+
+        for directory in [self.eclass_dir, os.path.join(get_pkgpath(), 'data')]:
+            if directory:
+                for f_name in glob.iglob(os.path.join(directory, '*.eclass')):
+                    result.append(os.path.basename(f_name)[:-7])
+
+        return list(set(result))
 
     def generate(self, eclass):
         """
@@ -50,13 +54,13 @@ class EclassGenerator(object):
         Returns:
             Eclass source as a list of strings.
         """
-        if not self.eclass_dir:
-            EclassError('No eclass dir')
-        f_name = os.path.join(self.eclass_dir, eclass + '.eclass')
-        if not os.path.isfile(f_name):
-            EclassError('No eclass ' + eclass)
-        with open(f_name, 'r') as f:
-            eclass = f.read().split('\n')
-            if eclass[-1] == '':
-                eclass = eclass[:-1]
-        return eclass
+        for directory in [self.eclass_dir, os.path.join(get_pkgpath(), 'data')]:
+            f_name = os.path.join(directory, eclass + '.eclass')
+            if os.path.isfile(f_name):
+                with open(f_name, 'r') as f:
+                    eclass = f.read().split('\n')
+                    if eclass[-1] == '':
+                        eclass = eclass[:-1]
+                return eclass
+
+        raise EclassError('No eclass ' + eclass)

diff --git a/gs_elpa/data/g-elpa.eclass b/gs_elpa/data/gs-elpa.eclass
similarity index 57%
rename from gs_elpa/data/g-elpa.eclass
rename to gs_elpa/data/gs-elpa.eclass
index ad9bb65..2a621f4 100644
--- a/gs_elpa/data/g-elpa.eclass
+++ b/gs_elpa/data/gs-elpa.eclass
@@ -1,16 +1,16 @@
 # Copyright 1999-2013 Gentoo Foundation
 # Distributed under the terms of the GNU General Public License v2
 # $Header: $
-# automatically generated by g-elpa
+# automatically generated by gs-elpa
 # please do not edit this file
 #
 # Original Author: Jauhien Piatlicki <piatlicki@gmail.com>
 # Purpose: support installation of elisp packages for emacs
-# from overlays generated by g-elpa
+# from overlays generated by gs-elpa
 #
 # Bugs to piatlicki@gmail.com
 #
-# @ECLASS: g-elpa.eclass
+# @ECLASS: gs-elpa.eclass
 #
 # @ECLASS-VARIABLE: REPO_URI
 # @DESCRIPTION: address of a repository of elisp packages
@@ -24,15 +24,8 @@
 # @ECLASS-VARIABLE: REALNAME
 # @DESCRIPTION: real name of a package in the repository
 #
-# @ECLASS-VARIABLE: GELPA_STORE_DIR
-# @DESCRIPTION: store location for downloaded sources
-GELPA_STORE_DIR="${PORTAGE_ACTUAL_DISTDIR:-${DISTDIR}}"
-#
-# @ECLASS-VARIABLE: GELPA_FETCH_CMD
-# @DESCRIPTION: fetch command
-GELPA_FETCH_CMD="wget"
 
-inherit elisp
+inherit elisp g-sorcery
 
 EXPORT_FUNCTIONS src_{unpack,compile,install}
 
@@ -44,35 +37,21 @@ fi
 
 SOURCEFILE=${REALNAME}-${PV}.${SUFFIX}
 
-g-elpa_fetch() {
-	addwrite "${GELPA_STORE_DIR}"
-	pushd "${GELPA_STORE_DIR}" >/dev/null || die "can't chdir to ${GELPA_STORE_DIR}"
-	if [[ ! -f "${SOURCEFILE}" ]]; then
-		$GELPA_FETCH_CMD ${REPO_URI}${SOURCEFILE} || die
-	fi
-	popd >/dev/null || die
-}
-
-g-elpa_src_unpack() {
-	if [[ x${DIGEST_SOURCES} = x ]]; then
-		g-elpa_fetch
-	fi
-
-	if [[ ${SOURCE_TYPE} != "single" ]]; then
-		tar xvf ${GELPA_STORE_DIR}/${SOURCEFILE} || die
-	else
+gs-elpa_src_unpack() {
+	g-sorcery_src_unpack
+	if [[ ${SOURCE_TYPE} = "single" ]]; then
 		mkdir ${P} || die
-		cp ${GELPA_STORE_DIR}/${SOURCEFILE} ./${P} || die
+		mv ./${SOURCEFILE} ./${P} || die
 	fi
 }
 
-g-elpa_src_compile() {
+gs-elpa_src_compile() {
 	rm -f ${PN}-pkg.el || die
 	elisp-make-autoload-file || die
 	elisp_src_compile || die
 }
 
-g-elpa_src_install() {
+gs-elpa_src_install() {
 	local sitefile="50${PN}-gentoo.el"
 	cat <<EOF >> ${sitefile} || die
 (add-to-list 'load-path "@SITELISP@")

diff --git a/gs_elpa/ebuild.py b/gs_elpa/ebuild.py
index e7fd502..460ccfa 100644
--- a/gs_elpa/ebuild.py
+++ b/gs_elpa/ebuild.py
@@ -29,7 +29,7 @@ class ElpaEbuildWithDigestGenerator(DefaultEbuildGenerator):
         vars_before_inherit = \
           ["repo_uri", "source_type", "realname", ("digest_sources", "yes")]
 
-        inherit = ["g-elpa"]
+        inherit = ["g-sorcery", "gs-elpa"]
         
         vars_after_description = \
           ["homepage", ("src_uri", "${REPO_URI}${REALNAME}-${PV}.${SUFFIX}")]
@@ -51,7 +51,7 @@ class ElpaEbuildWithoutDigestGenerator(DefaultEbuildGenerator):
         vars_before_inherit = \
           ["repo_uri", "source_type", "realname"]
 
-        inherit = ["g-elpa"]
+        inherit = ["g-sorcery", "gs-elpa"]
         
         vars_after_description = \
           ["homepage"]

diff --git a/gs_elpa/elpa_db.py b/gs_elpa/elpa_db.py
index b7ffefb..8f8cd6d 100644
--- a/gs_elpa/elpa_db.py
+++ b/gs_elpa/elpa_db.py
@@ -107,7 +107,7 @@ class ElpaDBGenerator(DBGenerator):
                           'repo_uri' : repo_uri,
                           'realname' : realname,
             #eclass entry
-                          'eclasses' : ['g-elpa'],
+                          'eclasses' : ['g-sorcery', 'gs-elpa'],
             #metadata entries
                           'maintainer' : [{'email' : 'piatlicki@gmail.com',
                                            'name' : 'Jauhien Piatlicki'}],


^ permalink raw reply related	[flat|nested] only message in thread

only message in thread, other threads:[~2013-08-29  1:12 UTC | newest]

Thread overview: (only message) (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2013-08-29  1:12 [gentoo-commits] proj/g-sorcery:master commit in: g_sorcery/, gs_elpa/data/, g_sorcery/data/, gs_elpa/ Jauhien Piatlicki

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox