From 688c0c982938b9f919d6e24cb3be38ae9818e3bb Mon Sep 17 00:00:00 2001 From: randomdan Date: Tue, 7 Aug 2012 22:38:13 +0000 Subject: Tweak to work with + prefix on use flags Mass fix to work with new metadata cache format --- gentoobrowse/console/packageimport.xml | 102 ++++++++++++++++----------------- gentoobrowse/views/search.xml | 2 +- gentoobrowse/views/use.xml | 4 +- 3 files changed, 51 insertions(+), 57 deletions(-) diff --git a/gentoobrowse/console/packageimport.xml b/gentoobrowse/console/packageimport.xml index c136294..4844dd0 100644 --- a/gentoobrowse/console/packageimport.xml +++ b/gentoobrowse/console/packageimport.xml @@ -2,26 +2,44 @@ - SELECT DISTINCT (REGEXP_MATCHES(filename, '^[^/]+'))[1] AS name FROM files WHERE filetypeid = 1 + SELECT DISTINCT SPLIT_PART(filename, '/', 1) AS name FROM files WHERE filetypeid = 1 + + + CREATE TEMPORARY TABLE ebuilddefs AS + SELECT d.*, c.categoryid, c.name AS catname, d[2] AS pkgname, d[3] AS version, ebuildversion_constructor(d[3]) AS versioninst + FROM ( + SELECT *, REGEXP_MATCHES(filename, '^([^/]+)/(.+)-([0-9].*)$') AS d + FROM CROSSTAB( + 'SELECT f.filename AS filename, f.fileid, f.firstseen, f.moddate, SPLIT_PART(content, ''='', 1) AS category, + (REGEXP_MATCHES(content, E''([^=]+)=(.*)''))[2] AS value + FROM filecache fc, files f + WHERE fc.fileid = f.fileid + AND f.filetypeid = 1 + ORDER BY 1,2', + 'SELECT DISTINCT SPLIT_PART(content, ''='', 1) AS attr + FROM filecache fc, files f + WHERE fc.fileid = f.fileid + AND f.filetypeid = 1 + ORDER BY attr') AS ct(filename TEXT, fileid INT, firstseen TIMESTAMP WITHOUT TIME ZONE, moddate TIMESTAMP WITHOUT TIME ZONE, + defined_phases TEXT, depend TEXT, description TEXT, eapi INT, + homepage TEXT, iuse TEXT, keywords TEXT, license TEXT, pdepend TEXT, properties TEXT, rdepend TEXT, required_use TEXT, + restrict TEXT, slot TEXT, src_uri TEXT, _eclasses_ TEXT, _md5_ TEXT)) d, categories c + WHERE SPLIT_PART(d.filename, '/', 1) = c.name + + + - SELECT categoryid, name, fc.content AS description FROM ( - SELECT c.categoryid, f.fileid, f.d[2] AS name, - RANK() OVER(PARTITION BY c.categoryid, f.d[2] ORDER BY ebuildversion_constructor(f.d[3]) DESC) AS r FROM ( - SELECT fileid, - REGEXP_MATCHES(filename, '^([^/]+)/(.+)-([0-9].*)$') as d - FROM files f - WHERE f.filetypeid = 1) f, - categories c - WHERE c.name = f.d[1]) f, filecache fc - WHERE f.r = 1 - AND fc.fileid = f.fileid - AND fc.line = 8 + SELECT categoryid, pkgname AS name, description + FROM ( + SELECT categoryid, pkgname, description, RANK() OVER(PARTITION BY categoryid, pkgname ORDER BY versioninst desc) r + FROM ebuilddefs) d + WHERE d.r = 1 @@ -32,19 +50,10 @@ - SELECT packageid, version, f.fileid AS ebuildid, ebuildversion_constructor(version) AS versioninst, fcs.content AS slot, - fcl.content AS license, f.firstseen, f.moddate - FROM ( SELECT f.fileid, f.firstseen, f.moddate, - (REGEXP_MATCHES(filename, '^[^/]+'))[1] AS cat, - (REGEXP_MATCHES(filename, '/(.+)-[0-9]'))[1] AS name, - (REGEXP_MATCHES(filename, '/.+-([0-9].*)$'))[1] AS version - FROM files f - WHERE filetypeid = 1) f LEFT OUTER JOIN filecache fcs - ON fcs.fileid = f.fileid AND fcs.line = 3 LEFT OUTER JOIN filecache fcl - ON fcl.fileid = f.fileid AND fcl.line = 7, categories c, packages p - WHERE f.cat = c.name - AND c.categoryid = p.categoryid - AND p.name = f.name + SELECT p.packageid, e.version, e.fileid AS ebuildid, e.versioninst, e.slot, e.license, e.firstseen, e.moddate + FROM ebuilddefs e, packages p + WHERE e.pkgname = p.name + AND e.categoryid = p.categoryid @@ -60,11 +69,8 @@ - SELECT DISTINCT f.fileid AS ebuildid, REGEXP_SPLIT_TO_TABLE(fc.content, ' ') AS arch - FROM filecache fc, files f - WHERE fc.line = 9 - AND fc.fileid = f.fileid - AND filetypeid = 1 + SELECT DISTINCT e.fileid AS ebuildid, REGEXP_SPLIT_TO_TABLE(e.keywords, ' ') AS arch + FROM ebuilddefs e @@ -74,11 +80,8 @@ - SELECT DISTINCT fc.fileid AS ebuildid, REGEXP_SPLIT_TO_TABLE(fc.content, ' ') AS use - FROM filecache fc, files f - WHERE fc.line = 11 - AND fc.fileid = f.fileid - AND filetypeid = 1 + SELECT DISTINCT e.fileid AS ebuildid, REGEXP_SPLIT_TO_TABLE(e.iuse, ' ') AS use + FROM ebuilddefs e @@ -88,14 +91,11 @@ - SELECT packageid, url FROM ( - SELECT DISTINCT e.packageid, REGEXP_SPLIT_TO_TABLE(fc.content, ' ') AS url - FROM filecache fc, ebuilds e, files f - WHERE fc.line = 6 - AND fc.fileid = e.ebuildid - AND fc.fileid = f.fileid - AND filetypeid = 1) AS u - WHERE url LIKE '%://%' + SELECT DISTINCT p.packageid, e.homepage AS url + FROM ebuilddefs e, packages p + WHERE e.pkgname = p.name + AND e.categoryid = p.categoryid + AND homepage LIKE '%://%' @@ -114,11 +114,8 @@ SELECT fileid, REGEXP_MATCHES(dep, E'([^a-zA-Z0-9]*)([a-zA-Z0-9-]+)/([a-zA-Z0-9_+-]+?)(-([0-9][^:]*))?(:([0-9.]+))?(\\[([^]]+)\\])?') as field FROM ( - SELECT fc.fileid, REGEXP_SPLIT_TO_TABLE(fc.content, ' ') AS dep - FROM filecache fc, files f - WHERE line = 1 - AND fc.fileid = f.fileid - AND filetypeid = 1 + SELECT e.fileid, REGEXP_SPLIT_TO_TABLE(e.depend, ' ') AS dep + FROM ebuilddefs e ) src ) AS src2 ) AS src3, categories c, packages p @@ -147,11 +144,8 @@ SELECT fileid, REGEXP_MATCHES(dep, E'([^a-zA-Z0-9]*)([a-zA-Z0-9-]+)/([a-zA-Z0-9_+-]+?)(-([0-9][^:]*))?(:([0-9.]+))?(\\[([^]]+)\\])?') as field FROM ( - SELECT fc.fileid, REGEXP_SPLIT_TO_TABLE(fc.content, ' ') AS dep - FROM filecache fc, files f - WHERE line = 2 - AND fc.fileid = f.fileid - AND filetypeid = 1 + SELECT e.fileid, REGEXP_SPLIT_TO_TABLE(e.rdepend, ' ') AS dep + FROM ebuilddefs e ) src ) AS src2 ) AS src3, categories c, packages p diff --git a/gentoobrowse/views/search.xml b/gentoobrowse/views/search.xml index db08d33..347642a 100644 --- a/gentoobrowse/views/search.xml +++ b/gentoobrowse/views/search.xml @@ -38,7 +38,7 @@ AND e.packageid = p.packageid AND p.categoryid = c.categoryid - AND eu.use = + AND LTRIM(eu.use, '+') = ORDER BY c.name, p.name diff --git a/gentoobrowse/views/use.xml b/gentoobrowse/views/use.xml index f0938bd..957cdbc 100644 --- a/gentoobrowse/views/use.xml +++ b/gentoobrowse/views/use.xml @@ -23,7 +23,7 @@ SELECT use, description FROM use_global - WHERE use = + WHERE LTRIM(use, '+') = @@ -32,7 +32,7 @@ SELECT packageid, use, description FROM use_local - WHERE use = + WHERE LTRIM(use, '+') = ORDER BY packageid -- cgit v1.2.3