Compare commits

...

2 Commits
main ... dev

Author SHA1 Message Date
8967a4eb96 7/6 2025-07-06 22:10:08 -04:00
a356b58b12 7/6 2025-07-06 22:09:18 -04:00
23 changed files with 789 additions and 417 deletions

0
.gitmodules vendored Normal file
View File

64
Makefile Normal file
View File

@ -0,0 +1,64 @@
#
# Makefile
#
# 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/>.
#
include config.mk
BDIR = ./build
SDIR = ./src
EDIR = ./etc
all: prep gpkg syspkg glist gquery gpc glacier-mkprofile glacier-update-pkgdb
@echo "Completed all build tasks."
prep:
mkdir -p $(BDIR)
mkdir -p $(BDIR)/bin
mkdir -p $(BDIR)/etc
gpkg: $(SDIR)/gpkg.c
$(CC) $(CFLAGS) $(SDIR)/gpkg.c -o $(BDIR)/bin/gpkg $(LIBS)
syspkg: $(SDIR)/syspkg.c
$(CC) $(CFLAGS) $(SDIR)/syspkg.c -o $(BDIR)/bin/syspkg $(LIBS)
glist: $(SDIR)/glist.c
$(CC) $(CFLAGS) $(LIBS) $(SDIR)/glist.c -o $(BDIR)/bin/glist
gquery: $(SDIR)/gquery.c
$(CC) $(CFLAGS) $(LIBS) $(SDIR)/gquery.c -o $(BDIR)/bin/gquery
gpc: $(SDIR)/gquery.c
$(CC) $(CFLAGS) $(LIBS) $(SDIR)/gquery.c -o $(BDIR)/bin/gquery
glacier-mkprofile: $(SDIR)/glacier-mkprofile.c
$(CC) $(CFLAGS) $(LIBS) $(SDIR)/glacier-mkprofile.c -o $(BDIR)/bin/glacier-mkprofile
glacier_update_pkgdb: $(SDIR)/glacier-update-pkgdb
$(CC) $(CFLAGS) $(LIBS) $(SDIR)/glacier-update-pkgdb -o $(BDIR)/bin/glacier-update-pkgdb
install:
install $(BDIR)/bin/gpkg -t $(PREFIX)/bin -m 644
install $(BDIR)/bin/syspkg -t $(PREFIX)/bin -m 644
install $(BDIR)/bin/glist -t $(PREFIX)/bin -m 644
install $(BDIR)/bin/gquery -t $(PREFIX)/bin -m 644
install $(BDIR)/bin/gpc -t $(PREFIX)/bin -m 644
install $(BDIR)/bin/glacier-mkprofile -t $(PREFIX)/bin -m 644
install $(BDIR)/bin/glacier-update-pkgdb -t $(PREFIX)/bin -m 644
install $(EDIR)/glacier.conf -t $(PREFIX)/etc -m 644
clean:
rm -rf $(BDIR)

50
Makefile.old Normal file
View File

@ -0,0 +1,50 @@
#
# Makefile
#
BDIR = ./build
SDIR = ./src
CWD := $(shell pwd)
.PHONY: build clean all prepare glacier gpkg
include config.mk
all: prepare glacier gpkg
@echo "Build completed successfully."
prepare:
mkdir -p $(BDIR)
mkdir -p $(BDIR)/bin
mkdir -p $(BDIR)/etc
mkdir -p $(BDIR)/include
mkdir -p $(BDIR)/scripts
cp -f $(CWD)/include/common.h $(BDIR)/include/
# First compile the common functionality
common.o: $(SDIR)/common.c
$(CC) -c $(SDIR)/common.c -o $(BDIR)/common.o $(CFLAGS) $(LDFLAGS)
glacier_common.o: $(SDIR)/glacier_common.c $(SDIR)/glacier_common.h
$(CC) -c $(SDIR)/glacier_common.c -o $(BDIR)/glacier_common.o $(CFLAGS) $(LDFLAGS)
runtime_functions.o: $(SDIR)/runtime_functions.c $(SDIR)/runtime_functions.h
$(CC) -c $(SDIR)/runtime_functions.c -o $(BDIR)/runtime_functions.o $(CFLAGS) $(LDFLAGS)
# Now compile the actual executables
glacier: common.o glacier_common.o runtime_functions.o $(SDIR)/glacier.c
$(CC) $(SDIR)/glacier.c $(BDIR)/common.o $(BDIR)/glacier_common.o $(BDIR)/runtime_functions.o -o $(BDIR)/bin/glacier $(CFLAGS) $(LDFLAGS) $(LIBFLAGS)
chmod +x $(BDIR)/bin/glacier
gpkg: common.o glacier_common.o runtime_functions.o $(SDIR)/gpkg.c
$(CC) $(SDIR)/gpkg.c $(BDIR)/common.o $(BDIR)/glacier_common.o $(BDIR)/runtime_functions.o -o $(BDIR)/bin/gpkg $(CFLAGS) $(LDFLAGS) $(LIBFLAGS)
chmod +x $(BDIR)/bin/gpkg
install: all
mkdir -p $(BDIR)/scripts
cp -r $(SDIR)/../scripts/install.sh $(BDIR)/scripts/
chmod +x $(BDIR)/scripts/install.sh
cd $(BDIR)/scripts && ./install.sh
clean:
rm -rvf $(BDIR)

