diff --git a/install/Makefile b/install/Makefile new file mode 100644 index 0000000..819fd92 --- /dev/null +++ b/install/Makefile @@ -0,0 +1,18 @@ +include config.mk + +all: + @echo Run \'make install\'. + +install: + mkdir -p $(DESTDIR)/etc/glacier + mkdir -p $(DESTDIR)/usr/glacier + mkdir -p $(DESTDIR)/usr/glacier/index + install ../src/bin/gpkg $(DESTDIR)/usr/bin + install ../src/bin/gquery $(DESTDIR)/usr/bin + install ../src/bin/syspkg $(DESTDIR)/usr/bin + install ../src/bin/gpc $(DESTDIR)/usr/bin + install ../src/bin/glist $(DESTDIR)/usr/bin + install ../src/bin/glacier-mkprofile $(DESTDIR)/usr/bin + install ../src/etc/glacier.conf /etc + install ../src/etc/make.conf /etc + install ../src/etc/call-hooks /etc/glacier diff --git a/install/build.sh b/install/build.sh deleted file mode 100644 index f586739..0000000 --- a/install/build.sh +++ /dev/null @@ -1,42 +0,0 @@ -#!/bin/sh - -if [ $(/usr/bin/id -u) != "0" ]; then - printf "[x] Must be run as root.\n" - exit 1 -fi - -WORKING_DIR=$(pwd) -SRC_DIR=$(pwd)/../src - -parse_install_conf() { - source ${WORKING_DIR}/install.conf - if [ "$?" != "0" ]; then - printf "[x] install.conf not found.\n" - exit 1 - fi -} - -mkdirs() { - mkdir /usr/glacier - - -installpkg() { - install ${SRC_DIR}/gpkg /bin - install ${SRC_DIR}/syspkg /bin - install ${SRC_DIR}/gquery /bin - install ${SRC_DIR}/glist /bin -} - -case $1 in - install) - parse_install_conf "$@" - installpkg "$@" - ;; - update) - parse_install_conf "$@" - installpkg "$@" - ;; - *) - printf "[x] Unknown option.\n" - exit 1 -esac diff --git a/install/config.mk b/install/config.mk new file mode 100644 index 0000000..716b138 --- /dev/null +++ b/install/config.mk @@ -0,0 +1 @@ +PREFIX = /usr diff --git a/src/bin/gpc b/src/bin/gpc old mode 100644 new mode 100755 index c8d0ff2..beb78b3 --- a/src/bin/gpc +++ b/src/bin/gpc @@ -18,3 +18,135 @@ # You should have received a copy of the GNU General Public License # along with Glacier. If not, see . +red="\033[1;31m" +green="\033[1;32m" +blue="\033[1;34m" +reset="\033[m" +check="\xE2\x9C\x93" + +check_if_vars_exist() { + MVARS=("PACKAGE_NAME" "PACKAGE_VER" "PACKAGE_DESC" "MAINTAINER" "LICENSE" "ARCH") + FILEVARS=("INCLUDED_FILES") + INTVARS=("SHA256SUMS") + SRCVARS=("PACKAGE_SRC" "SOURCES") + + VAR_FAILED=0 + + printf "${blue}[i]${reset} Checking variables...\n" + sleep 0.5 + + for m in ${MVARS[@]}; do + if [ ! -v $m ]; then + printf "${red}[x]${reset} Variable $m does not exist.\n" + VAR_FAILED=$((VAR_FAILED+1)) + sleep 0.1 + elif [ -v $m ]; then + printf "${green}[${check}]${reset} Variable $m exists.\n" + sleep 0.1 + fi + done + + for f in ${FILEVARS[@]}; do + if [ ! -v $f ]; then + printf "${red}[x]${reset} Variable $f does not exist.\n" + VAR_FAILED=$((VAR_FAILED+1)) + sleep 0.1 + elif [ -v $f ]; then + printf "${green}[${check}]${reset} Variable $f exists.\n" + sleep 0.1 + fi + done + + for i in ${INTVARS[@]}; do + if [ ! -v $i ]; then + printf "${red}[x]${reset} Variable $i does not exist.\n" + VAR_FAILED=$((VAR_FAILED+1)) + sleep 0.1 + elif [ -v $i ]; then + printf "${green}[${check}]${reset} Variable $i exists.\n" + sleep 0.1 + fi + done + + for s in ${SRCVARS[@]}; do + if [ ! -v $s ]; then + printf "${red}[x]${reset} Variable $s does not exist.\n" + VAR_FAILED=$((VAR_FAILED+1)) + sleep 0.1 + elif [ -v $s ]; then + printf "${green}[${check}]${reset} Variable $s exists.\n" + sleep 0.1 + fi + done +} + +check_if_functions_exist() { + UNIFUNCTIONS=("getsource" "buildpkg") + GFUNCTIONS=("installpkg" "updatepkg" "removepkg") + SYSFUNCTIONS=("installpkg_system" "updatepkg_system" "removepkg_system") + + FUNCTION_FAILED=0 + + printf "${blue}[i]${reset} Checking functions...\n" + sleep 0.5 + + for u in ${UNIFUNCTIONS[@]}; do + declare -f -F $u > /dev/null + if [ $? != 0 ]; then + printf "${red}[x]${reset} Function $u does not exist.\n" + FUNCTION_FAILED=$((FUNCTION_FAILED+1)) + sleep 0.1 + else + printf "${green}[${check}]${reset} Function $u exists.\n" + sleep 0.1 + fi + done + + for g in ${GFUNCTIONS[@]}; do + declare -f -F $g > /dev/null + if [ $? != 0 ]; then + printf "${red}[x]${reset} Function $g does not exist.\n" + FUNCTION_FAILED=$((FUNCTION_FAILED+1)) + sleep 0.1 + else + printf "${green}[${check}]${reset} Function $g exists.\n" + sleep 0.1 + fi + done + + for s in ${SYSFUNCTIONS[@]}; do + declare -f -F $s > /dev/null + if [ $? != 0 ]; then + printf "${red}[x]${reset} Function $s does not exist.\n" + FUNCTION_FAILED=$((FUNCTION_FAILED+1)) + sleep 0.1 + else + printf "${green}[${check}]${reset} Function $s exists.\n" + sleep 0.1 + fi + done +} + +results() { + printf "${blue}[*]${reset} Results:\n" + printf "Missing variables: $VAR_FAILED\n" + printf "Missing functions: $FUNCTION_FAILED\n" +} + +if [ "${1}" == "" ]; then + printf "${red}[x]${reset} You must specify a package to check.\n" + exit 1 +fi + +if [ ! -f "${1}" ]; then + printf "${red}[x]${reset} Package file does not exist.\n" + printf "${red}[x]${reset} Ensure you provide ${0} with an absolute path.\n" + exit 1 +fi +printf "${blue}[*]${reset} Sourcing package file...\n" +sleep 0.5 +source $1 +printf "source ${1}\n" +check_if_vars_exist "$@" +check_if_functions_exist "$@" +results "$@" diff --git a/src/bin/gpkg b/src/bin/gpkg index 16523d6..d009451 100755 --- a/src/bin/gpkg +++ b/src/bin/gpkg @@ -18,14 +18,24 @@ # You should have received a copy of the GNU General Public License # along with Glacier. If not, see . +if [ -f "/etc/glacier/call-hooks" ]; then + source /etc/glacier/call-hooks +elif [ ! -f "/etc/glacier/call-hooks" ]; then +cat << EOF +error: /etc/glacier/call-hooks does not exist. +unable to load configuration files: no call-hooks file exists. +ensure /etc/glacier/call-hooks exists, and contains the following: + source /etc/glacier.conf -if [ "$?" != "0" ]; then - printf "error while parsing Glacier's configuration file\n" - printf "ensure it exists and is accessible\n" - printf "exitting..." - exit 1 +source /etc/make.conf + +${0} will not attempt to run without this file. +EOF +exit 1 fi +pkgs=("${@}") + usage() { printf "${0} - Merge a package into the local package index\n" printf "usage: ${0} [-h] [-v] [-f] [-u] [-x] [-fl] [-ul] [-d] \n" @@ -86,11 +96,9 @@ checkdeps() { checkconflicts() { pkgs=("${@}") - for i in /opt/glacier/workspace/*; do - find /etc/glacier/pkginfo -wholename "${i}" - if [ "$?" != "0" ]; then - printf "${red}[${error}]${reset} Package conflicts with an installed package.\n" - exit 1 + for c in /opt/glacier/workspace/*; do + if [ -f /usr/glacier/index/${c} ]; then + printf "${red}[${error}]${reset} Package conflicts with ${c}.\n" fi done } @@ -143,6 +151,19 @@ index_pkg() { fi } +resolve_deps() { + for d in ${DEPENDS[@]}; do + printf "${blue}[i]${reset} Checking if dependency ${d} is satisfied...\n" + ls /usr/glacier/index | grep ${d} + if [ "$?" != "0" ]; then + printf "${blue}[i]${reset} ${d} not found, installing...\n" + ${0} -f ${d} + else + printf "${green}[${check}]${reset} ${d} satisfied.\n" + fi + done +} + case $1 in -h|--help) usage "$@" diff --git a/src/bin/gquery b/src/bin/gquery index c4963f1..0604599 100755 --- a/src/bin/gquery +++ b/src/bin/gquery @@ -18,7 +18,22 @@ # You should have received a copy of the GNU General Public License # along with Glacier. If not, see . +if [ -f "/etc/glacier/call-hooks" ]; then + source /etc/glacier/call-hooks +elif [ ! -f "/etc/glacier/call-hooks" ]; then +cat << EOF +error: /etc/glacier/call-hooks does not exist. +unable to load configuration files: no call-hooks file exists. +ensure /etc/glacier/call-hooks exists, and contains the following: + source /etc/glacier.conf +source /etc/make.conf + +${0} will not attempt to run without this file. +EOF +exit 1 +fi + usage() { printf "${0} - Query a package in the local package index\n" diff --git a/src/etc/call-hooks b/src/etc/call-hooks new file mode 100644 index 0000000..cde6641 --- /dev/null +++ b/src/etc/call-hooks @@ -0,0 +1,4 @@ +#!/usr/bin/env /bin/sh + +source /etc/glacier.conf +source /etc/make.conf diff --git a/src/etc/glacier.conf b/src/etc/glacier.conf index 2942384..7331331 100644 --- a/src/etc/glacier.conf +++ b/src/etc/glacier.conf @@ -12,10 +12,8 @@ export check="\xE2\x9C\x93" export error="\xE2\x9C\x95" # Command to be used for downloading packages -# This command will be invoked whenever files need to be downloaded -export GLACIER_DOWNLOAD_BACKEND="wget --quiet --show-progress" -# Use this backend for debugging -#export GLACIER_DOWNLOAD_BACKEND="wget" +# This command will be invoked to download files +export GLACIER_DOWNLOAD_BACKEND="curl -O -J" # -O flag tells curl to output to a file, -J tells curl to get filename from URL # Permitted software licenses # Glacier will install software licensed under what's listed here. Otherwise, it'll quit. @@ -26,7 +24,10 @@ export GLACIER_DOWNLOAD_BACKEND="wget --quiet --show-progress" # - Apache License (APACHE) # - Binary redistributable (BIN-REDIST) # - End-user-license-agreement (EULA) -export GLACIER_ALLOWED_LICENSES=("GPL v3" "MIT" "BSD" "APACHE") +# If, for any reason, a package uses a custom license, you can simply add it to this list. +export GLACIER_ALLOWED_LICENSES=("GPL v3" "GPL v2" "GPL" "MIT" "BSD" "APACHE") +#export GLACIER_ALLOWED_LICENSES=("GPL v3" "GPL v2" "GPL") # Copyleft ONLY +#export GLACIER_ALLOWED_LICENSES=("GPL v3" "GPL v2" "GPL" "MIT" "BSD" "APACHE" "BIN-REDIST" "EULA") # Package repository # WARNING: DO NOT SET OR CHANGE MANUALLY!!! diff --git a/src/etc/make.conf b/src/etc/make.conf index 146de20..58c9670 100644 --- a/src/etc/make.conf +++ b/src/etc/make.conf @@ -9,7 +9,8 @@ MAKEFLAGS="-j1" # Build and compile flags for C and C++ programs. # Disable these if packages are breaking. # Using too many optimizations may break packages. -CFLAGS="-O2 -fstack-protector-strong" +# Keep -pie and -static, unless a package explicitly does not support these options. +CFLAGS="-O2 -fstack-protector-strong -pie -static" CXXFLAGS="${CFLAGS}" # DO NOT CHANGE ANYTHING ELSE. THESE OPTIONS ARE SET BY `glacier-mkprofile` diff --git a/src/man/gpkg.8 b/src/man/gpkg.8 new file mode 100644 index 0000000..4a7e9cd --- /dev/null +++ b/src/man/gpkg.8 @@ -0,0 +1,42 @@ +.\" Manpage for gpkg. +.TH man 8 "24 March 2023" "4.0" "Glacier Manual" +.SH NAME +gpkg \- make changes to the local Glacier package index +.SH SYNPOPSIS +gpkg [-f] [-u] [-x] [-fl] [-ul] [-d] [-h] [-v] +.SH DESCRIPTION +gpkg is a program included with the Glacier package manager. Its purpose is to make changes to the local Glacier package index, a database listing all installed packages. gpkg performs functions such as merging, updating, and removing. It downloads a Glacier package, sources it, and runs the necessary functions. Afterwards, the package file is "indexed", where it can be queried by gquery(1). +.SH OPTIONS +.TP +.BR \-f \-\-install +merges a package into the packge index +.TP +.BR \-u \-\-update +updates a merged package +.TP +.BR \-x \-\-remove +removes a package from the package index +.TP +.BR \-fl \-\-localin +merges a locally downloaded package into the package index +.TP +.BR \-ul \-\-localup +updates a locally downloaded package +.TP +.BR \-d \-\-dload +downloads a package ONLY +.TP +.BR \-h \-\-help +shows a help message +.TP +.BR \-v \-\-version +shows the version +.SH EXAMPLES + Merge a package into /usr/glacier/index: + # gpkg -f repo/pkg +.SH SEE ALSO +gquery(1) syspkg(8) +.SH BUGS +Report all bugs on the issues page at https://git.everestlinux.org/EverestLinux/glacier +.SH AUTHOR +Liam Waldron (liamwaldron@everestlinux.org) diff --git a/src/man/syspkg.8 b/src/man/syspkg.8 new file mode 100644 index 0000000..252f404 --- /dev/null +++ b/src/man/syspkg.8 @@ -0,0 +1,39 @@ +.\" Manpage for syspkg. +.TH man 8 "12 April 2023" "4.0" "Glacier Manual" +.SH NAME +syspkg \- make changes to the global Glacier package index +.SH SYNOPSIS +syspkg [-f] [-u] [-x] [-fl] [-ul] [-h] [-v] +.SH DESCRIPTION +syspkg is a program included with the Glacier package manager. Its purpose is to make changes to the global Glacier package index, unlike gpkg(8), which modifies the local index. syspkg should not be used regularly, as the global index is controlled by Git, meaning all changes will be overwritten during an update. +.SH OPTIONS +.TP +.BR \-f \-\-install +merges a package into the package index +.TP +.BR \-u \-\-update +updates a merged package +.TP +.BR \-x \-\-remove +removes a package from the package index +.TP +.BR \-fl \-\-localin +merges a locally download package into the package index +.TP +.BR \-ul \-\-localup +updates a locally downloaded package +.TP +.BR \-h \-\-help +shows a help message +.TP +.BR \-v \-\-version +shows the version +.SH EXAMPLES + Merge a package into /glacier/index: + # syspkg -f repo/pkg +.SH SEE ALSO +gpkg(8) +.SH BUGS +Report all bugs on the issues page at https://git.everestlinux.org/EverestLinux/glacier +.SH AUTHOR +Liam Waldron (liamwaldron@everestlinux.org)