Basically previous pr but without wiki and actually i pushed this time #6
1 changed files with 39 additions and 7 deletions
42
aps
42
aps
|
@ -1,4 +1,5 @@
|
||||||
#!/bin/sh
|
#!/bin/sh
|
||||||
|
user="$(whoami)"
|
||||||
temp_location="/tmp"
|
temp_location="/tmp"
|
||||||
install_root="/tmp/alroot"
|
install_root="/tmp/alroot"
|
||||||
installed_pkg_database="${install_root}/var/aps/installed"
|
installed_pkg_database="${install_root}/var/aps/installed"
|
||||||
|
@ -11,7 +12,15 @@ die() {
|
||||||
rm "${lock}"
|
rm "${lock}"
|
||||||
exit 2
|
exit 2
|
||||||
}
|
}
|
||||||
|
verify(){
|
||||||
|
if [ ${user} != root ]
|
||||||
|
die "[E] Please run this option as root!"
|
||||||
|
else
|
||||||
|
#do nothing
|
||||||
|
fi
|
||||||
|
}
|
||||||
run_package_script() { # --- $2 is the package path, and $1 is the script to run
|
run_package_script() { # --- $2 is the package path, and $1 is the script to run
|
||||||
|
# --- RPS installs to root
|
||||||
{
|
{
|
||||||
if [ -x "${2}/${1}" ]; then
|
if [ -x "${2}/${1}" ]; then
|
||||||
echo ":: Running ${1}"
|
echo ":: Running ${1}"
|
||||||
|
@ -20,10 +29,11 @@ run_package_script() { # --- $2 is the package path, and $1 is the script to run
|
||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
install_local_package() {
|
install_local_package() { # --- Install-Local-Package install package LOCALLY!
|
||||||
[ ! -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 "[*] Copying package ${1} into temporary location ${temp_location}..."
|
||||||
|
verify
|
||||||
cp -prv "${1}" "${temp_location}"
|
cp -prv "${1}" "${temp_location}"
|
||||||
pkg_name="${1%/}"
|
pkg_name="${1%/}"
|
||||||
pkg_name="${pkg_name##*/}"
|
pkg_name="${pkg_name##*/}"
|
||||||
|
@ -69,7 +79,8 @@ install_local_package() {
|
||||||
unset pkg_config_makedepends
|
unset pkg_config_makedepends
|
||||||
unset pkg_config_depends
|
unset pkg_config_depends
|
||||||
}
|
}
|
||||||
remove_local_package() {
|
remove_local_package() { # --- Removes local packges
|
||||||
|
verify
|
||||||
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"
|
||||||
|
@ -79,8 +90,9 @@ remove_local_package() {
|
||||||
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() { # --- syncs to local repo databese
|
||||||
echo ":: Syncing local database for repo ${1}..."
|
echo ":: Syncing local database for repo ${1}..."
|
||||||
|
verify
|
||||||
if [ ! -d "${locpkg_database}/${1}" ]; then
|
if [ ! -d "${locpkg_database}/${1}" ]; then
|
||||||
echo ":: Local database for repo ${1} does not exist, cloning..."
|
echo ":: Local database for repo ${1} does not exist, cloning..."
|
||||||
git clone "${2}" "${locpkg_database}/${1}"
|
git clone "${2}" "${locpkg_database}/${1}"
|
||||||
|
@ -95,8 +107,9 @@ install_package_from_repo() { # NOTE(hippoz): This can get a tad confusing... ${
|
||||||
[ ! -d "${locpkg_database}/${1}/${2}" ] && die "[E] Target not found."
|
[ ! -d "${locpkg_database}/${1}/${2}" ] && die "[E] Target not found."
|
||||||
install_local_package "${locpkg_database}/${1}/${2}"
|
install_local_package "${locpkg_database}/${1}/${2}"
|
||||||
}
|
}
|
||||||
upgrade() {
|
upgrade() { # --- upgrades
|
||||||
echo ":: Upgrading installed packages..."
|
echo ":: Upgrading installed packages..."
|
||||||
|
verify
|
||||||
unset_config_values
|
unset_config_values
|
||||||
cd "${installed_pkg_database}" || die "Could not enter installed package database. Exiting..."
|
cd "${installed_pkg_database}" || die "Could not enter installed package database. Exiting..."
|
||||||
for pkg in */; do
|
for pkg in */; do
|
||||||
|
@ -117,7 +130,24 @@ upgrade() {
|
||||||
unset pkg_config_depends
|
unset pkg_config_depends
|
||||||
done
|
done
|
||||||
}
|
}
|
||||||
main() {
|
help(){
|
||||||
|
echo 'To install locally, do:'
|
||||||
|
echo 'aps install'
|
||||||
|
echo
|
||||||
|
echo 'To install from repo (synchronize), do:'
|
||||||
|
echo 'aps sync'
|
||||||
|
echo
|
||||||
|
echo 'To remove local packages, do:'
|
||||||
|
echo 'aps remove'
|
||||||
|
echo
|
||||||
|
echo 'To upgrade repos, do:'
|
||||||
|
echo 'aps upgrade'
|
||||||
|
echo
|
||||||
|
}
|
||||||
|
local_installed_list(){
|
||||||
|
ls ${locpkg_database}
|
||||||
|
}
|
||||||
|
main() { # --- does soem stuff
|
||||||
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. If you're sure no package manager is running, remove the file ${lock}."
|
||||||
exit 1
|
exit 1
|
||||||
|
@ -131,6 +161,8 @@ main() {
|
||||||
[ -z "${2}" ] && die "[*] No targets specified."
|
[ -z "${2}" ] && die "[*] No targets specified."
|
||||||
install_package_from_repo "official" "${2}" ;;
|
install_package_from_repo "official" "${2}" ;;
|
||||||
upgrade) upgrade "official" ;;
|
upgrade) upgrade "official" ;;
|
||||||
|
help) help ;;
|
||||||
|
list) local_installed_list ;;
|
||||||
*) die "[E] Invalid option ${1}, exiting..." ;;
|
*) die "[E] Invalid option ${1}, exiting..." ;;
|
||||||
esac
|
esac
|
||||||
rm "${lock}"
|
rm "${lock}"
|
||||||
|
|
Loading…
Reference in a new issue