public inbox for gentoo-commits@lists.gentoo.org
 help / color / mirror / Atom feed
From: "Magnus Granberg" <zorry@gentoo.org>
To: gentoo-commits@lists.gentoo.org
Subject: [gentoo-commits] dev/zorry:master commit in: gobs/bin/, gobs/pym/
Date: Sat, 29 Oct 2011 00:14:57 +0000 (UTC)	[thread overview]
Message-ID: <b728ae2804796599b7f18056a9e135a4c809fc25.zorry@gentoo> (raw)

commit:     b728ae2804796599b7f18056a9e135a4c809fc25
Author:     Magnus Granberg <zorry <AT> gentoo <DOT> org>
AuthorDate: Sat Oct 29 00:12:57 2011 +0000
Commit:     Magnus Granberg <zorry <AT> gentoo <DOT> org>
CommitDate: Sat Oct 29 00:12:57 2011 +0000
URL:        http://git.overlays.gentoo.org/gitweb/?p=dev/zorry.git;a=commit;h=b728ae28

Add gobs_setup_profile

---
 gobs/bin/gobs_setup_profile    |   12 ++++++
 gobs/pym/build_log.py          |   10 +++--
 gobs/pym/build_queru.py        |    2 +-
 gobs/pym/check_setup.py        |    7 ++++
 gobs/pym/init_setup_profile.py |   79 ++++++++++++++++++++++++++++++++++++++++
 gobs/pym/package.py            |   11 +-----
 gobs/pym/pgsql.py              |    7 ++++
 7 files changed, 114 insertions(+), 14 deletions(-)

diff --git a/gobs/bin/gobs_setup_profile b/gobs/bin/gobs_setup_profile
new file mode 100755
index 0000000..902ffe8
--- /dev/null
+++ b/gobs/bin/gobs_setup_profile
@@ -0,0 +1,12 @@
+#!/usr/bin/python
+# Copyright 2006-2011 Gentoo Foundation
+# Distributed under the terms of the GNU General Public License v2
+
+from gobs.init_setup_profile import setup_profile_main
+
+def main():
+	# Main
+	setup_profile_main(args=None)
+	
+if __name__ == "__main__":
+	main()
\ No newline at end of file

diff --git a/gobs/pym/build_log.py b/gobs/pym/build_log.py
index 354e8d3..80a186a 100644
--- a/gobs/pym/build_log.py
+++ b/gobs/pym/build_log.py
@@ -562,9 +562,11 @@ class gobs_buildlog(object):
 			os.chmod(emerge_info_logfilename, 0664)
 			print("Package: ", pkg.cpv, "logged to db.")
 		else:
-			try:
-				os.remove(settings.get("PORTAGE_LOG_FILE"))
-			except:
-				pass
+			# FIXME Remove the log some way so 
+			# mergetask._locate_failure_log(x) works in action_build()
+			#try:
+			#	os.remove(settings.get("PORTAGE_LOG_FILE"))
+			#except:
+			#	pass
 			print("Package: ", pkg.cpv, "NOT logged to db.")
 		CM.putConnection(conn)

diff --git a/gobs/pym/build_queru.py b/gobs/pym/build_queru.py
index 9794bbd..3f0bde8 100644
--- a/gobs/pym/build_queru.py
+++ b/gobs/pym/build_queru.py
@@ -670,7 +670,7 @@ class queruaction(object):
 		build_fail = self.emerge_main(argscmd, build_dict)
 		# Run depclean
 		print('build_fail', build_fail)
-		if not "clean" in build_dict['post_message']:
+		if not "noclean" in build_dict['post_message']:
 			depclean_fail = main_depclean()
 		try:
 			os.remove("/etc/portage/package.use/gobs.use")

diff --git a/gobs/pym/check_setup.py b/gobs/pym/check_setup.py
index cc9b55b..b5f612b 100644
--- a/gobs/pym/check_setup.py
+++ b/gobs/pym/check_setup.py
@@ -14,6 +14,13 @@ CM=connectionManager(gobs_settings_dict)
 if CM.getName()=='pgsql':
 	from gobs.pgsql import *
 
+def git_pull():
+	repo = Repo("/var/lib/gobs/" + gobs_settings_dict['gobs_gitreponame'] + "/")
+	repo_remote = repo.remotes.origin
+	repo_remote.pull()
+	master = repo.head.reference
+	print(master.log())
+
 def check_make_conf():
   # FIXME: mark any config updating true in the db when updating the configs
   # Get the config list

