Compare commits
2 commits
1e8f5ea4f2
...
0216a7771f
Author | SHA1 | Date | |
---|---|---|---|
|
0216a7771f | ||
|
85e814aff0 |
1 changed files with 21 additions and 19 deletions
40
aps
40
aps
|
@ -5,13 +5,12 @@ installed_pkg_database="${install_root}/var/aps/installed"
|
||||||
locpkg_database="${install_root}/var/aps/repos"
|
locpkg_database="${install_root}/var/aps/repos"
|
||||||
lock="${install_root}/var/aps/lock"
|
lock="${install_root}/var/aps/lock"
|
||||||
official="https://git.hippoz.xyz/alnux/repo"
|
official="https://git.hippoz.xyz/alnux/repo"
|
||||||
[ ! -d "${installed_pkg_database}" ] && mkdir -p "${installed_pkg_database}"
|
|
||||||
die() {
|
die() {
|
||||||
echo "${1}"
|
echo "aps: fatal: ${1}"
|
||||||
rm "${lock}"
|
rm "${lock}"
|
||||||
exit 2
|
exit 2
|
||||||
}
|
}
|
||||||
run_package_script() { # --- $2 is the package path, and $1 is the script to run
|
run_package_script() {
|
||||||
{
|
{
|
||||||
if [ -x "${2}/${1}" ]; then
|
if [ -x "${2}/${1}" ]; then
|
||||||
echo ":: Running ${1}"
|
echo ":: Running ${1}"
|
||||||
|
@ -23,7 +22,7 @@ run_package_script() { # --- $2 is the package path, and $1 is the script to run
|
||||||
install_local_package() {
|
install_local_package() {
|
||||||
[ ! -e "${1}" ] && die "[E] File ${1} does not exist. Exiting..."
|
[ ! -e "${1}" ] && die "[E] File ${1} does not exist. Exiting..."
|
||||||
# Extract the package
|
# Extract the package
|
||||||
echo "[*] Copying package ${1} into temporary location ${temp_location}..."
|
echo ":: Installing package ${1}"
|
||||||
cp -prv "${1}" "${temp_location}"
|
cp -prv "${1}" "${temp_location}"
|
||||||
pkg_name="${1%/}"
|
pkg_name="${1%/}"
|
||||||
pkg_name="${pkg_name##*/}"
|
pkg_name="${pkg_name##*/}"
|
||||||
|
@ -36,6 +35,7 @@ install_local_package() {
|
||||||
pkg_config_makedepends=""
|
pkg_config_makedepends=""
|
||||||
pkg_config_depends=""
|
pkg_config_depends=""
|
||||||
# Install package
|
# Install package
|
||||||
|
mkdir -p "${pkg_path}/payload"
|
||||||
. "${pkg_path}/package"
|
. "${pkg_path}/package"
|
||||||
run_package_script "build" "${pkg_path}"
|
run_package_script "build" "${pkg_path}"
|
||||||
run_package_script "predeploy" "${pkg_path}"
|
run_package_script "predeploy" "${pkg_path}"
|
||||||
|
@ -47,7 +47,6 @@ install_local_package() {
|
||||||
rm "${temp_location}/${pkg_name}-payloaddeploylog"
|
rm "${temp_location}/${pkg_name}-payloaddeploylog"
|
||||||
fi
|
fi
|
||||||
run_package_script "postdeploy" "${pkg_path}"
|
run_package_script "postdeploy" "${pkg_path}"
|
||||||
echo "[*] Install complete for target ${pkg_name}"
|
|
||||||
# Add package to database
|
# Add package to database
|
||||||
if [ -x "${pkg_path}/package" ]; then
|
if [ -x "${pkg_path}/package" ]; then
|
||||||
echo ":: Adding target ${pkg_name} to installed package database..."
|
echo ":: Adding target ${pkg_name} to installed package database..."
|
||||||
|
@ -58,7 +57,6 @@ install_local_package() {
|
||||||
die "[E] Target ${pkg_name} does not have a package script (it's an invalid package!). Exiting..."
|
die "[E] Target ${pkg_name} does not have a package script (it's an invalid package!). Exiting..."
|
||||||
fi
|
fi
|
||||||
# Cleanup
|
# Cleanup
|
||||||
echo "[*] Cleaning up after target ${pkg_name}..."
|
|
||||||
rm -r "${pkg_path}"
|
rm -r "${pkg_path}"
|
||||||
rm "${temp_location}/${pkg_name}-payloadfiles"
|
rm "${temp_location}/${pkg_name}-payloadfiles"
|
||||||
cd "${install_root}" || die "Could not return to main directory. Exiting..."
|
cd "${install_root}" || die "Could not return to main directory. Exiting..."
|
||||||
|
@ -68,47 +66,47 @@ install_local_package() {
|
||||||
unset pkg_config_ver
|
unset pkg_config_ver
|
||||||
unset pkg_config_makedepends
|
unset pkg_config_makedepends
|
||||||
unset pkg_config_depends
|
unset pkg_config_depends
|
||||||
|
echo "[*] Install complete for package ${pkg_name}"
|
||||||
}
|
}
|
||||||
remove_local_package() {
|
remove_local_package() {
|
||||||
|
echo ":: Removing target ${1}..."
|
||||||
pkg_path="${installed_pkg_database}/${1}"
|
pkg_path="${installed_pkg_database}/${1}"
|
||||||
[ ! -d "${pkg_path}" ] && die "Package could not be found in local installed package database. Exiting..."
|
[ ! -d "${pkg_path}" ] && die "Package could not be found in local installed package database. Exiting..."
|
||||||
payloadfiles_path="${pkg_path}/payloadfiles"
|
payloadfiles_path="${pkg_path}/payloadfiles"
|
||||||
[ ! -e "${payloadfiles_path}" ] && die "[E] Package ${1} does not have a payloadfiles file. Exiting..."
|
[ ! -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 "$(cat ${payloadfiles_path})"
|
||||||
rm -rv "${pkg_path}"
|
rm -rv "${pkg_path}"
|
||||||
echo "[*] Removal complete for target ${pkg_name}"
|
echo "[*] Removal complete for target ${pkg_name}"
|
||||||
}
|
}
|
||||||
sync_local_repo_database() {
|
sync_local_repo_database() {
|
||||||
echo ":: Syncing local database for repo ${1}..."
|
echo ":: Syncing local database for repo ${1}"
|
||||||
if [ ! -d "${locpkg_database}/${1}" ]; then
|
if [ ! -d "${locpkg_database}/${1}" ]; then
|
||||||
echo ":: Local database for repo ${1} does not exist, cloning..."
|
# Local database for repo doesnt exists - clone it
|
||||||
git clone "${2}" "${locpkg_database}/${1}"
|
git clone "${2}" "${locpkg_database}/${1}"
|
||||||
else
|
else
|
||||||
echo ":: Local database for repo ${1} exists, updating..."
|
# Local database for repo already exists - sync it
|
||||||
cd "${locpkg_database}/${1}" || die "Could not enter local database. Exiting..."
|
cd "${locpkg_database}/${1}" || die "Could not enter local database directory. Exiting..."
|
||||||
git pull
|
git pull
|
||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
install_package_from_repo() { # NOTE(hippoz): This can get a tad confusing... ${1} is the repo and ${2} is the package
|
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"
|
echo ":: Installing package ${2} from ${1} repo"
|
||||||
[ ! -d "${locpkg_database}/${1}/${2}" ] && die "[E] Target not found."
|
[ ! -d "${locpkg_database}/${1}/${2}" ] && die "Target not found."
|
||||||
install_local_package "${locpkg_database}/${1}/${2}"
|
install_local_package "${locpkg_database}/${1}/${2}"
|
||||||
}
|
}
|
||||||
upgrade() {
|
upgrade() {
|
||||||
echo ":: Upgrading installed packages..."
|
echo ":: Upgrading installed packages"
|
||||||
unset_config_values
|
cd "${installed_pkg_database}" || die "Could not enter local installed package database directory. Exiting..."
|
||||||
cd "${installed_pkg_database}" || die "Could not enter installed package database. Exiting..."
|
|
||||||
for pkg in */; do
|
for pkg in */; do
|
||||||
installed_pkg_path="${installed_pkg_database}/${pkg}"
|
installed_pkg_path="${installed_pkg_database}/${pkg}"
|
||||||
. "${installed_pkg_path}/package"
|
. "${installed_pkg_path}/package"
|
||||||
pkg_name="${installed_pkg_path%/}"
|
pkg_name="${installed_pkg_path%/}"
|
||||||
pkg_name="${pkg_name##*/}"
|
pkg_name="${pkg_name##*/}"
|
||||||
already_installed_version=${pkg_config_ver}
|
already_installed_version=${pkg_config_ver}
|
||||||
[ ! -d "${locpkg_database}/${1}/${pkg_name}" ] && die "[E] Package ${pkg_name} was not found in ${1}, exiting..."
|
[ ! -d "${locpkg_database}/${1}/${pkg_name}" ] && die "Package ${pkg_name} was not found in ${1}. Exiting..."
|
||||||
. "${locpkg_database}/${1}/${pkg_name}/package"
|
. "${locpkg_database}/${1}/${pkg_name}/package"
|
||||||
if [ ! "${already_installed_version}" = "${pkg_config_ver}" ]; then
|
if [ ! "${already_installed_version}" = "${pkg_config_ver}" ]; then
|
||||||
echo ":: Package ${pkg_name} is out of date, updating..."
|
echo ":: Updating package ${pkg_name} (out of date)"
|
||||||
install_package_from_repo "${1}" "${pkg_name}"
|
install_package_from_repo "${1}" "${pkg_name}"
|
||||||
fi
|
fi
|
||||||
unset pkg_config_deploy
|
unset pkg_config_deploy
|
||||||
|
@ -119,16 +117,20 @@ upgrade() {
|
||||||
}
|
}
|
||||||
main() {
|
main() {
|
||||||
if [ -f "${lock}" ]; then
|
if [ -f "${lock}" ]; then
|
||||||
echo "[E] A lock file already exists. If you're sure no package manager is running, remove the file ${lock}."
|
echo "[E] 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
|
exit 1
|
||||||
fi
|
fi
|
||||||
touch "${lock}"
|
touch "${lock}"
|
||||||
case ${1} in
|
case ${1} in
|
||||||
install) install_local_package "${2}" ;;
|
install) install_local_package "${2}" ;;
|
||||||
remove) remove_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)
|
||||||
sync_local_repo_database "official" ${official}
|
sync_local_repo_database "official" ${official}
|
||||||
[ -z "${2}" ] && die "[*] No targets specified."
|
[ -z "${2}" ] && exit 0
|
||||||
install_package_from_repo "official" "${2}" ;;
|
install_package_from_repo "official" "${2}" ;;
|
||||||
upgrade) upgrade "official" ;;
|
upgrade) upgrade "official" ;;
|
||||||
*) die "[E] Invalid option ${1}, exiting..." ;;
|
*) die "[E] Invalid option ${1}, exiting..." ;;
|
||||||
|
|
Loading…
Reference in a new issue