summaryrefslogtreecommitdiffstats
path: root/aports/apkrepo.lua
blob: 16a41c457dd32bb414e489160c0ec623bf41a910 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
local lfs = require('lfs')

local M = {}

function M.update_index(dir, arch, description)
	local indexopt = ""
	local descriptionopt = ""
	local olddir = lfs.currentdir()
	local archdir = ("%s/%s"):format(dir, arch)
	assert(lfs.chdir(archdir), archdir)
	local signed_index = "APKINDEX.tar.gz"
	local unsigned_index = "APKINDEX.tar.gz.unsigned"
	if lfs.attributes(signed_index) then
		indexopt = "--index "..signed_index
	end
	if description then
		descriptionopt="--description "..description
	end
	local indexcmd = ("apk index --quiet %s %s --output '%s' --rewrite-arch %s *.apk")
			:format(indexopt, descriptionopt, unsigned_index, arch)
	local signcmd = "abuild-sign -q "..unsigned_index
	assert(os.execute(indexcmd), indexcmd)
	assert(os.execute(signcmd), signcmd)
	assert(os.rename(unsigned_index, signed_index), signed_index)
	lfs.chdir(olddir)
end

return M