summaryrefslogtreecommitdiffstats
path: root/aports/pkg.lua
diff options
context:
space:
mode:
authorNatanael Copa <ncopa@alpinelinux.org>2014-01-01 13:49:02 +0000
committerNatanael Copa <ncopa@alpinelinux.org>2014-01-01 13:49:02 +0000
commit188bb4489afd5cc47e52a6590abb5543c27bad94 (patch)
tree6746c4cacbe28c0b8780939a11e28d2c5f85f064 /aports/pkg.lua
parentc82b489c1d8289949e6360d06b1457299917dd1e (diff)
downloadlua-aports-188bb4489afd5cc47e52a6590abb5543c27bad94.tar.bz2
lua-aports-188bb4489afd5cc47e52a6590abb5543c27bad94.tar.xz
pkg: add apk_file_exists()
tests if the .apk file exists for the given package
Diffstat (limited to 'aports/pkg.lua')
-rw-r--r--aports/pkg.lua20
1 files changed, 16 insertions, 4 deletions
diff --git a/aports/pkg.lua b/aports/pkg.lua
index 276a7b8..c25a0f8 100644
--- a/aports/pkg.lua
+++ b/aports/pkg.lua
@@ -80,14 +80,25 @@ end
function M.get_apk_file_path(pkg)
local pkgdest = abuild.get_conf("PKGDEST")
if pkgdest ~= nil and pkgdest ~= "" then
- return pkgdest.."/"..M.get_apk_filename(pkg)
+ return pkgdest.."/"..M.get_apk_file_name(pkg)
end
local repodest = abuild.get_conf("REPODEST")
if repodest ~= nil and repodest ~= "" then
- local arch = abuild.get_conf("CARCH")
- return repodest.."/"..M.get_repo_name(pkg).."/"..arch.."/"..M.get_apk_filename(pkg)
+ local arch = abuild.get_arch()
+ return repodest.."/"..M.get_repo_name(pkg).."/"..arch.."/"..M.get_apk_file_name(pkg)
end
- return pkg.dir.."/"..M.get_apk_filename(pkg)
+ return pkg.dir.."/"..M.get_apk_file_name(pkg)
+end
+
+function M.apk_file_exists(pkg)
+ -- technically we check if it is readable...
+ local filepath = M.get_apk_file_path(pkg)
+ local f = io.open(filepath)
+ if f == nil then
+ return false
+ end
+ f:close()
+ return true
end
function M.init(pkg)
@@ -97,5 +108,6 @@ function M.init(pkg)
pkg.get_repo_name = M.get_repo_name
pkg.get_apk_file_name = M.get_apk_file_name
pkg.get_apk_file_path = M.get_apk_file_path
+ pkg.apk_file_exists = M.apk_file_exists
end
return M