commit:     8449a45df3f33ccf90f60540a5aae1b571e3fe41
Author:     Magnus Granberg <zorry <AT> gentoo <DOT> org>
AuthorDate: Sat Feb  3 10:02:26 2024 +0000
Commit:     Magnus Granberg <zorry <AT> gentoo <DOT> org>
CommitDate: Sat Feb  3 10:02:26 2024 +0000
URL:        
https://gitweb.gentoo.org/proj/tinderbox-cluster.git/commit/?id=8449a45d

Use settings repository for portage settings

Signed-off-by: Magnus Granberg <zorry <AT> gentoo.org>

 buildbot_gentoo_ci/config/buildfactorys.py | 33 +++--------
 buildbot_gentoo_ci/db/model.py             |  5 +-
 buildbot_gentoo_ci/db/projects.py          |  3 +-
 buildbot_gentoo_ci/db/repositorys.py       |  2 +-
 buildbot_gentoo_ci/steps/portage.py        | 89 +++++++++++++++---------------
 buildbot_gentoo_ci/steps/repos.py          |  4 +-
 sql/gentoo_ci_schema.sql                   |  1 +
 7 files changed, 60 insertions(+), 77 deletions(-)

diff --git a/buildbot_gentoo_ci/config/buildfactorys.py 
b/buildbot_gentoo_ci/config/buildfactorys.py
index 6755308..ab80e19 100644
--- a/buildbot_gentoo_ci/config/buildfactorys.py
+++ b/buildbot_gentoo_ci/config/buildfactorys.py
@@ -1,4 +1,4 @@
-# Copyright 2021 Gentoo Authors
+# Copyright 2024 Gentoo Authors
 # Distributed under the terms of the GNU General Public License v2
 
 from buildbot.plugins import steps as buildbot_steps
@@ -105,32 +105,13 @@ def run_build_request():
     # update the repositorys listed in project_repository
     f.addStep(repos.UpdateRepos())
     # Clean and add new /etc/portage
