Merge pull request 'add debug and confirm' (#9) from Ohio2/aps:master into master
Reviewed-on: alnux/aps#9
This commit is contained in:
commit
e45205cb2f
4 changed files with 42 additions and 4 deletions
36
aps
36
aps
|
@ -1,4 +1,10 @@
|
||||||
#!/bin/sh
|
#!/bin/sh
|
||||||
|
|
||||||
|
#################################
|
||||||
|
# Alnux Packaging System, #
|
||||||
|
# the package manager for Alnux #
|
||||||
|
#################################
|
||||||
|
|
||||||
if [ -f "/etc/al/config" ]; then
|
if [ -f "/etc/al/config" ]; then
|
||||||
. /etc/al/config
|
. /etc/al/config
|
||||||
else
|
else
|
||||||
|
@ -8,12 +14,25 @@ else
|
||||||
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"
|
||||||
|
debug=off
|
||||||
|
fi
|
||||||
|
if [ ${debug} = on ]; then
|
||||||
|
set -x
|
||||||
fi
|
fi
|
||||||
die() {
|
die() {
|
||||||
echo "aps: fatal: ${1}"
|
echo "aps: fatal: ${1}"
|
||||||
rm "${lock}"
|
rm "${lock}"
|
||||||
exit 2
|
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() {
|
run_package_script() {
|
||||||
{
|
{
|
||||||
if [ -x "${2}/${1}" ]; then
|
if [ -x "${2}/${1}" ]; then
|
||||||
|
@ -26,6 +45,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 +93,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 +101,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 +128,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
|
||||||
|
@ -126,6 +149,17 @@ upgrade() {
|
||||||
unset pkg_config_depends
|
unset pkg_config_depends
|
||||||
done
|
done
|
||||||
}
|
}
|
||||||
|
version(){
|
||||||
|
echo "Alnux APS v0.0.8"
|
||||||
|
}
|
||||||
|
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)."
|
||||||
|
}
|
||||||
main() {
|
main() {
|
||||||
if [ -f "${lock}" ]; then
|
if [ -f "${lock}" ]; then
|
||||||
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}."
|
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}."
|
||||||
|
@ -144,6 +178,8 @@ main() {
|
||||||
[ -z "${2}" ] && exit 0
|
[ -z "${2}" ] && exit 0
|
||||||
install_package_from_repo "official" "${2}" ;;
|
install_package_from_repo "official" "${2}" ;;
|
||||||
upgrade) upgrade "official" ;;
|
upgrade) upgrade "official" ;;
|
||||||
|
help) help ;;
|
||||||
|
version) version ;;
|
||||||
*) die "[E] Invalid option ${1}, exiting..." ;;
|
*) die "[E] Invalid option ${1}, exiting..." ;;
|
||||||
esac
|
esac
|
||||||
rm "${lock}"
|
rm "${lock}"
|
||||||
|
|
|
@ -4,8 +4,9 @@
|
||||||
# Alnux Packaging System #
|
# Alnux Packaging System #
|
||||||
##########################
|
##########################
|
||||||
temp_location="/var/tmp"
|
temp_location="/var/tmp"
|
||||||
install_root="/var/tmp/alroot"
|
install_root="/"
|
||||||
installed_pkg_database="${install_root}/var/aps/installed"
|
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"
|
||||||
|
debug=off
|
||||||
|
|
|
@ -13,9 +13,10 @@ 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
|
install -v -Dm644 man/aps.8.gz ${prefix}/usr/share/man/man8/
|
||||||
fi
|
fi
|
||||||
|
|
BIN
man/aps.8.gz
Normal file
BIN
man/aps.8.gz
Normal file
Binary file not shown.
Loading…
Reference in a new issue