diff --git a/gobs/pym/init_setup_profile.py b/gobs/pym/init_setup_profile.py
new file mode 100644
index 0000000..6f640d9
--- /dev/null
+++ b/gobs/pym/init_setup_profile.py
@@ -0,0 +1,79 @@
+#!/usr/bin/python
+# Copyright 2006-2011 Gentoo Foundation
+# Distributed under the terms of the GNU General Public License v2
+
+""" 	This code will update the sql backend with needed info for
+	the Frontend and the Guest deamon. """
+
+import sys
+import os
+
+# Get the options from the config file set in gobs.readconf
+from gobs.readconf import get_conf_settings
+reader=get_conf_settings()
+gobs_settings_dict=reader.read_gobs_settings_all()
+# make a CM
+from gobs.ConnectionManager import connectionManager
+CM=connectionManager(gobs_settings_dict)
+#selectively import the pgsql/mysql querys
+if CM.getName()=='pgsql':
+  from gobs.pgsql import *
+
+from gobs.check_setup import check_make_conf, git_pull
+from gobs.arch import gobs_arch
+from gobs.package import gobs_package
+from gobs.categories import gobs_categories
+from gobs.old_cpv import gobs_old_cpv
+from gobs.categories import gobs_categories
+import portage
+
+def setup_profile_main(args=None):
+	"""
+	@param args: command arguments (default: sys.argv[1:])
+	@type args: list
+	"""
+	conn=CM.getConnection()
+	if args is None:
+		args = sys.argv[1:]
+		if args[0] is "-add":
+			git_pull()
+			check_make_conf()
+			print "Check configs done"
+			# Get default config from the configs table  and default_config=1
+			config_id = args[1]
+			default_config_root = "/var/lib/gobs/" + gobs_settings_dict['gobs_gitreponame'] + "/" + config_id + "/"
+			# Set config_root (PORTAGE_CONFIGROOT)  to default_config_root
+			mysettings = portage.config(config_root = default_config_root)
+			myportdb = portage.portdbapi(mysettings=mysettings)
+			init_package = gobs_package
+			# get the cp list
+			package_list_tree = package_list_tree = myportdb.cp_all()(mysettings, myportdb)
+			print "Setting default config to:", config_id
+			for package_line in sorted(package_list_tree):
+				build_dict = {}
+				packageDict = {}
+				ebuild_id_list = []
+				# split the cp to categories and package
+				element = package_line.split('/')
+				categories = element[0]
+				package = element[1]
+				print "C", categories + "/" + package			# C = Checking
+				pkgdir = mysettings['PORTDIR'] + "/" + categories + "/" + package
+				config_cpv_listDict = gobs_package.config_match_cp(categories, package, config_id)
+				packageDict['ebuild_version_tree'] = config_cpv_listDict['ebuild_version']
+				build_dict['checksum'] = portage.checksum.sha256hash(pkgdir + "/" + package + "-" + config_cpv_listDict['ebuild_version'] + ".ebuild")[0]
+				build_dict['package_id'] = have_package_db(categories, package)
+				build_dict['ebuild_version'] = config_cpv_listDict['ebuild_version']
+				ebuild_id = get_ebuild_id_db_checksum(connection, build_dict)
+				if ebuild_id is not None:
+					ebuild_id_list.append(ebuild_id)
+					gobs_package.add_new_ebuild_buildquery_db(ebuild_id_list, packageDict, config_cpv_listDict)
+		if args[0] is "-del":
+			config_id = args[1]
+			querue_id_list = get_queue_id_list_config(conn, config_id)
+			if querue_id_list is not None:
+				for querue_id in querue_id_list:
+					del_old_queue(conn, queue_id)
+	CM.putConnection(conn)
+
+		
\ No newline at end of file

diff --git a/gobs/pym/package.py b/gobs/pym/package.py
index 884ce7c..bbd5998 100644
--- a/gobs/pym/package.py
+++ b/gobs/pym/package.py
@@ -68,20 +68,16 @@ class gobs_package(object):
 		return config_cpv_listDict
 
 	def config_match_cp(self, categories, package, config_id):
-		conn=CM.getConnection()
 		config_cpv_listDict ={}