10
README
View File

@ -55,6 +55,16 @@ https://everestlinux.org/docs/glacier-setup
| Copyright | | Copyright |
+-----------+ +-----------+
Glacier uses the following third party libraries:
* Libconfig: licensed under the LGPL v2.1.
The source code for Libconfig is available at: <https://github.com/hyperrealm/libconfig>
* Libcrypto: a component of OpenSSL licensed under the Apache 2.0 License
The source code for Openssl and Libcrypto is available at: <https://github.com/openssl/openssl>
* Libglacier: licensed under the GPL v3.0.
The source code for Libglacier is available at: <https://git.everestlinux.org/EverestLinux/libglacier>
(C) 2021-2024 Everest Developers (C) 2021-2024 Everest Developers
This program is free software: you can redistribute it and/or modify it This program is free software: you can redistribute it and/or modify it
under the terms of the GNU General Public License as published by the under the terms of the GNU General Public License as published by the

118
README.md Normal file
View File

@ -0,0 +1,118 @@
# Glacier Package Manager
Glacier is the official package manager for Everest Linux. It's designed to be a simple, fast, and powerful tool for installing, updating, and removing packages.
## Features
- Simple command-line interface
- Support for multiple repositories
- Package integrity verification
- Source-based package installation
- Dependency resolution
- Comprehensive package database
## Requirements
- Linux (tested on Everest Linux)
- Bash
- wget
- tar
- git
- A C compiler (for source packages)
## Installation
### From Source
1. Clone the repository:
```
git clone https://git.everestlinux.org/EverestLinux/glacier.git
cd glacier
```
2. Build and install:
```
make
sudo make install
```
## Usage
Glacier provides both a long-form and short-form command syntax:
### Basic Commands
- `glacier --fetch [packages...]` or `glacier -f [packages...]`: Install packages
- `glacier --update [packages...]` or `glacier -u [packages...]`: Update packages
- `glacier --remove [packages...]` or `glacier -x [packages...]`: Remove packages
- `glacier --sync` or `glacier -y`: Synchronize package database
- `glacier --search <query>` or `glacier -s <query>`: Search for packages
- `glacier --list` or `glacier -l`: List installed packages
- `glacier --info <package>` or `glacier -i <package>`: Show information about a package
- `glacier --verify <package>` or `glacier -c <package>`: Verify package integrity
- `glacier --help` or `glacier -h`: Display help message
- `glacier --version` or `glacier -v`: Display version information
### Examples
Install a package:
```
sudo glacier -f bash
```
Update an installed package:
```
sudo glacier -u bash
```
Remove a package:
```
sudo glacier -x bash
```
Search for packages:
```
glacier -s gcc
```
Synchronize the package database:
```
sudo glacier -y
```
## Configuration
Glacier uses the following configuration files:
- `/etc/glacier.conf`: Main configuration file
- `/etc/glacier/profile.cfg`: System profile configuration
- `/etc/make.conf`: Build configuration for source packages
- `/etc/glacier/hooks.sh`: Hook scripts for package operations
## Package Repositories
Everest Linux organizes packages into different repositories:
- `world`: System software
- `galaxy`: GPL-licensed software
- `universe`: Open-source software (any license)
- `multiverse`: Proprietary software
Each repository also has a testing version (`world-testing`, `galaxy-testing`, etc.).
## Building Packages
Glacier uses a simple package format. Each package archive must contain:
- `PACKAGE-pkginfo.json`: Package metadata
- `INSTALL.sh`: Installation script
- `UPDATE.sh`: Update script
- `REMOVE.sh`: Removal script
- Source code or binaries
- License file (if not GPL 3.0)
For detailed information on building packages, see [the Everest Linux documentation](https://everestlinux.org/docs/intro-to-glacier).
## License
Glacier is licensed under the GNU General Public License v3.0. See the [LICENSE](LICENSE) file for details.

9
config.mk Normal file
View File

@ -0,0 +1,9 @@
#
# config.mk
#
CC = /bin/gcc
LD = /bin/ld
CFLAGS = -fstack-protector-strong -O2 -pie -Wall -Werror -static
LIBS = -lglacier -levconf -lconfini

View File

@ -1,41 +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;
# 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.
# 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.
@include "/etc/glacier/profile.cfg";

50
etc/glacier.conf Normal file
View File

@ -0,0 +1,50 @@
#
# glacier.conf
# The settings defined in this file will be loaded when Glacier is called.
# For more information, see https://www.everestlinux.org/docs/intro-to-glacier
#
# Services
# Whether Glacier will allow external service files to be called
# Services may pose a security risk to your system. Only use services you trust.
# default: false
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.
# 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 and EULA software (NONFREE)
# Packages may use custom licenses. In this case, Glacier will ask permission
# before adding it to this list.
# Default license configuration
GLACIER_ALLOWED_LICENSES = ["GPL", "MIT", "BSD", "APACHE"]
# Including non-free software
#GLACIER_ALLOWED_LICENSES = ["GPL", "MIT", "BSD", "APACHE", "NONFREE"]
# Package Integrity Checking
# Whether Glacier will check a package's expected checksum versus its actual checksum
# It is STRONGLY recommened to keep this setting ON
# default: true
GLACIER_DO_INT_CHECK = true
# Verbose logging
# Glacier will output more verbosely if this setting is enabled.
# default: false
GLACIER_VERBOSE = false
# Profile-specific settings
# These settings are tied into the system's profile. Changing these manually will
# certainly cause breakage.
# If, for any reason, you must change any of these settings, use `glacier-mkprofile`.
# You may need to recompile packages after doing so.
# Profile migration may cause breakage. Doing a clean install is the preferred and
# officially supported method for changing profiles.
@include "profile.conf"

46
etc/glacier.ini Normal file
View File

@ -0,0 +1,46 @@
#
# glacier.ini
# The settings defined in this file will be loaded when Glacier is executed.
# For more information, see https://www.everestlinux.org/docs/intro-to-glacier
#
# Services
# Whether Glacier will allow external service files to be called
# Services may pose a security risk to your system. Only use services you trust.
# Default: false
[services]
enabled=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.
# Some common license names with their designation codes are:
# * GNU General Public License (GPL)
# * MIT License (MIT)
# * BSD License (BSD)
# * Apache License (APACHE)
# * All proprietary licenses (NONFREE)
# Packages may use custon licenses. In this case, Glacier will ask permission
# before adding it to this list.
# Default configuration
[licenses]
allowed={"GPL", "MIT", "BSD", "APACHE"}
# Including non-free software
# [licenses]
# allowed={"GPL", "MIT", "BSD", "APACHE"}
# Package integrity checking
# Whether Glacier will check a package's expected checksum versus its actual checksum.
# It is STRONGLY recommended to keep this setting ON
# Default: true
[integrity-check]
enabled=true
# Verbose logging
# Glacier will output more verbosely if this setting is enabled.
# This setting may assist with debugging.
# Default: false
[verbose]
enabled=false

View File

@ -1,24 +1,23 @@
# #
# profile.cfg # profile.cfg
# The settings defined in this file descirbe the system's profile. # The settings defined in this file describe the system's profile.
# For more information on this file, see https://www.everestlinux.org/docs/intro-to-glacier # For more information, see https://www.everestlinux.org/docs/intro-to-glacier
# #
# Package Repository # Package Repository
# This is the URL which glacier-update-pkgdb will clone to the localdb # This is the URL which glacier-update-pkgdb will clone to the localdb
GLACIER_REPO = ""; GLACIER_REPO = ""
# System architecture # System architecture
# The architecture of your system's CPU # The architecture of your system's CPU
GLACIER_ARCH = ""; GLACIER_ARCH = ""
# Target compulation triplet # Target compilation triplet
# The triplet to be used during compilation, if cross compilation must be invoked # The triplet to be used during compilation, if cross compilation must be invoked
GLACIER_TARGET = ""; GLACIER_TARGET = ""
# System profile # System profile
# This variable tells Glacier about your system and which packages can be installed. # This variable tells Glacier about your system and which packages can be installed.
# This setting depends on the three above and should not be changed manually. # This setting depends on the three above and should not be changed manually.
# If you wixh to migrate system profiles, see https://www.everestlinux.org/docs/musl-or-glibc # If you wish to migrate, see https://www.everestlinux.org/docs/musl-or-glibc
GLACIER_SYSTEM_PROFILE = ""; GLACIER_SYSTEM_PROFILE = ""

27
etc/profile.ini Normal file
View File

@ -0,0 +1,27 @@
#
# profile.cfg
# The setting defined in this file describes the system's profile.
# For more information, see https://www.everestlinux.org/docs/intro-to-glacier
#
# Package repository
# This is the URL which glacier-update-pkgdb will clone to the localdb
[repo]
url=""
# System architecture
# The architecture of your system's CPU
[cpu]
arch=""
# Target compilation triplet
# THe triplet to be used during cross compilation, if it must be invoked
[cross-compile]
target=""
# System profile
# This variable tells Glacier about your system and which packages can be installed.
# This setting depends on the three above and should not be changed manually.
# If you wish to migrate, see https://www.everestlinux.org/docs/musl-or-glibc
[system]
profile=""

Binary file not shown.

View File

@ -1,185 +0,0 @@
/*
* glacier-mkprofile.c - Create and modify the system profile
*
* 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/>.
*/
#include <color.h>
#include <errno.h>
#include <libconfig.h>
#include <locale.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <unistd.h>
#include <wchar.h>
#include <glacier_config.h>
#include <glacier_log.h>
#include <glacier_pkgops.h>
#include <glacier_runtime.h>
#include "glacier.h"
const wchar_t w_check = 0x2713;
int iprofile;
static void
usage(int argc, char *argv[])
{
printf(COL_BLUE "[*] " COL_RESET "%s - create and modify the system profile\n", argv[0]);
printf(COL_BLUE "[?] " COL_RESET "usage: %s [-h] [-v] [-f] [-u] [-x]\n", argv[0]);
printf("\n");
printf("%s {-h} Show this message\n", argv[0]);
printf("%s {-v} Show the current version\n", argv[0]);
printf("%s {-l} List available system profiles\n", argv[0]);
printf("%s {-p} PROFILE Create or update the system profile PROFILE at /etc/glacier/profile.cfg\n", argv[0]);
printf("\n");
printf("Glacier is free software.\n");
printf("See the GNU GPL version 3 for details.\n");
}
static void
usage_small(int argc, char *argv[])
{
printf(COL_RED "[x] " COL_RESET "usage: %s [-h] [-v] [-l] [-p]\n", argv[0]);
}
int
main(int argc, char *argv[])
{
if (argc < 2) {
printf(COL_RED "[x] " COL_RESET "%s: not enough arguments (expected 1, got %i)\n", argv[0], argc - 1);
usage_small(argc, argv);
exit(1);
}
setlocale(LC_CTYPE, "");
int opt;
while ((opt = getopt(argc, argv, "hvlp:")) != -1) {
switch (opt) {
case 'h':
usage(argc, argv);
return 0;
break;
case 'v':
printf(GLACIER_VERSION "\n");
return 0;
break;
case 'l':
infolog("Available profiles:");
printf("1)\tx86_64-musl\n");
printf("\t");
return 0;
break;
case 'p':
if (argc < 3) { errlog("No system profile specified.");
return 1;
}
is_process_root("Cannot access the system profile: permission denied. Are you root?");
if (strcmp(optarg, "x86_64-musl") == 0) {
infolog ("Using system profile \"x86_64-musl\"");
iprofile = 1;
} else {
fprintf(stderr, COL_RED "[x] " COL_RESET "System profile %s is unknown or not supported.\n", optarg);
return 1;
}
if (access("/etc/glacier/profile.cfg", F_OK != 0)) {
infolog("No profile exists, skipping backup...");
} else if (access("/etc/glacier/profile.cfg", F_OK == 0) && access("/etc/glacier/profile.old", F_OK != 0)) {
infolog("Creating backup of old system profile at /etc/glacier/profile.old...");
if (remove("/etc/glacier/profile.old") == 0) {
infolog("Removed old backup.");
}
FILE *oldprofile, *oldprofile_back;
char filename[128], contents;
oldprofile = fopen("/etc/glacier/profile.cfg", "r");
oldprofile_back = fopen("/etc/glacier/profile.old", "a+");
contents = fgetc(oldprofile);
while (contents != EOF) {
fputc(contents, oldprofile_back);
contents = fgetc(oldprofile);
}
fclose(oldprofile);
fclose(oldprofile_back);
successlog("Successfully created backup.");
}
infolog("Creating new profile configuration file...");
static const char *newprofile = "/etc/glacier/profile.cfg";
config_t pprofile;
config_setting_t *setting, *root;
config_init(&pprofile);
root = config_root_setting(&pprofile);
if (iprofile == 1) {
infolog("Writing configuration to file...");
setting = config_setting_add(root, "GLACIER_REPO", CONFIG_TYPE_STRING);
config_setting_set_string(setting, "https://git.everestlinux.org/EverestLinux/epkgs-x86_64-musl");
printf("\tGLACIER_REPO = \"https://git.everestlinux.org/EverestLinux/epkgs-x86_64-musl\";\n");
setting = config_setting_add(root, "GLACIER_ARCH", CONFIG_TYPE_STRING);
config_setting_set_string(setting, "x86_64");
printf("\tGLACIER_ARCH = \"x86_64\";\n");
setting = config_setting_add(root, "GLACIER_TARGET", CONFIG_TYPE_STRING);
config_setting_set_string(setting, "x86_64-linux-musl");
printf("\tGLACIER_TARGET = \"x86_64-linux-musl\";\n");
setting = config_setting_add(root, "GLACIER_LOCALDB", CONFIG_TYPE_STRING);
config_setting_set_string(setting, "/glacier/localdb/epkgs-x86_64-musl");
printf("\tGLACIER_LOCALDB = \"/glacier/localdb/epkgs-x86_64-musl\";\n");
setting = config_setting_add(root, "GLACIER_SYSTEM_PROFILE", CONFIG_TYPE_STRING);
config_setting_set_string(setting, "x86_64-musl");
printf("\tGLACIER_SYSTEM_PROFILE = \"x86_64-musl\";\n");
}
if (! config_write_file(&pprofile, newprofile)) {
errlog("Error while applying new profile to configuration.");
config_destroy(&pprofile);
return(EXIT_FAILURE);
}
successlog("Successfully updated system profile.");
config_destroy(&pprofile);
return(EXIT_SUCCESS);
break;
case '?':
printf(COL_RED "[x] " COL_RESET "%s: Unknown argument '%s'.\n", argv[0], argv[1]);
usage_small(argc, argv);
return 1;
break;
}
}
printf(COL_RED "[x] " COL_RESET "%s: Unknown argument '%s'.\n", argv[0], argv[1]);
usage_small(argc, argv);
return 1;
}

Binary file not shown.

View File

@ -1,79 +0,0 @@
/*
* glacier-update-pkgdb.c - Update the local package database
*
* 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/>.
*/
#include <color.h>
#include <errno.h>
#include <libconfig.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <unistd.h>
#include <glacier_config.h>
#include <glacier_log.h>
#include <glacier_pkgops.h>
#include <glacier_runtime.h>
#include "glacier.h"
static void
usage(int argc, char *argv[])
{
printf(COL_BLUE "[*] " COL_RESET "%s - update the local package database\n", argv[0]);
printf(COL_BLUE "[?] " COL_RESET "usage: %s [-h] [-v] [-u]\n", argv[0]);
printf("\n");
printf("%s {-h} Show this messsage\n", argv[0]);
printf("%s {-v} Show the current version\n", argv[0]);
printf("%s {-u} Update the local database\n", argv[0]);
printf("\n");
printf("Glacier is free software.\n");
printf("See the GNU GPL version 3 for details.\n");
}
static void
usage_small(int argc, char *argv[])
{
printf(COL_RED "[x] " COL_RESET "usage: %s [-h] [-v] [-u]\n", argv[0]);
}
int
main(int argc, char *argv[])
{
if (argc < 2) {
printf(COL_RED "[x] " COL_RESET "%s: not enough arguments (expected 1, got %i)\n", argv[0], argc - 1);
usage_small(argc, argv);
exit(1);
}
int opt;
while ((opt = getopt(argc, argv, "hvu:")) != -1) {
switch (opt) {
case 'h':
usage(argc, argv);
return 0;
break;
case 'v':
printf(GLACIER_VERSION "\n");
return 0;
break;
case 'u':
return 0;
break;
}
}
}

View File

@ -1,25 +0,0 @@
/*
* glacier.h - Operate on the user package index
*
* This file is patr 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 GLACIER_H_
#define GLACIER_H_
#define GLACIER_VERSION "4.0.0rc"
#endif

BIN
src/gpkg

Binary file not shown.

View File

@ -1,112 +1,179 @@
/* /*
* gpkg.c - Operate on the user package index * gpkg.c - operate on the user index
* *
* This file is part of Glacier. * This file is part of Glacier.
* *
* Glacier is free software: you can redistribute it and/or modify it under the terms of the * Glacier is free software: you can redistribute it and/or modify it under the
* GNU General Public License as published by the Free Software Foundation, either * terms of the GNU General Public License as published by the Free Software
* version 3 of the License, or (at your option) any later version. * 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; * 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 * without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
* PARTICULAR PURPOSE. See the GNU General Public License for more details. * 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 * You should have received a copy of the GNU General Public License along with Glacier.
* not, see <https://www.gnu.org/licenses/>. * If not, see <https://www.gnu.org/licenses/>.
*/ */
#include <color.h> #include <color.h>
#include <confini.h>
#include <errno.h> #include <errno.h>
#include <libevconf.h>
#include <stdio.h> #include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <unistd.h> #include <unistd.h>
#include <glacier_config.h> #include <glacier/config.h>
#include <glacier_log.h> #include <glacier/data.h>
#include <glacier_pkgops.h> #include <glacier/log.h>
#include <glacier_runtime.h> #include <glacier/pkgops.h>
#include <glacier/runtime.h>
#include <glacier/security.h>
#include "glacier.h" #include "release.h"
#include "util.h"
typedef enum
{
MODE_HELP,
MODE_VER,
MODE_FETCH,
MODE_UPD,
MODE_RM,
MODE_NOARG
}
opt_t;
static void static void
usage(int argc, char *argv[]) usage(int argc, char *argv[])
{ {
printf(COL_BLUE "[*] " COL_RESET "%s - operate on the user package index\n", argv[0]); printf(COL_BLUE "[*] %s" COL_RESET
printf(COL_BLUE "[?] " COL_RESET "usage: %s [-h] [-v] [-f] [-u] [-x]\n", argv[0]); " - Operate on the user package index\n", argv[0]);
printf("\n"); printf("usage: %s [-h] [-v] [-f] [-u] [-x] PKG...\n", argv[0]);
printf("%s {-h} Show this message\n", argv[0]); printf("\n{-h}\t\tShow this message\n");
printf("%s {-v} Show the current version\n", argv[0]); printf("{-v}\t\tPrint the current version of %s\n", argv[0]);
printf("%s {-f} PKG Install package PKG\n", argv[0]); printf("{-f} PKG...\tMerge PKG from the local repository to the user index\n");
printf("%s {-u} PKG Update package PKG\n", argv[0]); printf("{-u} PKG...\tUpdate PKG located in the user index\n");
printf("%s {-x} PKG Remove package PKG\n", argv[0]); printf("{-x} PKG...\tRemove PKG from the user index\n");
printf("\n"); printf("\nGlacier is free software.\nSee the GNU GPL v3.0 for details.\n");
printf("Glacier is free software.\n");
printf("See the GNU GPL version 3 for details.\n");
} }
static void static void
usage_small(int argc, char *argv[]) usage_small(int argc, char *argv[])
{ {
printf(COL_RED "[x] " COL_RESET "usage: %s [-h] [-v] [-f] [-u] [-x]\n", argv[0]); printf(COL_RED "[x]" COL_RESET " usage: %s [-h] [-v] [-f] [-u] [-x] PKG...\n",
argv[0]);
}
static void
printver(void)
{
printf(GLACIER_VERSION "\n");
} }
int int
main(int argc, char *argv[]) main(int argc, char *argv[])
{ {
if (argc < 2) {
printf(COL_RED "[x] " COL_RESET "%s: not enough arguments (expected 1, got %i)\n", argv[0], argc - 1);
usage_small(argc, argv);
exit(1);
}
int opt; int opt;
opt_t MODE = MODE_NOARG;
while ((opt = getopt(argc, argv, "hvfux:")) != -1) { /*
switch(opt) { * an enum is used in this case to increase readability
* and reduce indentation that would result from using
* a getopt loop and switch directly in the
* execution cycle of the package manager
*/
while ((opt = getopt(argc, argv, ":hvf::u::x::")) != -1) {
switch (opt) {
case 'h': case 'h':
usage(argc, argv); MODE = MODE_HELP;
return 0;
break; break;
case 'v': case 'v':
printf(GLACIER_VERSION "\n"); MODE = MODE_VER;
return 0;
break; break;
case 'f': case 'f':
if (argc < 3) { errlog("No package(s) specified."); return 1; } MODE = MODE_FETCH;
if (is_process_root() == 0) {
errlog("Failed to open package index: permission denied. Are you root?");
return(EXIT_FAILURE);
}
runtime_exists();
if (errno != 0) { exit(1); }
init_config();
load_all_from_config();
mkworkspace();
die_config();
return 0;
break; break;
case 'u': case 'u':
if (argc < 3) { errlog("No package(s) specified."); return 1; } MODE = MODE_UPD;
is_process_root("Failed to open package index: permission denied. Are you root?");
mkworkspace();
return 0;
break; break;
case 'x': case 'x':
if (argc < 3) { errlog("No package(s) specified."); return 1; } MODE = MODE_RM;
is_process_root("Failed to open package index: permission denied. Are you root?");
mkworkspace();
return 0;
break; break;
case '?': default:
printf(COL_RED "[x] " COL_RESET "%s: Unknown argument '%s'.\n", argv[0], argv[1]); MODE = MODE_NOARG;
usage_small(argc, argv);
return 1;
break; break;
} }
} }
printf(COL_RED "[x] " COL_RESET "%s: Unknown argument '%s'.\n", argv[0], argv[1]); switch (MODE) {
usage_small(argc, argv); case (MODE_HELP):
return 1; usage(argc, argv);
break;
case (MODE_VER):
printver();
break;
case (MODE_FETCH):
if (argc < 3) {
gl_errlog("Not enough arguments (missing packages)");
usage_small(argc, argv);
return 1;
}
if (gl_is_process_root() == 0) {
gl_errlog("Cannot open /usr/glacier/index: permission denied. "
"Are you root?");
return 1;
}
config_storage_t config_store;
config_storage_t profile_store;
FILE *config;
FILE *profile;
config = fopen("/etc/glacier/glacier.ini", "rb");
profile = fopen("/etc/glacier/profile.ini", "rb");
if (config == NULL) {
gl_errlog("Error while opening Glacier configuration.");
gl_errlog("Ensure /etc/glacier.ini exists and is accessible.");
return 1;
}
if (profile == NULL) {
gl_errlog("Error while collecting information from the "
"system profile.");
gl_errlog("Ensure /etc/glacier/profile.ini exists and is "
"accessible.");
return 1;
}
config_store = gl_store_config(config);
profile_store = gl_store_config(profile);
if (store_empty(&config_store)) {
gl_errlog("Default Glacier configuration is empty");
fclose(config);
return 1;
}
if (store_empty(&profile_store)) {
gl_errlog("System profile is empty");
fclose(profile);
return 1;
}
break;
case (MODE_UPD):
break;
case (MODE_RM):
break;
case (MODE_NOARG):
usage_small(argc, argv);
return 1;
break;
}
return 0;
} }

