aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJoseph Hunkeler <jhunkeler@gmail.com>2019-12-19 01:32:00 -0500
committerJoseph Hunkeler <jhunkeler@gmail.com>2019-12-19 01:32:00 -0500
commit03351a8cb70339055fcdedc12b93bb3bd920b4de (patch)
tree16ec34a329247f4dfa79ad92be596d50062657ff
parentb3fcaefd320b0b4999d2d380139ab8610c6a0233 (diff)
downloadspmc-03351a8cb70339055fcdedc12b93bb3bd920b4de.tar.gz
Clean up a little bit.
-rw-r--r--include/spm.h1
-rw-r--r--src/config_global.c1
-rw-r--r--src/spm.c20
3 files changed, 12 insertions, 10 deletions
diff --git a/include/spm.h b/include/spm.h
index 9f3ae17..5e6e182 100644
--- a/include/spm.h
+++ b/include/spm.h
@@ -66,6 +66,7 @@ typedef struct {
char *tmp_dir;
char *user_config_basedir;
char *user_config_file;
+ int verbose;
ConfigItem **config;
struct utsname sysinfo;
} spm_vars;
diff --git a/src/config_global.c b/src/config_global.c
index b1c6dc2..bbce6ef 100644
--- a/src/config_global.c
+++ b/src/config_global.c
@@ -103,6 +103,7 @@ void init_config_global(void) {
SPM_GLOBAL.package_dir = NULL;
SPM_GLOBAL.tmp_dir = NULL;
SPM_GLOBAL.config = NULL;
+ SPM_GLOBAL.verbose = 0;
if (uname(&SPM_GLOBAL.sysinfo) != 0) {
fprintf(SYSERROR);
diff --git a/src/spm.c b/src/spm.c
index 14ebd2d..7877253 100644
--- a/src/spm.c
+++ b/src/spm.c
@@ -5,7 +5,6 @@
#include <errno.h>
#include "spm.h"
-int RUNTIME_VERBOSE = 0;
int RUNTIME_INSTALL = 0;
int RUNTIME_ROOTDIR = 0;
const int PACKAGE_MAX = 0xff;
@@ -26,14 +25,12 @@ int main(int argc, char *argv[]) {
memset(program_name, '\0', sizeof(program_name) + 1);
strcpy(program_name, basename(argv[0]));
-
// not much to see here yet
// at the moment this will all be random tests, for better or worse
// everything here is subject to change without notice
// Initialize configuration data
init_config_global();
- show_global_config();
// Ensure external programs are available for use.
check_runtime_environment();
@@ -61,10 +58,10 @@ int main(int argc, char *argv[]) {
}
else if (strcmp(arg, "-V") == 0 || strcmp(arg, "--version") == 0) {
printf("want version\n");
+ exit(0);
}
else if (strcmp(arg, "-v") == 0 || strcmp(arg, "--verbose") == 0) {
- printf("verbose mode\n");
- RUNTIME_VERBOSE = 1;
+ SPM_GLOBAL.verbose = 1;
}
else if (strcmp(arg, "-r") == 0 || strcmp(arg, "--root") == 0) {
RUNTIME_ROOTDIR = 1;
@@ -99,21 +96,24 @@ int main(int argc, char *argv[]) {
}
}
+ // Dump configuration
+ show_global_config();
+
if (RUNTIME_ROOTDIR && !RUNTIME_INSTALL) {
fprintf(stderr, "-r|--root requires -I|--install\n");
usage(program_name);
exit(1);
}
- if (isempty(root)) {
- printf("Using default installation root\n");
- sprintf(root, "%s%c%s", getenv("HOME"), DIRSEP, "spm_root");
- }
-
if (RUNTIME_INSTALL) {
Dependencies *deps = NULL;
dep_init(&deps);
+ if (isempty(root)) {
+ printf("Using default installation root\n");
+ sprintf(root, "%s%c%s", getenv("HOME"), DIRSEP, "spm_root");
+ }
+
printf("Installation root: %s\n", root);
printf("Requested packages:\n");
for (int i = 0; i < PACKAGE_MAX; i++) {