Skip to content

Commit

Permalink
fixed all.db path not being set correctly in init
Browse files Browse the repository at this point in the history
  • Loading branch information
AleksArt000 committed Nov 1, 2023
1 parent fa35632 commit b18651e
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 15 deletions.
2 changes: 1 addition & 1 deletion src/config.c
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ ConfigEntry configEntries[] = {
{ "MAIN_DIR", "/var/cccp" },
{ "WORK_DIR", "/var/cccp/work" },
{ "INSTALLED_DB", "/var/cccp/data/installed.db" },
{ "ALL_DB", "/var/cccp/all_db" },
{ "ALL_DB", "/var/cccp/data/all.db" },
{ "CONFIG_FILE", DEFAULT_CONFIG_FILE },
{ "SOVIET_REPOS", "/var/cccp/repos" },
{ "SOVIET_FORMATS", "ecmp" },
Expand Down
26 changes: 13 additions & 13 deletions src/init.c
Original file line number Diff line number Diff line change
Expand Up @@ -26,19 +26,19 @@ void init() {
dbg(3, "Setting variables");

// Set global variables for various paths and directories
setenv("SOVIET_ROOT", "/", 0);
setenv("SOVIET_MAIN_DIR", "/var/cccp", 0);
setenv("ROOT", "/", 0);
setenv("MAIN_DIR", "/var/cccp", 0);
setenv("SOVIET_DATA_DIR", "/var/cccp/data", 0);
setenv("SOVIET_WORK_DIR", "/var/cccp/work", 0);
setenv("WORK_DIR", "/var/cccp/work", 0);
setenv("SOVIET_SPM_DIR", "/var/cccp/spm", 0);
setenv("SOVIET_LOG_DIR", "/var/cccp/log", 0);
setenv("SOVIET_PLUGIN_DIR", "/var/cccp/plugins", 0);
setenv("SOVIET_BUILD_DIR", "/var/cccp/work/build", 0);
setenv("SOVIET_MAKE_DIR", "/var/cccp/work/make", 0);
setenv("SOVIET_INSTALLED_DB_PATH", "/var/cccp/data/installed.db", 0);
setenv("SOVIET_ALL_DB_PATH", "/var/cccp/data/all.db", 0);
setenv("INSTALLED_DB", "/var/cccp/data/installed.db", 0);
setenv("ALL_DB", "/var/cccp/data/all.db", 0);
setenv("SOVIET_TEST_LOG", "/var/cccp/log/test.log", 0);

// Clean the working directories
clean();

Expand Down Expand Up @@ -68,16 +68,16 @@ void init() {

// Verify if required directories exist, and create them if not
struct stat st = {0};
if (stat(getenv("SOVIET_ROOT"), &st) == -1) {
if (stat(getenv("ROOT"), &st) == -1) {
mkdir(getenv("SOVIET_ROOT"), 0777);
}
if (stat(getenv("SOVIET_MAIN_DIR"), &st) == -1) {
if (stat(getenv("MAIN_DIR"), &st) == -1) {
mkdir(getenv("SOVIET_MAIN_DIR"), 0777);
}
if (stat(getenv("SOVIET_DATA_DIR"), &st) == -1) {
mkdir(getenv("SOVIET_DATA_DIR"), 0777);
}
if (stat(getenv("SOVIET_WORK_DIR"), &st) == -1) {
if (stat(getenv("WORK_DIR"), &st) == -1) {
mkdir(getenv("SOVIET_WORK_DIR"), 0777);
}
if (stat(getenv("SOVIET_SPM_DIR"), &st) == -1) {
Expand All @@ -97,17 +97,17 @@ void init() {
}

// Initialize the databases
char* installed_db_path_env = getenv("SOVIET_INSTALLED_DB_PATH");
char* installed_db_path_env = getenv("INSTALLED_DB");
if (!installed_db_path_env) {
msg(ERROR, "SOVIET_INSTALLED_DB_PATH environment variable not set");
msg(ERROR, "INSTALLED_DB environment variable not set");
exit(1);
}
connect_db(&INSTALLED_DB, installed_db_path_env);
create_table_installed(INSTALLED_DB);

char* all_db_path_env = getenv("SOVIET_ALL_DB_PATH");
char* all_db_path_env = getenv("ALL_DB");
if (!all_db_path_env) {
msg(ERROR, "SOVIET_ALL_DB_PATH environment variable not set");
msg(ERROR, "ALL_DB environment variable not set");
exit(1);
}

Expand Down
2 changes: 1 addition & 1 deletion src/list.c
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
//will print the content of INSTALLED_DB
int list_installed()
{
msg(INFO, "listing installed packages from %s", getenv(INSTALLED_DB));
msg(INFO, "listing installed packages from %s", getenv("INSTALLED_DB"));
if(0 == 1)
{
sqlite3_stmt *stmt;
Expand Down

0 comments on commit b18651e

Please sign in to comment.