View File

@ -1,7 +0,0 @@
#include <glacier_log.h>
int
main()
{
successlog("hi");
}

23
src/release.h Normal file
View File

@ -0,0 +1,23 @@
/*
* templ.c - template file
*
* 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 RELEASE_H_
#define RELEASE_H_
#define GLACIER_VERSION "4.0.0-rc1"
#endif

164
src/syspkg.c Normal file
View File

@ -0,0 +1,164 @@
/*
* syspkg.c - operate on the system index
*
* 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/>.
*/
#include <color.h>
#include <confini.h>
#include <errno.h>
#include <libevconf.h>
#include <stdio.h>
#include <unistd.h>
#include <glacier/config.h>
#include <glacier/data.h>
#include <glacier/log.h>
#include <glacier/pkgops.h>
#include <glacier/runtime.h>
#include <glacier/security.h>
#include "release.h"
#include "util.h"
typedef enum
{
MODE_HELP,
MODE_VER,
MODE_FETCH,
MODE_UPD,
MODE_RM,
MODE_NOARG
}
opt_t;
static void
usage(int argc, char *argv[])
{
printf(COL_BLUE "[*] %s" COL_RESET
" - Operate on the system package index\n", argv[0]);
printf("usage: %s [-h] [-v] [-f] [-u] [-x] PKG...\n", argv[0]);
printf("{-h}\tShow this message\n");
printf("{-v}\tPrint the current version of %s\n", argv[0]);
printf("{-f} PKG...\tMerge PKG from the local repository to the system index\n");
printf("{-u} PKG...\tUpdate PKG located in the system index\n");
printf("{-x} PKG...\tRemove PKG from the system index\n");
printf("\nGlacier is free software.\nSee the GNU GPL v3.0 for details.\n");
}
static void
usage_small(int argc, char *argv[])
{
printf(COL_RED "[x]" COL_RESET " usage: %s [-h] [-v] [-f] [-u] [-x] PKG...\n",
argv[0]);
}
static void
printver(void)
{
printf(GLACIER_VERSION "\n");
}
static void
sys_index_warning(void)
{
gl_warnlog("Modifying the system package index may cause breakage.");
gl_warnlog("Be aware of this when making changes to the system package index.");
}
int
main(int argc, char *argv[])
{
int opt;
opt_t MODE = MODE_NOARG;
/*
* an enum is used in this case to increase readability
* and reduce indentation that would result from using
* a getopt loop and switch directly in the
* execution cycle of the package manager
*/
while ((opt = getopt(argc, argv, ":hvf::u::x::")) != -1) {
switch (opt) {
case 'h':
MODE = MODE_HELP;
break;
case 'v':
MODE = MODE_VER;
break;
case 'f':
MODE = MODE_FETCH;
break;
case 'u':
MODE = MODE_UPD;
break;
case 'x':
MODE = MODE_RM;
break;
default:
MODE = MODE_NOARG;
break;
}
}
switch (MODE) {
case (MODE_HELP):
usage(argc, argv);
break;
case (MODE_VER):
printver();
break;
case (MODE_FETCH):
if (argc < 3) {
gl_errlog("Not enough arguments (missing packages)");
usage_small(argc, argv);
return 1;
}
sys_index_warning();
if (gl_is_process_root() == 0) {
gl_errlog("Cannot open /usr/glacier/index: permission denied. "
"Are you root?");
return 1;
}
break;
case (MODE_UPD):
if (argc < 3) {
gl_errlog("Not enough arguments (missing packages)");
usage_small(argc, argv);
return 1;
}
sys_index_warning();
if (gl_is_process_root() == 0) {
gl_errlog("Cannot open /usr/glacier/index: permission denied. "
"Are you root?");
return 1;
}
break;
case (MODE_RM):
break;
case (MODE_NOARG):
usage_small(argc, argv);
return 1;
break;
}
return 0;
}

