From 981118ec5f6a79df64545ba44132a1be438eb19b Mon Sep 17 00:00:00 2001 From: Tom Marshall Date: Wed, 25 Oct 2017 20:27:08 +0200 Subject: Revert "kill package_extract_dir" This reverts commit 53c38b15381ace565227e49104a6fd64c4c28dcc. Change-Id: Id998923948fb51ef5640c8be8884801c4f8d90e3 --- updater/install.cpp | 32 ++++++++++++++++++++++++++++++++ 1 file changed, 32 insertions(+) (limited to 'updater') diff --git a/updater/install.cpp b/updater/install.cpp index 0d473fce4..86359d9e0 100644 --- a/updater/install.cpp +++ b/updater/install.cpp @@ -74,6 +74,7 @@ #endif #include "otautil/DirUtil.h" +#include "otautil/ZipUtil.h" #include "print_sha1.h" #include "tune2fs.h" #include "updater/updater.h" @@ -423,6 +424,36 @@ Value* SetProgressFn(const char* name, State* state, const std::vector>&argv) { + if (argv.size() != 2) { + return ErrorAbort(state, kArgsParsingFailure, "%s() expects 2 args, got %zu", name, + argv.size()); + } + + std::vector args; + if (!ReadArgs(state, argv, &args)) { + return ErrorAbort(state, kArgsParsingFailure, "%s() Failed to parse the argument(s)", name); + } + const std::string& zip_path = args[0]; + const std::string& dest_path = args[1]; + + ZipArchiveHandle za = static_cast(state->cookie)->package_zip; + + // To create a consistent system image, never use the clock for timestamps. + constexpr struct utimbuf timestamp = { 1217592000, 1217592000 }; // 8/1/2008 default + + bool success = ExtractPackageRecursive(za, zip_path, dest_path, ×tamp, sehandle); + + return StringValue(success ? "t" : ""); +} + // package_extract_file(package_file[, dest_file]) // Extracts a single package_file from the update package and writes it to dest_file, // overwriting existing files if necessary. Without the dest_file argument, returns the @@ -1045,6 +1076,7 @@ void RegisterInstallFunctions() { RegisterFunction("format", FormatFn); RegisterFunction("show_progress", ShowProgressFn); RegisterFunction("set_progress", SetProgressFn); + RegisterFunction("package_extract_dir", PackageExtractDirFn); RegisterFunction("package_extract_file", PackageExtractFileFn); RegisterFunction("getprop", GetPropFn); -- cgit v1.2.3