summaryrefslogtreecommitdiffstats
path: root/updater/install.cpp
diff options
context:
space:
mode:
authorYifan Hong <elsk@google.com>2020-04-28 22:31:11 +0200
committerYifan Hong <elsk@google.com>2020-05-08 04:25:26 +0200
commitdff80042750992ed635056cd9719481a14f93007 (patch)
tree7ceaaab834a5f056639d4c168a0a88b066981109 /updater/install.cpp
parentAdd slot suffix to DAP ops (diff)
downloadandroid_bootable_recovery-dff80042750992ed635056cd9719481a14f93007.tar
android_bootable_recovery-dff80042750992ed635056cd9719481a14f93007.tar.gz
android_bootable_recovery-dff80042750992ed635056cd9719481a14f93007.tar.bz2
android_bootable_recovery-dff80042750992ed635056cd9719481a14f93007.tar.lz
android_bootable_recovery-dff80042750992ed635056cd9719481a14f93007.tar.xz
android_bootable_recovery-dff80042750992ed635056cd9719481a14f93007.tar.zst
android_bootable_recovery-dff80042750992ed635056cd9719481a14f93007.zip
Diffstat (limited to 'updater/install.cpp')
-rw-r--r--updater/install.cpp16
1 files changed, 16 insertions, 0 deletions
diff --git a/updater/install.cpp b/updater/install.cpp
index 7608dc3cd..afa5195d0 100644
--- a/updater/install.cpp
+++ b/updater/install.cpp
@@ -852,6 +852,20 @@ Value* Tune2FsFn(const char* name, State* state, const std::vector<std::unique_p
return StringValue("t");
}
+Value* AddSlotSuffixFn(const char* name, State* state,
+ const std::vector<std::unique_ptr<Expr>>& argv) {
+ if (argv.size() != 1) {
+ return ErrorAbort(state, kArgsParsingFailure, "%s() expects 1 arg, got %zu", name, argv.size());
+ }
+ std::vector<std::string> args;
+ if (!ReadArgs(state, argv, &args)) {
+ return ErrorAbort(state, kArgsParsingFailure, "%s() Failed to parse the argument(s)", name);
+ }
+ const std::string& arg = args[0];
+ auto updater_runtime = state->updater->GetRuntime();
+ return StringValue(updater_runtime->AddSlotSuffix(arg));
+}
+
void RegisterInstallFunctions() {
RegisterFunction("mount", MountFn);
RegisterFunction("is_mounted", IsMountedFn);
@@ -885,4 +899,6 @@ void RegisterInstallFunctions() {
RegisterFunction("enable_reboot", EnableRebootFn);
RegisterFunction("tune2fs", Tune2FsFn);
+
+ RegisterFunction("add_slot_suffix", AddSlotSuffixFn);
}