From 0285f2e10b570d5ba4145fc7df0db875faff471a Mon Sep 17 00:00:00 2001 From: Carlo Landmeter Date: Tue, 30 Jan 2018 23:17:30 +0000 Subject: switch mirrors source to alpine infra/mirrors repo --- config.sample.lua | 3 ++- generate-html.lua | 8 +------- generate-json.lua | 13 ++++--------- 3 files changed, 7 insertions(+), 17 deletions(-) diff --git a/config.sample.lua b/config.sample.lua index e6088f9..20e2fb1 100644 --- a/config.sample.lua +++ b/config.sample.lua @@ -2,7 +2,8 @@ local conf = {} conf.version = "v0.0.1" conf.apkindex_list = "apkindex.list" -conf.mirrors_yaml = "https://git.alpinelinux.org/cgit/aports/plain/main/alpine-mirrors/mirrors.yaml" +-- private.yaml is taken from alpine mirrors repo +conf.mirrors_yaml = "/path/to/private.yaml" conf.master_url = "http://rsync.alpinelinux.org/alpine/" conf.outdir = "_out" conf.mirrors_html = "index.html" diff --git a/generate-html.lua b/generate-html.lua index feb8caa..e3038ff 100755 --- a/generate-html.lua +++ b/generate-html.lua @@ -3,7 +3,6 @@ local json = require("cjson") local lustache = require("lustache") local yaml = require("lyaml") -local request = require("http.request") local utils = require("utils") local conf = require("config") @@ -128,12 +127,7 @@ end function get_mirrors() - local headers, stream = assert(request.new_from_uri(conf.mirrors_yaml):go()) - if headers:get(":status") ~= "200" then - error("Failed to get mirrors yaml!") - end - local y = assert(stream:get_body_as_string()) - local mirrors = yaml.load(y) + local mirrors = yaml.load(utils.read_file(conf.mirrors_yaml)) for a,mirror in pairs(mirrors) do mirrors[a].location = mirror.location or "Unknown" mirrors[a].bandwidth = mirror.bandwidth or "Unknown" diff --git a/generate-json.lua b/generate-json.lua index f134da4..0d7fcb9 100755 --- a/generate-json.lua +++ b/generate-json.lua @@ -34,15 +34,9 @@ function rfc2616_date_to_ts(s) end ---- --- get a list of http urls from mirrors yaml -function get_mirrors(uri) +-- get a list of http urls from private yaml from mirrors repo +function get_mirrors(y) local res = {} - local headers, stream = assert(request.new_from_uri(uri):go()) - if headers:get(":status") ~= "200" then - error("Failed to get mirrors yaml!") - end - local y = assert(stream:get_body_as_string()) - stream:shutdown() local mirrors = yaml.load(y) for idx, mirror in ipairs(mirrors) do for _,url in ipairs(mirror.urls) do @@ -124,7 +118,8 @@ end function process_mirrors() local res = {} - local mirrors = get_mirrors(conf.mirrors_yaml) + local mirrors = get_mirrors(utils.read_file(conf.mirrors_yaml)) + --local mirrors = json.decode(utils.read_file(conf.mirrors_json)) for idx,mirror in ipairs(mirrors) do local start_time = os.time() res[idx] = {} -- cgit v1.2.3