1 create view syncinfo as
3 -- paths to libraries we need to keep around
7 join elflibraries EL on EL.file = PFL.hash
8 join elfneeded EN on EN.needed = EL.soname
9 join packagefiles PFN on EN.file = PFN.hash
11 on PFN.package = PN.package and PFN.version = PN.version and PFN.release = PN.release
13 PN.status = 'installing' or PN.status = 'installed'
14 and not (PFN.package = PFL.package and PFN.version = PFN.version and PFN.release = PFL.release)
19 join elflibraries EL on EL.file = PF.hash
20 join elfneeded EN on EN.needed = EL.soname
21 join packagefiles PL on EN.file = PL.hash
23 on PL.path = P.package and PL.version = P.version and PL.release = P.release
25 P.status = 'removing' or P.status = 'installed' or P.status = 'updating'
28 -- every path in 'installing' is either new or update, or no-op
31 when PFC.path is null and PFC.path not in (select path from waspreserved) then 'new'
33 printf('%s:%s:%s:%s', PFI.filetype, PFI.mode, PFI.username, PFI.groupname) is
34 printf('%s:%s:%s:%s', PFC.filetype, PFC.mode, PFC.username, PFC.groupname)
35 and PFI.hash is PFC.hash
39 printf('%s-%s-%s', PFI.package, PFI.version, PFI.release) as pkgid,
41 PFI.username, PFI.uid, PFI.groupname, PFI.gid, PFI.mode, PFI.filetype,
43 PFI.configuration + case when PFC.configuration = 1 then 2 else 0 end
45 PFI.target, PFI.device,
47 printf('%s:%s:%s:%s', PFI.filetype, PFI.mode, PFI.username, PFI.groupname) as mds,
48 printf('%s:%s:%s:%s', PFC.filetype, PFC.mode, PFC.username, PFC.groupname) as omds
52 on PFI.package = PI.package and PFI.version = PI.version and PFI.release = PI.release
54 on PC.package = PI.package and PC.status in ('installed','removing','updating')
55 left join packagefiles PFC
56 on PFC.package = PC.package
57 and PFC.version = PC.version
58 and PFC.release = PC.release
59 and PFC.path = PFI.path
61 PI.status = 'installing'
63 -- every path in updating is either remove or no-op
66 printf('%s-%s-%s', PFU.package, PFU.version, PFU.release) as pkgid,
68 PFU.username, PFU.uid, PFU.groupname, PFU.gid, PFU.mode, PFU.filetype,
70 PFU.configuration + case when PFC.configuration = 1 then 2 else 0 end
72 PFU.target, PFU.device,
74 printf('%s:%s:%s:%s', PFU.filetype, PFU.mode, PFU.username, PFU.groupname) as mds,
78 on PFU.package = PU.package and PFU.version = PU.version and PFU.release = PU.release
79 -- inner join because the installing package must exist or this shouldn't
80 -- be an 'updating' package
81 join packages P on PU.package = P.package and P.status = 'installing'
82 left join packagefiles PFI on
83 PFI.package = P.package
84 and PFI.version = P.version
85 and PFI.release = P.release
86 and PFI.path = PFU.path
88 -- handle paths owned by other installed packages
89 left join packages PI on PI.status = 'installed'
90 left join packagefiles PFC
91 on PFC.package = PI.package and PFC.version = PI.version and PFC.release = PI.release and PFC.path = PFU.path
94 PU.status in ('updating')
97 and PFU.path not in (select path from preserve)
99 -- every path in removing is either remove or no-op
100 -- not true, could be an update, but should be handled above
103 printf('%s-%s-%s', PFR.package, PFR.version, PFR.release) as pkgid,
105 PFR.username, PFR.uid, PFR.groupname, PFR.gid, PFR.mode, PFR.filetype,
107 PFR.configuration + case when PFC.configuration = 1 then 2 else 0 end
109 PFR.target, PFR.device,
111 printf('%s:%s:%s:%s', PFR.filetype, PFR.mode, PFR.username, PFR.groupname) as mds,
113 from packagefiles PFR
115 on PFR.package = PU.package and PFR.version = PU.version and PFR.release = PU.release
116 left join packages P on PU.package = P.package and P.status = 'installing'
117 left join packagefiles PFI on PFI.path = PFR.path
118 and PFI.package = P.package and PFI.version = P.version and PFI.release = P.release
120 -- handle paths owned by other installed packages
121 left join packages PI on PI.status = 'installed'
122 left join packagefiles PFC
123 on PFC.package = PI.package and PFC.version = PI.version and PFC.release = PI.release and PFC.path = PFR.path
126 PU.status in ('removing')
129 and PFR.path not in (select path from preserve)
131 -- paths in 'installed' or 'updated' are no-ops
135 printf('%s-%s-%s', PFP.package, PFP.version, PFP.release) as pkgid,
137 PFP.username, PFP.uid, PFP.groupname, PFP.gid, PFP.mode, PFP.filetype,
139 PFP.configuration as configuration,
140 PFP.target, PFP.device,
142 printf('%s:%s:%s:%s', PFP.filetype, PFP.mode, PFP.username, PFP.groupname) as mds,
145 -- TODO don't include installed or installing
146 -- left join packages P on P.package = PFP.package ...
147 -- where P.status not in ('installed','installing')