mirror of
https://gitlab.alpinelinux.org/alpine/abuild.git
synced 2025-01-24 16:22:57 +00:00
aports.lua: parse source strings
This commit is contained in:
parent
4335602da9
commit
0b605e179e
14
ap.in
14
ap.in
@ -68,6 +68,20 @@ subcmd.builddirs = {
|
||||
end
|
||||
}
|
||||
|
||||
subcmd.sources = {
|
||||
desc = "List sources",
|
||||
usage = "PKG...",
|
||||
run = function(opts)
|
||||
local i, p, _
|
||||
for i = 2, #opts do
|
||||
db:foreach_pkg(opts[i], function(_, p)
|
||||
aports.foreach_remote_source(p, function(url)
|
||||
print(p.pkgname, p.pkgver, string.gsub(url, p.pkgver, "$VERSION"))
|
||||
end)
|
||||
end)
|
||||
end
|
||||
end
|
||||
}
|
||||
|
||||
function print_usage()
|
||||
io.write("usage: ap -d <DIR> SUBCOMMAND [options]\n\nSubcommands are:\n")
|
||||
|
41
aports.lua
41
aports.lua
@ -1,6 +1,6 @@
|
||||
module(..., package.seeall)
|
||||
|
||||
local function split(str)
|
||||
local function split_subpkgs(str)
|
||||
local t = {}
|
||||
local e
|
||||
if (str == nil) then
|
||||
@ -12,16 +12,28 @@ local function split(str)
|
||||
return t
|
||||
end
|
||||
|
||||
local function split(str)
|
||||
local t = {}
|
||||
local e
|
||||
if (str == nil) then
|
||||
return nil
|
||||
end
|
||||
for e in string.gmatch(str, "%S+") do
|
||||
t[#t + 1] = e
|
||||
end
|
||||
return t
|
||||
end
|
||||
|
||||
local function split_apkbuild(line)
|
||||
local r = {}
|
||||
local dir,pkgname, pkgver, pkgrel, arch, depends, makedepends, subpackages, source = string.match(line, "([^|]*)|([^|]*)|([^|]*)|([^|]*)|([^|]*)|([^|]*)|([^|]*)|([^|]*)")
|
||||
local dir,pkgname, pkgver, pkgrel, arch, depends, makedepends, subpackages, source = string.match(line, "([^|]*)|([^|]*)|([^|]*)|([^|]*)|([^|]*)|([^|]*)|([^|]*)|([^|]*)|([^|]*)")
|
||||
r.dir = dir
|
||||
r.pkgname = pkgname
|
||||
r.pkgver = pkgver
|
||||
r.pkgrel = pkgrel
|
||||
r.depends = split(depends)
|
||||
r.makedepends = split(makedepends)
|
||||
r.subpackages = split(subpackages)
|
||||
r.subpackages = split_subpkgs(subpackages)
|
||||
r.source = split(source)
|
||||
return r
|
||||
end
|
||||
@ -86,6 +98,29 @@ function all_deps(p)
|
||||
return m
|
||||
end
|
||||
|
||||
function is_remote(url)
|
||||
local _,pref
|
||||
for _,pref in pairs{ "^http://", "^ftp://", "^https://" } do
|
||||
if string.match(url, pref) then
|
||||
return true
|
||||
end
|
||||
end
|
||||
return false
|
||||
end
|
||||
|
||||
-- iterate over all entries in source and execute the function for remote
|
||||
function foreach_remote_source(p, func)
|
||||
local _,s
|
||||
if p == nil or type(p.source) ~= "table" then
|
||||
return
|
||||
end
|
||||
for _,url in pairs(p.source) do
|
||||
if is_remote(url) then
|
||||
func(url)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
local function init_apkdb(repodirs)
|
||||
local pkgdb = {}
|
||||
local revdeps = {}
|
||||
|
Loading…
Reference in New Issue
Block a user