'Generic Commit'
Some checks failed
Build-Test-Publish / build (linux/amd64) (push) Failing after 10s
Build-Test-Publish / build (linux/arm64) (push) Successful in 58s
Build-Test-Publish / test-install-from-scratch (linux/amd64) (push) Has been skipped
Build-Test-Publish / test-install-from-scratch (linux/arm64) (push) Has been skipped
Some checks failed
Build-Test-Publish / build (linux/amd64) (push) Failing after 10s
Build-Test-Publish / build (linux/arm64) (push) Successful in 58s
Build-Test-Publish / test-install-from-scratch (linux/amd64) (push) Has been skipped
Build-Test-Publish / test-install-from-scratch (linux/arm64) (push) Has been skipped
This commit is contained in:
parent
faf6d691d9
commit
92319ea70e
@ -1,13 +0,0 @@
|
||||
#pragma once
|
||||
#include <string>
|
||||
|
||||
namespace common {
|
||||
|
||||
class ArchiveManager {
|
||||
public:
|
||||
ArchiveManager();
|
||||
bool pack(const std::string& folderPath, const std::string& archivePath);
|
||||
bool unpack(const std::string& archivePath, const std::string& outDir);
|
||||
};
|
||||
|
||||
} // namespace common
|
@ -7,7 +7,7 @@
|
||||
#include <iostream>
|
||||
#include <unistd.h>
|
||||
|
||||
#include "ArchiveManager.hpp"
|
||||
#include "archive_tgz.hpp"
|
||||
|
||||
namespace common {
|
||||
|
||||
@ -29,9 +29,7 @@ static std::string shellEscape(const std::string& str) {
|
||||
return result;
|
||||
}
|
||||
|
||||
ArchiveManager::ArchiveManager() {}
|
||||
|
||||
bool ArchiveManager::pack(const std::string& folderPath, const std::string& archivePath) {
|
||||
bool pack_tgz(const std::string& folderPath, const std::string& archivePath) {
|
||||
// Use system tar to create gzipped tarball
|
||||
std::ostringstream cmd;
|
||||
cmd << "tar -czf ";
|
||||
@ -43,7 +41,7 @@ bool ArchiveManager::pack(const std::string& folderPath, const std::string& arch
|
||||
return ret == 0;
|
||||
}
|
||||
|
||||
bool ArchiveManager::unpack(const std::string& archivePath, const std::string& outDir) {
|
||||
bool unpack_tgz(const std::string& archivePath, const std::string& outDir) {
|
||||
fs::create_directories(outDir);
|
||||
std::ostringstream cmd;
|
||||
cmd << "tar -xzf ";
|
9
getpkg/src/common/archive_tgz.hpp
Normal file
9
getpkg/src/common/archive_tgz.hpp
Normal file
@ -0,0 +1,9 @@
|
||||
#pragma once
|
||||
#include <string>
|
||||
|
||||
namespace common {
|
||||
|
||||
bool pack_tgz(const std::string& folderPath, const std::string& archivePath);
|
||||
bool unpack_tgz(const std::string& archivePath, const std::string& outDir);
|
||||
|
||||
} // namespace common
|
@ -57,7 +57,7 @@
|
||||
#include "BashrcEditor.hpp"
|
||||
#include "DropshellScriptManager.hpp"
|
||||
#include "GetbinClient.hpp"
|
||||
#include "ArchiveManager.hpp"
|
||||
#include "archive_tgz.hpp"
|
||||
#include "hash.hpp"
|
||||
#include <iostream>
|
||||
#include <string>
|
||||
@ -213,8 +213,7 @@ int install_tool(int argc, char* argv[]) {
|
||||
}
|
||||
|
||||
// Unpack tool
|
||||
common::ArchiveManager archiver;
|
||||
if (!archiver.unpack(archivePath.string(), binDir.string())) {
|
||||
if (!common::unpack_tgz(archivePath.string(), binDir.string())) {
|
||||
std::cerr << "Failed to unpack tool archive." << std::endl;
|
||||
return 1;
|
||||
}
|
||||
@ -292,8 +291,7 @@ int publish_tool(int argc, char* argv[]) {
|
||||
std::filesystem::path archivePath = std::filesystem::path(home) / ".tmp" / (labeltag + ".tgz");
|
||||
std::filesystem::create_directories(archivePath.parent_path());
|
||||
|
||||
common::ArchiveManager archiver;
|
||||
if (!archiver.pack(folder, archivePath.string())) {
|
||||
if (!common::pack_tgz(folder, archivePath.string())) {
|
||||
std::cerr << "Failed to create archive." << std::endl;
|
||||
return 1;
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user