Further cleanup

This commit is contained in:
Simon Quigley 2024-12-17 17:59:00 -06:00
parent 9abde5de3f
commit b2ef41d635

View File

@ -60,10 +60,6 @@ static std::mutex& get_repo_mutex(const fs::path& repo_path) {
return repo_mutexes[repo_path];
}
// Mutex and vector to store dput futures
static std::mutex dput_futures_mutex;
static std::vector<std::future<void>> dput_futures;
// Mutex and map to store failed packages and their reasons
static std::mutex failures_mutex;
static std::map<std::string, std::string> failed_packages;
@ -99,18 +95,19 @@ static int worker_count = 5;
static bool verbose = false;
static std::ofstream log_file_stream;
// Function to get the current UTC time as a formatted string
std::string get_current_utc_time() {
auto now = std::chrono::system_clock::now();
std::time_t now_c = std::chrono::system_clock::to_time_t(now);
std::tm tm_utc;
gmtime_r(&now_c, &tm_utc);
char buffer[20];
std::strftime(buffer, sizeof(buffer), "%Y-%m-%dT%H:%M:%SZ", &tm_utc);
return std::string(buffer);
}
// Function declarations
static std::optional<std::string> run_lintian(const fs::path& source_path);
static void log_all(const std::string &level, const std::string &msg, bool is_error=false);
static void log_info(const std::string &msg);
static void log_warning(const std::string &msg);
static void log_error(const std::string &msg);
static void log_verbose(const std::string &msg);
static void print_help(const std::string &prog_name);
static void run_command_silent_on_success(const std::vector<std::string> &cmd, const std::optional<fs::path> &cwd = std::nullopt);
static void git_init_once();
static void git_fetch_and_checkout(const fs::path &repo_path, const std::string &repo_url, const std::optional<std::string> &branch);
static YAML::Node load_config(const fs::path &config_path);
static void publish_lintian();
static std::vector<std::string> get_exclusions(const fs::path &packaging);
static void run_source_lintian(const std::string &name, const fs::path &source_path);
@ -122,7 +119,6 @@ static void build_package_stage(Package &pkg, const YAML::Node &releases);
static void build_package_stage_wrapper(Package &pkg, const YAML::Node &releases);
static void upload_package_stage(Package &pkg, bool skip_dput);
static void run_lintian_stage(Package &pkg);
static void clean_old_logs_local(const fs::path &log_dir); // Removed to avoid ambiguity
int main(int argc, char** argv) {
std::string prog_name = fs::path(argv[0]).filename().string();
@ -261,8 +257,7 @@ int main(int argc, char** argv) {
log_info("Package pulled successfully.");
} catch(std::exception &e) {
log_error(std::string("Pull task generated an exception: ") + e.what());
// Record the failure if not already recorded
// (Handled inside pull_package)
// Failure already recorded inside pull_package
}
}
log_info("Completed Stage 1: All packages pulled.");
@ -369,9 +364,11 @@ SUMMARY:
log_info("Skipping cleanup as per flag.");
}
// Publish Lintian results
log_info("Publishing Lintian results.");
publish_lintian();
// Final Cleanup of old logs
log_info("Cleaning old logs.");
try {
clean_old_logs(LOG_DIR); // Using common::clean_old_logs
@ -693,9 +690,9 @@ static void run_source_lintian(const std::string &name, const fs::path &source_p
}
log_verbose("Created Lintian suppression file: " + temp_file.string());
std::string cmd = "lintian -EvIL +pedantic --suppress-tags-from-file " + temp_file.string() + " " + source_path.string() + " 2>&1";
// Using the unique_ptr with correct deleter to avoid warnings
auto deleter = [](FILE* ptr) { pclose(ptr); };
// Using a lambda deleter to ensure the correct signature and avoid warnings
auto deleter = [](FILE* ptr) { if(ptr) pclose(ptr); };
std::unique_ptr<FILE, decltype(deleter)> pipe(popen(cmd.c_str(), "r"), deleter);
if(!pipe) {