blob: e4cddbd5475b94b4cc6985b314a6840faaf8c183 [file] [log] [blame]
// Copyright 2016 The Fuchsia Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#include <dirent.h>
#include <lib/async-loop/cpp/loop.h>
#include <lib/async-loop/default.h>
#include <lib/syslog/cpp/macros.h>
#include <string.h>
#include <sys/types.h>
#include <string>
#include "src/lib/fxl/command_line.h"
#include "src/lib/fxl/log_settings_command_line.h"
#include "src/sys/sysmgr/app.h"
constexpr bool kAutoUpdatePackagesDefault = true;
constexpr bool kAutoUpdatePackagesDefault = false;
// Flag that allows overriding the "auto_update_packages" default set in GN. Useful for tests.
const char kAutoUpdatePackages[] = "auto_update_packages";
int main(int argc, const char** argv) {
auto command_line = fxl::CommandLineFromArgcArgv(argc, argv);
if (!fxl::SetLogSettingsFromCommandLine(command_line)) {
return 1;
bool auto_update_packages = kAutoUpdatePackagesDefault;
if (command_line.HasOption(kAutoUpdatePackages)) {
std::string s;
command_line.GetOptionValue(kAutoUpdatePackages, &s);
if (s == "true") {
auto_update_packages = true;
} else if (s == "false") {
auto_update_packages = false;
} else {
FX_LOGS(ERROR) << "Invalid value for auto_update_packages: " << s;
async::Loop loop(&kAsyncLoopConfigAttachToCurrentThread);
auto component_context = sys::ComponentContext::CreateAndServeOutgoingDirectory();
sysmgr::App app(auto_update_packages, component_context->svc(), &loop);
return 0;