1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
|
<?xml version="1.0"?>
<packageimport name="bugassociate" xmlns:xi="http://www.w3.org/2001/XInclude"
xmlns:project2="http://project2.randomdan.homeip.net">
<project2:sqlmerge name="repos" datasource="postgres" targettable="repos" useview="yes">
<sql>SELECT name FROM PG_LS_DIR('gentoobrowse') name</sql>
<columns>
<name key="true" />
</columns>
</project2:sqlmerge>
<project2:sqlmerge name="files" datasource="postgres" targettable="files">
<sql>
WITH RECURSIVE filelist AS (
SELECT ('gentoobrowse/' || pg_ls_dir) AS filename, st.size, st.modification, st.isdir
FROM PG_LS_DIR('gentoobrowse'), PG_STAT_FILE('gentoobrowse') st
UNION ALL
SELECT parent.filename || '/' || cur, st.size, st.modification, st.isdir
FROM filelist parent, PG_LS_DIR(parent.filename) cur, PG_STAT_FILE(parent.filename || '/' || cur) st
WHERE parent.isdir
AND cur != 'packages'
AND cur != 'lost+found'
AND cur != 'distfiles'
AND cur NOT LIKE '.%'
)
SELECT
r.repoid,
fl.filename,
ft.filetypeid,
(STRING_TO_ARRAY(fl.filename, '/'))[3:100] pathparts,
fl.size filesize,
fl.modification AT TIME ZONE 'utc' moddate
FROM filelist fl, repos r, filetypes ft
WHERE (STRING_TO_ARRAY(fl.filename, '/'))[2] = r.name
AND (STRING_TO_ARRAY(fl.filename, '/'))[3:100] ~ ft.spec
AND NOT fl.isdir
</sql>
<columns>
<filename key="true" />
<repoid key="true" />
<pathparts />
<filesize />
<moddate />
<filetypeid />
</columns>
</project2:sqlmerge>
</packageimport>
|