From: Michael Tremer Date: Sat, 25 Jun 2022 15:01:26 +0000 (+0000) Subject: repos: Drop auxiliary repos and replace with custom distro config X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=19e05f59bd225f0bfcb354a14c84637eea2a26bb;p=pbs.git repos: Drop auxiliary repos and replace with custom distro config Signed-off-by: Michael Tremer --- diff --git a/src/buildservice/distribution.py b/src/buildservice/distribution.py index f4c1a18e..cbc08a18 100644 --- a/src/buildservice/distribution.py +++ b/src/buildservice/distribution.py @@ -5,9 +5,6 @@ import logging from . import base from . import packages from . import sources - -from .repository import Repository, RepositoryAux - from .decorators import * class Distributions(base.Object): @@ -74,6 +71,12 @@ class Distribution(base.DataObject): "contact = %s" % self.contact, ] + # Add any custom configuration + if self.custom_config: + lines += ( + "### CUSTOM CONFIG ###", self.custom_config, "### CUSTOM CONFIG END ###", + ) + return "\n".join(lines) @property @@ -122,6 +125,16 @@ class Distribution(base.DataObject): tag = property(get_tag, set_tag) + # Custom Configuration + + def get_custom_config(self): + return self.data.custom_config + + def set_custom_config(self, custom_config): + self._set_attribute("custom_config", custom_config or "") + + custom_config = property(get_custom_config, set_custom_config) + @lazy_property def repos(self): repos = self.backend.repos._get_repositories(""" @@ -143,20 +156,6 @@ class Distribution(base.DataObject): # XXX legacy repositories = repos - @lazy_property - def repositories_aux(self): - _repos = self.db.query("SELECT id FROM repositories_aux \ - WHERE status = 'enabled' AND distro_id = %s", self.id) - - repos = [] - for repo in _repos: - repo = RepositoryAux(self.pakfire, repo.id) - repo._distro = self - - repos.append(repo) - - return sorted(repos) - def get_repo(self, slug): repo = self.backend.repos._get_repository(""" SELECT @@ -188,9 +187,6 @@ class Distribution(base.DataObject): if repo.enabled_for_builds: repos.append(repo) - # Add all aux. repositories. - repos += self.repositories_aux - return repos @property diff --git a/src/buildservice/repository.py b/src/buildservice/repository.py index b72c0990..4850c874 100644 --- a/src/buildservice/repository.py +++ b/src/buildservice/repository.py @@ -448,38 +448,3 @@ class Repository(base.DataObject): }) return self.pakfire.repos.get_history(**kwargs) - - -class RepositoryAux(base.DataObject): - table = "repositories_aux" - - @property - def name(self): - return self.data.name - - @property - def description(self): - return self.data.description or "" - - @property - def url(self): - return self.data.url - - @property - def slug(self): - return self.name.lower() - - @property - def distro(self): - return self.pakfire.distros.get_by_id(self.data.distro_id) - - def get_config(self, local=False): - lines = [ - "[repo:%s]" % self.slug, - "description = %s - %s" % (self.distro.name, self.name), - "enabled = 1", - "baseurl = %s" % self.url, - "priority = 0", - ] - - return "\n".join(lines) diff --git a/src/database.sql b/src/database.sql index d07f5551..7e60f3df 100644 --- a/src/database.sql +++ b/src/database.sql @@ -405,7 +405,8 @@ CREATE TABLE public.distributions ( tag text NOT NULL, deleted boolean DEFAULT false NOT NULL, arches text[] DEFAULT ARRAY[]::text[] NOT NULL, - created_at timestamp without time zone DEFAULT CURRENT_TIMESTAMP NOT NULL + created_at timestamp without time zone DEFAULT CURRENT_TIMESTAMP NOT NULL, + custom_config text DEFAULT ''::text NOT NULL ); @@ -1088,7 +1089,7 @@ CREATE TABLE public.repositories ( id integer NOT NULL, name text NOT NULL, slug text, - description text NOT NULL, + description text DEFAULT ''::text NOT NULL, distro_id integer NOT NULL, parent_id integer, key_id integer, @@ -1104,43 +1105,6 @@ CREATE TABLE public.repositories ( ALTER TABLE public.repositories OWNER TO pakfire; --- --- Name: repositories_aux; Type: TABLE; Schema: public; Owner: pakfire --- - -CREATE TABLE public.repositories_aux ( - id integer NOT NULL, - name text NOT NULL, - description text, - url text NOT NULL, - distro_id integer NOT NULL, - status text DEFAULT 'disabled'::text NOT NULL -); - - -ALTER TABLE public.repositories_aux OWNER TO pakfire; - --- --- Name: repositories_aux_id_seq; Type: SEQUENCE; Schema: public; Owner: pakfire --- - -CREATE SEQUENCE public.repositories_aux_id_seq - START WITH 1 - INCREMENT BY 1 - NO MINVALUE - NO MAXVALUE - CACHE 1; - - -ALTER TABLE public.repositories_aux_id_seq OWNER TO pakfire; - --- --- Name: repositories_aux_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: pakfire --- - -ALTER SEQUENCE public.repositories_aux_id_seq OWNED BY public.repositories_aux.id; - - -- -- Name: repositories_builds; Type: TABLE; Schema: public; Owner: pakfire -- @@ -1666,13 +1630,6 @@ ALTER TABLE ONLY public.queue_delete ALTER COLUMN id SET DEFAULT nextval('public ALTER TABLE ONLY public.repositories ALTER COLUMN id SET DEFAULT nextval('public.repositories_id_seq'::regclass); --- --- Name: repositories_aux id; Type: DEFAULT; Schema: public; Owner: pakfire --- - -ALTER TABLE ONLY public.repositories_aux ALTER COLUMN id SET DEFAULT nextval('public.repositories_aux_id_seq'::regclass); - - -- -- Name: repositories_builds id; Type: DEFAULT; Schema: public; Owner: pakfire -- @@ -1881,14 +1838,6 @@ ALTER TABLE ONLY public.queue_delete ADD CONSTRAINT idx_2198155_primary PRIMARY KEY (id); --- --- Name: repositories_aux idx_2198179_primary; Type: CONSTRAINT; Schema: public; Owner: pakfire --- - -ALTER TABLE ONLY public.repositories_aux - ADD CONSTRAINT idx_2198179_primary PRIMARY KEY (id); - - -- -- Name: repositories_builds idx_2198189_primary; Type: CONSTRAINT; Schema: public; Owner: pakfire -- @@ -2588,14 +2537,6 @@ ALTER TABLE ONLY public.packages ADD CONSTRAINT packages_commit_id FOREIGN KEY (commit_id) REFERENCES public.sources_commits(id); --- --- Name: repositories_aux repositories_aux_distro_id; Type: FK CONSTRAINT; Schema: public; Owner: pakfire --- - -ALTER TABLE ONLY public.repositories_aux - ADD CONSTRAINT repositories_aux_distro_id FOREIGN KEY (distro_id) REFERENCES public.distributions(id); - - -- -- Name: repositories_builds repositories_builds_build_id; Type: FK CONSTRAINT; Schema: public; Owner: pakfire --