Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fixed some environment variables variating between comfig.c and init.c #26

Merged
merged 3 commits into from
Nov 1, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions src/config.c
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,8 @@ ConfigEntry configEntries[] = {
{ "SOVIET_DEFAULT_FORMAT", "ecmp" },
{ "MAIN_DIR", "/var/cccp" },
{ "WORK_DIR", "/var/cccp/work" },
{ "INSTALLED_DB", "/var/cccp/installed_db" },
{ "ALL_DB", "/var/cccp/all_db" },
{ "INSTALLED_DB", "/var/cccp/data/installed.db" },
{ "ALL_DB", "/var/cccp/data/all.db" },
{ "CONFIG_FILE", DEFAULT_CONFIG_FILE },
{ "SOVIET_REPOS", "/var/cccp/repos" },
{ "SOVIET_FORMATS", "ecmp" },
Expand Down
32 changes: 16 additions & 16 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,17 +68,17 @@ void init() {

// Verify if required directories exist, and create them if not
struct stat st = {0};
if (stat(getenv("SOVIET_ROOT"), &st) == -1) {
mkdir(getenv("SOVIET_ROOT"), 0777);
if (stat(getenv("ROOT"), &st) == -1) {
mkdir(getenv("ROOT"), 0777);
}
if (stat(getenv("SOVIET_MAIN_DIR"), &st) == -1) {
mkdir(getenv("SOVIET_MAIN_DIR"), 0777);
if (stat(getenv("MAIN_DIR"), &st) == -1) {
mkdir(getenv("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) {
mkdir(getenv("SOVIET_WORK_DIR"), 0777);
if (stat(getenv("WORK_DIR"), &st) == -1) {
mkdir(getenv("WORK_DIR"), 0777);
}
if (stat(getenv("SOVIET_SPM_DIR"), &st) == -1) {
mkdir(getenv("SOVIET_SPM_DIR"), 0777);
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
2 changes: 1 addition & 1 deletion src/move.c
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ void move_binaries(char** locations, long loc_size) {
// Iterate through locations and move the binaries to their correct locations
for (int i = 0; i < loc_size; i++) {
char dest_loc[PATH_MAX];
sprintf(dest_loc, "%s/%s", getenv("SOVIET_ROOT"), locations[i]);
sprintf(dest_loc, "%s/%s", getenv("ROOT"), locations[i]);
char build_loc[PATH_MAX];
sprintf(build_loc, "%s/%s", getenv("SOVIET_BUILD_DIR"), locations[i]);

Expand Down