From d0f56d00582903dbc758f25c48c743d29852a8d3 Mon Sep 17 00:00:00 2001 From: "A. Wilcox" Date: Thu, 26 Mar 2020 13:54:56 -0500 Subject: Script: Use --keys-dir during base installation If the system APK does not trust the keys specified in the HorizonScript, execution of the script would fail. This commit fixes that omission. --- hscript/script_e.cc | 23 +++++++++++++++-------- 1 file changed, 15 insertions(+), 8 deletions(-) (limited to 'hscript/script_e.cc') diff --git a/hscript/script_e.cc b/hscript/script_e.cc index 91ebe0f..9e30b95 100644 --- a/hscript/script_e.cc +++ b/hscript/script_e.cc @@ -522,13 +522,15 @@ bool Script::execute() const { /* REQ: Runner.Execute.pkginstall.APKDB */ output_info("internal", "initialising APK"); if(opts.test(Simulate)) { - std::cout << "/sbin/apk --root " << targetDirectory() << " --initdb add" + std::cout << "/sbin/apk --root " << targetDirectory() << " --initdb " + << "--keys-dir " << targetDirectory() << "/etc/apk/keys add" << std::endl; } #ifdef HAS_INSTALL_ENV else { if(run_command("/sbin/apk", - {"--root", targetDirectory(), "--initdb", "add"}) != 0) { + {"--root", targetDirectory(), "--initdb", "--keys-dir", + targetDirectory() + "/etc/apk/keys", "add"}) != 0) { EXECUTE_FAILURE("pkginstall"); return false; } @@ -543,26 +545,31 @@ bool Script::execute() const { pkg_list << pkg << " "; } - std::cout << "apk --root " << targetDirectory() << " update" + std::cout << "apk --root " << targetDirectory() << " --keys-dir " + << targetDirectory() << "/etc/apk/keys" << " update" << std::endl; - std::cout << "apk --root " << targetDirectory() << " add " + std::cout << "apk --root " << targetDirectory() << " --keys-dir " + << targetDirectory() << "/etc/apk/keys" << " add " << pkg_list.str() << std::endl; } #ifdef HAS_INSTALL_ENV else { if(run_command("/sbin/apk", - {"--root", targetDirectory(), "update"}) != 0) { + {"--root", targetDirectory(), "--keys-dir", + targetDirectory() + "/etc/apk/keys", "update"}) != 0) { EXECUTE_FAILURE("pkginstall"); return false; } - std::vector params(this->internal->packages.size() + 3); + std::vector params(this->internal->packages.size() + 5); params[0] = "--root"; params[1] = targetDirectory(); - params[2] = "add"; + params[2] = "--keys-dir"; + params[3] = targetDirectory() + "/etc/apk/keys"; + params[4] = "add"; std::copy(this->internal->packages.begin(), this->internal->packages.end(), - params.begin() + 3); + params.begin() + 5); if(run_command("/sbin/apk", params) != 0) { EXECUTE_FAILURE("pkginstall"); -- cgit v1.2.3-60-g2f50