diff options
| author | dacctal <dacctalyt@gmail.com> | 2026-04-17 08:16:21 +0000 |
|---|---|---|
| committer | dacctal <dacctalyt@gmail.com> | 2026-04-17 08:16:21 +0000 |
| commit | c421fe8fb87e949bae1860f0d501cf8e89ce0f18 (patch) | |
| tree | 7b2ec26ec674bf864feb80a38aa9b33c7401e479 | |
| parent | 574708a5f97907c4b4e67788d38f89fac0981b70 (diff) | |
started manifest template
| -rw-r--r-- | Makefile | 6 | ||||
| -rw-r--r-- | TODO.md | 2 | ||||
| -rw-r--r-- | bldit.lua | 14 | ||||
| -rw-r--r-- | include/set_install_directories.hh | 6 | ||||
| -rw-r--r-- | include/vars.hh | 3 | ||||
| -rwxr-xr-x | pkgit | bin | 222176 -> 227176 bytes | |||
| -rw-r--r-- | src/build.cc | 2 | ||||
| -rw-r--r-- | src/cla_parse.cc | 10 | ||||
| -rw-r--r-- | src/copy_install.cc | 13 | ||||
| -rw-r--r-- | src/create_pkg.cc | 2 | ||||
| -rw-r--r-- | src/fetch_git.cc | 8 | ||||
| -rw-r--r-- | src/help.cc | 10 | ||||
| -rw-r--r-- | src/is_updated.cc | 1 | ||||
| -rw-r--r-- | src/link_install.cc | 24 | ||||
| -rw-r--r-- | src/remove_pkg.cc | 6 | ||||
| -rw-r--r-- | src/set_install_directories.cc (renamed from src/read_config.cc) | 13 | ||||
| -rw-r--r-- | src/setup_dirs.cc | 12 | ||||
| -rw-r--r-- | src/setup_pkgit.cc | 5 | ||||
| -rw-r--r-- | src/vars.cc | 21 |
19 files changed, 94 insertions, 64 deletions
@@ -5,9 +5,11 @@ CXXFLAGS += $(shell pkg-config --cflags --libs luajit ) -I./include -L/usr/lib default: pkgit -pkgit: src/main.cc +pkgit: src/*.cc ${CC} -o pkgit src/*.cc ${CXXFLAGS} - chmod +x pkgit + +debug: src/*.cc + ${CC} -o pkgit src/*.cc ${CXXFLAGS} -g -O0 install: pkgit install -d ${DESTDIR}${PREFIX}/bin @@ -7,7 +7,7 @@ - [x] lua repos - [x] CLA parsing - [x] lua config primary(/etc) / secondary(.config) checks -- [ ] lua variables for install paths +- [x] lua variables for install paths - [ ] lua dependency listing - [ ] lua custom source fetching methods - [ ] version management diff --git a/bldit.lua b/bldit.lua new file mode 100644 index 0000000..11744e8 --- /dev/null +++ b/bldit.lua @@ -0,0 +1,14 @@ +bldit_version = "0.0.0" +package_version = "0.0.0" + +global_dependencies = {} + +targets = { + default = { + dependencies = {} + compile = function() os.execute("make") end + pre_install = function() end + install = function() os.execute("make install") end + post_install = function() end + } +} diff --git a/include/set_install_directories.hh b/include/set_install_directories.hh new file mode 100644 index 0000000..2de9dd1 --- /dev/null +++ b/include/set_install_directories.hh @@ -0,0 +1,6 @@ +#ifndef SET_INSTALL_DIRECTORIES +#define SET_INSTALL_DIRECTORIES + +void set_install_directories(); + +#endif diff --git a/include/vars.hh b/include/vars.hh index 448b6df..71045ee 100644 --- a/include/vars.hh +++ b/include/vars.hh @@ -6,9 +6,11 @@ #include <map> extern std::map<std::string, std::string> repos; +extern std::map<std::string, std::string> install_directories; extern bool is_symlink_install; extern bool is_verbose; +extern bool config_exists; struct Pkg { std::string url; @@ -29,7 +31,6 @@ extern const std::string bin; extern const std::string lib; extern const std::string include; extern const std::string pkgblds; - extern const std::string all_dirs[5]; // version Binary files differdiff --git a/src/build.cc b/src/build.cc index c378dda..adbfec5 100644 --- a/src/build.cc +++ b/src/build.cc @@ -16,4 +16,4 @@ void build(std::filesystem::path build_dir) { if (lua_build(build_dir.c_str())) { return; } } std::cout << print_error << "no usable build system was found\n"; -} +}
\ No newline at end of file diff --git a/src/cla_parse.cc b/src/cla_parse.cc index c721fb9..2813ded 100644 --- a/src/cla_parse.cc +++ b/src/cla_parse.cc @@ -27,10 +27,6 @@ void cla_parse(int argc, char** argv) { is_symlink_install = true; } - if (strcmp(argv[i], "--verbose") == 0 || strcmp(argv[i], "-v") == 0) { - is_verbose = true; - } - if (strcmp(argv[i], "add") == 0 || strcmp(argv[i], "a") == 0) { for (int j = i+1; i < argc; j++) { if (argv[j]) { @@ -85,7 +81,11 @@ void cla_parse(int argc, char** argv) { list_pkgs(); return; - } else if (strcmp(argv[i], "help") == 0 || strcmp(argv[i], "h") == 0) { + } else if (strcmp(argv[i], "--version") == 0 || strcmp(argv[i], "-v") == 0) { + std::cout << version << std::endl; + return; + + } else if (strcmp(argv[i], "--help") == 0 || strcmp(argv[i], "-h") == 0) { help(); return; diff --git a/src/copy_install.cc b/src/copy_install.cc index 4e6294e..a87fa21 100644 --- a/src/copy_install.cc +++ b/src/copy_install.cc @@ -9,23 +9,24 @@ void copy_install(std::filesystem::path build_dir) { for (auto const& dir_entry : std::filesystem::recursive_directory_iterator(build_dir)) { if (dir_entry.path().extension().string().rfind(".so", 0) == 0) { - if (!std::filesystem::exists(lib+"/"+dir_entry.path().filename().string())) { - copy(dir_entry, lib+"/"+dir_entry.path().filename().string()); + if (!std::filesystem::exists(install_directories["lib"]+"/"+dir_entry.path().filename().string())) { + copy(dir_entry, install_directories["lib"]+"/"+dir_entry.path().filename().string()); if (is_verbose) { std::cout << print_pkgit << "copied library: " << dir_entry << "\n"; } } else { /*std::cout << print_pkgit << "library already exists: " << dir_entry << "\n";*/ } } else if (!access(dir_entry.path().c_str(), X_OK) && !is_directory(dir_entry.path())) { - if (!std::filesystem::exists(bin+"/"+dir_entry.path().filename().string()) && + if (!std::filesystem::exists(install_directories["bin"]+"/"+dir_entry.path().filename().string()) && + dir_entry.path().extension() != ".sample" && dir_entry.path().filename().string() != "bldit" && dir_entry.path().filename().string() != "build.sh" && dir_entry.path().filename().string() != "compile.sh") { - copy(dir_entry, bin+"/"+dir_entry.path().filename().string()); + copy(dir_entry, install_directories["bin"]+"/"+dir_entry.path().filename().string()); if (is_verbose) { std::cout << print_pkgit << "copied executable: " << dir_entry << "\n"; } } else { /*std::cout << print_pkgit << "executable already exists: " << dir_entry << "\n";*/ } } else if (dir_entry.path().extension() == ".h") { - if (!std::filesystem::exists(include+"/"+dir_entry.path().filename().string())) { - copy(dir_entry, include+"/"+dir_entry.path().filename().string()); + if (!std::filesystem::exists(install_directories["include"]+"/"+dir_entry.path().filename().string())) { + copy(dir_entry, install_directories["include"]+"/"+dir_entry.path().filename().string()); if (is_verbose) { std::cout << print_pkgit << "copied include: " << dir_entry << "\n"; } } else { /*std::cout << print_pkgit << "include already exists: " << dir_entry << "\n";*/ } } diff --git a/src/create_pkg.cc b/src/create_pkg.cc index 458150c..a6b78e9 100644 --- a/src/create_pkg.cc +++ b/src/create_pkg.cc @@ -30,7 +30,7 @@ Pkg create_pkg(std::string arg) { pkg.ver = "HEAD"; - pkg.src = pkgblds + "/" + pkg.name + "/" + pkg.ver; + pkg.src = install_directories["pkgblds"] + "/" + pkg.name + "/" + pkg.ver; return pkg; } diff --git a/src/fetch_git.cc b/src/fetch_git.cc index 6c07e69..c4fd3b2 100644 --- a/src/fetch_git.cc +++ b/src/fetch_git.cc @@ -5,19 +5,15 @@ int fetch_git(Pkg pkg) { std::string clone_cmds[] = { - "git -c advice.detachedHead=false clone --depth=1 " + pkg.url + - " " + pkg.src.c_str(), "git -c advice.detachedHead=false clone " + pkg.url + " " + pkg.src.c_str(), "git -c advice.detachedHead=false clone --branch " + pkg.ver + - " --depth=1 " + pkg.url + " " + pkg.src.c_str(), - "git -c advice.detachedHead=false clone --branch " + pkg.ver + " " + pkg.url + " " + pkg.src.c_str() }; if (strcmp(pkg.ver.c_str(), "HEAD") == 0) { - if (system(clone_cmds[0].c_str()) != 0) { system(clone_cmds[1].c_str()); } + if (system(clone_cmds[0].c_str()) != 0) { system(clone_cmds[0].c_str()); } } else { - if (system(clone_cmds[2].c_str()) != 0) { system(clone_cmds[3].c_str()); } + if (system(clone_cmds[2].c_str()) != 0) { system(clone_cmds[1].c_str()); } } return 0; } diff --git a/src/help.cc b/src/help.cc index 026144c..e20f546 100644 --- a/src/help.cc +++ b/src/help.cc @@ -22,14 +22,12 @@ void help() { std::cout << ""+red+"subcommands"+color_reset+":\n"; std::cout << ""+color_reset+"├─ "+green+"a"+color_reset+", "+yellow+"add "+blue+"[url, file] "+gray+"# add a repo/repopkg\n"; std::cout << ""+color_reset+"├─ "+green+"b"+color_reset+", "+yellow+"build "+blue+"[path] "+gray+"# build a package\n"; - std::cout << ""+color_reset+"│└── "+green+"-v"+color_reset+", "+yellow+"--verbose"+blue+"[tag] "+gray+"# give full output of build\n"; std::cout << ""+color_reset+"├┬ "+green+"i"+color_reset+", "+yellow+"install "+blue+"[pkgs, urls] "+gray+"# install a package/repo\n"; - std::cout << ""+color_reset+"│├── "+green+"-v"+color_reset+", "+yellow+"--verbose"+blue+"[tag] "+gray+"# give full output of install\n"; - std::cout << ""+color_reset+"│├── "+green+"-t:"+color_reset+", "+yellow+"--tag:"+blue+"[tag] "+gray+"# specify a version\n"; - std::cout << ""+color_reset+"│└── "+green+"-l:"+color_reset+", "+yellow+"--list:"+blue+"[filename] "+gray+"# install from a package list\n"; + //std::cout << ""+color_reset+"│├── "+green+"-t:"+color_reset+", "+yellow+"--tag:"+blue+"[tag] "+gray+"# specify a version\n"; + //std::cout << ""+color_reset+"│└── "+green+"-l:"+color_reset+", "+yellow+"--list:"+blue+"[filename] "+gray+"# install from a package list\n"; std::cout << ""+color_reset+"├─ "+green+"r"+color_reset+", "+yellow+"remove "+blue+"[pkgs] "+gray+"# remove an installed package\n"; - std::cout << ""+color_reset+"├─ "+green+"f"+color_reset+", "+yellow+"files "+blue+"[pkgs] "+gray+"# list all files of a package\n"; - std::cout << ""+color_reset+"├─ "+green+"s"+color_reset+", "+yellow+"search "+blue+"[pkgs] "+gray+"# search for packages\n"; + //std::cout << ""+color_reset+"├─ "+green+"f"+color_reset+", "+yellow+"files "+blue+"[pkgs] "+gray+"# list all files of a package\n"; + //std::cout << ""+color_reset+"├─ "+green+"s"+color_reset+", "+yellow+"search "+blue+"[pkgs] "+gray+"# search for packages\n"; std::cout << ""+color_reset+"├─ "+green+"l"+color_reset+", "+yellow+"list "+gray+"# list installed packages\n"; std::cout << ""+color_reset+"└─ "+green+"u"+color_reset+", "+yellow+"update "+gray+"# update all installed packages\n"; std::cout << "\n"; diff --git a/src/is_updated.cc b/src/is_updated.cc index f166dd8..b2c3b43 100644 --- a/src/is_updated.cc +++ b/src/is_updated.cc @@ -5,6 +5,7 @@ bool is_updated(std::string src) { if (src != std::filesystem::current_path().string()) { + if (!std::filesystem::exists(src)) { return false; } std::filesystem::current_path(src); } if (cmd_out("git pull") == "Already up to date.") { return true; } diff --git a/src/link_install.cc b/src/link_install.cc index 26c2b30..3eee1ee 100644 --- a/src/link_install.cc +++ b/src/link_install.cc @@ -7,26 +7,30 @@ #include "vars.hh" void link_install(std::filesystem::path build_dir) { - for (auto const& dir_entry : std::filesystem::recursive_directory_iterator(build_dir)) + for (auto const& dir_entry : std::filesystem::recursive_directory_iterator(build_dir)) { + std::string lib_link = install_directories["lib"]+"/"+dir_entry.path().filename().string(); + std::string bin_link = install_directories["bin"]+"/"+dir_entry.path().filename().string(); + std::string include_link = install_directories["include"]+"/"+dir_entry.path().filename().string(); if (dir_entry.path().extension().string().rfind(".so", 0) == 0) { - if (!std::filesystem::exists(lib+"/"+dir_entry.path().filename().string())) { - create_symlink(dir_entry, lib+"/"+dir_entry.path().filename().string()); - if (is_verbose) { std::cout << print_pkgit << "linked library: " << dir_entry << "\n"; } + if (!std::filesystem::exists(lib_link)) { + create_symlink(dir_entry, lib_link); + if (is_verbose) { std::cout << print_pkgit << "copied library: " << dir_entry << "\n"; } } else { /*std::cout << print_pkgit << "library already exists: " << dir_entry << "\n";*/ } } else if (!access(dir_entry.path().c_str(), X_OK) && !is_directory(dir_entry.path())) { - if (!std::filesystem::exists(bin+"/"+dir_entry.path().filename().string()) && + if (!std::filesystem::exists(bin_link) && dir_entry.path().filename().string() != "bldit" && dir_entry.path().filename().string() != "build.sh" && dir_entry.path().filename().string() != "compile.sh") { - create_symlink(dir_entry, bin+"/"+dir_entry.path().filename().string()); - if (is_verbose) { std::cout << print_pkgit << "linked executable: " << dir_entry << "\n"; } + create_symlink(dir_entry, bin_link); + if (is_verbose) { std::cout << print_pkgit << "copied executable: " << dir_entry << "\n"; } } else { /*std::cout << print_pkgit << "executable already exists: " << dir_entry << "\n";*/ } } else if (dir_entry.path().extension() == ".h") { - if (!std::filesystem::exists(include+"/"+dir_entry.path().filename().string())) { - create_symlink(dir_entry, include+"/"+dir_entry.path().filename().string()); - if (is_verbose) { std::cout << print_pkgit << "linked include: " << dir_entry << "\n"; } + if (!std::filesystem::exists(include_link)) { + create_symlink(dir_entry, include_link); + if (is_verbose) { std::cout << print_pkgit << "copied include: " << dir_entry << "\n"; } } else { /*std::cout << print_pkgit << "include already exists: " << dir_entry << "\n";*/ } } + } } diff --git a/src/remove_pkg.cc b/src/remove_pkg.cc index fa41bbc..6b82296 100644 --- a/src/remove_pkg.cc +++ b/src/remove_pkg.cc @@ -9,15 +9,15 @@ void remove_pkg(Pkg pkg) { for (auto const& dir_entry : std::filesystem::recursive_directory_iterator(pkg.src)) { if (dir_entry.path().extension().string().rfind(".so", 0) == 0) { - std::filesystem::remove(lib+"/"+dir_entry.path().filename().string()); + std::filesystem::remove(install_directories["lib"]+"/"+dir_entry.path().filename().string()); std::cout << print_pkgit << "removed library: " << dir_entry << "\n"; } else if (!access(dir_entry.path().c_str(), X_OK) && !is_directory(dir_entry.path())) { - std::filesystem::remove(bin+"/"+dir_entry.path().filename().string()); + std::filesystem::remove(install_directories["bin"]+"/"+dir_entry.path().filename().string()); std::cout << print_pkgit << "removed executable: " << dir_entry << "\n"; } else if (dir_entry.path().extension() == ".h") { - std::filesystem::remove(include+"/"+dir_entry.path().filename().string()); + std::filesystem::remove(install_directories["include"]+"/"+dir_entry.path().filename().string()); std::cout << print_pkgit << "removed include: " << dir_entry << "\n"; } } diff --git a/src/read_config.cc b/src/set_install_directories.cc index 560b978..4eb712e 100644 --- a/src/read_config.cc +++ b/src/set_install_directories.cc @@ -1,10 +1,13 @@ +#include <iostream> + extern "C" { #include <luajit-2.1/lua.h> #include <luajit-2.1/lauxlib.h> #include <luajit-2.1/lualib.h> } -#include <vars.hh> +#include "set_install_directories.hh" +#include "vars.hh" void set_install_directories() { lua_State *L = lua_open(); @@ -27,14 +30,8 @@ void set_install_directories() { const char *key = lua_tostring(L, -2); const char *value = lua_tostring(L, -1); - install_dirs[key] = value; + install_directories[key] = value; lua_pop(L, 1); } - - bin = install_dirs["bin"]; - lib = install_dirs["lib"]; - include = install_dirs["include"]; - pkgblds = install_dirs["pkgblds"]; - } diff --git a/src/setup_dirs.cc b/src/setup_dirs.cc index f0be153..3a349e6 100644 --- a/src/setup_dirs.cc +++ b/src/setup_dirs.cc @@ -1,10 +1,16 @@ #include <filesystem> +#include <iostream> #include "setup_dirs.hh" #include "vars.hh" void setup_dirs() { - for(unsigned int a = 0; a < sizeof(all_dirs)/sizeof(all_dirs[0]); a++) { - std::filesystem::create_directories(all_dirs[a]); - } + std::filesystem::create_directories(config_dir); + std::filesystem::create_directories(install_directories["bin"]); + std::filesystem::create_directories(install_directories["lib"]); + std::filesystem::create_directories(install_directories["include"]); + std::filesystem::create_directories(install_directories["pkgblds"]); + //for(unsigned int i = 0; i < sizeof(all_dirs)/sizeof(all_dirs[0]); i++) { + //std::filesystem::create_directories(all_dirs[i]); + //} } diff --git a/src/setup_pkgit.cc b/src/setup_pkgit.cc index 398cd93..15dc60c 100644 --- a/src/setup_pkgit.cc +++ b/src/setup_pkgit.cc @@ -1,8 +1,13 @@ +#include <iostream> + +#include "set_install_directories.hh" #include "setup_pkgit.hh" #include "setup_dirs.hh" #include "setup_repo.hh" +#include "vars.hh" void setup_pkgit() { + set_install_directories(); setup_dirs(); setup_repo(); } diff --git a/src/vars.cc b/src/vars.cc index 38e39bb..c288be9 100644 --- a/src/vars.cc +++ b/src/vars.cc @@ -22,21 +22,20 @@ const std::string repo_file = config_dir + "/repos.lua"; bool config_exists = std::filesystem::exists(root_config) || std::filesystem::exists(home_config); -const std::string bin = home_dir + "/.local/bin"; -const std::string lib = home_dir + "/.local/lib"; -const std::string include = home_dir + "/.local/include"; -const std::string pkgblds = home_dir + "/.local/share/pkgit"; - +const std::string bin = config_exists ? install_directories["bin"] : home_dir + "/.local/bin"; +const std::string lib = config_exists ? install_directories["lib"] : home_dir + "/.local/lib"; +const std::string include = config_exists ? install_directories["include"] : home_dir + "/.local/include"; +const std::string pkgblds = config_exists ? install_directories["pkgblds"] : home_dir + "/.local/share/pkgit"; const std::string all_dirs[] = { - config_dir, - bin, - lib, - include, - pkgblds + config_dir, + install_directories["bin"], + install_directories["lib"], + install_directories["include"], + install_directories["pkgblds"] }; // version -const std::string version = "0.1.0-breakout"; +const std::string version = "0.0.0"; // colors const std::string red = "\e[0;31m"; |
