X-Git-Url: https://pd.if.org/git/?a=blobdiff_plain;f=lib%2Ffindpkg.c;h=6d7981a315055bbe50024fe73b3fe6ca34e3a698;hb=c42bb61b39cceab59c17d352f2593f3a5239a27d;hp=6ea843cbecad5f39d6d5d280055734f23702a78e;hpb=622e72618da01e320a5303ef588f9220e8a78558;p=zpackage diff --git a/lib/findpkg.c b/lib/findpkg.c index 6ea843c..6d7981a 100644 --- a/lib/findpkg.c +++ b/lib/findpkg.c @@ -36,11 +36,15 @@ void zpm_sqlite_error(struct zpm *zpm) { } char *zpm_findlib(struct zpm *zpm, char *soname, char *where) { - char *select = "select pkgid, package, version, release from packagefiles_status join elflibraries on file = hash"; - char *group = "order by package, version collate vercmp desc, cast(release as integer)"; sqlite3_str *sql; char *query, *pkgid = 0; +char *select = "select printf('%%s-%%s-%%s',P.package,P.version,P.release) as pkgid, P.package, P.version, P.release\ + from packagefiles PF\ + join elflibraries EL on EL.file = PF.hash\ + join packages P on P.package = PF.package and P.version = PF.version and P.release = PF.release"; + char *order = "order by P.package, P.version, cast(P.release as integer)"; + /* null pkgstr find "best" package * best is shortest complete package if any are complete * shortest incomplete if any are incomplete @@ -51,7 +55,7 @@ char *zpm_findlib(struct zpm *zpm, char *soname, char *where) { sql = sqlite3_str_new(zpm->db); sqlite3_str_appendall(sql, select); - sqlite3_str_appendf(sql, " where soname = %Q", soname); + sqlite3_str_appendf(sql, " where P.hash is not null and EL.soname = %Q", soname); if (where) { sqlite3_str_appendall(sql, " and "); @@ -59,7 +63,7 @@ char *zpm_findlib(struct zpm *zpm, char *soname, char *where) { } sqlite3_str_appendall(sql, " "); - sqlite3_str_appendall(sql, group); + sqlite3_str_appendall(sql, order); sqlite3_str_appendall(sql, " limit 1;"); if (sqlite3_str_errcode(sql)) {