Compare commits
No commits in common. "master" and "master" have entirely different histories.
8 changed files with 232 additions and 299 deletions
|
@ -1,5 +1,3 @@
|
||||||
# aps
|
# aps
|
||||||
|
|
||||||
the alnux package manager
|
the alnux package manager
|
||||||
|
|
||||||
(the code is completely and utterly horrible and i cant believe i actually wrote this lol)
|
|
18
altools/repo
18
altools/repo
|
@ -1,18 +0,0 @@
|
||||||
#!/bin/sh
|
|
||||||
|
|
||||||
########################################
|
|
||||||
# Repo, a repository manager for alnux #
|
|
||||||
########################################
|
|
||||||
. /etc/al/config
|
|
||||||
case $1 in
|
|
||||||
# add a repo
|
|
||||||
add) git clone https://${3}/${2}.git ${install_root}/var/aps/repos/${2}
|
|
||||||
echo "${2}" >> ${install_root}/etc/al/repo.conf
|
|
||||||
;;
|
|
||||||
# update a repo
|
|
||||||
update) pushd && cd ${install_root}/var/aps/repos/${2} && git pull && popd ;;
|
|
||||||
# destroy a repo (remove)
|
|
||||||
destroy) rm -rfv ${install_root}/var/aps/repos/${2}
|
|
||||||
sed -i "/^${2}/d" ${install_root}/etc/al/repo.conf
|
|
||||||
;;
|
|
||||||
esac
|
|
35
altools/sel
35
altools/sel
|
@ -1,35 +0,0 @@
|
||||||
#!/bin/sh
|
|
||||||
|
|
||||||
#########################
|
|
||||||
# Alnux sel(ect) Script #
|
|
||||||
#########################
|
|
||||||
. /etc/al/config
|
|
||||||
if [ -f "${install_root}/etc/al/lnver" ]; then
|
|
||||||
. /etc/al/lnver.cfg
|
|
||||||
fi
|
|
||||||
case $1 in
|
|
||||||
linux) case $2 in
|
|
||||||
# Lists all kernels
|
|
||||||
list) ls ${install_root}/usr/src/ | grep 'linux' &&
|
|
||||||
ls -L ${install_root}/usr/src/linux 2>/dev/null
|
|
||||||
;;
|
|
||||||
# Sets a kernel version
|
|
||||||
set) lnver=${3}
|
|
||||||
echo "lnver=${3}" > ${install_root}/etc/al/lnver.cfg
|
|
||||||
;;
|
|
||||||
# Links the set kernel version.
|
|
||||||
link) ln -sv ${install_root}/usr/src/linux-${lnver} ${install_root}/usr/src/linux &&
|
|
||||||
mkdir -pv ${install_root}/var/aps/packages/linux/ &&
|
|
||||||
echo "/boot/vmlinuz-linux-${lnver}" > ${install_root}/var/aps/packages/linux/payloadfiles &&
|
|
||||||
echo "/usr/src/${lnver}" >> ${install_root}/var/aps/packages/linux/payloadfiles &&
|
|
||||||
echo "pkg_config_deploy=true" > ${install_root}/var/aps/packages/linux/package &&
|
|
||||||
echo "pkg_config_ver='${lnver}'" >> ${install_root}/var/aps/packages/linux/package &&
|
|
||||||
echo "pkg_config_name='linux'" >> ${install_root}/var/aps/packages/linux/package &&
|
|
||||||
echo "pkg_config_makedepends=''" >> ${install_root}/var/aps/packages/linux/package &&
|
|
||||||
echo "pkg_config_depends=''" >> ${install_root}/var/aps/packages/linux/package
|
|
||||||
|
|
||||||
;;
|
|
||||||
# Destroys the symlink.
|
|
||||||
destroy) rm -rfv ${install_root}/usr/src/linux ;;
|
|
||||||
esac
|
|
||||||
esac
|
|
208
aps
208
aps
|
@ -1,208 +0,0 @@
|
||||||
#!/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} -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}"
|
|
||||||
|
|
||||||
}
|
|
||||||
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}"
|
|
231
aps.sh
Normal file
231
aps.sh
Normal file
|
@ -0,0 +1,231 @@
|
||||||
|
#!/bin/sh
|
||||||
|
|
||||||
|
AL_TEMP_LOCATION="/tmp"
|
||||||
|
AL_INSTALL_ROOT="/tmp/alroot"
|
||||||
|
AL_INSTALLED_PKG_DATABASE="${AL_INSTALL_ROOT}/var/aps/installed"
|
||||||
|
AL_LOCAL_PKG_DATABASE="${AL_INSTALL_ROOT}/var/aps/repos"
|
||||||
|
AL_LOCK="${AL_INSTALL_ROOT}/var/aps/lock"
|
||||||
|
|
||||||
|
# Repo config
|
||||||
|
official="https://git.hippoz.xyz/alnux/repo"
|
||||||
|
|
||||||
|
set_default_package_config_values() {
|
||||||
|
AL_PKG_CONFIG_DEPLOY=true
|
||||||
|
AL_PKG_CONFIG_VER="0.1"
|
||||||
|
AL_PKG_CONFIG_NAME="alnuxpackage"
|
||||||
|
AL_PKG_CONFIG_MAKEDEPENDS=""
|
||||||
|
AL_PKG_CONFIG_DEPENDS=""
|
||||||
|
}
|
||||||
|
|
||||||
|
unset_config_values() {
|
||||||
|
unset AL_PKG_CONFIG_DEPLOY
|
||||||
|
unset AL_PKG_CONFIG_VER
|
||||||
|
unset AL_PKG_CONFIG_NAME
|
||||||
|
unset AL_PKG_CONFIG_MAKEDEPENDS
|
||||||
|
unset AL_PKG_CONFIG_DEPENDS
|
||||||
|
}
|
||||||
|
|
||||||
|
load_installed_pkg_config() {
|
||||||
|
echo ":: Looking up package ${1} in local installed packages..."
|
||||||
|
set_default_package_config_values
|
||||||
|
if [ -d "${AL_INSTALLED_PKG_DATABASE}/${1}" ]; then
|
||||||
|
echo ":: Package ${1} was found, loading config..."
|
||||||
|
AL_PKG_NAME=${1}
|
||||||
|
AL_PKG_PACKAGE_PATH="${AL_INSTALLED_PKG_DATABASE}/${1}"
|
||||||
|
run_package_script "package"
|
||||||
|
else
|
||||||
|
echo "[E] Package ${1} was not found in the local installed package database, exiting..."
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
}
|
||||||
|
|
||||||
|
extract_package() {
|
||||||
|
echo "[*] Copying package ${1} into temporary location ${AL_TEMP_LOCATION}..."
|
||||||
|
#tar -xf "${1}" -C "${AL_TEMP_LOCATION}"
|
||||||
|
cp -prv "${1}" "${AL_TEMP_LOCATION}"
|
||||||
|
AL_PKG_NAME="${1%/}"
|
||||||
|
AL_PKG_NAME="${AL_PKG_NAME##*/}"
|
||||||
|
AL_PKG_NAME=$(echo "${AL_PKG_NAME}" | cut -f 1 -d '.')
|
||||||
|
cd "${AL_INSTALL_ROOT}"
|
||||||
|
|
||||||
|
AL_PKG_PACKAGE_PATH="${AL_TEMP_LOCATION}/${AL_PKG_NAME}"
|
||||||
|
|
||||||
|
set_default_package_config_values
|
||||||
|
}
|
||||||
|
|
||||||
|
add_package_to_database() {
|
||||||
|
if [ ! -d "${AL_INSTALLED_PKG_DATABASE}" ]; then
|
||||||
|
echo "[*] Package database folder not found, creating..."
|
||||||
|
mkdir -pv "${AL_INSTALLED_PKG_DATABASE}"
|
||||||
|
fi
|
||||||
|
|
||||||
|
if [ -x "${AL_PKG_PACKAGE_PATH}/package" ]; then
|
||||||
|
echo ":: Adding target ${AL_PKG_NAME} to installed package database..."
|
||||||
|
if [ ! -d "${AL_INSTALLED_PKG_DATABASE}/${AL_PKG_NAME}" ]; then
|
||||||
|
echo "[*] Package folder for ${AL_PKG_NAME} not found, creating..."
|
||||||
|
mkdir "${AL_INSTALLED_PKG_DATABASE}/${AL_PKG_NAME}"
|
||||||
|
fi
|
||||||
|
cp -pv "${AL_PKG_PACKAGE_PATH}/package" "${AL_INSTALLED_PKG_DATABASE}/${AL_PKG_NAME}/package"
|
||||||
|
if [ -e "${AL_TEMP_LOCATION}/${AL_PKG_NAME}-payloadfiles" ]; then
|
||||||
|
cp -pv "${AL_TEMP_LOCATION}/${AL_PKG_NAME}-payloadfiles" "${AL_INSTALLED_PKG_DATABASE}/${AL_PKG_NAME}/payloadfiles"
|
||||||
|
fi
|
||||||
|
else
|
||||||
|
echo "[*] Target ${AL_PKG_NAME} does not have a package script and will not be added to the installed package database"
|
||||||
|
fi
|
||||||
|
}
|
||||||
|
|
||||||
|
run_package_script() {
|
||||||
|
if [ -x "${AL_PKG_PACKAGE_PATH}/${1}" ]; then
|
||||||
|
echo ":: Running ${1} script for target ${AL_PKG_NAME}..."
|
||||||
|
. "${AL_PKG_PACKAGE_PATH}/${1}"
|
||||||
|
fi
|
||||||
|
}
|
||||||
|
|
||||||
|
deploy_package_payload() {
|
||||||
|
if [ "${AL_PKG_CONFIG_DEPLOY}" = true ]; then
|
||||||
|
echo ":: Deploying target ${AL_PKG_NAME}..."
|
||||||
|
cp -rpv "${AL_PKG_PACKAGE_PATH}/payload"/* "${AL_INSTALL_ROOT}" > "${AL_TEMP_LOCATION}/${AL_PKG_NAME}-payloaddeploylog"
|
||||||
|
sed 's/^.*-> //' "${AL_TEMP_LOCATION}/${AL_PKG_NAME}-payloaddeploylog" | tr -d \'\" > "${AL_TEMP_LOCATION}/${AL_PKG_NAME}-payloadfiles"
|
||||||
|
rm "${AL_TEMP_LOCATION}/${AL_PKG_NAME}-payloaddeploylog"
|
||||||
|
fi
|
||||||
|
}
|
||||||
|
|
||||||
|
install_extracted_package() {
|
||||||
|
run_package_script "package"
|
||||||
|
run_package_script "build"
|
||||||
|
run_package_script "predeploy"
|
||||||
|
deploy_package_payload
|
||||||
|
run_package_script "postdeploy"
|
||||||
|
|
||||||
|
echo "[*] Install complete for target ${AL_PKG_NAME}"
|
||||||
|
}
|
||||||
|
|
||||||
|
extract_cleanup() {
|
||||||
|
echo "[*] Cleaning up after target ${AL_PKG_NAME}..."
|
||||||
|
rm -rv "${AL_PKG_PACKAGE_PATH}"
|
||||||
|
rm -v "${AL_TEMP_LOCATION}/${AL_PKG_NAME}-payloadfiles"
|
||||||
|
|
||||||
|
unset AL_PKG_PACKAGE_PATH
|
||||||
|
unset AL_PKG_NAME
|
||||||
|
|
||||||
|
unset_config_values
|
||||||
|
|
||||||
|
cd "${AL_INSTALL_ROOT}"
|
||||||
|
}
|
||||||
|
|
||||||
|
install_local_package() {
|
||||||
|
if [ ! -e "${1}" ]; then
|
||||||
|
echo "[E] File ${1} does not exist, exiting..."
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
|
||||||
|
extract_package "${1}"
|
||||||
|
install_extracted_package
|
||||||
|
add_package_to_database
|
||||||
|
extract_cleanup
|
||||||
|
}
|
||||||
|
|
||||||
|
remove_local_package() {
|
||||||
|
load_installed_pkg_config "${1}"
|
||||||
|
PAYLOADFILES_PATH="${AL_PKG_PACKAGE_PATH}/payloadfiles"
|
||||||
|
|
||||||
|
if [ ! -e "${PAYLOADFILES_PATH}" ]; then
|
||||||
|
echo "[E] Package ${1} does not have a payloadfiles file. Exiting..."
|
||||||
|
exit 0
|
||||||
|
fi
|
||||||
|
|
||||||
|
echo ":: Removing target ${1}..."
|
||||||
|
|
||||||
|
rm -rv $(<${PAYLOADFILES_PATH})
|
||||||
|
rm -rv ${AL_PKG_PACKAGE_PATH}
|
||||||
|
|
||||||
|
echo "[*] Removal complete for target ${AL_PKG_NAME}"
|
||||||
|
}
|
||||||
|
|
||||||
|
sync_local_repo_database() {
|
||||||
|
echo ":: Syncing local database for repo ${1}..."
|
||||||
|
if [ ! -d "${AL_LOCAL_PKG_DATABASE}/${1}" ]; then
|
||||||
|
echo ":: Local database for repo ${1} does not exist, cloning..."
|
||||||
|
git clone "${2}" "${AL_LOCAL_PKG_DATABASE}/${1}"
|
||||||
|
else
|
||||||
|
echo ":: Local database for repo ${1} exists, updating..."
|
||||||
|
cd "${AL_LOCAL_PKG_DATABASE}/${1}"
|
||||||
|
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"
|
||||||
|
if [ ! -d "${AL_LOCAL_PKG_DATABASE}/${1}/${2}" ]; then
|
||||||
|
echo "[E] Package ${2} was not found in ${1}, exiting..."
|
||||||
|
exit 1
|
||||||
|
else
|
||||||
|
install_local_package "${AL_LOCAL_PKG_DATABASE}/${1}/${2}"
|
||||||
|
fi
|
||||||
|
}
|
||||||
|
|
||||||
|
upgrade() {
|
||||||
|
echo ":: Upgrading installed packages..."
|
||||||
|
unset_config_values
|
||||||
|
cd "${AL_INSTALLED_PKG_DATABASE}"
|
||||||
|
for pkg in */; do
|
||||||
|
INSTALLED_PKG_PATH="${AL_INSTALLED_PKG_DATABASE}/${pkg}"
|
||||||
|
. ${INSTALLED_PKG_PATH}/package
|
||||||
|
AL_PKG_NAME="${INSTALLED_PKG_PATH%/}"
|
||||||
|
AL_PKG_NAME="${AL_PKG_NAME##*/}"
|
||||||
|
|
||||||
|
ALREADY_INSTALLED_VERSION=${AL_PKG_CONFIG_VER}
|
||||||
|
|
||||||
|
if [ ! -d "${AL_LOCAL_PKG_DATABASE}/${1}/${AL_PKG_NAME}" ]; then
|
||||||
|
echo "[E] Package ${AL_PKG_NAME} was not found in ${1}, exiting..."
|
||||||
|
exit 1
|
||||||
|
else
|
||||||
|
. "${AL_LOCAL_PKG_DATABASE}/${1}/${AL_PKG_NAME}/package"
|
||||||
|
fi
|
||||||
|
|
||||||
|
if [ ! "${ALREADY_INSTALLED_VERSION}" = "${AL_PKG_CONFIG_VER}" ]; then
|
||||||
|
echo ":: Package ${AL_PKG_NAME} is out of date, updating..."
|
||||||
|
install_package_from_repo "${1}" "${AL_PKG_NAME}"
|
||||||
|
fi
|
||||||
|
|
||||||
|
unset_config_values
|
||||||
|
done
|
||||||
|
}
|
||||||
|
|
||||||
|
main() {
|
||||||
|
if [ -f "${AL_LOCK}" ]; then
|
||||||
|
echo "[E] A lock file already exists."
|
||||||
|
echo " If you're sure no package manager is running,"
|
||||||
|
echo " remove the file ${AL_LOCK}"
|
||||||
|
fi
|
||||||
|
touch "${AL_LOCK}"
|
||||||
|
|
||||||
|
case ${1} in
|
||||||
|
install)
|
||||||
|
install_local_package "${2}"
|
||||||
|
;;
|
||||||
|
remove)
|
||||||
|
remove_local_package "${2}"
|
||||||
|
;;
|
||||||
|
sync)
|
||||||
|
sync_local_repo_database "official" ${official}
|
||||||
|
if [ -z "${2}" ]; then
|
||||||
|
echo "[*] No targets specified."
|
||||||
|
else
|
||||||
|
install_package_from_repo "official" "${2}"
|
||||||
|
fi
|
||||||
|
;;
|
||||||
|
upgrade)
|
||||||
|
upgrade "official"
|
||||||
|
;;
|
||||||
|
*)
|
||||||
|
echo "[E] Invalid option ${1}, exiting..."
|
||||||
|
rm "${AL_LOCK}"
|
||||||
|
exit 0
|
||||||
|
;;
|
||||||
|
esac
|
||||||
|
|
||||||
|
rm "${AL_LOCK}"
|
||||||
|
}
|
||||||
|
|
||||||
|
main "${1}" "${2}"
|
|
@ -1,12 +0,0 @@
|
||||||
|
|
||||||
##########################
|
|
||||||
# A config file for the #
|
|
||||||
# Alnux Packaging System #
|
|
||||||
##########################
|
|
||||||
temp_location="/var/tmp"
|
|
||||||
install_root="/"
|
|
||||||
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
|
|
23
install.sh
23
install.sh
|
@ -1,23 +0,0 @@
|
||||||
#!/bin/sh
|
|
||||||
|
|
||||||
##########################
|
|
||||||
# INSTALL SCRIPT FOR APS #
|
|
||||||
##########################
|
|
||||||
case $1 in
|
|
||||||
--prefix) prefix=$2 ;;
|
|
||||||
*) prefix=/
|
|
||||||
esac
|
|
||||||
if [ ${prefix} == / ]; then
|
|
||||||
if [ $(whoami) != root ]; then
|
|
||||||
echo '[E] You must run as root!'
|
|
||||||
kill 2
|
|
||||||
fi
|
|
||||||
else
|
|
||||||
export install_root=${prefix}
|
|
||||||
./aps sync alnux
|
|
||||||
install -v aps ${prefix}/usr/bin/ &&
|
|
||||||
install -v altools/sel ${prefix}/usr/bin/ &&
|
|
||||||
install -v altools/repo ${prefix}/usr/bin/ &&
|
|
||||||
install -v config/config ${prefix}/etc/al &&
|
|
||||||
install -v -Dm644 man/aps.8.gz ${prefix}/usr/share/man/man8/
|
|
||||||
fi
|
|
BIN
man/aps.8.gz
BIN
man/aps.8.gz
Binary file not shown.
Loading…
Reference in a new issue