7/21
This commit is contained in:
parent
b7b31abc0e
commit
455b329c58
13
bootstrap/bootstrap.sh
Normal file
13
bootstrap/bootstrap.sh
Normal file
@ -0,0 +1,13 @@
|
|||||||
|
#!/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() {}
|
72
busybox
Normal file
72
busybox
Normal file
@ -0,0 +1,72 @@
|
|||||||
|
#
|
||||||
|
# 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
Executable file
BIN
curl/a.out
Executable file
Binary file not shown.
83
curl/libcurl.c
Normal file
83
curl/libcurl.c
Normal file
@ -0,0 +1,83 @@
|
|||||||
|
/***************************************************************************
|
||||||
|
* _ _ ____ _
|
||||||
|
* 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;
|
||||||
|
}
|
@ -23,6 +23,11 @@ GLACIER_ALLOW_SERVICES = false;
|
|||||||
# If, for any reason, a package uses a custom license, you can simply add it to this list.
|
# 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;
|
||||||
|
|
||||||
# Profile-specific settings
|
# Profile-specific settings
|
||||||
# WARNING: The settings below are tied into the system's profile. Changing any of these manually
|
# WARNING: The settings below are tied into the system's profile. Changing any of these manually
|
||||||
# will certainly cause breakage.
|
# will certainly cause breakage.
|
||||||
|
39
glacier.cfg
Normal file
39
glacier.cfg
Normal file
@ -0,0 +1,39 @@
|
|||||||
|
#
|
||||||
|
# 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 ###
|
@ -60,6 +60,7 @@ void warnlog(char MSG[]);
|
|||||||
|
|
||||||
/*
|
/*
|
||||||
* errlog
|
* errlog
|
||||||
|
*
|
||||||
* DESCRIPTION: Errlog outputs a stylized error message. It follows Glacier's uniform CLI style.
|
* DESCRIPTION: Errlog outputs a stylized error message. It follows Glacier's uniform CLI style.
|
||||||
* PARAMETERS:
|
* PARAMETERS:
|
||||||
* char MSG[] -> The message to output
|
* char MSG[] -> The message to output
|
||||||
|
72
include/glacier_pkgops.h
Normal file
72
include/glacier_pkgops.h
Normal file
@ -0,0 +1,72 @@
|
|||||||
|
/*
|
||||||
|
* glacier_pkgops.h - Package-related function declarations for libglacier
|
||||||
|
*
|
||||||
|
* This file is part of Glacier.
|
||||||
|
*
|
||||||
|
* Glacier is free software: you can redistribute it and/or modify it under the terms of the
|
||||||
|
* GNU General Public License as published by the Free Software Foundation, either
|
||||||
|
* version 3 of the License, or (at your option) any later version.
|
||||||
|
*
|
||||||
|
* Glacier is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY;
|
||||||
|
* without even the implied warranty of MERCHANTABILITY or FITNESS FOR A
|
||||||
|
* PARTICULAR PURPOSE. See the GNU General Public License for more details.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU General Public License along with Glacier. If
|
||||||
|
* not, see <https://www.gnu.org/licenses/>.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#ifndef GLACIERPKGOPS_H_
|
||||||
|
#define GLACIERPKGOPS_H_
|
||||||
|
|
||||||
|
/*
|
||||||
|
* parse_pkg_file
|
||||||
|
*
|
||||||
|
* DESCRIPTION: Parse_pkg_file parses a Glacier-compatible package.
|
||||||
|
* PARAMETERS:
|
||||||
|
* char fname[] -> The package file to parse
|
||||||
|
* RETURN VAUES:
|
||||||
|
* 0 on success, 1 on failure
|
||||||
|
* CAVEATS:
|
||||||
|
* None.
|
||||||
|
* EXAMPLE:
|
||||||
|
* init_config();
|
||||||
|
*/
|
||||||
|
|
||||||
|
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();
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
#endif
|
@ -22,3 +22,16 @@
|
|||||||
* runtime_exists
|
* runtime_exists
|
||||||
*
|
*
|
||||||
* DESCRIPTION: runtime_exists checks if all necessary runtime files exist.
|
* DESCRIPTION: runtime_exists checks if all necessary runtime files exist.
|
||||||
|
* PARAMETERS:
|
||||||
|
* None.
|
||||||
|
* RETURN VALUES:
|
||||||
|
* None.
|
||||||
|
* CAVEATS:
|
||||||
|
* None.
|
||||||
|
* EXAMPLE:
|
||||||
|
* runtime_exists();
|
||||||
|
*/
|
||||||
|
|
||||||
|
void runtime_exists();
|
||||||
|
|
||||||
|
#endif
|
||||||
|
139
libglacier.c
139
libglacier.c
@ -16,11 +16,17 @@
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
#include <color.h>
|
#include <color.h>
|
||||||
|
#include <errno.h>
|
||||||
|
#include <lauxlib.h>
|
||||||
#include <libconfig.h>
|
#include <libconfig.h>
|
||||||
|
#include <locale.h>
|
||||||
|
#include <lua.h>
|
||||||
|
#include <lualib.h>
|
||||||
#include <stdbool.h>
|
#include <stdbool.h>
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
#include <unistd.h>
|
#include <unistd.h>
|
||||||
|
#include <wchar.h>
|
||||||
|
|
||||||
/* Global variables */
|
/* Global variables */
|
||||||
|
|
||||||
@ -29,6 +35,7 @@ config_setting_t *setting;
|
|||||||
const char str;
|
const char str;
|
||||||
int GLACIER_ALLOW_SERVICES;
|
int GLACIER_ALLOW_SERVICES;
|
||||||
char GLACIER_ALLOWED_LICENSES;
|
char GLACIER_ALLOWED_LICENSES;
|
||||||
|
int GLACIER_DO_INT_CHECK;
|
||||||
|
|
||||||
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" };
|
||||||
|
|
||||||
@ -151,8 +158,135 @@ load_setting_from_config()
|
|||||||
else
|
else
|
||||||
warnlog("GLACIER_SERVICES_ALLOWED is not defined in glacier.cfg.");
|
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.");
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
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);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
int
|
||||||
|
run_build_task()
|
||||||
|
{
|
||||||
|
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);
|
||||||
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
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);
|
||||||
|
}
|
||||||
|
*/
|
||||||
|
|
||||||
|
int
|
||||||
|
parse_pkg_file(char fname[])
|
||||||
|
{
|
||||||
|
if (fname == NULL) {
|
||||||
|
fprintf(stderr, "LIBRARY ERROR: fname not specified\n");
|
||||||
|
exit(1);
|
||||||
|
}
|
||||||
|
|
||||||
|
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
|
int
|
||||||
main(int argc, char *argv[])
|
main(int argc, char *argv[])
|
||||||
{
|
{
|
||||||
@ -162,4 +296,9 @@ main(int argc, char *argv[])
|
|||||||
init_config();
|
init_config();
|
||||||
load_setting_from_config();
|
load_setting_from_config();
|
||||||
die_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
Executable file
BIN
libglacier.test
Executable file
Binary file not shown.
13
lua/Makefile
Normal file
13
lua/Makefile
Normal file
@ -0,0 +1,13 @@
|
|||||||
|
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
Normal file
37
lua/lua.c
Normal file
@ -0,0 +1,37 @@
|
|||||||
|
#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
Executable file
BIN
lua/lua.test
Executable file
Binary file not shown.
3
lua/testpkg.lua
Normal file
3
lua/testpkg.lua
Normal file
@ -0,0 +1,3 @@
|
|||||||
|
#!/usr/bin/lua
|
||||||
|
|
||||||
|
print("Executed lua file")
|
1
pkg/pm
Submodule
1
pkg/pm
Submodule
@ -0,0 +1 @@
|
|||||||
|
Subproject commit b387d1d3bbbdc4ae9b66ac37a001415601b04429
|
Loading…
Reference in New Issue
Block a user