-
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
8 changed files
with
118 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,60 @@ | ||
/* | ||
* Copyright (c) Roc Streaming authors | ||
* | ||
* This Source Code Form is subject to the terms of the Mozilla Public | ||
* License, v. 2.0. If a copy of the MPL was not distributed with this | ||
* file, You can obtain one at http://mozilla.org/MPL/2.0/. | ||
*/ | ||
|
||
#include "cmd_uninstall.hpp" | ||
#include "build_info.hpp" | ||
|
||
#include <fmt/core.h> | ||
#include <spdlog/spdlog.h> | ||
|
||
#include <unistd.h> | ||
#include <filesystem> | ||
|
||
using namespace rocvad; | ||
|
||
CmdUninstall::CmdUninstall(CLI::App& parent) | ||
{ | ||
register_command(parent.add_subcommand("uninstall", "uninstall driver and tool")); | ||
} | ||
|
||
bool CmdUninstall::execute(const Environment& env) | ||
{ | ||
if (geteuid() != 0) { | ||
spdlog::error("should be run with root privileges\ntry \"sudo {} uninstall\"", | ||
BuildInfo::tool_name); | ||
return false; | ||
} | ||
|
||
int n_ok = 0, n_warn = 0, n_err = 0; | ||
|
||
for (auto path : {BuildInfo::driver_bundle_path, BuildInfo::tool_path}) { | ||
std::error_code err; | ||
const auto n_removed = std::filesystem::remove_all(path, err); | ||
|
||
if (n_removed != 0 && !err) { | ||
fmt::println("removed {}", path); | ||
n_ok++; | ||
} else if (n_removed == 0 && !err) { | ||
spdlog::warn("can't remove \"{}\": Not found", path); | ||
n_warn++; | ||
} else if (err) { | ||
spdlog::error("can't remove \"{}\": {}", path, err.message()); | ||
n_err++; | ||
} | ||
} | ||
|
||
if (n_ok == 0) { | ||
fmt::println("nothing removed"); | ||
} else if (n_err == 0) { | ||
fmt::println("everything removed"); | ||
} else { | ||
fmt::println("completed with errors"); | ||
} | ||
|
||
return (n_err == 0); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
/* | ||
* Copyright (c) Roc Streaming authors | ||
* | ||
* This Source Code Form is subject to the terms of the Mozilla Public | ||
* License, v. 2.0. If a copy of the MPL was not distributed with this | ||
* file, You can obtain one at http://mozilla.org/MPL/2.0/. | ||
*/ | ||
|
||
#pragma once | ||
|
||
#include "cmd_base.hpp" | ||
|
||
namespace rocvad { | ||
|
||
class CmdUninstall : public CmdBase | ||
{ | ||
public: | ||
CmdUninstall(CLI::App& parent); | ||
|
||
bool execute(const Environment& env) override; | ||
}; | ||
|
||
} // namespace rocvad |