summaryrefslogtreecommitdiff
path: root/hscript/script_v.cc
diff options
context:
space:
mode:
authorA. Wilcox <AWilcox@Wilcox-Tech.com>2020-05-26 02:42:30 -0500
committerA. Wilcox <AWilcox@Wilcox-Tech.com>2020-05-26 02:42:30 -0500
commit8b00a5779ace2b919f6d9f31fb50d37086a78914 (patch)
treeae07a14086aead37138c494207515e8e2ee914c4 /hscript/script_v.cc
parent441543b73cffd6c589e4c848113dd126d984e07f (diff)
downloadhorizon-8b00a5779ace2b919f6d9f31fb50d37086a78914.tar.gz
horizon-8b00a5779ace2b919f6d9f31fb50d37086a78914.tar.bz2
horizon-8b00a5779ace2b919f6d9f31fb50d37086a78914.tar.xz
horizon-8b00a5779ace2b919f6d9f31fb50d37086a78914.zip
hscript: Implement (undocumented, untested) 'version' key
Diffstat (limited to 'hscript/script_v.cc')
-rw-r--r--hscript/script_v.cc26
1 files changed, 14 insertions, 12 deletions
diff --git a/hscript/script_v.cc b/hscript/script_v.cc
index b91af8d..173bb50 100644
--- a/hscript/script_v.cc
+++ b/hscript/script_v.cc
@@ -107,11 +107,16 @@ int validate_one_account(const std::string &name, UserDetail *detail) {
*/
bool add_default_repos(std::vector<std::unique_ptr<Repository>> &repos,
const Script *s, bool firmware = false) {
+ std::string base_url = "https://distfiles.adelielinux.org/adelie/";
+ const ScriptLocation p{"internal", 0};
+ const Key *ver = s->getOneValue("version");
+ if(ver != nullptr) {
+ base_url += dynamic_cast<const StringKey *>(ver)->value() + "/";
+ } else {
+ base_url += "stable/";
+ }
Repository *sys_key = dynamic_cast<Repository *>(
- Repository::parseFromData(
- "https://distfiles.adelielinux.org/adelie/stable/system", {"", 0},
- nullptr, nullptr, s
- )
+ Repository::parseFromData(base_url + "system", p, nullptr, nullptr, s)
);
if(!sys_key) {
output_error("internal", "failed to create default system repository");
@@ -120,10 +125,7 @@ bool add_default_repos(std::vector<std::unique_ptr<Repository>> &repos,
std::unique_ptr<Repository> sys_repo(sys_key);
repos.push_back(std::move(sys_repo));
Repository *user_key = dynamic_cast<Repository *>(
- Repository::parseFromData(
- "https://distfiles.adelielinux.org/adelie/stable/user", {"", 0},
- nullptr, nullptr, s
- )
+ Repository::parseFromData(base_url + "user", p, nullptr, nullptr, s)
);
if(!user_key) {
output_error("internal", "failed to create default user repository");
@@ -138,7 +140,7 @@ bool add_default_repos(std::vector<std::unique_ptr<Repository>> &repos,
Repository *fw_key = dynamic_cast<Repository *>(
Repository::parseFromData(
"https://distfiles.apkfission.net/adelie-stable/nonfree",
- 0, nullptr, nullptr, s
+ {"internal", 0}, nullptr, nullptr, s
)
);
if(!fw_key) {
@@ -163,8 +165,8 @@ bool add_default_repo_keys(std::vector<std::unique_ptr<SigningKey>> &keys,
const Script *s, bool firmware = false) {
SigningKey *key = dynamic_cast<SigningKey *>(
SigningKey::parseFromData(
- "/etc/apk/keys/packages@adelielinux.org.pub", {"", 0},
- nullptr, nullptr, s)
+ "/etc/apk/keys/packages@adelielinux.org.pub",
+ {"internal", 0}, nullptr, nullptr, s)
);
if(!key) {
output_error("internal", "failed to create default repository signing key");
@@ -178,7 +180,7 @@ bool add_default_repo_keys(std::vector<std::unique_ptr<SigningKey>> &keys,
if(firmware) {
SigningKey *fkey = dynamic_cast<SigningKey *>(SigningKey::parseFromData(
"/etc/apk/keys/packages@pleroma.apkfission.net-5ac0b300.rsa.pub",
- {"", 0}, nullptr, nullptr, s)
+ {"internal", 0}, nullptr, nullptr, s)
);
if(!fkey) {
output_error("internal", "failed to create firmware signing key");