1 create view syncinfo as
3 -- paths to libraries we need to keep around
8 join elflibraries EL on EL.file = PFL.hash
9 join elfneeded EN on EN.needed = EL.soname
10 join packagefiles PFN on EN.file = PFN.hash
12 on PFN.package = PN.package and PFN.version = PN.version and PFN.release = PN.release
14 PN.status = 'installing' or PN.status = 'installed'
15 and not (PFN.package = PFL.package and PFN.version = PFN.version and PFN.release = PFL.release)
20 join elflibraries EL on EL.file = PF.hash
21 join elfneeded EN on EN.needed = EL.soname
22 join packagefiles PL on EN.file = PL.hash
24 on PL.path = P.package and PL.version = P.version and PL.release = P.release
26 P.status = 'removing' or P.status = 'installed' or P.status = 'updating'
29 -- every path in 'installing' is either new or update, or no-op
30 -- but we have to calculate them separately I think.
31 -- once for new, once for update, and once for no-op, might be able
32 -- to combine update and no-op
35 printf('%s-%s-%s', PFI.package, PFI.version, PFI.release) as pkgid,
36 PFI.path, PFI.username, PFI.uid, PFI.groupname, PFI.gid, PFI.mode,
37 PFI.filetype, PFI.mtime, PFI.hash,
39 -- + case when PFC.configuration = 1 then 2 else 0 end
41 PFI.target, PFI.device, null as ohash,
42 printf('%s:%s:%s:%s', PFI.filetype, PFI.mode, PFI.username, PFI.groupname) as mds,
43 --printf('%s:%s:%s:%s', PFC.filetype, PFC.mode, PFC.username, PFC.groupname) as omds
49 on PFI.package = PI.package and PFI.version = PI.version and PFI.release = PI.release
52 left join packagefiles PFC on PFI.path = PFC.path
55 on (PFI.package is not PC.package or PFI.release is not PC.release or PC.version is not PFI.version)
56 and PC.status in ('installed','removing','updating')
57 and PFC.package = PC.package and PFC.version = PC.version and PFC.release = PC.release
61 PI.status = 'installing'
63 not exists (select PFC.path
66 on PFC.package = PC.package and PFC.version = PC.version and PFC.release = PC.release
67 where PFC.path = PFI.path
68 and PC.status in ('installed','removing','updating')
74 PC.status not in ('installed','removing','updating')
78 -- every path in updating and removing is either remove or no-op
79 -- not true, could be an update, but should be handled above
84 when PFI.filetype is PFC.filetype
85 and PFI.mode is PFC.mode and PFI.username is PFC.username
86 and PFI.groupname is PFC.groupname and PFI.hash is PFC.hash
88 when PC.status = 'installed' then 'md conflict'
91 printf('%s-%s-%s', PFI.package, PFI.version, PFI.release) as pkgid,
92 PFI.path, PFI.username, PFI.uid, PFI.groupname, PFI.gid, PFI.mode,
93 PFI.filetype, PFI.mtime, PFI.hash,
94 PFI.configuration + case when PFC.configuration = 1 then 2 else 0 end
96 PFI.target, PFI.device, PFC.hash as ohash,
97 printf('%s:%s:%s:%s', PFI.filetype, PFI.mode, PFI.username, PFI.groupname) as mds,
98 printf('%s:%s:%s:%s', PFC.filetype, PFC.mode, PFC.username, PFC.groupname) as omds
103 on PFI.package = P.package and PFI.version = P.version and PFI.release = P.release
105 join packagefiles PFC on PFI.path = PFC.path
108 on (PFI.package is not PC.package or PFI.release is not PC.release or PC.version is not PFI.version)
109 -- er, no, it's a conflict if it's in installed and it doesn't match
110 and PC.status in ('installed','updating','removing')
111 and PFC.package = PC.package and PFC.version = PC.version and PFC.release = PC.release
114 P.status = 'installing'
115 --and PFC.path is not null
118 -- every path in updating and removing is either remove or no-op
119 -- not true, could be an update, but should be handled above
122 printf('%s-%s-%s', PFR.package, PFR.version, PFR.release) as pkgid,
124 PFR.username, PFR.uid, PFR.groupname, PFR.gid, PFR.mode, PFR.filetype,
127 --PFR.target, coalesce(P.status, ' null status '), --PFR.device,
128 -- PFI.path, coalesce(PFI.status, ' null status '), --PFR.device,
129 PFR.target, PFR.device,
132 printf('%s:%s:%s:%s', PFR.filetype, PFR.mode, PFR.username, PFR.groupname) as mds,
134 from packagefiles PFR
136 on PFR.package = PU.package and PFR.version = PU.version and PFR.release = PU.release
137 and PU.status in ('removing','updating')
140 not exists (select path from
143 on PFI.package = P.package and PFI.version = P.version and PFI.release = P.release and P.status in ('installing','installed')
144 where PFI.path = PFR.path
148 -- paths in 'installed' or 'updated' are no-ops
152 printf('%s-%s-%s', PFP.package, PFP.version, PFP.release) as pkgid,
154 PFP.username, PFP.uid, PFP.groupname, PFP.gid, PFP.mode, PFP.filetype,
156 PFP.configuration as configuration,
157 PFP.target, PFP.device,
159 printf('%s:%s:%s:%s', PFP.filetype, PFP.mode, PFP.username, PFP.groupname) as mds,
162 -- TODO don't include installed or installing
163 -- left join packages P on P.package = PFP.package ...
164 -- where P.status not in ('installed','installing')