summaryrefslogtreecommitdiffstats
path: root/secfixes.lua
diff options
context:
space:
mode:
authorNatanael Copa <ncopa@alpinelinux.org>2016-12-23 18:13:23 +0100
committerNatanael Copa <ncopa@alpinelinux.org>2016-12-23 18:13:23 +0100
commit9997d1011bb191734519aeed66c150b3f83875e8 (patch)
treed25d83a6dc4e37d9f04009fe99b0fb422d17a978 /secfixes.lua
parent93897c8b89f771b177233fddab51121a0ffe5c6a (diff)
downloadalpine-secdb-9997d1011bb191734519aeed66c150b3f83875e8.tar.bz2
alpine-secdb-9997d1011bb191734519aeed66c150b3f83875e8.tar.xz
add script that generates the yaml from aports tree
Diffstat (limited to 'secfixes.lua')
-rw-r--r--secfixes.lua60
1 files changed, 60 insertions, 0 deletions
diff --git a/secfixes.lua b/secfixes.lua
new file mode 100644
index 0000000..0788726
--- /dev/null
+++ b/secfixes.lua
@@ -0,0 +1,60 @@
+-- script to parse the aports tree and generate the secdb yaml
+
+yaml = require('lyaml')
+
+function read_apkbuild(file)
+ local repo, pkg = file:match("([a-z]+)/([^/]+)/APKBUILD")
+ local f = io.open(file)
+ if f == nil then
+ return
+ end
+ while true do
+ line = f:read("*line")
+ if line == nil then
+ break
+ end
+ if line:match("^# secfixes") then
+ local y = " - pkg:\n"..
+ " name: "..pkg.."\n"
+ while line ~= nil and line:match("^#") do
+ local l = line:gsub("^# ", " ")
+ if l == nil then
+ break
+ end
+ y = y..l.."\n"
+ line = f:read("*line")
+ end
+ f:close()
+ io.write(y)
+ return
+ end
+ end
+ f:close()
+end
+
+opthelp = [[
+ --repo=REPO set repository
+]]
+
+opts, args = require('optarg').from_opthelp(opthelp)
+
+repo = (opts.repo or "main")
+distroversion = "v3.4"
+
+-- print header
+io.write(([[
+---
+distroversion: %s
+reponame: %s
+archs:
+ - x86_64
+ - x86
+ - armhf
+urlprefix: http://dl-cdn.alpinelinux.org/alpine
+apkurl: "{{urlprefix}}/{{distroversion}}/{{reponame}}/{{arch}}/{{pkg.name}}-{{pkg.ver}}.apk"
+packages:
+]]):format(distroversion, repo))
+
+for i = 1,#arg do
+ read_apkbuild(arg[i])
+end