0.1.0 BETA
0.1.0 is a complete rewrite @hippoz, @hippoz it is supposed to clean up aps. :trol:
This commit is contained in:
parent
696425afd9
commit
06bba6f68f
11 changed files with 378 additions and 200 deletions
|
@ -1,5 +1,3 @@
|
|||
# aps
|
||||
# APS
|
||||
|
||||
the alnux package manager
|
||||
|
||||
(the code is completely and utterly horrible and i cant believe i actually wrote this lol)
|
1
altools/README.md
Normal file
1
altools/README.md
Normal file
|
@ -0,0 +1 @@
|
|||
# This follows the UNIX philosophy
|
32
altools/alinitsys
Executable file
32
altools/alinitsys
Executable file
|
@ -0,0 +1,32 @@
|
|||
#!/bin/sh
|
||||
|
||||
#############
|
||||
# ALINITSYS #
|
||||
#############
|
||||
|
||||
# ALINITSYS is a passthrough to RUNIT OR OPENRC, if RUNIT OR OPENRC exists, if not, then ALINITSYS will wrap it up and init the system.
|
||||
|
||||
function init(){
|
||||
exec runit && echo ":: Running Runit..." || echo ":: Runit not found..." ;
|
||||
exec openrc && echo ":: Running OpenRC..." || echo ":: OpenRC not found..." ;
|
||||
echo ":: Running alinitsys"
|
||||
}
|
||||
function rescue(){
|
||||
echo "[E] Something might've went wrong..."
|
||||
echo ":: Dropping into the SH"
|
||||
exec sh
|
||||
}
|
||||
function daemon(){
|
||||
/var/service/*/start
|
||||
}
|
||||
function getty(){
|
||||
echo ":: Getting TTY"
|
||||
exec getty || exec stty
|
||||
}
|
||||
function start(){
|
||||
init ||
|
||||
daemon &&
|
||||
getty ||
|
||||
rescue
|
||||
}
|
||||
start
|
5
altools/c/Makefile
Normal file
5
altools/c/Makefile
Normal file
|
@ -0,0 +1,5 @@
|
|||
ccflags = -O3
|
||||
compile:
|
||||
gcc $(ccflags) pow.c -o pow
|
||||
clean:
|
||||
rm pow
|
BIN
altools/c/pow
Executable file
BIN
altools/c/pow
Executable file
Binary file not shown.
28
altools/c/pow.c
Normal file
28
altools/c/pow.c
Normal file
|
@ -0,0 +1,28 @@
|
|||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
#include <unistd.h>
|
||||
#include <sys/reboot.h>
|
||||
|
||||
int main (int argc, char *argv[]) {
|
||||
if (geteuid() != 0) {
|
||||
printf("[E] pow must be run as root\n");
|
||||
return 1;
|
||||
}
|
||||
|
||||
sync();
|
||||
|
||||
switch (argv[1] ? argv[1][0]: 0) {
|
||||
case 's':
|
||||
case 'p':
|
||||
reboot(RB_POWER_OFF);
|
||||
return 0;
|
||||
|
||||
case 'r':
|
||||
reboot(RB_AUTOBOOT);
|
||||
return 0;
|
||||
|
||||
default:
|
||||
printf("pow r[eboot]|p[oweroff]|s[hutdown]\n");
|
||||
return 1;
|
||||
}
|
||||
}
|
18
altools/dae
Executable file
18
altools/dae
Executable file
|
@ -0,0 +1,18 @@
|
|||
#!/bin/sh
|
||||
|
||||
###########################
|
||||
# DAE, the deamon manager #
|
||||
###########################
|
||||
|
||||
function daemonctl(){
|
||||
case $1 in
|
||||
stop) . /etc/al/serivces/$2.alsysd
|
||||
stop ;;
|
||||
start) . /etc/al/services/$2.alsysd
|
||||
start ;;
|
||||
esac
|
||||
case $2 in
|
||||
--verbose) set -x ;;
|
||||
*) ;;
|
||||
esac
|
||||
}
|
13
altools/mkinitramfs
Executable file
13
altools/mkinitramfs
Executable file
|
@ -0,0 +1,13 @@
|
|||
#!/bin/sh
|
||||
|
||||
###############
|
||||
# MKINITRAMFS #
|
||||
###############
|
||||
|
||||
if [ ! -d /usr/src/initramfs ]; then
|
||||
mkdir -p /usr/src/initramfs/{bin,dev,etc,lib,lib64,mnt/root,proc,root,sbin,sys}
|
||||
cp --archive /dev/{null,console,tty,sd*} /usr/src/initramfs/dev/
|
||||
cp --archive /bin/busybox /usr/src/initramfs/bin/busybox
|
||||
fi
|
||||
cd /usr/src/initramfs
|
||||
find . -print0 | cpio --null --create --verbose --format=newc | gzip --best > /boot/initramfs.cpio.gz
|
BIN
altools/pow
Executable file
BIN
altools/pow
Executable file
Binary file not shown.
269
aps
269
aps
|
@ -1,208 +1,83 @@
|
|||
#!/bin/sh
|
||||
|
||||
#################################
|
||||
# Alnux Packaging System, #
|
||||
# the package manager for Alnux #
|
||||
#################################
|
||||
|
||||
if [ -f "$XDG_CONFIG_HOME/al/config" ]; then
|
||||
. $XDG_CONFIG_HOME/al/config
|
||||
elif [ -f "$HOME/.config/al/config" ]; then
|
||||
. $HOME/.config/al/config
|
||||
elif [ -f "/etc/al/config" ]; then
|
||||
. /etc/al/config
|
||||
else
|
||||
temp_location="/var/tmp"
|
||||
install_root="/var/tmp/alroot"
|
||||
installed_pkg_database="${install_root}/var/aps/installed"
|
||||
locpkg_database="${install_root}/var/aps/repos"
|
||||
lock="${install_root}/var/aps/lock"
|
||||
official="https://git.hippoz.xyz/alnux/repo"
|
||||
debug=off
|
||||
fi
|
||||
if [ ${debug} = on ]; then
|
||||
set -x
|
||||
fi
|
||||
die() {
|
||||
echo "aps: fatal: ${1}"
|
||||
rm "${lock}"
|
||||
###################
|
||||
# aps. rewritten. #
|
||||
###################
|
||||
# OHIO: aps *needs* to be rewritten, i can't add any thing else in the aps.old.sh
|
||||
temp_location="/var/tmp"
|
||||
install_root="/var/tmp/alroot"
|
||||
installed_pkg_database="${install_root}/var/aps/installed"
|
||||
locpkg_database="${install_root}/var/aps/repos"
|
||||
lock="${install_root}/var/aps/lock"
|
||||
official="https://git.hippoz.xyz/alnux/repo"
|
||||
debug=off
|
||||
function prn(){
|
||||
echo -e "\e[34m==>\e[39m $1"
|
||||
}
|
||||
function wrn(){
|
||||
echo -e "\e[34m==>\e[33m WARNING:\e[39m $1"
|
||||
}
|
||||
function err(){
|
||||
echo -e "\e[34m==>\e[31m ERROR:\e[39m $1" &&
|
||||
rm ${lock} 2>&1 > /dev/null &&
|
||||
exit 2
|
||||
}
|
||||
confirm(){
|
||||
echo -ne "Are you sure? [Y/n] "
|
||||
read prompt
|
||||
if [[ ${prompt} = [nN] ]]; then
|
||||
die "User said no. Exiting..."
|
||||
elif [[ ${prompt} != [yY] ]]; then
|
||||
die "User gave invalid input. Exiting..."
|
||||
fi
|
||||
function notf(){
|
||||
echo -e "\e[34m==>\e[36m NOTIFICATION:\e[39m $1"
|
||||
}
|
||||
run_package_script() {
|
||||
{
|
||||
if [ -x "${2}/${1}" ]; then
|
||||
echo ":: Running ${1}"
|
||||
#cd "${2}" || die "Could not enter package working directory. Exiting..."
|
||||
"${2}/${1}" "${2}/payload" "${2}"
|
||||
fi
|
||||
}
|
||||
function dbg(){
|
||||
wrn "THIS IS A DEBUG TEST BUILD, IT MAY NOT WORK, IT'S GLITCHY AS FUCK!"
|
||||
}
|
||||
install_local_package() {
|
||||
[ ! -e "${1}" ] && die "File ${1} does not exist. Exiting..."
|
||||
# Extract the package
|
||||
confirm
|
||||
echo ":: Installing package ${1}"
|
||||
cp -prv "${1}" "${temp_location}"
|
||||
pkg_name="${1%/}"
|
||||
pkg_name="${pkg_name##*/}"
|
||||
pkg_name=$(echo "${pkg_name}" | cut -f 1 -d '.')
|
||||
pkg_path="${temp_location}/${pkg_name}"
|
||||
cd "${pkg_path}" || die "Could not enter package path."
|
||||
# Set default values for package
|
||||
pkg_config_deploy=true
|
||||
pkg_config_ver="0"
|
||||
pkg_config_makedepends=""
|
||||
pkg_config_depends=""
|
||||
# Download sources.
|
||||
if [ -f sources ]; then
|
||||
pkg_config_sources=$(cat sources)
|
||||
pkg_config_sources_to=$(echo ${pkg_config_sources} | sed 's:.*/::')
|
||||
curl -# ${pkg_config_sources} -o ${pkg_config_sources_to}
|
||||
mkdir pkg_bd
|
||||
tar -xf 1 ${pkg_config_sources_to} -C ${pkg_path}
|
||||
fi
|
||||
# Install package
|
||||
mkdir -p "${pkg_path}/payload"
|
||||
. "${pkg_path}/package"
|
||||
cd pkg_bd/
|
||||
run_package_script "build" "${pkg_path}"
|
||||
cd ../..
|
||||
run_package_script "predeploy" "${pkg_path}"
|
||||
# Deploy package
|
||||
if [ "${pkg_config_deploy}" = true ]; then
|
||||
echo ":: Deploying target ${pkg_name}..."
|
||||
cp -rpv "${pkg_path}/payload"/* "${install_root}" > "${temp_location}/${pkg_name}-payloaddeploylog"
|
||||
sed 's/^.*-> //' "${temp_location}/${pkg_name}-payloaddeploylog" | tr -d \'\" > "${temp_location}/${pkg_name}-payloadfiles"
|
||||
rm "${temp_location}/${pkg_name}-payloaddeploylog"
|
||||
fi
|
||||
run_package_script "postdeploy" "${pkg_path}"
|
||||
# Add package to database
|
||||
if [ -x "${pkg_path}/package" ]; then
|
||||
echo ":: Adding target ${pkg_name} to installed package database..."
|
||||
[ ! -d "${installed_pkg_database}/${pkg_name}" ] && mkdir "${installed_pkg_database}/${pkg_name}"
|
||||
cp -pv "${pkg_path}/package" "${installed_pkg_database}/${pkg_name}/package"
|
||||
[ -e "${temp_location}/${pkg_name}-payloadfiles" ] && cp -pv "${temp_location}/${pkg_name}-payloadfiles" "${installed_pkg_database}/${pkg_name}/payloadfiles"
|
||||
else
|
||||
die "Target ${pkg_name} does not have a package script (it's an invalid package!). Exiting..."
|
||||
fi
|
||||
# Cleanup
|
||||
rm -r "${pkg_path}"
|
||||
rm "${temp_location}/${pkg_name}-payloadfiles"
|
||||
cd "${install_root}" || die "Could not return to main directory. Exiting..."
|
||||
unset pkg_path
|
||||
unset pkg_name
|
||||
unset pkg_config_deploy
|
||||
unset pkg_config_ver
|
||||
unset pkg_config_makedepends
|
||||
unset pkg_config_depends
|
||||
echo "[*] Install complete for package ${pkg_name}"
|
||||
}
|
||||
sync_deps(){
|
||||
confirm
|
||||
echo ":: Syncing dependencies for ${1}"
|
||||
install_package_from_repo "${pkg_makedepends}"
|
||||
install_package_from_repo "${pkg_deps}"
|
||||
echo "[*] Install dependencies for ${1}"
|
||||
function pkg_find(){
|
||||
# i could not even bother, i had to copy kiss in some sense
|
||||
set -- "$1" "$2" "$3" "${4:-"$AL_REPO"}"
|
||||
IFS=:
|
||||
|
||||
}
|
||||
remove_local_package() {
|
||||
confirm
|
||||
echo ":: Removing target ${1}..."
|
||||
pkg_path="${installed_pkg_database}/${1}"
|
||||
[ ! -d "${pkg_path}" ] && die "Package could not be found in local installed package database. Exiting..."
|
||||
payloadfiles_path="${pkg_path}/payloadfiles"
|
||||
[ ! -e "${payloadfiles_path}" ] && die "[E] Package ${1} does not have a payloadfiles file. Exiting..."
|
||||
rm -rv "$(cat ${payloadfiles_path})"
|
||||
rm -rv "${pkg_path}"
|
||||
echo "[*] Removal complete for target ${pkg_name}"
|
||||
}
|
||||
sync_local_repo_database() {
|
||||
echo ":: Syncing local database for repo ${1}"
|
||||
if [ ! -d "${locpkg_database}/${1}" ]; then
|
||||
# Local database for repo doesnt exists - clone it
|
||||
git clone "${2}" "${locpkg_database}/${1}"
|
||||
else
|
||||
# Local database for repo already exists - sync it
|
||||
cd "${locpkg_database}/${1}" || die "Could not enter local database directory. Exiting..."
|
||||
git pull
|
||||
fi
|
||||
}
|
||||
install_package_from_repo() { # NOTE(hippoz): This can get a tad confusing... ${1} is the repo and ${2} is the package
|
||||
echo ":: Installing package ${2} from ${1} repo"
|
||||
[ ! -d "${locpkg_database}/${1}/${2}" ] && die "Target not found."
|
||||
install_local_package "${locpkg_database}/${1}/${2}"
|
||||
}
|
||||
upgrade() {
|
||||
confirm
|
||||
echo ":: Upgrading installed packages"
|
||||
cd "${installed_pkg_database}" || die "Could not enter local installed package database directory. Exiting..."
|
||||
for pkg in */; do
|
||||
installed_pkg_path="${installed_pkg_database}/${pkg}"
|
||||
. "${installed_pkg_path}/package"
|
||||
pkg_name="${installed_pkg_path%/}"
|
||||
pkg_name="${pkg_name##*/}"
|
||||
already_installed_version=${pkg_config_ver}
|
||||
[ ! -d "${locpkg_database}/${1}/${pkg_name}" ] && die "Package ${pkg_name} was not found in ${1}. Exiting..."
|
||||
. "${locpkg_database}/${1}/${pkg_name}/package"
|
||||
if [ ! "${already_installed_version}" = "${pkg_config_ver}" ]; then
|
||||
echo ":: Updating package ${pkg_name} (out of date)"
|
||||
install_package_from_repo "${1}" "${pkg_name}"
|
||||
fi
|
||||
unset pkg_config_deploy
|
||||
unset pkg_config_ver
|
||||
unset pkg_config_makedepends
|
||||
unset pkg_config_depends
|
||||
for _find_path in $4 "${3:-$sys_db}"; do set +f
|
||||
for _find_pkg in "$_find_path/"$1; do
|
||||
test "${3:--d}" "$_find_pkg" && set -f -- "$@" "$_find_pkg"
|
||||
done
|
||||
done
|
||||
|
||||
unset IFS
|
||||
# alnux search i guess
|
||||
#case $2-$# in
|
||||
# *-4) return 1 ;;
|
||||
# -*) repo_dir=$5; repo_name=${5##*/} ;;
|
||||
# *) shift 4; printf '%s\n' "$@"
|
||||
#esac
|
||||
}
|
||||
version(){
|
||||
echo "Alnux APS v0.0.8.1"
|
||||
}
|
||||
help(){
|
||||
echo "Alnux APS, the packaging system for Alnux."
|
||||
echo ""
|
||||
echo "sync - Synchronizes from package repository."
|
||||
echo "install - Installs from local package information file and build file."
|
||||
echo "upgrade - Upgrades from package repository."
|
||||
echo "remove - Removes a package from /var/aps/installed and it's install files (payloadfiles)."
|
||||
echo "list - Lists currently installed packages."
|
||||
echo "help - Display this message."
|
||||
echo "version - Display the version."
|
||||
}
|
||||
list(){
|
||||
ls ${installed_pkg_database} | sed 's/^README.md//g'
|
||||
}
|
||||
main() {
|
||||
if [ -f "${lock}" ]; then
|
||||
echo "A lock file already exists (another instance of the package manager could be running). If you're sure no package manager is running, remove the file ${lock}."
|
||||
exit 1
|
||||
function pkg_local(){
|
||||
if [ -z "$AL_REPO" ]; then
|
||||
wrn "Alnux Repo variable is not set, Setting to /var/db/repo/core!"
|
||||
prn "To set the Alnux Repo var, either:"
|
||||
prn " edit /etc/profile or your shell's profile to include your repo and sub-repos, "
|
||||
prn " much like this: export AL_REPO=/var/db/repo/core:/var/db/repo/extra OR"
|
||||
prn " export Alnux Repo var like this: export AL_REPO=/var/db/repo/core:/var/db/repo/extra"
|
||||
export AL_REPO=/var/db/repo/core
|
||||
notf "AL_REPO set to /var/db/repo/core"
|
||||
|
||||
fi
|
||||
touch "${lock}"
|
||||
case ${1} in
|
||||
install) install_local_package "${2}" ;;
|
||||
remove) remove_local_package "${2}" ;;
|
||||
#sync-dep)
|
||||
# sync_local_repo_database "official" ${official}
|
||||
# [ -z "${2}" ] && exit 0
|
||||
# install_package_from_repo "official" "${2}" ;;
|
||||
sync)
|
||||
sync_local_repo_database "official" ${official}
|
||||
[ -z "${2}" ] && exit 0
|
||||
install_package_from_repo "official" "${2}" ;;
|
||||
upgrade) upgrade "official" ;;
|
||||
help) help ;;
|
||||
version) version ;;
|
||||
list) list ;;
|
||||
*) die "Invalid option ${1}, exiting..." ;;
|
||||
esac
|
||||
rm "${lock}"
|
||||
pkg_find $@
|
||||
}
|
||||
main "${1}" "${2}"
|
||||
function help(){
|
||||
prn "APS Version 0.1.0"
|
||||
prn "h|help) prints this message"
|
||||
prn "v|version) version"
|
||||
prn "s|sync) install package(s)"
|
||||
prn "u|update) update"
|
||||
prn "i|install) install LOCAL package(s)"
|
||||
}
|
||||
function version(){
|
||||
prn "APS Version 0.1.0"
|
||||
}
|
||||
function main(){
|
||||
dbg
|
||||
case $1 in
|
||||
s|sync) pkg_local $@ ;;
|
||||
v|version) version ;;
|
||||
h|help) help ;;
|
||||
*) err "Invalid option"
|
||||
esac
|
||||
}
|
||||
main $1
|
208
aps.old
Executable file
208
aps.old
Executable file
|
@ -0,0 +1,208 @@
|
|||
#!/bin/sh
|
||||
|
||||
#################################
|
||||
# Alnux Packaging System, #
|
||||
# the package manager for Alnux #
|
||||
#################################
|
||||
|
||||
if [ -f "$XDG_CONFIG_HOME/al/config" ]; then
|
||||
. $XDG_CONFIG_HOME/al/config
|
||||
elif [ -f "$HOME/.config/al/config" ]; then
|
||||
. $HOME/.config/al/config
|
||||
elif [ -f "/etc/al/config" ]; then
|
||||
. /etc/al/config
|
||||
else
|
||||
temp_location="/var/tmp"
|
||||
install_root="/var/tmp/alroot"
|
||||
installed_pkg_database="${install_root}/var/aps/installed"
|
||||
locpkg_database="${install_root}/var/aps/repos"
|
||||
lock="${install_root}/var/aps/lock"
|
||||
official="https://git.hippoz.xyz/alnux/repo"
|
||||
debug=off
|
||||
fi
|
||||
if [ ${debug} = on ]; then
|
||||
set -x
|
||||
fi
|
||||
die() {
|
||||
echo "aps: fatal: ${1}"
|
||||
rm "${lock}"
|
||||
exit 2
|
||||
}
|
||||
confirm(){
|
||||
echo -ne "Are you sure? [Y/n] "
|
||||
read prompt
|
||||
if [[ ${prompt} = [nN] ]]; then
|
||||
die "User said no. Exiting..."
|
||||
elif [[ ${prompt} != [yY] ]]; then
|
||||
die "User gave invalid input. Exiting..."
|
||||
fi
|
||||
}
|
||||
run_package_script() {
|
||||
{
|
||||
if [ -x "${2}/${1}" ]; then
|
||||
echo ":: Running ${1}"
|
||||
#cd "${2}" || die "Could not enter package working directory. Exiting..."
|
||||
"${2}/${1}" "${2}/payload" "${2}"
|
||||
fi
|
||||
}
|
||||
}
|
||||
install_local_package() {
|
||||
[ ! -e "${1}" ] && die "File ${1} does not exist. Exiting..."
|
||||
# Extract the package
|
||||
confirm
|
||||
echo ":: Installing package ${1}"
|
||||
cp -prv "${1}" "${temp_location}"
|
||||
pkg_name="${1%/}"
|
||||
pkg_name="${pkg_name##*/}"
|
||||
pkg_name=$(echo "${pkg_name}" | cut -f 1 -d '.')
|
||||
pkg_path="${temp_location}/${pkg_name}"
|
||||
cd "${pkg_path}" || die "Could not enter package path."
|
||||
# Set default values for package
|
||||
pkg_config_deploy=true
|
||||
pkg_config_ver="0"
|
||||
pkg_config_makedepends=""
|
||||
pkg_config_depends=""
|
||||
# Download sources.
|
||||
if [ -f sources ]; then
|
||||
pkg_config_sources=$(cat sources)
|
||||
pkg_config_sources_to=$(echo ${pkg_config_sources} | sed 's:.*/::')
|
||||
curl -# ${pkg_config_sources}
|
||||
mkdir pkg_bd
|
||||
tar -xf 1 ${pkg_config_sources_to} -C ${pkg_path}
|
||||
fi
|
||||
# Install package
|
||||
mkdir -p "${pkg_path}/payload"
|
||||
. "${pkg_path}/package"
|
||||
cd pkg_bd/
|
||||
run_package_script "build" "${pkg_path}"
|
||||
cd ../..
|
||||
run_package_script "predeploy" "${pkg_path}"
|
||||
# Deploy package
|
||||
if [ "${pkg_config_deploy}" = true ]; then
|
||||
echo ":: Deploying target ${pkg_name}..."
|
||||
cp -rpv "${pkg_path}/payload"/* "${install_root}" > "${temp_location}/${pkg_name}-payloaddeploylog"
|
||||
sed 's/^.*-> //' "${temp_location}/${pkg_name}-payloaddeploylog" | tr -d \'\" > "${temp_location}/${pkg_name}-payloadfiles"
|
||||
rm "${temp_location}/${pkg_name}-payloaddeploylog"
|
||||
fi
|
||||
run_package_script "postdeploy" "${pkg_path}"
|
||||
# Add package to database
|
||||
if [ -x "${pkg_path}/package" ]; then
|
||||
echo ":: Adding target ${pkg_name} to installed package database..."
|
||||
[ ! -d "${installed_pkg_database}/${pkg_name}" ] && mkdir "${installed_pkg_database}/${pkg_name}"
|
||||
cp -pv "${pkg_path}/package" "${installed_pkg_database}/${pkg_name}/package"
|
||||
[ -e "${temp_location}/${pkg_name}-payloadfiles" ] && cp -pv "${temp_location}/${pkg_name}-payloadfiles" "${installed_pkg_database}/${pkg_name}/payloadfiles"
|
||||
else
|
||||
die "Target ${pkg_name} does not have a package script (it's an invalid package!). Exiting..."
|
||||
fi
|
||||
# Cleanup
|
||||
rm -r "${pkg_path}"
|
||||
rm "${temp_location}/${pkg_name}-payloadfiles"
|
||||
cd "${install_root}" || die "Could not return to main directory. Exiting..."
|
||||
unset pkg_path
|
||||
unset pkg_name
|
||||
unset pkg_config_deploy
|
||||
unset pkg_config_ver
|
||||
unset pkg_config_makedepends
|
||||
unset pkg_config_depends
|
||||
echo "[*] Install complete for package ${pkg_name}"
|
||||
}
|
||||
sync_deps(){
|
||||
confirm
|
||||
echo ":: Syncing dependencies for ${1}"
|
||||
install_package_from_repo "${pkg_makedepends}"
|
||||
install_package_from_repo "${pkg_deps}"
|
||||
echo "[*] Install dependencies for ${1}"
|
||||
|
||||
}
|
||||
remove_local_package() {
|
||||
confirm
|
||||
echo ":: Removing target ${1}..."
|
||||
pkg_path="${installed_pkg_database}/${1}"
|
||||
[ ! -d "${pkg_path}" ] && die "Package could not be found in local installed package database. Exiting..."
|
||||
payloadfiles_path="${pkg_path}/payloadfiles"
|
||||
[ ! -e "${payloadfiles_path}" ] && die "[E] Package ${1} does not have a payloadfiles file. Exiting..."
|
||||
rm -rv "$(cat ${payloadfiles_path})"
|
||||
rm -rv "${pkg_path}"
|
||||
echo "[*] Removal complete for target ${pkg_name}"
|
||||
}
|
||||
sync_local_repo_database() {
|
||||
echo ":: Syncing local database for repo ${1}"
|
||||
if [ ! -d "${locpkg_database}/${1}" ]; then
|
||||
# Local database for repo doesnt exists - clone it
|
||||
git clone "${2}" "${locpkg_database}/${1}"
|
||||
else
|
||||
# Local database for repo already exists - sync it
|
||||
cd "${locpkg_database}/${1}" || die "Could not enter local database directory. Exiting..."
|
||||
git pull
|
||||
fi
|
||||
}
|
||||
install_package_from_repo() { # NOTE(hippoz): This can get a tad confusing... ${1} is the repo and ${2} is the package
|
||||
echo ":: Installing package ${2} from ${1} repo"
|
||||
[ ! -d "${locpkg_database}/${1}/${2}" ] && die "Target not found."
|
||||
install_local_package "${locpkg_database}/${1}/${2}"
|
||||
}
|
||||
upgrade() {
|
||||
confirm
|
||||
echo ":: Upgrading installed packages"
|
||||
cd "${installed_pkg_database}" || die "Could not enter local installed package database directory. Exiting..."
|
||||
for pkg in */; do
|
||||
installed_pkg_path="${installed_pkg_database}/${pkg}"
|
||||
. "${installed_pkg_path}/package"
|
||||
pkg_name="${installed_pkg_path%/}"
|
||||
pkg_name="${pkg_name##*/}"
|
||||
already_installed_version=${pkg_config_ver}
|
||||
[ ! -d "${locpkg_database}/${1}/${pkg_name}" ] && die "Package ${pkg_name} was not found in ${1}. Exiting..."
|
||||
. "${locpkg_database}/${1}/${pkg_name}/package"
|
||||
if [ ! "${already_installed_version}" = "${pkg_config_ver}" ]; then
|
||||
echo ":: Updating package ${pkg_name} (out of date)"
|
||||
install_package_from_repo "${1}" "${pkg_name}"
|
||||
fi
|
||||
unset pkg_config_deploy
|
||||
unset pkg_config_ver
|
||||
unset pkg_config_makedepends
|
||||
unset pkg_config_depends
|
||||
done
|
||||
}
|
||||
version(){
|
||||
echo "Alnux APS v0.0.8.1"
|
||||
}
|
||||
help(){
|
||||
echo "Alnux APS, the packaging system for Alnux."
|
||||
echo ""
|
||||
echo "sync - Synchronizes from package repository."
|
||||
echo "install - Installs from local package information file and build file."
|
||||
echo "upgrade - Upgrades from package repository."
|
||||
echo "remove - Removes a package from /var/aps/installed and it's install files (payloadfiles)."
|
||||
echo "list - Lists currently installed packages."
|
||||
echo "help - Display this message."
|
||||
echo "version - Display the version."
|
||||
}
|
||||
list(){
|
||||
ls ${installed_pkg_database} | sed 's/^README.md//g'
|
||||
}
|
||||
main() {
|
||||
if [ -f "${lock}" ]; then
|
||||
echo "A lock file already exists (another instance of the package manager could be running). If you're sure no package manager is running, remove the file ${lock}."
|
||||
exit 1
|
||||
fi
|
||||
touch "${lock}"
|
||||
case ${1} in
|
||||
install) install_local_package "${2}" ;;
|
||||
remove) remove_local_package "${2}" ;;
|
||||
#sync-dep)
|
||||
# sync_local_repo_database "official" ${official}
|
||||
# [ -z "${2}" ] && exit 0
|
||||
# install_package_from_repo "official" "${2}" ;;
|
||||
sync)
|
||||
sync_local_repo_database "official" ${official}
|
||||
[ -z "${2}" ] && exit 0
|
||||
install_package_from_repo "official" "${2}" ;;
|
||||
upgrade) upgrade "official" ;;
|
||||
help) help ;;
|
||||
version) version ;;
|
||||
list) list ;;
|
||||
*) die "Invalid option ${1}, exiting..." ;;
|
||||
esac
|
||||
rm "${lock}"
|
||||
}
|
||||
main "${1}" "${2}"
|
Loading…
Reference in a new issue