16
src/templ.c Normal file
View File

@ -0,0 +1,16 @@
/*
* templ.c - template file
*
* 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/>.
*/

66
src/util.h Normal file
View File

@ -0,0 +1,66 @@
#ifndef UTIL_H_
#define UTIL_H_
#define _POSIX_C_SOURCE 200809L
#undef _GNU_SOURCE
#undef _DEFAULT_SOURCE
#define _XOPEN_SOURCE 700
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <strings.h>
#define MAX_BUFFER_SIZE 128
/*
* Aliases for concise data types
*/
typedef void u1;
typedef char i8;
typedef unsigned int u16;
typedef int i16;
typedef unsigned long u32;
typedef long i32;
typedef float f32;
typedef unsigned long long u64;
typedef long long i64;
static inline i16
strtoi(const i8 *str, i16 *out)
{
i8 *endptr = NULL;
errno = 0;
long val = strtol(str, &endptr, 10);
if (errno != 0 || endptr == str || *endptr != '\0') {
return 1;
}
*out = (int)val;
return 0;
}
static inline i16
strtob(const i8 *str, int *out)
{
if (strcasecmp(str, "true") == 0 || strcmp(str, "1") == 0) {
*out = 1;
return 0;
}
else if (strcasecmp(str, "false") == 0 || strcmp(str, "0") == 0) {
*out = 0;
return 0;
}
return 1;
}
static inline i16
store_empty(const config_storage_t *storage)
{
return storage -> count == 0;
}
#endif