From af9eb91e8f9985f23d9ff8dfc4c6ce8c979a9dcf Mon Sep 17 00:00:00 2001 From: Carlo Landmeter Date: Sun, 22 Mar 2015 19:24:35 +0000 Subject: add arch to queries and cleanup package tpl --- aports.lua | 26 +++++++++++++------------- tpl/package.tpl | 16 ++++------------ 2 files changed, 17 insertions(+), 25 deletions(-) diff --git a/aports.lua b/aports.lua index fea447d..bf06a43 100755 --- a/aports.lua +++ b/aports.lua @@ -81,11 +81,11 @@ function PackageRenderer:get(arch, name) if table ~= nil then table.install_size = human_bytes(table.install_size) table.size = human_bytes(table.size) - table.deps = QueryDeps(table.deps) + table.deps = QueryDeps(table.deps, arch) table.deps_qty = (table.deps ~= nil) and #table.deps or "0" - table.reqbys = QueryRequiredBy(table.provides) - table.reqdeps_qty = (table.reqdeps ~= nil) and #table.reqdeps or "0" - table.subpkgs = QuerySubPackages(table.origin, table.name) + table.reqbys = QueryRequiredBy(table.provides, arch) + table.reqbys_qty = (table.reqbys ~= nil) and #table.reqbys or "0" + table.subpkgs = QuerySubPackages(table.origin, table.name, arch) table.subpkgs_qty = (table.subpkgs ~= nil) and #table.subpkgs or "0" table.maintainer = (table.maintainer ~= "") and string.gsub(table.maintainer, '<.*>', '') or "None" for k in pairs (table) do @@ -158,14 +158,14 @@ function QueryPackage(name, arch) return r end -function QueryDeps(deps) +function QueryDeps(deps, arch) require('DBI') local names = {} local dbh = assert(DBI.Connect('SQLite3', 'db/apkindex.db')) - local sth = assert(dbh:prepare('select name from apkindex where provides like ?')) + local sth = assert(dbh:prepare('select name from apkindex where provides like ? and arch like ?')) for _,k in pairs (deps:split(" ")) do if k:begins('so:') then - sth:execute("%"..k.."%") + sth:execute("%"..k.."%", arch) local l = sth:fetch(true) if l ~= nil then names[l.name] = l.name @@ -184,15 +184,15 @@ function QueryDeps(deps) end end -function QueryRequiredBy(provides) +function QueryRequiredBy(provides, arch) require('DBI') local names = {} local dbh = assert(DBI.Connect('SQLite3', 'db/apkindex.db')) - local sth = assert(dbh:prepare('select name from apkindex where deps like ?')) + local sth = assert(dbh:prepare('select name from apkindex where deps like ? and arch like ?')) for _,d in pairs (provides:split(" ")) do if d:begins('so:') then d = string.gsub(d, '=.*', '') - sth:execute("%"..d.."%") + sth:execute("%"..d.."%", arch) for row in sth:rows(true) do if row ~= nil then names[row.name] = row.name @@ -210,12 +210,12 @@ function QueryRequiredBy(provides) end end -function QuerySubPackages(origin, name) +function QuerySubPackages(origin, name, arch) require('DBI') local names = {} local dbh = assert(DBI.Connect('SQLite3', 'db/apkindex.db')) - local sth = assert(dbh:prepare('select name from apkindex where origin like ?')) - sth:execute(origin) + local sth = assert(dbh:prepare('select name from apkindex where origin like ? and arch like ?')) + sth:execute(origin, arch) local r = {} for row in sth:rows(true) do if row.name ~= name then diff --git a/tpl/package.tpl b/tpl/package.tpl index 9114555..898faa0 100644 --- a/tpl/package.tpl +++ b/tpl/package.tpl @@ -25,7 +25,7 @@ Project: - URL + {{{url}}} Licence: @@ -35,10 +35,6 @@ Architecture: {{{arch}}} - - Checksum: - {{{csum}}} - Size: {{{size}}} @@ -46,14 +42,10 @@ Installed size: {{{install_size}}} - {{/install_size}}{{#provides}} - - Provides: - {{{provides}}} - {{/provides}}{{#install_if}} + {{/install_size}}{{#install_if}} Install if: - {{{install_if}}} + {{{install_if}}} {{/install_if}}{{#name}} Origin: @@ -96,7 +88,7 @@
    {{#reqbys}} -- cgit v1.2.3