-		# Change config/setup
-		mysettings_setup = self.change_config(config_id)
-		myportdb_setup = portage.portdbapi(mysettings=mysettings_setup)
 		# Get latest cpv from portage with the config
-		latest_ebuild = myportdb_setup.xmatch('bestmatch-visible', categories + "/" + package)
+		latest_ebuild = self._myportdb_setup.xmatch('bestmatch-visible', categories + "/" + package)
 		latest_ebuild_version = unicode("")
 		# Check if could get cpv from portage
 		if latest_ebuild != "":
 			# Get the version of cpv
 			latest_ebuild_version = portage.versions.cpv_getversion(latest_ebuild)
 			# Get the iuse and use flags for that config/setup
-			init_useflags = gobs_use_flags(mysettings_setup, myportdb_setup, latest_ebuild)
+			init_useflags = gobs_use_flags(self._mysettings, self._myportdb, latest_ebuild)
 			iuse_flags_list, final_use_list = init_useflags.get_flags()
 			iuse_flags_list2 = []
 			for iuse_line in iuse_flags_list:
@@ -95,9 +91,6 @@ class gobs_package(object):
 				attDict['categories'] = categories
 				config_cpv_listDict[config_id] = attDict
 		# Clean some cache
-		myportdb_setup.close_caches()
-		portage.portdbapi.portdbapi_instances.remove(myportdb_setup)
-		CM.putConnection(conn)
 		return config_cpv_listDict
 
 	def get_ebuild_metadata(self, ebuild_line):

diff --git a/gobs/pym/pgsql.py b/gobs/pym/pgsql.py
index 9e7d3f5..b241d1b 100644
--- a/gobs/pym/pgsql.py
+++ b/gobs/pym/pgsql.py
@@ -322,6 +322,13 @@ def have_package_buildqueue(connection, ebuild_id, config_id):
 	entries = cursor.fetchone()
 	return entries
 
+def get queue_id_list_config(connection, config_id)
+	cursor = connection.cursor()
+	sqlQ = 'SELECT queue_id FROM buildqueue WHERE  config_id = %s'
+	cursor.execute(sqlQ,  (config_id,))
+	entries = cursor.fetchoall()
+	return entries
+
 def add_new_package_buildqueue(connection, ebuild_id, config_id, iuse_flags_list, use_enable, message):
   cursor = connection.cursor()
   sqlQ="SELECT insert_buildqueue( %s, %s, %s, %s, %s )"



             reply	other threads:[~2011-10-29  0:15 UTC|newest]

Thread overview: 32+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2011-10-29  0:14 Magnus Granberg [this message]
  -- strict thread matches above, loose matches on Subject: below --
2012-12-27 23:09 [gentoo-commits] dev/zorry:master commit in: gobs/bin/, gobs/pym/ Magnus Granberg
2012-12-23 17:09 Magnus Granberg
2012-12-22  2:59 Magnus Granberg
2012-12-21  1:44 Magnus Granberg
2012-12-19  2:11 Magnus Granberg
2012-12-07 14:07 Magnus Granberg
2012-12-05 23:56 Magnus Granberg
2012-11-29 22:22 Magnus Granberg
2012-07-17  0:07 Magnus Granberg
2012-06-26 22:10 Magnus Granberg
2012-05-13 17:59 Magnus Granberg
2012-05-09 23:12 Magnus Granberg
2012-05-06 10:41 Magnus Granberg
2012-05-04 22:32 Magnus Granberg
2012-05-01  1:12 Magnus Granberg
2012-04-30 12:08 Magnus Granberg
2012-04-29 14:43 Magnus Granberg
2012-04-29 13:16 Magnus Granberg
2012-04-29 13:13 Magnus Granberg
2012-04-28 16:01 Magnus Granberg
2012-04-27 22:22 Magnus Granberg
2012-04-27 20:59 Magnus Granberg
2011-11-01 21:14 Magnus Granberg
2011-09-28 10:53 Magnus Granberg
2011-09-28  0:33 Magnus Granberg
2011-09-26 23:25 Magnus Granberg
2011-08-31  1:46 Magnus Granberg
2011-08-30 23:02 Magnus Granberg
2011-07-31 13:43 Magnus Granberg
2011-04-24 22:13 Magnus Granberg
2011-04-23 14:23 Magnus Granberg

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=b728ae2804796599b7f18056a9e135a4c809fc25.zorry@gentoo \
    --to=zorry@gentoo.org \
    --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