-    #NOTE: remove the symlink befor the dir
-    #f.addStep(buildbot_steps.ShellCommand(
-    #                    flunkOnFailure=False,
-    #                    name='Clean make.profile',
-    #                    command=['rm', 'make.profile'],
-    #                    workdir='/etc/portage/'
-    #                    ))
-    if buildbot_steps.FileExists(file='portage/make.conf', workdir='/etc/', 
haltOnFailure = False):
-        f.addStep(buildbot_steps.ShellCommand(
+    f.addStep(buildbot_steps.ShellCommand(
                         flunkOnFailure=False,
                         name='Remove portage dir',
                         command=['rm', '-R', 'portage'],
                         workdir='/etc/'
                         ))
-    f.addStep(buildbot_steps.ShellCommand(
-                        flunkOnFailure=False,
-                        name='Create portage dir',
-                        command=['mkdir', 'portage'],
-                        workdir='/etc/'
-                        ))
-    #f.addStep(buildbot_steps.RemoveDirectory(dir="portage",
-    #                            name='Remove portage dir',
-    #                            workdir='/etc/'))
-    #f.addStep(buildbot_steps.MakeDirectory(dir="portage",
-    #                            name = 'Create the portage dir',
-    #                            workdir='/etc/'))
+    f.addStep(portage.SetPortageSettings())
     # Clean /var/cache/portage/logs and emerge.log
     f.addStep(buildbot_steps.ShellCommand(
                         flunkOnFailure=False,
@@ -153,13 +134,13 @@ def run_build_request():
     # setup repos.conf dir
     #f.addStep(buildbot_steps.MakeDirectory(dir="repos.conf",
     #                            workdir='/etc/portage/'))
-    f.addStep(portage.SetReposConf())
+    #f.addStep(portage.SetReposConf())
     # setup make.conf
-    f.addStep(portage.SetMakeConf())
+    f.addStep(portage.SetHostConf())
     # setup env
-    f.addStep(portage.SetEnvDefault())
+    #f.addStep(portage.SetEnvDefault())
     # setup package.*
-    f.addStep(portage.SetPackageDefault())
+    #f.addStep(portage.SetPackageDefault())
     # setup files in /etc if needed
     # run --regen if needed on repo
     # check cpv match

diff --git a/buildbot_gentoo_ci/db/model.py b/buildbot_gentoo_ci/db/model.py
index 3ae4f92..b6a0c43 100644
--- a/buildbot_gentoo_ci/db/model.py
+++ b/buildbot_gentoo_ci/db/model.py
@@ -15,7 +15,7 @@
 # Copyright Buildbot Team Members
 # Origins: buildbot.db.model.py
 # Modifyed by Gentoo Authors.
-# Copyright 2023 Gentoo Authors
+# Copyright 2024 Gentoo Authors
 
 import uuid
 
@@ -136,6 +136,9 @@ class Model(base.DBConnectorComponent):
         sa.Column('profile_repository_uuid', sa.String(36),
                   sa.ForeignKey('repositorys.uuid', ondelete='CASCADE'),
                   nullable=False),
+        sa.Column('settings_repository_uuid', sa.String(36),
+                  sa.ForeignKey('repositorys.uuid', ondelete='CASCADE'),
+                  nullable=False),
         sa.Column('keyword_id', sa.Integer,
                   sa.ForeignKey('keywords.id', ondelete='CASCADE'),
                   nullable=False),

diff --git a/buildbot_gentoo_ci/db/projects.py 
b/buildbot_gentoo_ci/db/projects.py
index 9dcfa45..7ffac97 100644
--- a/buildbot_gentoo_ci/db/projects.py
+++ b/buildbot_gentoo_ci/db/projects.py
@@ -15,7 +15,7 @@
 # Copyright Buildbot Team Members
 # Origins: buildbot.db.*
 # Modifyed by Gentoo Authors.
-# Copyright 2021 Gentoo Authors
+# Copyright 2024 Gentoo Authors
 
 import sqlalchemy as sa
 
@@ -220,6 +220,7 @@ class ProjectsConnectorComponent(base.DBConnectorComponent):
             description=row.description,
             profile=row.profile,
             profile_repository_uuid=row.profile_repository_uuid,
+            settings_repository_uuid=row.settings_repository_uuid,
             keyword_id=row.keyword_id,
             image=row.image,
             status=row.status,

diff --git a/buildbot_gentoo_ci/db/repositorys.py 
b/buildbot_gentoo_ci/db/repositorys.py
index 8fee1d3..8b7ee82 100644
--- a/buildbot_gentoo_ci/db/repositorys.py
+++ b/buildbot_gentoo_ci/db/repositorys.py
@@ -15,7 +15,7 @@
 # Copyright Buildbot Team Members
 # Origins: buildbot.db.*
 # Modifyed by Gentoo Authors.
-# Copyright 2023 Gentoo Authors
+# Copyright 2024 Gentoo Authors
 
 import sqlalchemy as sa
 

diff --git a/buildbot_gentoo_ci/steps/portage.py 
b/buildbot_gentoo_ci/steps/portage.py
index 6d838d7..74a8e37 100644
--- a/buildbot_gentoo_ci/steps/portage.py
+++ b/buildbot_gentoo_ci/steps/portage.py
@@ -35,6 +35,45 @@ def WriteTextToFile(path, text_list):
         yield f.write(separator)
         yield f.close
 
+class SetPortageSettings(BuildStep):
+
+    name = 'SetPortageSettings'
+    description = 'Running'
+    descriptionDone = 'Ran'
+    descriptionSuffix = None
+    haltOnFailure = True
+    flunkOnFailure = True
+
+    def __init__(self, **kwargs):
+        super().__init__(**kwargs)
+
+    @defer.inlineCallbacks
+    def run(self):
+        self.gentooci = 
self.master.namedServices['services'].namedServices['gentooci']
+        portage_repos_path = self.getProperty('portage_repos_path')
+        project_data = self.getProperty('project_data')
+        settings_repository_data = yield 
self.gentooci.db.repositorys.getRepositoryByUuid(project_data['settings_repository_uuid'])
+        portagesetting_path = yield os.path.join(portage_repos_path, 
settings_repository_data['name'], 'Project', project_data['uuid'], 'portage')
+        shell_commad_list = [
+                    'ln',
+                    '-s'
+                    ]
+        if self.getProperty('rootworkdir'):
+            symlink_portage_path = yield 
os.path.join(self.getProperty('rootworkdir'), 'etc/portage')
+        else:
+            symlink_portage_path = '/etc/portage'
+        shell_commad_list.append(portagesetting_path)
+        shell_commad_list.append(symlink_portage_path)
+        yield self.build.addStepsAfterCurrentStep([
+            steps.ShellCommand(
+                        command=shell_commad_list,
+                        workdir='/'
+                )
+            ])
+        log = yield self.addLog('Portage setting')
+        yield log.addStdout('Portage setting path: ' + portagesetting_path + 
'\n')
+        return SUCCESS
+
 class SetMakeProfile(BuildStep):
 
     name = 'SetMakeProfile'
@@ -162,9 +201,9 @@ class SetReposConf(BuildStep):
         yield self.build.addStepsAfterCurrentStep(self.aftersteps_list)
         return SUCCESS
 
-class SetMakeConf(BuildStep):
+class SetHostConf(BuildStep):
 
-    name = 'SetMakeConf'
+    name = 'SetHostConf'
     description = 'Running'
     descriptionDone = 'Ran'
     descriptionSuffix = None
@@ -188,55 +227,13 @@ class SetMakeConf(BuildStep):
         separator1 = '\n'
         separator2 = ' '
         makeconf_list = []
-        log = yield self.addLog('make.conf')
-        for k in makeconf_variables_data:
-            makeconf_variables_values_data = yield 
self.gentooci.db.projects.getProjectMakeConfById(project_data['uuid'], k['id'])
-            makeconf_variable_list = []
-            # CFLAGS
-            if k['variable'] == 'CFLAGS' or k['variable'] == 'FCFLAGS':
-                makeconf_variable_list.append('-O2')
-                makeconf_variable_list.append('-pipe')
-                makeconf_variable_list.append('-fno-diagnostics-color')
-                #FIXME:
-                # Depend on worker we may have to add a diffrent march
-                makeconf_variable_list.append('-march=native')
-            if k['variable'] == 'CXXFLAGS':
-                makeconf_variable_list.append('${CFLAGS}')
-            if k['variable'] == 'FFLAGS':
-                makeconf_variable_list.append('${FCFLAGS}')
-            # Add default setting if use_default
-            if project_data['use_default']:
-                default_project_data = yield 
self.gentooci.db.projects.getProjectByName(self.gentooci.config.project['project']['update_db'])
-                default_makeconf_variables_values_data = yield 
self.gentooci.db.projects.getProjectMakeConfById(default_project_data['uuid'], 
k['id'])
-                for v in default_makeconf_variables_values_data:
-                    if v['build_id'] == 0:
-                        makeconf_variable_list.append(v['value'])
-            for v in makeconf_variables_values_data:
-                if v['build_id'] == 0:
-                    makeconf_variable_list.append(v['value'])
-            #NOTE: set it by project
-            #if k['variable'] == 'ACCEPT_LICENSE' and makeconf_variable_list 
!= []:
-            #    makeconf_variable_list.append('ACCEPT_LICENSE="*"')
-            if makeconf_variable_list != []:
-                makeconf_variable_string = k['variable'] + '="' + 
separator2.join(makeconf_variable_list) + '"'
-                makeconf_list.append(makeconf_variable_string)
-        # add hardcoded variables from config file
-        config_makeconfig = 
self.gentooci.config.project['project']['config_makeconfig']
-        for v in config_makeconfig:
-            makeconf_list.append(v)
-        # add ACCEPT_KEYWORDS from the project_data info
-        keyword_data = yield 
self.gentooci.db.keywords.getKeywordById(project_data['keyword_id'])
-        if project_data['status'] == 'unstable':
-            makeconf_keyword = '~' + keyword_data['name']
-        else:
-            makeconf_keyword = keyword_data['name']
-        makeconf_list.append('ACCEPT_KEYWORDS="' + makeconf_keyword + '"')
+        log = yield self.addLog('host.conf')
         makeconf_list.append('MAKEOPTS="-j14"')
         makeconf_string = separator1.join(makeconf_list)
         print(makeconf_string)
         yield self.build.addStepsAfterCurrentStep([
             steps.StringDownload(makeconf_string + separator1,
-                                workerdest="make.conf",
+                                workerdest="host.conf",
                                 workdir=portage_etc_path)
             ])
         # display the make.conf

diff --git a/buildbot_gentoo_ci/steps/repos.py 
b/buildbot_gentoo_ci/steps/repos.py
index 6d37906..729ab06 100644
--- a/buildbot_gentoo_ci/steps/repos.py
+++ b/buildbot_gentoo_ci/steps/repos.py
@@ -212,7 +212,7 @@ class UpdateRepos(BuildStep):
                     yield self.build.addStepsAfterCurrentStep([
                         steps.Git(repourl=repository_data['url'],
                             name = 'RunGit',
-                            descriptionDone=GitdescriptionDone,
+                            descriptionDone=repository_data['name'],
                             branch = branch,
                             mode=repository_data['mode'],
                             method=repository_data['method'],
@@ -228,7 +228,7 @@ class UpdateRepos(BuildStep):
                     yield self.build.addStepsAfterCurrentStep([
                         steps.GitLab(repourl=repository_data['url'],
                             name = 'RunGit',
-                            descriptionDone=GitdescriptionDone,
+                            descriptionDone=repository_data['name'],
                             branch = branch,
                             mode=repository_data['mode'],
                             method=repository_data['method'],

diff --git a/sql/gentoo_ci_schema.sql b/sql/gentoo_ci_schema.sql
index ee89db8..ce12072 100644
--- a/sql/gentoo_ci_schema.sql
+++ b/sql/gentoo_ci_schema.sql
@@ -489,6 +489,7 @@ CREATE TABLE public.projects (
     description text,
     profile character varying(255) NOT NULL,
     profile_repository_uuid character varying(36) NOT NULL,
+    settings_repository_uuid character varying(36) NOT NULL,
     keyword_id integer,
     status public.projects_status,
     auto boolean,

Reply via email to