diff --git a/src/get.c b/src/get.c index 4f0c689..34dca80 100755 --- a/src/get.c +++ b/src/get.c @@ -38,6 +38,9 @@ int get_repos(char** list) struct dirent *dir; d = opendir(getenv("SOVIET_REPOS_DIR")); int count = 0; + list[count] = calloc(strlen("local") + 1, 1); + sprintf(list[count], "local"); + count++; if (d) { while ((dir = readdir(d)) != NULL) diff --git a/src/install.c b/src/install.c index 0bc38b5..6d0c1a0 100755 --- a/src/install.c +++ b/src/install.c @@ -155,6 +155,10 @@ int f_install_package_source(const char* spm_path, int as_dep, char* repo) { setenv("SHA256", pkg.sha256, 1); } + // Set environment variables for building + setenv("BUILD_ROOT", build_dir, 1); + + // Check if a package is a collection if(strcmp(pkg.type, "con") != 0) { @@ -174,11 +178,11 @@ int f_install_package_source(const char* spm_path, int as_dep, char* repo) { if (getuid() == 0) { /* process is running as root, drop privileges */ - if (setgid(1000) != 0) + if (setgid(65534) != 0) { msg(ERROR, "setgid: Unable to drop group privileges"); } - if (setuid(1000) != 0) + if (setuid(65534) != 0) { msg(ERROR, "setuid: Unable to drop user privileges"); } @@ -200,6 +204,21 @@ int f_install_package_source(const char* spm_path, int as_dep, char* repo) { dbg(1, "Making %s done", pkg.name); + // Run 'install' command + if (pkg.info.install == NULL && strlen(pkg.info.install) == 0) { + msg(FATAL, "No install command!"); + } + + char install_cmd[64 + strlen(legacy_dir) + strlen(pkg.info.install)]; + sprintf(install_cmd, "( cd %s && %s )", legacy_dir, pkg.info.install); + + dbg(2, "Executing install command: %s", install_cmd); + if (system(install_cmd) != 0) { + msg(FATAL, "Failed to install %s", pkg.name); + return -2; + } + dbg(1, "Install command executed!"); + // Get package locations dbg(1, "Getting locations for %s", pkg.name); pkg.locationsCount = get_locations(&pkg.locations, getenv("SOVIET_BUILD_DIR")); @@ -448,7 +467,7 @@ int free_pkg(struct package* pkg) { if (pkg->info.special != NULL) free(pkg->info.special); if (pkg->info.download != NULL) free(pkg->info.download); if (pkg->info.install != NULL) free(pkg->info.install); - if (pkg->info.prepare != NULL) free(pkg->info.install); + if (pkg->info.prepare != NULL) free(pkg->info.prepare); if (pkg->info.test != NULL) free(pkg->info.test); if (pkg->locations) { diff --git a/src/make.c b/src/make.c index 62c89d6..3ca5f58 100755 --- a/src/make.c +++ b/src/make.c @@ -34,10 +34,6 @@ int make(char* package_dir, struct package* pkg) { cmd_params = ""; } - // Set environment variables for building - setenv("BUILD_ROOT", build_dir, 1); - - // TODO: this // Thinking about putting the package caching here // Maybe it will check if the installed version matches $VERSION @@ -168,7 +164,8 @@ int make(char* package_dir, struct package* pkg) { dbg(2, "Executing prepare command: %s", prepare_cmd); if (system(prepare_cmd) != 0) { - return 1; + msg(FATAL, "Failed to prepare %s", pkg->name); + return -2; } dbg(1, "Prepare command executed!"); } @@ -197,22 +194,6 @@ int make(char* package_dir, struct package* pkg) { dbg(1, "Test command executed!"); } - // Run 'install' command - if (pkg->info.install == NULL && strlen(pkg->info.install) == 0) { - msg(ERROR, "No install command!"); - return -3; - } - - char install_cmd[64 + strlen(package_dir) + strlen(pkg->info.install) + strlen(cmd_params)]; - sprintf(install_cmd, "( cd %s && %s ) %s", package_dir, pkg->info.install, cmd_params); - - dbg(2, "Executing install command: %s", install_cmd); - if (system(install_cmd) != 0) { - msg(FATAL, "Failed to install %s", pkg->name); - return -2; - } - dbg(1, "Install command executed!"); - return 0; } diff --git a/src/uninstall.c b/src/uninstall.c index 60d74ba..e4aebfc 100755 --- a/src/uninstall.c +++ b/src/uninstall.c @@ -38,10 +38,6 @@ int uninstall(char* name) int REPO_COUNT = get_repos(REPOS); char* dataSpmPath = calloc(MAX_PATH, sizeof(char)); - // add local repo - REPOS[REPO_COUNT] = "local"; - REPO_COUNT++; - for (int j = 0; j < REPO_COUNT; j++) { // Generate the path to the package's SPM file