mirror of
https://github.com/davidallendj/gdpm.git
synced 2025-12-20 03:27:02 -07:00
Fixed installing issue with no set remote
- Added default remote repo - Fixed adding and removing remote repos
This commit is contained in:
parent
8b1f1374d8
commit
996c47466e
6 changed files with 46 additions and 29 deletions
|
|
@ -23,8 +23,10 @@ namespace gdpm::constants::error{
|
||||||
DIRECTORY_EXISTS,
|
DIRECTORY_EXISTS,
|
||||||
DIRECTORY_NOT_FOULD,
|
DIRECTORY_NOT_FOULD,
|
||||||
HOST_UNREACHABLE,
|
HOST_UNREACHABLE,
|
||||||
|
REMOTE_NOT_FOUND,
|
||||||
EMPTY_RESPONSE,
|
EMPTY_RESPONSE,
|
||||||
INVALID_ARGS,
|
INVALID_ARGS,
|
||||||
|
INVALID_ARG_COUNT,
|
||||||
INVALID_CONFIG,
|
INVALID_CONFIG,
|
||||||
INVALID_KEY,
|
INVALID_KEY,
|
||||||
HTTP_RESPONSE_ERROR,
|
HTTP_RESPONSE_ERROR,
|
||||||
|
|
|
||||||
|
|
@ -47,7 +47,7 @@ namespace gdpm::package {
|
||||||
bool enable_cache = true;
|
bool enable_cache = true;
|
||||||
bool enable_sync = true;
|
bool enable_sync = true;
|
||||||
bool skip_prompt = false;
|
bool skip_prompt = false;
|
||||||
string remote_source = "";
|
string remote_source = "origin";
|
||||||
install_method_e install_method = GLOBAL_LINK_LOCAL;
|
install_method_e install_method = GLOBAL_LINK_LOCAL;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -15,7 +15,7 @@ namespace gdpm::remote{
|
||||||
GDPM_DLL_EXPORT error _handle_remote(config::context& config, const args_t& args, const opts_t& opts);
|
GDPM_DLL_EXPORT error _handle_remote(config::context& config, const args_t& args, const opts_t& opts);
|
||||||
GDPM_DLL_EXPORT void set_repositories(config::context& context, const repository_map& repos);
|
GDPM_DLL_EXPORT void set_repositories(config::context& context, const repository_map& repos);
|
||||||
GDPM_DLL_EXPORT void add_repositories(config::context& context, const repository_map& repos);
|
GDPM_DLL_EXPORT void add_repositories(config::context& context, const repository_map& repos);
|
||||||
GDPM_DLL_EXPORT void remove_respositories(config::context& context, const repo_names& name);
|
GDPM_DLL_EXPORT void remove_respositories(config::context& context, const repo_names& names);
|
||||||
GDPM_DLL_EXPORT void move_repository(config::context& context, int old_position, int new_position);
|
GDPM_DLL_EXPORT void move_repository(config::context& context, int old_position, int new_position);
|
||||||
GDPM_DLL_EXPORT void print_repositories(const config::context& context);
|
GDPM_DLL_EXPORT void print_repositories(const config::context& context);
|
||||||
}
|
}
|
||||||
0
src/README.md
Normal file
0
src/README.md
Normal file
|
|
@ -90,6 +90,16 @@ namespace gdpm::package{
|
||||||
return error();
|
return error();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* Check if provided param is in remote sources*/
|
||||||
|
if(!config.remote_sources.contains(params.remote_source)){
|
||||||
|
error error(
|
||||||
|
constants::error::NOT_FOUND,
|
||||||
|
"Remote resource not found in config."
|
||||||
|
);
|
||||||
|
log::error(error);
|
||||||
|
return error;
|
||||||
|
}
|
||||||
|
|
||||||
/* Try and obtain all requested packages. */
|
/* Try and obtain all requested packages. */
|
||||||
std::vector<string_pair> dir_pairs;
|
std::vector<string_pair> dir_pairs;
|
||||||
task_list tasks;
|
task_list tasks;
|
||||||
|
|
@ -161,7 +171,7 @@ namespace gdpm::package{
|
||||||
|
|
||||||
/* Check if we already have a stored temporary file before attempting to download */
|
/* Check if we already have a stored temporary file before attempting to download */
|
||||||
if(std::filesystem::exists(tmp_zip) && std::filesystem::is_regular_file(tmp_zip)){
|
if(std::filesystem::exists(tmp_zip) && std::filesystem::is_regular_file(tmp_zip)){
|
||||||
log::println("Found cached package. Skipping download.", p.title);
|
log::info("Found cached package. Skipping download.", p.title);
|
||||||
}
|
}
|
||||||
else{
|
else{
|
||||||
/* Download all the package files and place them in tmp directory. */
|
/* Download all the package files and place them in tmp directory. */
|
||||||
|
|
@ -226,7 +236,7 @@ namespace gdpm::package{
|
||||||
if(p_cache.empty()){
|
if(p_cache.empty()){
|
||||||
error error(
|
error error(
|
||||||
constants::error::NOT_FOUND,
|
constants::error::NOT_FOUND,
|
||||||
"\nCould not find any packages to remove."
|
"Could not find any packages to remove."
|
||||||
);
|
);
|
||||||
log::error(error);
|
log::error(error);
|
||||||
return error;
|
return error;
|
||||||
|
|
|
||||||
|
|
@ -11,14 +11,6 @@ namespace gdpm::remote{
|
||||||
const args_t& args,
|
const args_t& args,
|
||||||
const opts_t& opts
|
const opts_t& opts
|
||||||
){
|
){
|
||||||
log::println("_handle_remote");
|
|
||||||
for(const auto& arg : args){
|
|
||||||
log::println("arg: {}", arg);
|
|
||||||
}
|
|
||||||
for(const auto& opt : opts){
|
|
||||||
log::println("opt: {}:{}", opt.first, utils::join(opt.second));
|
|
||||||
}
|
|
||||||
|
|
||||||
/* Check if enough arguments are supplied */
|
/* Check if enough arguments are supplied */
|
||||||
size_t argc = args.size();
|
size_t argc = args.size();
|
||||||
if (argc < 1){
|
if (argc < 1){
|
||||||
|
|
@ -28,19 +20,30 @@ namespace gdpm::remote{
|
||||||
|
|
||||||
/* Check which subcommand is supplied */
|
/* Check which subcommand is supplied */
|
||||||
string sub_command = args.front();
|
string sub_command = args.front();
|
||||||
args_t argv(args.begin()+1, args.end());
|
if(sub_command == "add"){
|
||||||
if(argv.size() < 2){
|
if(args.size() < 3 || args.empty()){
|
||||||
error error(
|
error error(
|
||||||
constants::error::INVALID_ARGS,
|
constants::error::INVALID_ARG_COUNT,
|
||||||
"Invalid number of args"
|
"Invalid number of args."
|
||||||
);
|
);
|
||||||
log::error(error);
|
log::error(error);
|
||||||
return error;
|
return error;
|
||||||
|
}
|
||||||
|
string name = args[1];
|
||||||
|
string url = args[2];
|
||||||
|
add_repositories(config, {{name, url}});
|
||||||
|
}
|
||||||
|
else if (sub_command == "remove") {
|
||||||
|
if(args.size() < 2 || args.empty()){
|
||||||
|
error error(
|
||||||
|
constants::error::INVALID_ARG_COUNT,
|
||||||
|
"Invalid number of args."
|
||||||
|
);
|
||||||
|
log::error(error);
|
||||||
|
return error;
|
||||||
|
}
|
||||||
|
remove_respositories(config, {args.begin()+1, args.end()});
|
||||||
}
|
}
|
||||||
string name = argv[1];
|
|
||||||
string url = argv[2];
|
|
||||||
if(sub_command == "add") add_repositories(config, {{name, url}});
|
|
||||||
else if (sub_command == "remove") remove_respositories(config, argv);
|
|
||||||
// else if (sub_command == "set") set_repositories(config::context &context, const repository_map &repos)
|
// else if (sub_command == "set") set_repositories(config::context &context, const repository_map &repos)
|
||||||
else if (sub_command == "list") print_repositories(config);
|
else if (sub_command == "list") print_repositories(config);
|
||||||
else{
|
else{
|
||||||
|
|
@ -79,9 +82,12 @@ namespace gdpm::remote{
|
||||||
config::context& config,
|
config::context& config,
|
||||||
const repo_names& names
|
const repo_names& names
|
||||||
){
|
){
|
||||||
std::for_each(names.end(), names.begin(), [&config](const string& repo){
|
for(auto it = names.begin(); it != names.end();){
|
||||||
config.remote_sources.erase(repo);
|
if(config.remote_sources.contains(*it)){
|
||||||
});
|
config.remote_sources.erase(*it);
|
||||||
|
}
|
||||||
|
it++;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
@ -94,10 +100,9 @@ namespace gdpm::remote{
|
||||||
}
|
}
|
||||||
|
|
||||||
void print_repositories(const config::context& config){
|
void print_repositories(const config::context& config){
|
||||||
log::println("Remote sources:");
|
|
||||||
const auto &rs = config.remote_sources;
|
const auto &rs = config.remote_sources;
|
||||||
std::for_each(rs.begin(), rs.end(), [](const string_pair& p){
|
std::for_each(rs.begin(), rs.end(), [](const string_pair& p){
|
||||||
log::println("\t{}: {}", p.first, p.second);
|
log::println("{}: {}", p.first, p.second);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
Loading…
Add table
Add a link
Reference in a new issue