From e69b9c1197bf6390bb23177be9531c552f284fdb Mon Sep 17 00:00:00 2001 From: Liam Waldron Date: Sat, 28 Dec 2024 13:04:11 -0500 Subject: [PATCH 1/2] add finishing touches for v4.0.3-rc --- VERSION | 2 +- etc/make.conf | 21 ++++++ include/globals.h | 7 ++ include/security.h | 2 +- libglacier.c | 176 +++++++++++++++++++++++---------------------- pkg/run-pkg.c | 27 ------- 6 files changed, 119 insertions(+), 116 deletions(-) create mode 100644 etc/make.conf delete mode 100644 pkg/run-pkg.c diff --git a/VERSION b/VERSION index 220c212..08fd861 100644 --- a/VERSION +++ b/VERSION @@ -1 +1 @@ -4.0.0-rc7 +4.0.3-rc diff --git a/etc/make.conf b/etc/make.conf new file mode 100644 index 0000000..5a486e7 --- /dev/null +++ b/etc/make.conf @@ -0,0 +1,21 @@ +# +# make.conf +# The settings defined in this file will be loaded when 'make' is called during a Glacier operation. +# For more information on this file, see https://www.everestlinux.org/docs/intro-to-glacier +# + +# Number of parallel makejobs. By default this is set by nproc and should be optimal for your system. +MAKEFLAGS="-j$(nproc)" + +# Build and compile flags for C and C++ programs. +# Using too many build flags will break packages. Disable these if packages are breaking. +CFLAGS="-O2" +CXXFLAGS="${CFLAGS}" + +# Treat all warnings as errors +# Not recommended, as many packages with larger codebases may refuse to compile. +#CFLAGS="-Werror" + +# Prefix for packages to be installed. +# Not all packages will honor this. +PREFIX="/usr" diff --git a/include/globals.h b/include/globals.h index 25df87a..9c48331 100644 --- a/include/globals.h +++ b/include/globals.h @@ -22,6 +22,10 @@ extern config_t cfg; extern config_setting_t *setting; extern const char str; +extern char GLACIER_ALLOWED_LICENSES; +extern int GLACIER_DO_INT_CHECK; +extern int GLACIER_VERBOSE; + extern const char *GLACIER_REPO; extern const char *GLACIER_ARCH; extern const char *GLACIER_TARGET; @@ -30,4 +34,7 @@ extern const char *GLACIER_SYSTEM_PROFILE; const char *runtime_files[]; +extern FILE *expected_hash; +extern FILE *pkg; + #endif diff --git a/include/security.h b/include/security.h index 591d480..38bc257 100644 --- a/include/security.h +++ b/include/security.h @@ -33,6 +33,6 @@ * compare_file_hash("pkg.sha256sum", "pkg.tar.xz"); */ -int compare_file_hash(char ORIG_HASH[], char FILE[]); +/* int compare_file_hash(char ORIG_HASH[], char FILE[]); */ #endif diff --git a/libglacier.c b/libglacier.c index 1c18328..f6bdbd9 100644 --- a/libglacier.c +++ b/libglacier.c @@ -37,44 +37,63 @@ #define MAX_CHILDREN 64 #define MAX_SIZE 256 -/* Global variables */ +/* + * Global Variables + * + * Descriptions are given as comments after the variable declaration. + * DEFINED IN: globals.h + * + */ -config_t cfg; -config_setting_t *setting; -const char str; +config_t cfg; /* Context for libconfig */ +config_setting_t *setting; /* Pointer for setting */ +const char str; /* Unsure what this does, will possibly remove later */ -int GLACIER_ALLOW_SERVICES; -char GLACIER_ALLOWED_LICENSES; -int GLACIER_DO_INT_CHECK; -int GLACIER_VERBOSE; +int GLACIER_ALLOW_SERVICES; /* Declaration of GLACIER_ALLOW_SERVICES as given in glacier.cfg */ +char GLACIER_ALLOWED_LICENSES; /* Declaration of GLACIER_ALLOWED_LICENSES as given in glacier.cfg */ +int GLACIER_DO_INT_CHECK; /* Declaration of GLACIER_DO_INT_CHECK as given in glacier.cfg */ +int GLACIER_VERBOSE; /* Declaration of GLACIER_VERBOSE as given in glacier.cfg */ -const char *GLACIER_REPO; -const char *GLACIER_ARCH; -const char *GLACIER_TARGET; -const char *GLACIER_LOCALDB; -const char *GLACIER_SYSTEM_PROFILE; +const char *GLACIER_REPO; /* Declaration of GLACIER_REPO as defined in profile.cfg */ +const char *GLACIER_ARCH; /* Declaration of GLACIER_ARCH as defined in profile.cfg */ +const char *GLACIER_TARGET; /* Declaration of GLACIER_TARGET as defined in profile.cfg */ +const char *GLACIER_LOCALDB; /* Declaration of GLACIER_LOCALDB as defined in profile.cfg */ +const char *GLACIER_SYSTEM_PROFILE; /* Declaration of GLACIER_SYSTEM_PROFILE as defined in profile.cfg */ +/* Required runtime files */ const char *runtime_files[] = { "/etc/glacier.cfg", "/etc/glacier/call-hooks", "/etc/make.conf" }; +FILE *expected_hash; /* File pointer for expected hash */ +FILE *pkg; /* File pointer for package hash */ + +/* + * END GLOBAL VARIABLES + */ + +/* + * node + * + * DESCRIPTION: Definition of node type. + * DEFINED IN: data.h + * + */ + struct node { char *data; struct node *children[MAX_CHILDREN]; int numChildren; }; -FILE *expected_hash; -FILE *pkg; - /* * infolog * * DESCRIPTION: Output a stylized info message. * PARAMETERS: char MSG[] - * DEFINED IN: glacier_log.h + * DEFINED IN: log.h * */ @@ -94,7 +113,7 @@ infolog(char MSG[]) * * DESCRIPTION: Output a stylized warning message. * Parameters: char MSG[] - * DEFINED IN: glacier_log.h + * DEFINED IN: log.h * */ @@ -109,12 +128,13 @@ warnlog(char MSG[]) return; } + continue; /* * errlog * * DESCRIPTION: Output a stylized error message. * PARAMETERS: char MSG[] - * DEFINED IN: glacier_log.h + * DEFINED IN: log.h * */ @@ -134,7 +154,7 @@ errlog(char MSG[]) * * DESCRIPTION: Output a stylized success message. * PARAMETERS: char MSG[] - * DEFINED IN: glacier_log.h + * DEFINED IN: log.h * */ @@ -154,7 +174,7 @@ successlog(char MSG[]) * * DESCRIPTION: Check if necesary runtime files exist. * PARAMETERS: None. - * DEFINED IN: glacier_runtime.h + * DEFINED IN: runtime.h * */ @@ -182,7 +202,7 @@ runtime_exists(void) * * DESCRIPTION: Check if process is running as root. * PARAMETERS: char MSG[] - * DEFINED IN: glacier_runtime.h + * DEFINED IN: runtime.h * */ @@ -202,7 +222,7 @@ is_process_root(void) * * DESCRIPTION: Initialize libconfig. * PARAMETERS: None. - * DEFINED IN: glacier_config.h + * DEFINED IN: config.h * */ @@ -230,7 +250,7 @@ init_config(void) * * DESCRIPTION: Kill libconfig. * PARAMETERS: None. - * DEFINED IN: glacier_config.h + * DEFINED IN: config.h * */ @@ -251,49 +271,46 @@ die_config(void) * * DESCRIPTION: Loads all settings from the Glacier config file. * PARAMETERS: None. - * DEFINED IN: glacier_config.h + * DEFINED IN: config.h * */ int load_all_from_config(void) { - config_lookup_bool(&cfg, "GLACIER_DO_INT_CHECK", &GLACIER_DO_INT_CHECK); - config_lookup_bool(&cfg, "GLACIER_VERBOSE", &GLACIER_VERBOSE); + /* this is probably really ugly but it works */ + if (! config_lookup_bool(&cfg, "GLACIER_DO_INT_CHECK", &GLACIER_DO_INT_CHECK)) { return 1; } + if (! config_lookup_bool(&cfg, "GLACIER_VERBOSE", &GLACIER_VERBOSE)) { return 1; } - config_lookup_string(&cfg, "GLACIER_REPO", &GLACIER_REPO); - config_lookup_string(&cfg, "GLACIER_ARCH", &GLACIER_ARCH); - config_lookup_string(&cfg, "GLACIER_TARGET", &GLACIER_TARGET); - config_lookup_string(&cfg, "GLACIER_SYSTEM_PROFILE", &GLACIER_SYSTEM_PROFILE); + return 0; } -/* issues with this idk +/* + * load_all_from_profile + * + * DESCRIPTION: Loads all settings from the Glacier system profile. + * PARAMETERS: None. + * DEFINED IN: config.h + * + */ + int -load_all_from_config() +load_all_from_profile(void) { - if(config_lookup_bool(&cfg, "GLACIER_ALLOW_SERVICES", &GLACIER_ALLOW_SERVICES)) - printf("Services allowed: %s\n", GLACIER_ALLOW_SERVICES ? "true" : "false"); - else - warnlog("GLACIER_SERVICES_ALLOWED is not defined in glacier.cfg."); + if (! config_lookup_string(&cfg, "GLACIER_REPO", &GLACIER_REPO)) { return 1; } + if (! config_lookup_string(&cfg, "GLACIER_ARCH", &GLACIER_ARCH)) { return 1; } + if (! config_lookup_string(&cfg, "GLACIER_TARGET", &GLACIER_TARGET)) { return 1; } + if (! config_lookup_string(&cfg, "GLACIER_SYSTEM_PROFILE", &GLACIER_SYSTEM_PROFILE)) { return 1; } - if(config_lookup_bool(&cfg, "GLACIER_DO_INT_CHECK", &GLACIER_DO_INT_CHECK)) - printf("Integrity checking enabled: %s\n", GLACIER_DO_INT_CHECK ? "true" : "false"); - else - warnlog("GLACIER_DO_INT_CHECK is not defined in glacier.cfg."); - - if(config_lookup_bool(&cfg, "GLACIER_VERBOSE", &GLACIER_VERBOSE)) - printf("Verbose logging: %s\n", GLACIER_VERBOSE ? "true" : "false"); - else - warnlog("GLACIER_VERBOSE is not defined in glacier.cfg."); + return 0; } -*/ /* * load_setting_from_config * * DESCRIPTION: Load a specified setting from the Glacier config file. * PARAMETERS: char SETTING[] - * DEFINED IN: glacier_config.h + * DEFINED IN: config.h * */ @@ -306,7 +323,7 @@ load_setting_from_config(char SETTING[]) * * DESCRIPTION: Create a dependency tree node. * PARAMETERS: char *data -* DEFINED IN: glacier_data.h +* DEFINED IN: data.h * */ @@ -324,7 +341,7 @@ struct node * * DESCRIPTION: Add a child node to a parent node. * PARAMETERS: struct node *parent, struct node *child - * DEFINED IN: glacier_data.h + * DEFINED IN: data.h * */ @@ -344,7 +361,7 @@ add_child(struct node *parent, struct node *child) * * DESCRIPTION: Print a dependency tree. * PARAMETERS: struct node *root, int level -* DEFINED IN: glacier_data.h +* DEFINED IN: data.h * */ @@ -366,7 +383,14 @@ print_tree(struct node *root, int level) } } -/* Definition of queue data type */ +/* + * queue + * + * DESCRIPTION: Definition of queue type. + * DEFINED IN: data.h + * + */ + typedef struct { int items[MAX_SIZE]; int front; @@ -378,7 +402,7 @@ typedef struct { * * DESCRIPTION: Initialize a queue. * PARAMETERS: queue *q -* DEFINED IN: glacier_data.h +* DEFINED IN: data.h * */ @@ -394,7 +418,7 @@ init_queue(queue *q) * * DESCRIPTION: Check if queue is empty. * PARAMETERS: struct node *root, int level -* DEFINED IN: glacier_data.h +* DEFINED IN: data.h * */ @@ -405,7 +429,7 @@ bool queue_is_empty(queue *q) { return (q -> front == q -> rear -1); } * * DESCRIPTION: Check if queue is full. * PARAMETERS: queue *q -* DEFINED IN: glacier_data.h +* DEFINED IN: data.h * */ @@ -416,7 +440,7 @@ bool queue_is_full(queue *q) { return (q -> rear == MAX_SIZE); } * * DESCRIPTION: Enqueue an element at the back of the queue. * PARAMETERS: queue *q, int value -* DEFINED IN: glacier_data.h +* DEFINED IN: data.h * */ @@ -437,7 +461,7 @@ enqueue (queue *q, int value) * * DESCRIPTION: Dequeue the element at the front of the queue. * PARAMETERS: queue *q, int value -* DEFINED IN: glacier_data.h +* DEFINED IN: data.h * */ @@ -457,7 +481,7 @@ dequeue(queue *q) * * DESCRIPTION: View the element at the front of the queue. * PARAMETERS: struct node *root, int level -* DEFINED IN: glacier_data.h +* DEFINED IN: data.h * */ @@ -477,7 +501,7 @@ peek(queue *q) * * DESCRIPTION: Print the queue. * PARAMETERS: queue *q -* DEFINED IN: glacier_data.h +* DEFINED IN: data.h * */ @@ -502,7 +526,7 @@ print_queue(queue *q) * * DESCRIPTION: Creates a new Glacier workspace in /tmp. * PARAMETERS: None. - * DEFINED IN: glacier_pkgops.h + * DEFINED IN: pkgops.h * */ @@ -531,11 +555,10 @@ mkworkspace(void) * * DESCRIPTION: Copies a package archive from the localdb to the workspace, and unpacks it. * PARAMETERS: char PACKAGE[] - * DEFINED IN: glacier_pkgops.h + * DEFINED IN: pkgops.h * */ - int prepare_pkg(char PACKAGE[]) { @@ -587,35 +610,12 @@ prepare_pkg(char PACKAGE[]) } } -/* download_package_sources() is deprecated and will be removed in a later release. */ - -/* int -download_package_sources(char PACKAGE[]) -{ - printf(COL_BLUE "[i] " COL_RESET "Downloading package archive for %s...\n", PACKAGE); - if (GLACIER_SYSTEM_PROFILE == "x86-musl") { - execl("/glacier/tools/wget", "https://git.everestlinux.org/EverestLinux/epkgs-x86-musl/", NULL); - } else { - printf(COL_RED "[x] " COL_RESET "System profile '%s' is not supported.\n", GLACIER_SYSTEM_PROFILE); - } -} */ - -void -TEST_chdir(char dir[]) -{ - char *buf; - chdir(dir); - buf = (char *) malloc(100*sizeof(char)); - getcwd(buf, 100); - printf("%s\n", buf); -} - /* * run_make_task * * DESCRIPTION: Runs a make task in current working directory * PARAMETERS: char TASK[] - * DEFINED IN: glacier_pkgops.h + * DEFINED IN: pkgops.h * */ @@ -643,10 +643,11 @@ run_make_task(char TASK[]) * * DESCRIPTION: Compare two file hashes * PARAMETERS: char ORIG_HASH[], char FILE[] - * DEFINED IN: glacier_security.h + * DEFINED IN: security.h * */ +/* int compare_file_hash(char ORIG_HASH[], char FILE[]) { @@ -677,3 +678,4 @@ compare_file_hash(char ORIG_HASH[], char FILE[]) printf("%02x", hash[i]); } } +*/ diff --git a/pkg/run-pkg.c b/pkg/run-pkg.c deleted file mode 100644 index 2a54626..0000000 --- a/pkg/run-pkg.c +++ /dev/null @@ -1,27 +0,0 @@ -#include -#include -#include - -int -run_make_task(char task[]) -{ - char *build_args[] = { - "/bin/make", - task, - NULL - }; - - execvp( - "/bin/make", - build_args - ); - if (errno != 0 ) { - return errno; - } -} - -int -main() -{ - run_make_task("help"); -} From 38f6c5adf7a2f6f9a754366526c3d0991704c7af Mon Sep 17 00:00:00 2001 From: Liam Waldron Date: Sat, 28 Dec 2024 13:06:52 -0500 Subject: [PATCH 2/2] fix compilation error on line 131 --- libglacier.c | 1 - 1 file changed, 1 deletion(-) diff --git a/libglacier.c b/libglacier.c index f6bdbd9..1493f7d 100644 --- a/libglacier.c +++ b/libglacier.c @@ -128,7 +128,6 @@ warnlog(char MSG[]) return; } - continue; /* * errlog *