Refuse to install on buster, part 2.
This commit is contained in:
+1
-1
@@ -2,7 +2,7 @@
|
|||||||
build/
|
build/
|
||||||
|
|
||||||
#VS Code config files.
|
#VS Code config files.
|
||||||
.vscode/
|
# .vscode/ Sort this out later. .gitignore-ing an already tracked file doesn't actually work.
|
||||||
#settings
|
#settings
|
||||||
|
|
||||||
Testing/
|
Testing/
|
||||||
|
|||||||
Vendored
+11
-1
@@ -10,6 +10,13 @@
|
|||||||
// For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387
|
// For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387
|
||||||
"version": "0.2.0",
|
"version": "0.2.0",
|
||||||
"configurations": [
|
"configurations": [
|
||||||
|
{
|
||||||
|
"name": "Attach to Edge",
|
||||||
|
"port": 9222,
|
||||||
|
"request": "attach",
|
||||||
|
"type": "msedge",
|
||||||
|
"webRoot": "${workspaceFolder}"
|
||||||
|
},
|
||||||
{
|
{
|
||||||
"name": "(gdb) Attach",
|
"name": "(gdb) Attach",
|
||||||
"type": "cppdbg",
|
"type": "cppdbg",
|
||||||
@@ -308,8 +315,11 @@
|
|||||||
// Resolved by CMake Tools:
|
// Resolved by CMake Tools:
|
||||||
"program": "${command:cmake.launchTargetPath}",
|
"program": "${command:cmake.launchTargetPath}",
|
||||||
"args": [
|
"args": [
|
||||||
|
"--prefix",
|
||||||
|
"/usr/sbin",
|
||||||
"--nosudo", // run without sudo (which will fail because of perms, but allow us to debug deeper into install code.)
|
"--nosudo", // run without sudo (which will fail because of perms, but allow us to debug deeper into install code.)
|
||||||
"--disable-p2p"
|
"--install"
|
||||||
|
|
||||||
//"--get-current-port"
|
//"--get-current-port"
|
||||||
//"--install"
|
//"--install"
|
||||||
//"--enable-p2p" , "CA", "PiPedalTest","12345678","14"
|
//"--enable-p2p" , "CA", "PiPedalTest","12345678","14"
|
||||||
|
|||||||
-115
@@ -1,115 +0,0 @@
|
|||||||
// Copyright (c) 2022 Robin Davies
|
|
||||||
//
|
|
||||||
// Permission is hereby granted, free of charge, to any person obtaining a copy of
|
|
||||||
// this software and associated documentation files (the "Software"), to deal in
|
|
||||||
// the Software without restriction, including without limitation the rights to
|
|
||||||
// use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
|
|
||||||
// the Software, and to permit persons to whom the Software is furnished to do so,
|
|
||||||
// subject to the following conditions:
|
|
||||||
//
|
|
||||||
// The above copyright notice and this permission notice shall be included in all
|
|
||||||
// copies or substantial portions of the Software.
|
|
||||||
//
|
|
||||||
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
||||||
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
|
|
||||||
// FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
|
|
||||||
// COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
|
|
||||||
// IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
|
|
||||||
// CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
|
||||||
|
|
||||||
#include "pch.h"
|
|
||||||
#include "Lv2Log.hpp"
|
|
||||||
#include <iostream>
|
|
||||||
#include <chrono>
|
|
||||||
#include <iomanip>
|
|
||||||
|
|
||||||
using namespace pipedal;
|
|
||||||
|
|
||||||
#include <mutex>
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
static auto timeZero = std::chrono::system_clock::now();
|
|
||||||
bool Lv2Log::show_time_ = true;
|
|
||||||
|
|
||||||
std::string timeTag()
|
|
||||||
{
|
|
||||||
if (!Lv2Log::show_time()) return "";
|
|
||||||
|
|
||||||
using namespace std::chrono;
|
|
||||||
|
|
||||||
auto now = std::chrono::system_clock::now();
|
|
||||||
std::time_t now_c = std::chrono::system_clock::to_time_t(now);
|
|
||||||
|
|
||||||
auto milliseconds = std::chrono::duration_cast<std::chrono::milliseconds>(now.time_since_epoch()) % 1000;
|
|
||||||
|
|
||||||
|
|
||||||
std::stringstream s;
|
|
||||||
|
|
||||||
using namespace std;
|
|
||||||
s << std::put_time(std::localtime(&now_c), "%Y-%m-%d %H:%M:%S") << "." << std::setw(3) << std::setfill('0') << milliseconds.count() << " ";
|
|
||||||
return s.str();
|
|
||||||
|
|
||||||
}
|
|
||||||
class StdErrLogger : public Lv2Logger
|
|
||||||
{
|
|
||||||
std::mutex m;
|
|
||||||
|
|
||||||
|
|
||||||
public : virtual ~StdErrLogger() {}
|
|
||||||
|
|
||||||
virtual void onError(const char* message)
|
|
||||||
{
|
|
||||||
std::lock_guard lock(m);
|
|
||||||
std::cerr << timeTag() << "ERR: " << message << std::endl;
|
|
||||||
}
|
|
||||||
virtual void onWarning(const char* message)
|
|
||||||
{
|
|
||||||
std::lock_guard lock(m);
|
|
||||||
std::cerr << timeTag() << "WRN: " << message << std::endl;
|
|
||||||
}
|
|
||||||
|
|
||||||
virtual void onDebug(const char* message)
|
|
||||||
{
|
|
||||||
std::lock_guard lock(m);
|
|
||||||
std::cerr << timeTag() << "DBG: " << message << std::endl;
|
|
||||||
}
|
|
||||||
virtual void onInfo(const char* message)
|
|
||||||
{
|
|
||||||
std::lock_guard lock(m);
|
|
||||||
std::cerr << timeTag() << "INF: " << message << std::endl;
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
Lv2Logger *Lv2Log::logger_ = new StdErrLogger();
|
|
||||||
|
|
||||||
LogLevel Lv2Log::log_level_ = LogLevel::Debug;
|
|
||||||
|
|
||||||
void Lv2Log::v_error(const char *format, va_list arglist)
|
|
||||||
{
|
|
||||||
char buffer[512];
|
|
||||||
vsnprintf(buffer,sizeof(buffer),format,arglist);
|
|
||||||
logger_->onError(buffer);
|
|
||||||
}
|
|
||||||
void Lv2Log::v_warning(const char *format, va_list arglist)
|
|
||||||
{
|
|
||||||
char buffer[512];
|
|
||||||
vsnprintf(buffer,sizeof(buffer),format,arglist);
|
|
||||||
logger_->onWarning(buffer);
|
|
||||||
}
|
|
||||||
void Lv2Log::v_debug(const char *format, va_list arglist)
|
|
||||||
{
|
|
||||||
char buffer[512];
|
|
||||||
vsnprintf(buffer,sizeof(buffer),format,arglist);
|
|
||||||
logger_->onDebug(buffer);
|
|
||||||
}
|
|
||||||
void Lv2Log::v_info(const char *format, va_list arglist)
|
|
||||||
{
|
|
||||||
char buffer[512];
|
|
||||||
vsnprintf(buffer,sizeof(buffer),format,arglist);
|
|
||||||
logger_->onInfo(buffer);
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
-167
@@ -1,167 +0,0 @@
|
|||||||
// Copyright (c) 2022 Robin Davies
|
|
||||||
//
|
|
||||||
// Permission is hereby granted, free of charge, to any person obtaining a copy of
|
|
||||||
// this software and associated documentation files (the "Software"), to deal in
|
|
||||||
// the Software without restriction, including without limitation the rights to
|
|
||||||
// use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
|
|
||||||
// the Software, and to permit persons to whom the Software is furnished to do so,
|
|
||||||
// subject to the following conditions:
|
|
||||||
//
|
|
||||||
// The above copyright notice and this permission notice shall be included in all
|
|
||||||
// copies or substantial portions of the Software.
|
|
||||||
//
|
|
||||||
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
||||||
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
|
|
||||||
// FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
|
|
||||||
// COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
|
|
||||||
// IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
|
|
||||||
// CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
|
||||||
|
|
||||||
#pragma once
|
|
||||||
#include <stdarg.h>
|
|
||||||
#include <chrono>
|
|
||||||
|
|
||||||
namespace pipedal
|
|
||||||
{
|
|
||||||
|
|
||||||
class Lv2Logger
|
|
||||||
{
|
|
||||||
public:
|
|
||||||
virtual ~Lv2Logger() = default;
|
|
||||||
|
|
||||||
virtual void onError(const char *message) = 0;
|
|
||||||
virtual void onWarning(const char *message) = 0;
|
|
||||||
virtual void onDebug(const char *message) = 0;
|
|
||||||
virtual void onInfo(const char *message) = 0;
|
|
||||||
};
|
|
||||||
|
|
||||||
enum class LogLevel
|
|
||||||
{
|
|
||||||
None = 0,
|
|
||||||
Error = 1,
|
|
||||||
Warning = 2,
|
|
||||||
Info = 3,
|
|
||||||
Debug = 4
|
|
||||||
};
|
|
||||||
|
|
||||||
class Lv2Log
|
|
||||||
{
|
|
||||||
private:
|
|
||||||
|
|
||||||
static Lv2Logger *logger_;
|
|
||||||
static LogLevel log_level_;
|
|
||||||
static bool show_time_;
|
|
||||||
|
|
||||||
static void v_error(const char *format, va_list arglist);
|
|
||||||
static void v_warning(const char *format, va_list arglist);
|
|
||||||
static void v_debug(const char *format, va_list arglist);
|
|
||||||
static void v_info(const char *format, va_list arglist);
|
|
||||||
|
|
||||||
public:
|
|
||||||
static void set_logger(Lv2Logger *logger)
|
|
||||||
{
|
|
||||||
Lv2Log::logger_ = logger;
|
|
||||||
}
|
|
||||||
static void log_level(LogLevel level)
|
|
||||||
{
|
|
||||||
Lv2Log::log_level_ = level;
|
|
||||||
}
|
|
||||||
static LogLevel log_level()
|
|
||||||
{
|
|
||||||
return Lv2Log::log_level_;
|
|
||||||
}
|
|
||||||
static void show_time(bool show)
|
|
||||||
{
|
|
||||||
show_time_ = show;
|
|
||||||
}
|
|
||||||
static bool show_time() {
|
|
||||||
return show_time_;
|
|
||||||
}
|
|
||||||
|
|
||||||
// static void error(const char* message) {
|
|
||||||
// if (Lv2Log::log_level_ >= LogLevel::Error)
|
|
||||||
// {
|
|
||||||
// logger_->onError(message);
|
|
||||||
// }
|
|
||||||
// }
|
|
||||||
// static void warning(const char* message) {
|
|
||||||
// if (Lv2Log::log_level_ >= LogLevel::Warning)
|
|
||||||
// {
|
|
||||||
// logger_->onWarning(message);
|
|
||||||
// }
|
|
||||||
// }
|
|
||||||
// static void debug(const char* message) {
|
|
||||||
// if (Lv2Log::log_level_ >= LogLevel::Debug)
|
|
||||||
// {
|
|
||||||
// logger_->onDebug(message);
|
|
||||||
// }
|
|
||||||
// }
|
|
||||||
// static void info(const char* message) {
|
|
||||||
// if (Lv2Log::log_level_ >= LogLevel::Info)
|
|
||||||
// {
|
|
||||||
// logger_->onInfo(message);
|
|
||||||
// }
|
|
||||||
// }
|
|
||||||
|
|
||||||
static void info(const char *format, ...)
|
|
||||||
{
|
|
||||||
if (Lv2Log::log_level_ >= LogLevel::Info)
|
|
||||||
{
|
|
||||||
va_list arglist;
|
|
||||||
va_start(arglist, format);
|
|
||||||
v_info(format, arglist);
|
|
||||||
va_end(arglist);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
static void info(const std::string &str)
|
|
||||||
{
|
|
||||||
info("%s", str.c_str());
|
|
||||||
}
|
|
||||||
|
|
||||||
static void debug(const char *format, ...)
|
|
||||||
{
|
|
||||||
if (Lv2Log::log_level_ >= LogLevel::Debug)
|
|
||||||
{
|
|
||||||
va_list arglist;
|
|
||||||
va_start(arglist, format);
|
|
||||||
v_debug(format, arglist);
|
|
||||||
va_end(arglist);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
static void debug(const std::string &str)
|
|
||||||
{
|
|
||||||
debug("%s", str.c_str());
|
|
||||||
}
|
|
||||||
|
|
||||||
static void warning(const char *format, ...)
|
|
||||||
{
|
|
||||||
if (Lv2Log::log_level_ >= LogLevel::Warning)
|
|
||||||
{
|
|
||||||
va_list arglist;
|
|
||||||
va_start(arglist, format);
|
|
||||||
v_warning(format, arglist);
|
|
||||||
va_end(arglist);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
static void warning(const std::string &str)
|
|
||||||
{
|
|
||||||
warning("%s", str.c_str());
|
|
||||||
}
|
|
||||||
|
|
||||||
static void error(const char *format, ...)
|
|
||||||
{
|
|
||||||
if (Lv2Log::log_level_ >= LogLevel::Warning)
|
|
||||||
{
|
|
||||||
va_list arglist;
|
|
||||||
va_start(arglist, format);
|
|
||||||
v_error(format, arglist);
|
|
||||||
va_end(arglist);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
static void error(const std::string &str)
|
|
||||||
{
|
|
||||||
error("%s", str.c_str());
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
} // namespace pipedal
|
|
||||||
@@ -70,8 +70,39 @@ const std::string &pipedal::GetWifiConfigWlanAddress()
|
|||||||
return gWlanAddress;
|
return gWlanAddress;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static bool gNetworkManagerTestExecuted = false;
|
||||||
|
static bool gUsingNetworkManager = false;
|
||||||
|
|
||||||
|
void pipedal::PretendNetworkManagerIsInstalled()
|
||||||
|
{
|
||||||
|
gNetworkManagerTestExecuted = true;
|
||||||
|
gUsingNetworkManager = true;
|
||||||
|
}
|
||||||
bool pipedal::UsingNetworkManager()
|
bool pipedal::UsingNetworkManager()
|
||||||
{
|
{
|
||||||
|
if (gNetworkManagerTestExecuted)
|
||||||
|
{
|
||||||
|
return gUsingNetworkManager;
|
||||||
|
}
|
||||||
|
bool bResult = false;
|
||||||
|
auto result = sysExecForOutput("systemctl","is-active NetworkManager");
|
||||||
|
if (result.exitCode == EXIT_SUCCESS)
|
||||||
|
{
|
||||||
|
std::string text = result.output.erase(result.output.find_last_not_of(" \n\r\t")+1);
|
||||||
|
if (text == "active")
|
||||||
|
{
|
||||||
|
bResult = true;
|
||||||
|
} else if (text == "inactive")
|
||||||
|
{
|
||||||
|
bResult = false;
|
||||||
|
} else {
|
||||||
|
throw std::runtime_error(SS("UsingNetworkManager: unexpected result (" << text << ")"));
|
||||||
|
}
|
||||||
|
gNetworkManagerTestExecuted = true;
|
||||||
|
gUsingNetworkManager = bResult;
|
||||||
|
return bResult;
|
||||||
|
}
|
||||||
|
|
||||||
// does the neworkManager service path exists?
|
// does the neworkManager service path exists?
|
||||||
return std::filesystem::exists(NETWORK_MANAGER_SERVICE_PATH);
|
return std::filesystem::exists(NETWORK_MANAGER_SERVICE_PATH);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -36,4 +36,6 @@ namespace pipedal {
|
|||||||
void OnWifiInstallComplete();
|
void OnWifiInstallComplete();
|
||||||
|
|
||||||
bool UsingNetworkManager();
|
bool UsingNetworkManager();
|
||||||
|
void PretendNetworkManagerIsInstalled();
|
||||||
|
|
||||||
} // namespace.
|
} // namespace.
|
||||||
Reference in New Issue
Block a user