v4.0.0-rc
This commit is contained in:
parent
9f14fd745c
commit
ee51ce5ed5
11
Makefile
11
Makefile
@ -15,5 +15,16 @@ test:
|
||||
$(CC) libglacier.c $(LIBFLAGS) -o libglacier.test
|
||||
cp etc/example.cfg ./glacier.cfg
|
||||
|
||||
lib:
|
||||
$(CC) libglacier.c -c $(LIBFLAGS) -o lib/libglacier.o
|
||||
$(AR) -rc lib/libglacier.a lib/libglacier.o
|
||||
|
||||
install:
|
||||
install lib/libglacier.a $(PREFIX)/lib
|
||||
install include/glacier_config.h $(PREFIX)/include
|
||||
install include/glacier_log.h $(PREFIX)/include
|
||||
install include/glacier_pkgops.h $(PREFIX)/include
|
||||
install include/glacier_runtime.h $(PREFIX)/include
|
||||
|
||||
clean:
|
||||
rm libglacier.test libglacier.a glacier.cfg
|
||||
|
48
README
48
README
@ -10,6 +10,52 @@ much more time, it should futureproof Glacier and make it easier to deploy and t
|
||||
|
||||
+ Usage
|
||||
|
||||
#include <glacier_log.h>
|
||||
#include <glacier_config.h>
|
||||
#include <glacier_log.h>
|
||||
#include <glacier_pkgops.h>
|
||||
#include <glacier_runtime.h>
|
||||
|
||||
See the relevant documentation for more information on libglacier functions.
|
||||
|
||||
+ Installation
|
||||
|
||||
Libglacier requires the following libraries to compile:
|
||||
|
||||
- libcolor
|
||||
- libconfig
|
||||
|
||||
Once these are installed, you can continue with the installation.
|
||||
|
||||
Clone this repository:
|
||||
|
||||
$ git clone https://git.everestlinux.org/EverestLinux/libglacier
|
||||
|
||||
Enter the directory and edit config.mk:
|
||||
|
||||
$ cd libglacier
|
||||
$ $EDITOR config.mk
|
||||
|
||||
Build the library:
|
||||
|
||||
$ make
|
||||
|
||||
NOTE: libglacier is distributed as a static library only.
|
||||
|
||||
Install the library and header files:
|
||||
|
||||
# make install
|
||||
|
||||
+ Linking
|
||||
|
||||
To link libglacier into your program, ensure the proper header files are included.
|
||||
Then simply add the following to your compiler flags:
|
||||
|
||||
-lglacier
|
||||
|
||||
+ Documentation
|
||||
|
||||
Online documentation can be found at https://everestlinux.org/docs/libglacier
|
||||
Offline documentation can be accessed with the following command:
|
||||
|
||||
$ man libglacier
|
||||
|
||||
|
@ -1,15 +0,0 @@
|
||||
#!/bin/sh
|
||||
|
||||
red="\033[1;31m"
|
||||
green="\033[1;32m"
|
||||
yellow="\033[1;33m"
|
||||
blue="\033[1;34m"
|
||||
reset="\033[m"
|
||||
check="\xE2\x9C\x93"
|
||||
error="\xE2\x9C\x95"
|
||||
warning="\x21"
|
||||
question="\x3F"
|
||||
|
||||
mkdirs() {
|
||||
printf "${blue}[i]${reset}
|
||||
}
|
72
busybox
72
busybox
@ -1,72 +0,0 @@
|
||||
#
|
||||
# busybox
|
||||
#
|
||||
|
||||
# Package metadata
|
||||
PACKAGE_NAME="busybox"
|
||||
PACKAGE_VER="1.36.0"
|
||||
PACKAGE_DESC="Busybox embedded UNIX utilities"
|
||||
MAINTAINER="liamwaldron@everestlinux.org"
|
||||
LICENSE="GPL v2"
|
||||
ARCH="x86"
|
||||
INCLUDED_FILES=("/bin/busybox" "/linuxrc")
|
||||
|
||||
# Integrity checking
|
||||
SHA256SUMS="2d60a4df73d14da518c3e8a7d51830c35918b54572029624ea4b86e8298fb528"
|
||||
|
||||
# Dependency information
|
||||
DEPENDS=("")
|
||||
CONFLICTS=("")
|
||||
|
||||
# Source information
|
||||
PACKAGE_SRC="https://git.busybox.net/busybox"
|
||||
SOURCES=("busybox-1.36.0")
|
||||
|
||||
# Installation
|
||||
getsource() {
|
||||
wget $PACKAGE_SRC
|
||||
cd ${SOURCES[0]}
|
||||
}
|
||||
|
||||
buildpkg() {
|
||||
curl https://git.everestlinux.org/EverestLinux/sys-pkg-configs/raw/branch/main/config.busybox-1.36.0 -o .config
|
||||
make ARCH="x86_64" CROSS_COMPILE="x86_64-linux-musl-" # these MUST be set
|
||||
}
|
||||
|
||||
installpkg() {
|
||||
make ARCH="x86_64" CROSS_COMPILE="x86_64-linux-musl-" \
|
||||
CONFIG_PREFIX="${BLDR_OUT_DIR}/pkgs/busybox" install
|
||||
cp -v examples/depmod.pl ${TOOLCHAIN_PATH}/bin
|
||||
chmod -v 755 ${TOOLCHAIN_PATH}/bin/depmod.pl
|
||||
touch ${BLDR_OUT_DIR}/pkgs/busybox/.ispkg
|
||||
# Never install files to /bin, they will get
|
||||
# overwritten when the user pulls a new update
|
||||
}
|
||||
|
||||
installpkg_system() {
|
||||
printf "Not supported for this package.\n"
|
||||
exit 1
|
||||
}
|
||||
|
||||
removepkg() {
|
||||
rm -rf ${BLDR_OUT_DIR}/pkgs/busybox
|
||||
}
|
||||
|
||||
removepkg_system() {
|
||||
printf "Not supported for this package.\n"
|
||||
exit 1
|
||||
}
|
||||
|
||||
updatepkg() {
|
||||
buildpkg "$@"
|
||||
installpkg "$@"
|
||||
}
|
||||
|
||||
updatepkg_system() {
|
||||
printf "Not supported for this package.\n"
|
||||
exit 1
|
||||
}
|
||||
|
||||
#
|
||||
# end busybox
|
||||
#
|
BIN
curl/a.out
BIN
curl/a.out
Binary file not shown.
@ -1,83 +0,0 @@
|
||||
/***************************************************************************
|
||||
* _ _ ____ _
|
||||
* Project ___| | | | _ \| |
|
||||
* / __| | | | |_) | |
|
||||
* | (__| |_| | _ <| |___
|
||||
* \___|\___/|_| \_\_____|
|
||||
*
|
||||
* Copyright (C) Daniel Stenberg, <daniel@haxx.se>, et al.
|
||||
*
|
||||
* This software is licensed as described in the file COPYING, which
|
||||
* you should have received as part of this distribution. The terms
|
||||
* are also available at https://curl.se/docs/copyright.html.
|
||||
*
|
||||
* You may opt to use, copy, modify, merge, publish, distribute and/or sell
|
||||
* copies of the Software, and permit persons to whom the Software is
|
||||
* furnished to do so, under the terms of the COPYING file.
|
||||
*
|
||||
* This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
|
||||
* KIND, either express or implied.
|
||||
*
|
||||
* SPDX-License-Identifier: curl
|
||||
*
|
||||
***************************************************************************/
|
||||
/* <DESC>
|
||||
* Simple HTTPS GET
|
||||
* </DESC>
|
||||
*/
|
||||
#include <stdio.h>
|
||||
#include <curl/curl.h>
|
||||
|
||||
int main(void)
|
||||
{
|
||||
CURL *curl;
|
||||
CURLcode res;
|
||||
|
||||
curl_global_init(CURL_GLOBAL_DEFAULT);
|
||||
|
||||
curl = curl_easy_init();
|
||||
if(curl) {
|
||||
curl_easy_setopt(curl, CURLOPT_URL, "https://example.com/");
|
||||
|
||||
#ifdef SKIP_PEER_VERIFICATION
|
||||
/*
|
||||
* If you want to connect to a site who is not using a certificate that is
|
||||
* signed by one of the certs in the CA bundle you have, you can skip the
|
||||
* verification of the server's certificate. This makes the connection
|
||||
* A LOT LESS SECURE.
|
||||
*
|
||||
* If you have a CA cert for the server stored someplace else than in the
|
||||
* default bundle, then the CURLOPT_CAPATH option might come handy for
|
||||
* you.
|
||||
*/
|
||||
curl_easy_setopt(curl, CURLOPT_SSL_VERIFYPEER, 0L);
|
||||
#endif
|
||||
|
||||
#ifdef SKIP_HOSTNAME_VERIFICATION
|
||||
/*
|
||||
* If the site you are connecting to uses a different host name that what
|
||||
* they have mentioned in their server certificate's commonName (or
|
||||
* subjectAltName) fields, libcurl refuses to connect. You can skip this
|
||||
* check, but it makes the connection insecure.
|
||||
*/
|
||||
curl_easy_setopt(curl, CURLOPT_SSL_VERIFYHOST, 0L);
|
||||
#endif
|
||||
|
||||
/* cache the CA cert bundle in memory for a week */
|
||||
curl_easy_setopt(curl, CURLOPT_CA_CACHE_TIMEOUT, 604800L);
|
||||
|
||||
/* Perform the request, res gets the return code */
|
||||
res = curl_easy_perform(curl);
|
||||
/* Check for errors */
|
||||
if(res != CURLE_OK)
|
||||
fprintf(stderr, "curl_easy_perform() failed: %s\n",
|
||||
curl_easy_strerror(res));
|
||||
|
||||
/* always cleanup */
|
||||
curl_easy_cleanup(curl);
|
||||
}
|
||||
|
||||
curl_global_cleanup();
|
||||
|
||||
return 0;
|
||||
}
|
@ -21,13 +21,17 @@ GLACIER_ALLOW_SERVICES = false;
|
||||
# - Binary-redistributable software (BIN-REDIST)
|
||||
# - End-user-license-agreement (EULA)
|
||||
# If, for any reason, a package uses a custom license, you can simply add it to this list.
|
||||
GLACIER_ALLOWED_LICENSES = [ "GPL", "MIT", "BSD", "APACHE" ]
|
||||
GLACIER_ALLOWED_LICENSES = [ "GPL", "MIT", "BSD", "APACHE" ];
|
||||
|
||||
# Package integrity checking
|
||||
# WARNING: It is strongly recommended to keep this enabled.
|
||||
# This ensures all incoming packages are not tampered with.
|
||||
GLACIER_DO_INT_CHECK = true;
|
||||
|
||||
# Verbose logging
|
||||
# Enable this option to see exta verbosity.
|
||||
GLACIER_VERBOSE = false;
|
||||
|
||||
# Profile-specific settings
|
||||
# WARNING: The settings below are tied into the system's profile. Changing any of these manually
|
||||
# will certainly cause breakage.
|
||||
|
39
glacier.cfg
39
glacier.cfg
@ -1,39 +0,0 @@
|
||||
#
|
||||
# glacier.cfg
|
||||
# The settings defined in this file will be loaded when Glacier is called.
|
||||
# For more information on this file, see https://www.everestlinux.org/docs/intro-to-glacier
|
||||
#
|
||||
|
||||
# Services
|
||||
# Whether Glacier will allow external service files to be called
|
||||
# WARNING: Services may pose a security risk to your system. Only use services you trust.
|
||||
GLACIER_ALLOW_SERVICES = false;
|
||||
|
||||
# Permitted software licenses
|
||||
# When installing a package, Glacier will check its license. If said license is listed here,
|
||||
# it will proceed with the installation. Otherwise, it'll return an error.
|
||||
# For more information on licenses listed below, see https://www.everestlinux.org/docs/intro-to-glacier
|
||||
# Some common license names with their designation codes are:
|
||||
# - GNU General Public License (GPL)
|
||||
# - MIT License (MIT)
|
||||
# - BSD License (BSD)
|
||||
# - Apache license (APACHE)
|
||||
# - Binary-redistributable software (BIN-REDIST)
|
||||
# - End-user-license-agreement (EULA)
|
||||
# If, for any reason, a package uses a custom license, you can simply add it to this list.
|
||||
GLACIER_ALLOWED_LICENSES = [ "GPL", "MIT", "BSD", "APACHE" ]
|
||||
|
||||
# Package integrity checking
|
||||
# WARNING: It is strongly recommended to keep this enabled.
|
||||
# This ensures all incoming packages are not tampered with.
|
||||
GLACIER_DO_INT_CHECK = true;
|
||||
|
||||
# Profile-specific settings
|
||||
# WARNING: The settings below are tied into the system's profile. Changing any of these manually
|
||||
# will certainly cause breakage.
|
||||
# If, for any reason, you must change any of these settings, use `glacier-mkprofile`.
|
||||
# Profile migration may cause breakage. Doing a clean install is the preferred method for changing profiles.
|
||||
|
||||
### DO NOT EDIT ANY SETTINGS BELOW THIS LINE ###
|
||||
### DO NOT EDIT ANY SETTINGS BELOW THIS LINE ###
|
||||
### DO NOT EDIT ANY SETTINGS BELOW THIS LINE ###
|
@ -53,16 +53,35 @@ int die_config();
|
||||
/**************************************************************************************************************/
|
||||
|
||||
/*
|
||||
* load_setting_from_config
|
||||
* load_all_from_config
|
||||
* DESCRIPTION: Initialize all settings from glacier.cfg.
|
||||
* PARAMETERS:
|
||||
* None.
|
||||
* RETURN VALUES:
|
||||
* 0 on success, 1 on file does not exist, 2 on library error
|
||||
* CAVEATS:
|
||||
* None.
|
||||
* EXAMPLE:
|
||||
* load_all_from_config();
|
||||
*/
|
||||
|
||||
int load_all_from_config();
|
||||
|
||||
/**************************************************************************************************************/
|
||||
|
||||
/*
|
||||
* load_setting_from_config
|
||||
* DESCRIPTION: Initialize a specified from glacier.cfg.
|
||||
* PARAMETERS:
|
||||
* char SETTING[] -> The setting to initialize
|
||||
* RETURN VALUES:
|
||||
* 0 on success, 1 on setting not found, 2 on file does not exist, 3 on library error
|
||||
* CAVEATS:
|
||||
* None.
|
||||
* EXAMPLE:
|
||||
* load_setting_from_config();
|
||||
*/
|
||||
|
||||
void load_setting_from_config();
|
||||
int load_setting_from_config(char SETTING[]);
|
||||
|
||||
#endif
|
||||
|
@ -19,54 +19,54 @@
|
||||
#define GLACIERPKGOPS_H_
|
||||
|
||||
/*
|
||||
* parse_pkg_file
|
||||
* mkworkspace
|
||||
*
|
||||
* DESCRIPTION: Parse_pkg_file parses a Glacier-compatible package.
|
||||
* DESCRIPTION: Mkworkspace prepares /tmp/glacier-workspace for an operation
|
||||
* PARAMETERS:
|
||||
* char fname[] -> The package file to parse
|
||||
* None.
|
||||
* RETURN VAUES:
|
||||
* 0 on success, 2 on library error
|
||||
* CAVEATS:
|
||||
* None.
|
||||
* EXAMPLE:
|
||||
* mkworkspace();
|
||||
*/
|
||||
|
||||
int mkworkspace();
|
||||
|
||||
/*
|
||||
* prepare_pkg
|
||||
*
|
||||
* DESCRIPTION: Prepare_pkg copies a package archive from the localdb, and untars it
|
||||
* PARAMETERS:
|
||||
* char PACKAGE[] -> The package file to prepare
|
||||
* RETURN VAUES:
|
||||
* 0 on success, 1 on package does not exist, or error untarring
|
||||
* CAVEATS:
|
||||
* The example presented is bad. You should be calling the system profile variable
|
||||
* rather than manually specifying one.
|
||||
* EXAMPLE:
|
||||
* prepare_pkg("/glacier/localdb/epkgs-x86_64-musl/foo.tar");
|
||||
*/
|
||||
|
||||
int prepare_pkg(char PACKAGE[]);
|
||||
|
||||
/*
|
||||
* run_make_task
|
||||
*
|
||||
* DESCRIPTION: Run_make_task runs a specified make task in a package's current working directory
|
||||
* PARAMETERS:
|
||||
* char TASK[] -> The make task to run
|
||||
* RETURN VAUES:
|
||||
* 0 on success, 1 on failure
|
||||
* CAVEATS:
|
||||
* None.
|
||||
* MUST be run after prepare_pkg(), or else errors will occur
|
||||
* Same caveat as above. Do not manually specify the system profile, use its variable.
|
||||
* EXAMPLE:
|
||||
* init_config();
|
||||
* prepare_pkg("/glacier/localdb/epkgs-x86_64-musl/foo.tar");
|
||||
* run_make_task("installpkg");
|
||||
*/
|
||||
|
||||
int parse_pkg_file();
|
||||
|
||||
/*
|
||||
* download_package_sources
|
||||
*
|
||||
* DESCRIPTION: Download_package_sources downloads the source code for a package.
|
||||
* PARAMETERS:
|
||||
* char PACKAGE[] -> The package name to download
|
||||
* RETURN VALUES:
|
||||
* 0 on success, 1 on failure
|
||||
* CAVEATS:
|
||||
* The URL for the package repository will autofill.
|
||||
* EXAMPLE:
|
||||
* download_package_sources("vim");
|
||||
*/
|
||||
|
||||
int download_package_source();
|
||||
|
||||
/*
|
||||
* run_build_task
|
||||
*
|
||||
* DESCRIPTION: Execute the package's pkgops file with parameter 'build'.
|
||||
* PARAMETERS:
|
||||
* None.
|
||||
* RETURN VALUES:
|
||||
* 0 on success, 1 on failure
|
||||
* CAVEATS:
|
||||
* Can only work on one package at a time. Implement in a loop for multiple.
|
||||
* EXAMPLE:
|
||||
* run_build_task();
|
||||
*/
|
||||
|
||||
int run_build_task();
|
||||
|
||||
|
||||
|
||||
int run_make_task(char TASK[]);
|
||||
|
||||
#endif
|
||||
|
288
libglacier.c
288
libglacier.c
@ -16,15 +16,16 @@
|
||||
*/
|
||||
|
||||
#include <color.h>
|
||||
#include <dirent.h>
|
||||
#include <errno.h>
|
||||
#include <lauxlib.h>
|
||||
#include <libconfig.h>
|
||||
#include <locale.h>
|
||||
#include <lua.h>
|
||||
#include <lualib.h>
|
||||
#include <stdbool.h>
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include <sys/stat.h>
|
||||
#include <sys/types.h>
|
||||
#include <unistd.h>
|
||||
#include <wchar.h>
|
||||
|
||||
@ -33,11 +34,17 @@
|
||||
config_t cfg;
|
||||
config_setting_t *setting;
|
||||
const char str;
|
||||
|
||||
int GLACIER_ALLOW_SERVICES;
|
||||
char GLACIER_ALLOWED_LICENSES;
|
||||
int GLACIER_DO_INT_CHECK;
|
||||
int GLACIER_VERBOSE;
|
||||
|
||||
const char *runtime_files[] = { "/etc/glacier.cfg", "/etc/glacier/call-hooks", "/etc/make.conf" };
|
||||
const char *runtime_files[] = {
|
||||
"/etc/glacier.cfg",
|
||||
"/etc/glacier/call-hooks",
|
||||
"/etc/make.conf"
|
||||
};
|
||||
|
||||
/*
|
||||
* infolog
|
||||
@ -104,7 +111,7 @@ errlog(char MSG[])
|
||||
*
|
||||
*/
|
||||
|
||||
void
|
||||
int
|
||||
runtime_exists()
|
||||
{
|
||||
int f;
|
||||
@ -116,7 +123,7 @@ runtime_exists()
|
||||
printf("%s does not exist\n", runtime_files[f]);
|
||||
}
|
||||
}
|
||||
return;
|
||||
return 1;
|
||||
}
|
||||
|
||||
/*
|
||||
@ -140,8 +147,17 @@ init_config()
|
||||
}
|
||||
|
||||
infolog("Initialized libconfig");
|
||||
return 0;
|
||||
}
|
||||
|
||||
/*
|
||||
* die_config
|
||||
*
|
||||
* DESCRIPTION: Kill libconfig.
|
||||
* PARAMETERS: None.
|
||||
*
|
||||
*/
|
||||
|
||||
int
|
||||
die_config()
|
||||
{
|
||||
@ -150,8 +166,17 @@ die_config()
|
||||
return(EXIT_SUCCESS);
|
||||
}
|
||||
|
||||
void
|
||||
load_setting_from_config()
|
||||
/*
|
||||
* load_all_from_config
|
||||
*
|
||||
* DESCRIPTION: Loads all settings from the Glacier config file.
|
||||
* PARAMETERS: None.
|
||||
*
|
||||
*/
|
||||
|
||||
/* 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");
|
||||
@ -163,9 +188,111 @@ load_setting_from_config()
|
||||
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_setting_from_config
|
||||
*
|
||||
* DESCRIPTION: Load a specified setting from the Glacier config file.
|
||||
* PARAMETERS: char SETTING[]
|
||||
*
|
||||
*/
|
||||
|
||||
int
|
||||
load_setting_from_config(char SETTING[])
|
||||
{}
|
||||
|
||||
/*
|
||||
* mkworkspace
|
||||
*
|
||||
* DESCRIPTION: Creates a new Glacier workspace in /tmp.
|
||||
* PARAMETERS: None.
|
||||
*
|
||||
*/
|
||||
|
||||
int
|
||||
mkworkspace()
|
||||
{
|
||||
DIR* workspace = opendir("/tmp/glacier-workspace");
|
||||
if (workspace) {
|
||||
infolog("Not creating new workspace, valid workspace already exists.");
|
||||
} else if (ENOENT == errno) {
|
||||
infolog("Creating new Glacier workspace...");
|
||||
mkdir("/tmp/glacier-workspace", 0777);
|
||||
} else {
|
||||
printf("LIBRARY ERROR: opendir() failed\n");
|
||||
return 2;
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* prepare_pkg
|
||||
*
|
||||
* DESCRIPTION: Copies a package archive from the localdb to the workspace, and unpacks it.
|
||||
* PARAMETERS: char PACKAGE[]
|
||||
*
|
||||
*/
|
||||
|
||||
|
||||
int
|
||||
prepare_pkg(char PACKAGE[])
|
||||
{
|
||||
if (PACKAGE == NULL) {
|
||||
printf(COL_RED "[x] " COL_RESET "Package '%s' does not exist in the local database.\n", PACKAGE);
|
||||
errlog("Ensure your local database is up to date and try again.");
|
||||
errlog("This can be done by running 'glacier-update-pkgdb' as root.");
|
||||
return 1;
|
||||
} else {
|
||||
char PKG_NEW[512];
|
||||
strcat(PKG_NEW, "/tmp/glacier-workspace/");
|
||||
strcat(PKG_NEW, PACKAGE);
|
||||
strcat(PKG_NEW, ".tar");
|
||||
FILE *pkg_old, *pkg_new;
|
||||
char filename[100], contents;
|
||||
|
||||
pkg_old = fopen(PACKAGE, "r");
|
||||
pkg_new = fopen(PKG_NEW, "a+");
|
||||
|
||||
contents = fgetc(pkg_old);
|
||||
|
||||
while (contents != EOF) {
|
||||
fputc(contents, pkg_new);
|
||||
contents = fgetc(pkg_old);
|
||||
}
|
||||
|
||||
fclose(pkg_old);
|
||||
fclose(pkg_new);
|
||||
char *tar_args[] = {
|
||||
"/bin/tar", /* This should be changed to /glacier/bin/tar later on */
|
||||
"-xvf",
|
||||
PKG_NEW,
|
||||
NULL,
|
||||
};
|
||||
|
||||
execvp(
|
||||
"/bin/tar", /* Above comment applies here */
|
||||
tar_args
|
||||
);
|
||||
if (errno != 0) {
|
||||
printf(COL_RED "[x] " COL_RESET "Error while unpacking archive for package %s.\n", PACKAGE);
|
||||
return errno;
|
||||
}
|
||||
remove(PKG_NEW);
|
||||
char pkg_dir[512];
|
||||
strcat(pkg_dir, "/tmp/glacier-workspace/");
|
||||
strcat(pkg_dir, PACKAGE);
|
||||
chdir(pkg_dir);
|
||||
}
|
||||
}
|
||||
|
||||
/* 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);
|
||||
@ -174,131 +301,42 @@ download_package_sources(char PACKAGE[])
|
||||
} else {
|
||||
printf(COL_RED "[x] " COL_RESET "System profile '%s' is not supported.\n", GLACIER_SYSTEM_PROFILE);
|
||||
}
|
||||
}
|
||||
} */
|
||||
|
||||
int
|
||||
run_build_task()
|
||||
void
|
||||
TEST_chdir(char dir[])
|
||||
{
|
||||
execl("pkgops", "build", NULL);
|
||||
}
|
||||
|
||||
int
|
||||
run_install_task()
|
||||
{
|
||||
execl("pkgops", "install", NULL);
|
||||
}
|
||||
|
||||
int
|
||||
run_update_task()
|
||||
{
|
||||
execl("pkgops", "update", NULL);
|
||||
}
|
||||
|
||||
int
|
||||
run_remove_task()
|
||||
{
|
||||
execl("pkgops", "remove", NULL);
|
||||
}
|
||||
|
||||
int
|
||||
run_s_install_task()
|
||||
{
|
||||
execl("pkgops", "s_install", NULL);
|
||||
}
|
||||
|
||||
int
|
||||
run_s_update_task()
|
||||
{
|
||||
execl("pkgops", "s_update", NULL);
|
||||
}
|
||||
|
||||
int
|
||||
run_s_remove_task()
|
||||
{
|
||||
execl("pkgops", "s_remove", NULL);
|
||||
char *buf;
|
||||
chdir(dir);
|
||||
buf = (char *) malloc(100*sizeof(char));
|
||||
getcwd(buf, 100);
|
||||
printf("%s\n", buf);
|
||||
}
|
||||
|
||||
/*
|
||||
void
|
||||
init_lua()
|
||||
{
|
||||
lua_State *L = luaL_newstate();
|
||||
luaL_openlibs(L);
|
||||
}
|
||||
|
||||
int
|
||||
load_lua_file(char luafile[])
|
||||
{
|
||||
if (luaL_loadfile(L, luafile)) {
|
||||
fprintf(stderr, "LIBRARY ERROR: Could not open package %s. Does it exist?\n");
|
||||
lua_close(L);
|
||||
exit(1);
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
int
|
||||
exec_lua_file(char luafile[])
|
||||
{
|
||||
if (lua_pcall(L, 0, 0, 0)) {
|
||||
fprintf(stderr, "LIBRARY ERROR: Failed to execute package %s.\n");
|
||||
lua_close(L);
|
||||
exit(1);
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
void
|
||||
die_lua()
|
||||
{
|
||||
lua_close(L);
|
||||
}
|
||||
* run_make_task
|
||||
*
|
||||
* DESCRIPTION: Runs a make task in current working directory
|
||||
* PARAMETERS: char TASK[]
|
||||
*
|
||||
*/
|
||||
|
||||
int
|
||||
parse_pkg_file(char fname[])
|
||||
run_make_task(char TASK[])
|
||||
{
|
||||
if (fname == NULL) {
|
||||
fprintf(stderr, "LIBRARY ERROR: fname not specified\n");
|
||||
exit(1);
|
||||
char *build_args[] = {
|
||||
"/bin/make", /* This should be changed to /glacier/bin/make later on */
|
||||
TASK,
|
||||
NULL
|
||||
};
|
||||
|
||||
execvp(
|
||||
"/bin/make", /* Above comment applies here */
|
||||
build_args
|
||||
);
|
||||
if (errno != 0) {
|
||||
errlog("An error occurred while running the make task.");
|
||||
return errno;
|
||||
}
|
||||
}
|
||||
|
||||
if (access(fname, F_OK) != 0) {
|
||||
fprintf(stderr, COL_RED "[x] " COL_RESET "Package file '%s' does not exist.\n", fname);
|
||||
exit(1);
|
||||
}
|
||||
|
||||
|
||||
FILE *pkg;
|
||||
|
||||
char filename[100], contents;
|
||||
|
||||
pkg = fopen(fname, "r");
|
||||
infolog("Parsing package file...");
|
||||
contents = fgetc(pkg);
|
||||
while (contents != EOF) {
|
||||
printf("%c", contents);
|
||||
contents = fgetc(pkg);
|
||||
}
|
||||
|
||||
fclose(pkg);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
int
|
||||
main(int argc, char *argv[])
|
||||
{
|
||||
errlog("Unknown option.");
|
||||
printf(COL_RED "[x]" COL_RESET " usage: %s [-h] [-v] [-f] [-u] [-x] [-fl] [-ul] [-d] [-s] PKG\n", argv[0]);
|
||||
runtime_exists();
|
||||
init_config();
|
||||
load_setting_from_config();
|
||||
die_config();
|
||||
parse_pkg_file("busybox");
|
||||
/* init_lua();
|
||||
load_lua_file("lua/testpkg.lua");
|
||||
exec_lua_file("lua/testpkg.lua");
|
||||
die_lua(); */
|
||||
}
|
||||
|
BIN
libglacier.test
BIN
libglacier.test
Binary file not shown.
13
lua/Makefile
13
lua/Makefile
@ -1,13 +0,0 @@
|
||||
include ../config.mk
|
||||
|
||||
all:
|
||||
@echo "Run 'make test' to generate a test binary."
|
||||
@echo "Run 'make clean' to remove the generated binary."
|
||||
|
||||
test:
|
||||
$(CC) -I/usr/include/lua5.2 \
|
||||
-Wall -llua \
|
||||
lua.c -o lua.test
|
||||
|
||||
clean:
|
||||
rm lua.test
|
37
lua/lua.c
37
lua/lua.c
@ -1,37 +0,0 @@
|
||||
#include <color.h>
|
||||
#include <lua.h>
|
||||
#include <lualib.h>
|
||||
#include <lauxlib.h>
|
||||
#include <locale.h>
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <wchar.h>
|
||||
|
||||
const wchar_t check = 0x2713;
|
||||
|
||||
int
|
||||
main(int argc, char **argv)
|
||||
{
|
||||
printf(COL_BLUE "[i] " COL_RESET "Initializing Lua state...\n");
|
||||
lua_State *L = luaL_newstate();
|
||||
luaL_openlibs(L);
|
||||
|
||||
printf(COL_BLUE "[i] " COL_RESET "Loading test package...\n");
|
||||
if (luaL_loadfile(L, "testpkg.lua")) {
|
||||
fprintf(stderr, COL_RED "[x] " COL_RESET "Failed to load test package file.\n");
|
||||
lua_close(L);
|
||||
exit(1);
|
||||
}
|
||||
|
||||
printf(COL_BLUE "[i] " COL_RESET "Executing test package...\n");
|
||||
if (lua_pcall(L, 0, 0, 0)) {
|
||||
fprintf(stderr, COL_RED "[x] " COL_RESET "Failed to execute test package file.\n");
|
||||
lua_close(L);
|
||||
exit(1);
|
||||
}
|
||||
|
||||
lua_close(L);
|
||||
printf("Closed lua libraries\n");
|
||||
return 0;
|
||||
}
|
||||
|
BIN
lua/lua.test
BIN
lua/lua.test
Binary file not shown.
@ -1,3 +0,0 @@
|
||||
#!/usr/bin/lua
|
||||
|
||||
print("Executed lua file")
|
38
pkg/Makefile
Normal file
38
pkg/Makefile
Normal file
@ -0,0 +1,38 @@
|
||||
include config.mk
|
||||
|
||||
all:
|
||||
@echo "No option specified."
|
||||
|
||||
help:
|
||||
@echo "NOTICE: This program should not be run directly."
|
||||
@echo "It is intended to be run within Glacier"
|
||||
@echo ""
|
||||
@echo "Possible options for make:"
|
||||
@echo "- buildpkg"
|
||||
@echo "- installpkg"
|
||||
@echo "- installpkg_s"
|
||||
@echo "- updatepkg"
|
||||
@echo "- updatepkg_s"
|
||||
@echo "- removepkg"
|
||||
@echo "- removepkg_s"
|
||||
|
||||
buildpkg:
|
||||
# Commands required to build the package
|
||||
|
||||
installpkg:
|
||||
# Commands required to install the package as USER
|
||||
|
||||
installpkg_s:
|
||||
# Commands required to install the package as SYSTEM
|
||||
|
||||
updatepkg:
|
||||
# Comands required to update the package as USER
|
||||
|
||||
updatepkg_s:
|
||||
# Commands required to update the package as SYSTEM
|
||||
|
||||
removepkg:
|
||||
# Commands required to remove the package as USER
|
||||
|
||||
removepkg_s:
|
||||
# Commands required to remove the package as SYSTEM
|
3
pkg/clean_mkconfig.sh
Normal file
3
pkg/clean_mkconfig.sh
Normal file
@ -0,0 +1,3 @@
|
||||
#!/bin/sh
|
||||
|
||||
rm -f config.mk
|
9
pkg/create_mkconfig.sh
Normal file
9
pkg/create_mkconfig.sh
Normal file
@ -0,0 +1,9 @@
|
||||
#!/bin/sh
|
||||
|
||||
. /etc/make.conf
|
||||
|
||||
echo "MAKEFLAGS = ${MAKEFLAGS}" >> config.mk
|
||||
echo "CFLAGS = ${CFLAGS}" >> config.mk
|
||||
echo "CXXFLAGS = ${CXXFLAGS}" >> config.mk
|
||||
echo "PREFIX = ${PREFIX}" >> /config.mk
|
||||
echo "ARCH = ${ARCH}" >> config.mk
|
15
pkg/meta.cfg
Normal file
15
pkg/meta.cfg
Normal file
@ -0,0 +1,15 @@
|
||||
#
|
||||
# meta.cfg
|
||||
#
|
||||
|
||||
# Information
|
||||
PACKAGE_NAME = "";
|
||||
PACKAGE_VER = "";
|
||||
PACKAGE_DESC = "";
|
||||
MAINTAINER = "";
|
||||
LICENSE = "";
|
||||
ARCH = "";
|
||||
|
||||
# Dependencies/Conflicts
|
||||
DEPENDS = [""];
|
||||
CONFLICTS = [""];
|
1
pkg/pm
1
pkg/pm
@ -1 +0,0 @@
|
||||
Subproject commit b387d1d3bbbdc4ae9b66ac37a001415601b04429
|
27
pkg/run-pkg.c
Normal file
27
pkg/run-pkg.c
Normal file
@ -0,0 +1,27 @@
|
||||
#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