add debug and confirm #9

Merged
hippoz merged 5 commits from Ohio2/aps:master into master 2021-08-26 16:31:30 +03:00
2 changed files with 17 additions and 3 deletions
Showing only changes of commit 2ea5c8a809 - Show all commits

14
aps
View file

@ -14,6 +14,16 @@ die() {
rm "${lock}" rm "${lock}"
exit 2 exit 2
} }
confirm(){
echo -ne "Are you sure? [Y/n] "
read prompt
if [[ $prompt = [nN] ]]; then
die "[E] User said no. Exiting..."
elif [[ $prompt = [yY] ]]; then
else
die "[E] User gave invalid input. Exiting..."
fi
}
run_package_script() { run_package_script() {
{ {
if [ -x "${2}/${1}" ]; then if [ -x "${2}/${1}" ]; then
@ -26,6 +36,7 @@ run_package_script() {
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
confirm
echo ":: Installing package ${1}" echo ":: Installing package ${1}"
cp -prv "${1}" "${temp_location}" cp -prv "${1}" "${temp_location}"
pkg_name="${1%/}" pkg_name="${1%/}"
@ -73,6 +84,7 @@ install_local_package() {
echo "[*] Install complete for package ${pkg_name}" echo "[*] Install complete for package ${pkg_name}"
} }
sync_deps(){ sync_deps(){
confirm
echo ":: Syncing dependencies for ${1}" echo ":: Syncing dependencies for ${1}"
install_package_from_repo "${pkg_makedepends}" install_package_from_repo "${pkg_makedepends}"
install_package_from_repo "${pkg_deps}" install_package_from_repo "${pkg_deps}"
@ -80,6 +92,7 @@ sync_deps(){
} }
remove_local_package() { remove_local_package() {
confirm
echo ":: Removing target ${1}..." 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..."
@ -106,6 +119,7 @@ install_package_from_repo() { # NOTE(hippoz): This can get a tad confusing... ${
install_local_package "${locpkg_database}/${1}/${2}" install_local_package "${locpkg_database}/${1}/${2}"
} }
upgrade() { upgrade() {
confirm
echo ":: Upgrading installed packages" echo ":: Upgrading installed packages"
cd "${installed_pkg_database}" || die "Could not enter local installed package database directory. Exiting..." cd "${installed_pkg_database}" || die "Could not enter local installed package database directory. Exiting..."
for pkg in */; do for pkg in */; do

View file

@ -13,9 +13,9 @@ if [ ${prefix} == / ]; then
kill 2 kill 2
fi fi
else else
./aps sync alnux
install -v aps ${prefix}/usr/bin/ && install -v aps ${prefix}/usr/bin/ &&
install -v altools/sel ${prefix}/usr/bin/ && install -v altools/sel ${prefix}/usr/bin/ &&
install -v altools/repo ${prefix}/usr/bin/ && install -v altools/repo ${prefix}/usr/bin/ &&
${prefix}/usr/bin/aps sync alnux && install -v config/config ${prefix}/etc/al
install -v config/config /etc/al
fi fi