aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authordacctal <dacctal@muc.symlinx.net>2026-04-05 18:54:52 +0000
committerdacctal <dacctal@muc.symlinx.net>2026-04-05 18:54:52 +0000
commit8be34eec7e3dc9852d7f29a4e333470d98008888 (patch)
treed03fc235a4fc43996bfcf12229ebcfdb649f7c66 /src
parented78991edc4755c0276dcb4eb454b43fa38296fc (diff)
universal(?) lua support
Diffstat (limited to 'src')
-rw-r--r--src/add_repo.cc16
-rw-r--r--src/lua_build.cc8
-rw-r--r--src/setup_repo.cc9
3 files changed, 22 insertions, 11 deletions
diff --git a/src/add_repo.cc b/src/add_repo.cc
index 3de06dc..f2a4910 100644
--- a/src/add_repo.cc
+++ b/src/add_repo.cc
@@ -5,16 +5,22 @@
#include "vars.hh"
void add_repo(std::string repo, std::string repo_name) {
- std::ifstream rfile(repo_file);
+ bool is_previous_repos = false;
std::string rfile_line;
std::string rfile_contents;
- while (getline(rfile, rfile_line)) {
- rfile_contents += rfile_line + "\n";
+ if (std::filesystem::exists(repo_file)) {
+ std::ifstream rfile(repo_file);
+ while (getline(rfile, rfile_line)) {
+ rfile_contents += rfile_line + "\n";
+ }
+ rfile.close();
+ is_previous_repos = true;
}
- rfile.close();
+
+ std::string previous_repos = is_previous_repos ? rfile_contents : "";
std::ofstream wfile;
wfile.open(repo_file);
- wfile << rfile_contents << "repos[\"" << repo_name << "\"] = \"" << repo << "\"" << std::endl;
+ wfile << previous_repos << "repos[\"" << repo_name << "\"] = \"" << repo << "\"" << std::endl;
wfile.close();
}
diff --git a/src/lua_build.cc b/src/lua_build.cc
index 7d89450..bf21f66 100644
--- a/src/lua_build.cc
+++ b/src/lua_build.cc
@@ -1,9 +1,11 @@
#include <iostream>
#include <filesystem>
#include <map>
-#include <lua5.1/lua.h>
-#include <lua5.1/lauxlib.h>
-#include <lua5.1/lualib.h>
+extern "C" {
+#include <luajit-2.1/lua.h>
+#include <luajit-2.1/lauxlib.h>
+#include <luajit-2.1/lualib.h>
+}
#include "lua_build.hh"
#include "vars.hh"
diff --git a/src/setup_repo.cc b/src/setup_repo.cc
index 402238f..99ca451 100644
--- a/src/setup_repo.cc
+++ b/src/setup_repo.cc
@@ -1,7 +1,9 @@
#include <iostream>
-#include <lua5.1/lua.h>
-#include <lua5.1/lauxlib.h>
-#include <lua5.1/lualib.h>
+extern "C" {
+#include <luajit-2.1/lua.h>
+#include <luajit-2.1/lauxlib.h>
+#include <luajit-2.1/lualib.h>
+}
#include "setup_repo.hh"
#include "ensure_repo.hh"
@@ -15,6 +17,7 @@ void setup_repo() {
if (luaL_loadfile(L, config_file.c_str()) || lua_pcall(L, 0, 0, 0)){
std::cout << print_error << "cannot run configuration script: " << lua_tostring(L, -1) << "\n";
+ return;
}
lua_getglobal(L, "repos");