Verified Commit a8489ebe authored by Karel Koci's avatar Karel Koci 🤘 Committed by Karel Koci

Drop package content extra option

This was originaly introduced to allow local packages to be installed.
It was later replaced with localrepo and was marked as obsoleted for
long time.
parent 6d3cad56
......@@ -38,7 +38,7 @@ local WARN = WARN
module "requests"
-- luacheck: globals known_packages package_wrap known_repositories known_repositories_all repo_serial repository repository_get content_requests install uninstall script known_content_packages package
-- luacheck: globals known_packages package_wrap known_repositories known_repositories_all repo_serial repository repository_get content_requests install uninstall script package
-- Verifications fields are same for script, repository and package. Lets define them here once and then just append.
local allowed_extras_verification = {
......@@ -177,14 +177,6 @@ We just store them in an array for future processing.
]]
known_packages = {}
--[[
We store here packages with content extra field. These must be
downloaded and parsed before they are aggregated. But they are
also added to known_packages, this is just list of packages needing
special treatment.
]]
known_content_packages = {}
--[[
This package is just a promise of a real package in the future. It holds the
name and possibly some additional info for the package. Once we go through
......@@ -196,7 +188,7 @@ has been run).
The package has no methods, it's just a stupid structure.
]]
function package(content, pkg, extra)
function package(_, pkg, extra)
-- Minimal typo verification. Further verification is done when actually using the package.
extra = allowed_extras_check_type(allowed_package_extras, "package", extra or {})
extra_check_verification("package", extra)
......@@ -236,12 +228,6 @@ function package(content, pkg, extra)
result.name = pkg
result.tp = "package"
table.insert(known_packages, result)
if extra.content then -- if content is specified, it requires special treatment before aggregation
WARN("Content field of Package command is obsoleted! You can use local repository instead.")
table.insert(known_content_packages, result)
-- We start downloading right away
utils.private(result).content_uri = uri(content, extra.content, extra)
end
return result
end
......
......@@ -30,7 +30,6 @@ local table = table
local string = string
local events_wait = events_wait
local run_util = run_util
local mkdtemp = mkdtemp
local DBG = DBG
local WARN = WARN
local ERROR = ERROR
......@@ -41,7 +40,7 @@ local uri = require "uri"
module "postprocess"
-- luacheck: globals get_repos deps_canon conflicts_canon available_packages pkg_aggregate run get_content_pkgs sort_candidates
-- luacheck: globals get_repos deps_canon conflicts_canon available_packages pkg_aggregate run sort_candidates
function get_repos()
DBG("Getting repos")
......@@ -146,57 +145,6 @@ function get_repos()
end
end
--[[
We have to download and unpack packages with extra field content, because
we don't know their version without seeing their values from field such as
version.
]]
function get_content_pkgs()
local uris = {}
local errors = {}
for _, pkg in pairs(requests.known_content_packages) do
local content_uri = utils.private(pkg).content_uri
table.insert(uris, content_uri)
local function downloaded(ok, data)
if ok then
local tmpdir = mkdtemp()
local pkg_dir = backend.pkg_unpack(data, tmpdir)
local _, _, _, control = backend.pkg_examine(pkg_dir)
-- Remove unpacked package. Because we might run no far than planning.
-- If it is going to be installed, it will be unpacked again.
utils.cleanup_dirs({pkg_dir, tmpdir})
if pkg.name ~= control.Package then
if utils.arr2set(pkg.ignore or {})["content"] then
ERROR("Package content specified for package " .. pkg.name .. ", but it contains package " .. control.Package .. ". Ignoring as requested.")
else
table.insert(errors, utils.exception("corruption", "Package content specified for package " .. pkg.name .. ", but it contains package " .. control.Package))
end
return
end
pkg.candidate = control
pkg.candidate.data = data
pkg.candidate.pkg = pkg
else
if utils.arr2set(pkg.ignore or {})["content"] then
WARN("Can't get content for package " .. pkg.name .. ", " .. data.reason .. ". Ignoring as requested.")
else
table.insert(errors, utils.exception("unreachable", "Can't get content for package " .. pkg.name .. ": " .. data.reason))
end
end
end
content_uri:cback(downloaded)
end
-- Download and extract all content
uri.wait(unpack(uris))
-- Check if we encountered some errors
if next(errors) then
local multi = utils.exception('multiple', "Multiple exceptions (" .. #errors .. ")")
multi.errors = errors
error(multi)
end
end
-- Helper function for deps_canon ‒ handles 0 and 1 item dependencies.
local function dep_size_check(dep)
if not next(dep.sub) then
......@@ -523,7 +471,6 @@ function run()
if repo_errors then
WARN("Not all repositories are available")
end
get_content_pkgs()
pkg_aggregate()
end
......
......@@ -185,67 +185,6 @@ function test_get_repos_broken_nonfatal()
}, requests.known_repositories_all)
end
function test_get_content_pkgs()
local context = sandbox.new("Local")
requests.known_content_packages = {{name="updater"}}
utils.private(requests.known_content_packages[1]).content_uri = uri(context, "file://" .. dir .. "tests/data/updater.ipk")
local expect = {
{
name = "updater",
candidate = {
Status = {"install", "user", "installed"},
Package = "updater",
Version = "129",
Depends = "libc, vixie-cron, openssl-util, libatsha204, curl, cert-backup, opkg, bzip2, cznic-cacert-bundle",
Source = "feeds/turrispackages/cznic/updater",
Section = "opt",
Maintainer = "Michal Vaner <michal.vaner@nic.cz>",
Architecture = "mpc85xx",
Description = "updater",
["Installed-Size"] = "14773",
Conffiles = {["/etc/config/updater"] = "b5cf279732a87011eadfe522a0c163b98682bef2919afc4f96330f9f103a3230"},
files = {
["/usr/bin/updater-unstuck.sh"] = true,
["/etc/config/updater"] = true,
["/usr/share/updater/keys/standby.pem"] = true,
["/etc/ssl/updater.pem"] = true,
["/usr/bin/updater.sh"] = true,
["/usr/bin/updater-wipe.sh"] = true,
["/usr/bin/updater-utils.sh"] = true,
["/etc/init.d/updater"] = true,
["/usr/bin/updater-worker.sh"] = true,
["/usr/share/updater/keys/release.pem"] = true,
["/usr/bin/updater-resume.sh"] = true,
}
}
}
}
expect[1].candidate.pkg = expect[1]
postprocess.get_content_pkgs()
-- set data to nil. We can't check that easily enough. Same goes for Installed-time
requests.known_content_packages[1].candidate.data = nil
requests.known_content_packages[1].candidate["Installed-Time"] = nil
assert_table_equal(expect, requests.known_content_packages)
end
-- Lest break things and expect exception
function test_get_content_pkgs_missing()
local context = sandbox.new("Local")
requests.known_content_packages = {{name="updater"}}
utils.private(requests.known_content_packages[1]).content_uri = uri(context, "file://" .. dir .. "tests/data/nonexistent.ipk")
assert_exception(function() postprocess.get_content_pkgs() end, "multiple")
end
-- Lest break things but ignore it
function test_get_content_pkgs_missing_ignore()
local context = sandbox.new("Local")
requests.known_content_packages = {{name="updater", ignore={"content"}}}
utils.private(requests.known_content_packages[1]).content_uri = uri(context, "file://" .. dir .. "tests/data/nonexistent.ipk")
postprocess.get_content_pkgs()
assert_table_equal({{name="updater", ignore={"content"}}}, requests.known_content_packages)
end
-- Default values for package modifiers to be added if they are not mentioned
local modifier_def = {
tp = "package",
......
......@@ -13,7 +13,6 @@ UPD_SYS_TESTS := \
steal-confs \
simple-update \
multiple-repos \
pkg-content \
reboot \
provides \
provides-replace \
......
sed -i -e 's/^Installed-Time: .*/Installed-Time: 0/' "$ROOT_DIR"/usr/lib/opkg/status
rm "$ROOT_DIR"/config
testpkg = Package("test1", { content = "file://%ROOT_DIR%/test.ipk" })
Install("test1")
Package: test1
Version: 1
License: GPL-2.0
Section: none
Architecture: all
Installed-Size: 0
Description: Test package 1 from repo 1
Package: test1
Version: 1
Status: install user installed
Architecture: all
Installed-Time: 0
file://$ROOT_DIR/config --batch -R "$ROOT_DIR"
sed -i -e "s#%ROOT_DIR%#$ROOT_DIR#" $ROOT_DIR/config
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment