Compare commits

..

2 commits

Author SHA1 Message Date
Ohio2
5fb7ca5148 revert two things 2021-07-16 22:26:13 +02:00
Ohio2
8f6c3e2b1a reverted removal of lb 2021-07-16 22:21:13 +02:00
3 changed files with 5 additions and 138 deletions

138
aps
View file

@ -1,138 +0,0 @@
#!/bin/sh
temp_location="/tmp"
install_root="/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"
[ ! -d "${installed_pkg_database}" ] && mkdir -p "${installed_pkg_database}"
die() {
echo "${1}"
rm "${lock}"
exit 2
}
run_package_script() { # --- $2 is the package path, and $1 is the script to run
{
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 "[E] File ${1} does not exist. Exiting..."
# Extract the package
echo "[*] Copying package ${1} into temporary location ${temp_location}..."
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=""
# Install package
. "${pkg_path}/package"
run_package_script "build" "${pkg_path}"
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}"
echo "[*] Install complete for target ${pkg_name}"
# 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 "[E] Target ${pkg_name} does not have a package script (it's an invalid package!). Exiting..."
fi
# Cleanup
echo "[*] Cleaning up after target ${pkg_name}..."
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
}
remove_local_package() {
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..."
echo ":: Removing target ${1}..."
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
echo ":: Local database for repo ${1} does not exist, cloning..."
git clone "${2}" "${locpkg_database}/${1}"
else
echo ":: Local database for repo ${1} exists, updating..."
cd "${locpkg_database}/${1}" || die "Could not enter local database. 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 "[E] Target not found."
install_local_package "${locpkg_database}/${1}/${2}"
}
upgrade() {
echo ":: Upgrading installed packages..."
unset_config_values
cd "${installed_pkg_database}" || die "Could not enter installed package database. 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 "[E] Package ${pkg_name} was not found in ${1}, exiting..."
. "${locpkg_database}/${1}/${pkg_name}/package"
if [ ! "${already_installed_version}" = "${pkg_config_ver}" ]; then
echo ":: Package ${pkg_name} is out of date, updating..."
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
}
main() {
if [ -f "${lock}" ]; then
echo "[E] A lock file already exists. 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)
sync_local_repo_database "official" ${official}
[ -z "${2}" ] && die "[*] No targets specified."
install_package_from_repo "official" "${2}" ;;
upgrade) upgrade "official" ;;
*) die "[E] Invalid option ${1}, exiting..." ;;
esac
rm "${lock}"
}
main "${1}" "${2}"

5
linux-bin/package Executable file
View file

@ -0,0 +1,5 @@
pkg_config_deploy=true
pkg_config_ver="0.1"
pkg_config_name="linux-bin"
pkg_config_makedepends=""
pkg_config_depends=""

Binary file not shown.