Merge pull request 'release/v4.0.3-rc' (#5) from release/v4.0.3-rc into main
Reviewed-on: #5
This commit is contained in:
commit
73df7a5e74
21
etc/make.conf
Normal file
21
etc/make.conf
Normal file
@ -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"
|
@ -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
|
||||
|
@ -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
|
||||
|
181
libglacier.c
181
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
|
||||
*
|
||||
*/
|
||||
|
||||
@ -114,7 +133,7 @@ warnlog(char MSG[])
|
||||
*
|
||||
* DESCRIPTION: Output a stylized error message.
|
||||
* PARAMETERS: char MSG[]
|
||||
* DEFINED IN: glacier_log.h
|
||||
* DEFINED IN: log.h
|
||||
*
|
||||
*/
|
||||
|
||||
@ -134,7 +153,7 @@ errlog(char MSG[])
|
||||
*
|
||||
* DESCRIPTION: Output a stylized success message.
|
||||
* PARAMETERS: char MSG[]
|
||||
* DEFINED IN: glacier_log.h
|
||||
* DEFINED IN: log.h
|
||||
*
|
||||
*/
|
||||
|
||||
@ -154,7 +173,7 @@ successlog(char MSG[])
|
||||
*
|
||||
* DESCRIPTION: Check if necesary runtime files exist.
|
||||
* PARAMETERS: None.
|
||||
* DEFINED IN: glacier_runtime.h
|
||||
* DEFINED IN: runtime.h
|
||||
*
|
||||
*/
|
||||
|
||||
@ -182,7 +201,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 +221,7 @@ is_process_root(void)
|
||||
*
|
||||
* DESCRIPTION: Initialize libconfig.
|
||||
* PARAMETERS: None.
|
||||
* DEFINED IN: glacier_config.h
|
||||
* DEFINED IN: config.h
|
||||
*
|
||||
*/
|
||||
|
||||
@ -230,7 +249,7 @@ init_config(void)
|
||||
*
|
||||
* DESCRIPTION: Kill libconfig.
|
||||
* PARAMETERS: None.
|
||||
* DEFINED IN: glacier_config.h
|
||||
* DEFINED IN: config.h
|
||||
*
|
||||
*/
|
||||
|
||||
@ -251,49 +270,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
|
||||
int
|
||||
load_all_from_config()
|
||||
{
|
||||
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_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.");
|
||||
}
|
||||
/*
|
||||
* load_all_from_profile
|
||||
*
|
||||
* DESCRIPTION: Loads all settings from the Glacier system profile.
|
||||
* PARAMETERS: None.
|
||||
* DEFINED IN: config.h
|
||||
*
|
||||
*/
|
||||
|
||||
int
|
||||
load_all_from_profile(void)
|
||||
{
|
||||
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; }
|
||||
|
||||
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 +322,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 +340,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 +360,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 +382,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 +401,7 @@ typedef struct {
|
||||
*
|
||||
* DESCRIPTION: Initialize a queue.
|
||||
* PARAMETERS: queue *q
|
||||
* DEFINED IN: glacier_data.h
|
||||
* DEFINED IN: data.h
|
||||
*
|
||||
*/
|
||||
|
||||
@ -394,7 +417,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 +428,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 +439,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 +460,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 +480,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 +500,7 @@ peek(queue *q)
|
||||
*
|
||||
* DESCRIPTION: Print the queue.
|
||||
* PARAMETERS: queue *q
|
||||
* DEFINED IN: glacier_data.h
|
||||
* DEFINED IN: data.h
|
||||
*
|
||||
*/
|
||||
|
||||
@ -502,7 +525,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 +554,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 +609,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 +642,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 +677,4 @@ compare_file_hash(char ORIG_HASH[], char FILE[])
|
||||
printf("%02x", hash[i]);
|
||||
}
|
||||
}
|
||||
*/
|
||||
|
@ -1,27 +0,0 @@
|
||||
#include <errno.h>
|
||||
#include <stdio.h>
|
||||
#include <unistd.h>
|
||||
|
||||
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");
|
||||
}
|
Loading…
Reference in New Issue
Block a user