blob: 564c11f3e269daa881d4f10191c212dc0c8cb2b7 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
|
#include <iostream>
#include <string>
#include <filesystem>
#include "create_pkg.hh"
#include "name_from_url.hh"
#include "vars.hh"
Pkg create_pkg(std::string arg) {
Pkg pkg;
bool is_in_repos = false;
for (auto repo : repos) {
if (arg == repo.first) { is_in_repos = true; }
}
if (arg.rfind("http", 0) == 0) {
pkg.url = arg;
pkg.name = name_from_url(arg);
} else if (arg == ".") {
pkg.url = "";
pkg.name = name_from_url(std::filesystem::current_path().string());
} else if (is_in_repos) {
pkg.url = repos[arg];
pkg.name = arg;
} else {
std::cout << print_error << "'" << arg << "'" << " is not a valid package";
exit(1);
}
pkg.ver = "HEAD";
pkg.src = pkgblds + "/" + pkg.name + "/" + pkg.ver;
return pkg;
}
|