aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/apt-panopticon.lua
diff options
context:
space:
mode:
authoronefang2019-12-25 23:12:12 +1000
committeronefang2019-12-25 23:12:12 +1000
commitdbf65dd0c9b57e92579669a40fb9c9e7a8b2af0a (patch)
tree809183bbba48e52af738d8454e49fe74b377834c /apt-panopticon.lua
parentDon't log some APT.execute() calls. (diff)
downloadapt-panopticon-dbf65dd0c9b57e92579669a40fb9c9e7a8b2af0a.zip
apt-panopticon-dbf65dd0c9b57e92579669a40fb9c9e7a8b2af0a.tar.gz
apt-panopticon-dbf65dd0c9b57e92579669a40fb9c9e7a8b2af0a.tar.bz2
apt-panopticon-dbf65dd0c9b57e92579669a40fb9c9e7a8b2af0a.tar.xz
Proper Updated check.
Diffstat (limited to 'apt-panopticon.lua')
-rwxr-xr-xapt-panopticon.lua43
1 files changed, 41 insertions, 2 deletions
diff --git a/apt-panopticon.lua b/apt-panopticon.lua
index 5493683..b7a35fc 100755
--- a/apt-panopticon.lua
+++ b/apt-panopticon.lua
@@ -591,6 +591,19 @@ local getMirrors = function ()
591 active = false 591 active = false
592 m[t] = d 592 m[t] = d
593-- TODO - Should do some input validation on BaseURL, and everything else. 593-- TODO - Should do some input validation on BaseURL, and everything else.
594 elseif "Rate" == t then
595 local time, unit = d:match('(%d+) *(%a+)')
596 time = tonumber(time)
597 unit = unit:sub(1, 1)
598 m[t] = time .. ' ' .. unit
599 if 'm' == unit then
600 time = time * 60
601 elseif 'h' == unit then
602 time = time * 60 * 60
603 else
604 C('Unknown Rate for mirror ' .. host)
605 end
606 m['Updated'] = time
594 else 607 else
595 m[t] = d 608 m[t] = d
596 end 609 end
@@ -600,9 +613,14 @@ local getMirrors = function ()
600 end 613 end
601 end 614 end
602 if APT.testing("DNSRR") then 615 if APT.testing("DNSRR") then
603 mirrors[APT.options.roundRobin.value] = { ["Protocols"] = { ["http"] = true; ["https"] = true; }; 616 mirrors[APT.options.roundRobin.value] = { ["Protocols"] = { ["http"] = true; ["https"] = true; }; ['Updated'] = 300;
604 ["FQDN"] = APT.options.roundRobin.value; ["Active"] = 'yes'; ["BaseURL"] = APT.options.roundRobin.value; } 617 ["FQDN"] = APT.options.roundRobin.value; ["Active"] = 'yes'; ["BaseURL"] = APT.options.roundRobin.value; }
605 end 618 end
619 local file, e = io.open("results/mirrors.lua", "w+")
620 if nil == file then C("opening mirrors file - " .. e) else
621 file:write(APT.dumpTable(mirrors, "", "mirrors") .. "\nreturn mirrors\n")
622 file:close()
623 end
606 return mirrors 624 return mirrors
607end 625end
608 626
@@ -754,7 +772,12 @@ end
754 772
755local parseRelease = function(host) 773local parseRelease = function(host)
756 local list = {inf = 'Release', parser = parsePackages, out = 'Packages', files = {}, nextf = 'debs'} 774 local list = {inf = 'Release', parser = parsePackages, out = 'Packages', files = {}, nextf = 'debs'}
775 local updated = false
776 local status, now = APT.execute('TZ="GMT" date "+%s"', false)
777 now = tonumber(now:sub(2, -2))
757 for i, n in pairs(releases) do 778 for i, n in pairs(releases) do
779 local status, old = APT.execute([[TZ="GMT" date -d "$(grep '^Date:' results_old/pkgmaster.devuan.org/merged/dists/]] .. n .. [[/Release.SORTED | cut -d ' ' -f 2-)" '+%s']], false)
780 old = tonumber(old:sub(2, -2))
758 for l, o in pairs(releaseFiles) do 781 for l, o in pairs(releaseFiles) do
759 if repoExists(i .. o) then 782 if repoExists(i .. o) then
760 postDownload(host, n, o) 783 postDownload(host, n, o)
@@ -784,13 +807,28 @@ local parseRelease = function(host)
784 os.execute('rm -f results/' .. host .. '/merged/dists/' .. n .. '/Release 2>/dev/null; ') 807 os.execute('rm -f results/' .. host .. '/merged/dists/' .. n .. '/Release 2>/dev/null; ')
785 else 808 else
786-- TODO - compare to the pkgmaster copy. 809-- TODO - compare to the pkgmaster copy.
810 if APT.testing('Updated') then
811 local status, new = APT.execute([[TZ="GMT" date -d "$(grep '^Date:' results/]] .. host .. [[/merged/dists/]] .. n .. [[/Release.SORTED | cut -d ' ' -f 2-)" '+%s']], false)
812 new = tonumber(new:sub(2, -2))
813 local upd = old + APT.mirrors[host].Updated
814 if old ~= new then
815 if upd >= now then
816 W('Release ' .. n .. ' not updated yet, should update @ ' .. os.date('!%F %T', upd), 'http', 'Updated', host)
817 else
818 E('Release ' .. n .. ' not updated, should have updated @ ' .. os.date('!%F %T', upd) .. ', but was last updated @ ' .. os.date('!%F %T', new), 'http', 'Updated', host)
819 end
820 updated = false
821 else
822 updated = true
823 end
824 end
787 end 825 end
788 826
789-- TODO - if it's not Integrity and not reference, then just do a HEAD check and compare file times? 827-- TODO - if it's not Integrity and not reference, then just do a HEAD check and compare file times?
790-- TODO - like we do with debs, pick just the smallest Packages.xz that has changed. 828-- TODO - like we do with debs, pick just the smallest Packages.xz that has changed.
791-- Though we are sorting Release by name, so we can do the diff with the one from results_old, so we'll need to sort by size to. 829-- Though we are sorting Release by name, so we can do the diff with the one from results_old, so we'll need to sort by size to.
792-- pkgmaster still needs to download all the changed Packages.xz files though. 830-- pkgmaster still needs to download all the changed Packages.xz files though.
793 if APT.testing("Integrity") or (APT.options.referenceSite.value == host) then 831 if updated or APT.testing("Integrity") or (APT.options.referenceSite.value == host) then
794 local dfile, e = io.open(outFile, "r") 832 local dfile, e = io.open(outFile, "r")
795 if nil == dfile then W("opening " .. outFile .. " file - " .. e) else 833 if nil == dfile then W("opening " .. outFile .. " file - " .. e) else
796 for l in dfile:lines() do 834 for l in dfile:lines() do
@@ -931,6 +969,7 @@ if 0 < #arg then
931 I("Starting tests for " .. arg[1] .. " with these tests - " .. table.concat(APT.options.tests.value, ", ")) 969 I("Starting tests for " .. arg[1] .. " with these tests - " .. table.concat(APT.options.tests.value, ", "))
932 if nil ~= arg[2] then I(" Using IP " .. arg[2]); ip = arg[2] end 970 if nil ~= arg[2] then I(" Using IP " .. arg[2]); ip = arg[2] end
933 if nil ~= arg[3] then I(" Using file " .. arg[3]); end 971 if nil ~= arg[3] then I(" Using file " .. arg[3]); end
972 APT.mirrors = loadfile("results/mirrors.lua")()
934 APT.results = APT.padResults(APT.results) 973 APT.results = APT.padResults(APT.results)
935 974
936 if APT.origin then 975 if APT.origin then