1 create view preserve_packages as
2 with package_libraries_status as (
3 select P.package, P.release, P.version, P.status, EL.soname
6 join packagefiles PF on PF.hash = EL.file
8 on P.package = PF.package and P.version = PF.version and P.release = PF.release
10 , package_libraries_needed_status as (
12 P.package, P.release, P.version, P.status, EN.needed as soname, group_concat(PF.path) as needed_by
15 join packagefiles PF on PF.hash = EN.file
17 on P.package = PF.package and P.version = PF.version and P.release = PF.release
18 group by P.package, P.release, P.version, P.status, EN.needed
21 PLS.package, PLS.version, PLS.release, PLS.soname
22 ,PLN.package as npackage, PLN.version as nversion, PLN.release as nrelease, PLN.needed_by
23 --,PLI.soname, PLI.package, PLI.version, PLI.release
24 from package_libraries_needed_status PLN
25 join package_libraries_status PLS
26 on PLN.soname = PLS.soname
27 and PLN.status = 'installed'
28 and PLS.status != 'installed'
29 left join package_libraries_status PLI
30 on PLI.status = 'installed'
31 and PLI.soname = PLN.soname
32 where PLI.package is null