Move old aps to a stash
This commit is contained in:
parent
46cdedc6a2
commit
a713b01352
2 changed files with 7 additions and 212 deletions
11
aps
11
aps
|
@ -3,8 +3,11 @@
|
||||||
###################
|
###################
|
||||||
# aps. rewritten. #
|
# aps. rewritten. #
|
||||||
###################
|
###################
|
||||||
# OHIO: aps *needs* to be rewritten, i can't add any thing else in the aps.old.sh
|
# OHIO: aps *needs* to be rewritten, i can't add any thing else in the aps (v0.0.8.1)
|
||||||
# OHIO: aps is rewritten in 9/10th's so it's no longer a debug build
|
# OHIO: aps is rewritten in 9/10th's so it's no longer a debug build
|
||||||
|
# OHIO: it's rewritten however it has some old code from aps (v0.0.8.1)
|
||||||
|
# KEMAL: abandon all hope, ye who enter here.
|
||||||
|
# OHIO: ^, however my code is cleaner than the mess before.
|
||||||
if [ -f "$XDG_CONFIG_HOME/al/config" ]; then
|
if [ -f "$XDG_CONFIG_HOME/al/config" ]; then
|
||||||
. $XDG_CONFIG_HOME/al/config
|
. $XDG_CONFIG_HOME/al/config
|
||||||
elif [ -f "$HOME/.config/al/config" ]; then
|
elif [ -f "$HOME/.config/al/config" ]; then
|
||||||
|
@ -154,8 +157,8 @@ function pkg_local(){
|
||||||
else
|
else
|
||||||
wrn "No sums file(s) found! Be careful!"
|
wrn "No sums file(s) found! Be careful!"
|
||||||
fi
|
fi
|
||||||
runbuildsh "build" "${pkg_path}/pkgex"
|
runbuildsh "build" "${pkg_path}/pkgsrc"
|
||||||
runbuildsh "predeploy" "${pkg_path}/pkgex"
|
runbuildsh "predeploy" "${pkg_path}/pkgsrc"
|
||||||
# Old APS code from before the rewrite!
|
# Old APS code from before the rewrite!
|
||||||
# Deploy package
|
# Deploy package
|
||||||
if [ "${pkg_config_deploy}" = true ]; then
|
if [ "${pkg_config_deploy}" = true ]; then
|
||||||
|
@ -164,7 +167,7 @@ function pkg_local(){
|
||||||
sed 's/^.*-> //' "${temp_location}/${pkg_name}-payloaddeploylog" | tr -d \'\" > "${temp_location}/${pkg_name}-payloadfiles"
|
sed 's/^.*-> //' "${temp_location}/${pkg_name}-payloaddeploylog" | tr -d \'\" > "${temp_location}/${pkg_name}-payloadfiles"
|
||||||
rm "${temp_location}/${pkg_name}-payloaddeploylog"
|
rm "${temp_location}/${pkg_name}-payloaddeploylog"
|
||||||
fi
|
fi
|
||||||
runbuildsh "postdeploy" "${pkg_path}/pkgex"
|
runbuildsh "postdeploy" "${pkg_path}/pkgsrc"
|
||||||
# Yet more old APS code
|
# Yet more old APS code
|
||||||
if [ -x "${pkg_path}/package" ]; then
|
if [ -x "${pkg_path}/package" ]; then
|
||||||
prn "Adding target ${pkg_name} to installed package database..."
|
prn "Adding target ${pkg_name} to installed package database..."
|
||||||
|
|
208
aps.old
208
aps.old
|
@ -1,208 +0,0 @@
|
||||||
#!/bin/sh
|
|
||||||
|
|
||||||
#################################
|
|
||||||
# Alnux Packaging System, #
|
|
||||||
# the package manager for Alnux #
|
|
||||||
#################################
|
|
||||||
|
|
||||||
if [ -f "$XDG_CONFIG_HOME/al/config" ]; then
|
|
||||||
. $XDG_CONFIG_HOME/al/config
|
|
||||||
elif [ -f "$HOME/.config/al/config" ]; then
|
|
||||||
. $HOME/.config/al/config
|
|
||||||
elif [ -f "/etc/al/config" ]; then
|
|
||||||
. /etc/al/config
|
|
||||||
else
|
|
||||||
temp_location="/var/tmp"
|
|
||||||
install_root="/var/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"
|
|
||||||
debug=off
|
|
||||||
fi
|
|
||||||
if [ ${debug} = on ]; then
|
|
||||||
set -x
|
|
||||||
fi
|
|
||||||
die() {
|
|
||||||
echo "aps: fatal: ${1}"
|
|
||||||
rm "${lock}"
|
|
||||||
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() {
|
|
||||||
{
|
|
||||||
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 "File ${1} does not exist. Exiting..."
|
|
||||||
# Extract the package
|
|
||||||
confirm
|
|
||||||
echo ":: Installing package ${1}"
|
|
||||||
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=""
|
|
||||||
# Download sources.
|
|
||||||
if [ -f sources ]; then
|
|
||||||
pkg_config_sources=$(cat sources)
|
|
||||||
pkg_config_sources_to=$(echo ${pkg_config_sources} | sed 's:.*/::')
|
|
||||||
curl -# ${pkg_config_sources}
|
|
||||||
mkdir pkg_bd
|
|
||||||
tar -xf 1 ${pkg_config_sources_to} -C ${pkg_path}
|
|
||||||
fi
|
|
||||||
# Install package
|
|
||||||
mkdir -p "${pkg_path}/payload"
|
|
||||||
. "${pkg_path}/package"
|
|
||||||
cd pkg_bd/
|
|
||||||
run_package_script "build" "${pkg_path}"
|
|
||||||
cd ../..
|
|
||||||
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}"
|
|
||||||
# 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 "Target ${pkg_name} does not have a package script (it's an invalid package!). Exiting..."
|
|
||||||
fi
|
|
||||||
# Cleanup
|
|
||||||
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
|
|
||||||
echo "[*] Install complete for package ${pkg_name}"
|
|
||||||
}
|
|
||||||
sync_deps(){
|
|
||||||
confirm
|
|
||||||
echo ":: Syncing dependencies for ${1}"
|
|
||||||
install_package_from_repo "${pkg_makedepends}"
|
|
||||||
install_package_from_repo "${pkg_deps}"
|
|
||||||
echo "[*] Install dependencies for ${1}"
|
|
||||||
|
|
||||||
}
|
|
||||||
remove_local_package() {
|
|
||||||
confirm
|
|
||||||
echo ":: Removing target ${1}..."
|
|
||||||
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..."
|
|
||||||
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
|
|
||||||
# Local database for repo doesnt exists - clone it
|
|
||||||
git clone "${2}" "${locpkg_database}/${1}"
|
|
||||||
else
|
|
||||||
# Local database for repo already exists - sync it
|
|
||||||
cd "${locpkg_database}/${1}" || die "Could not enter local database directory. 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 "Target not found."
|
|
||||||
install_local_package "${locpkg_database}/${1}/${2}"
|
|
||||||
}
|
|
||||||
upgrade() {
|
|
||||||
confirm
|
|
||||||
echo ":: Upgrading installed packages"
|
|
||||||
cd "${installed_pkg_database}" || die "Could not enter local installed package database directory. 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 "Package ${pkg_name} was not found in ${1}. Exiting..."
|
|
||||||
. "${locpkg_database}/${1}/${pkg_name}/package"
|
|
||||||
if [ ! "${already_installed_version}" = "${pkg_config_ver}" ]; then
|
|
||||||
echo ":: Updating package ${pkg_name} (out of date)"
|
|
||||||
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
|
|
||||||
}
|
|
||||||
version(){
|
|
||||||
echo "Alnux APS v0.0.8.1"
|
|
||||||
}
|
|
||||||
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)."
|
|
||||||
echo "list - Lists currently installed packages."
|
|
||||||
echo "help - Display this message."
|
|
||||||
echo "version - Display the version."
|
|
||||||
}
|
|
||||||
list(){
|
|
||||||
ls ${installed_pkg_database} | sed 's/^README.md//g'
|
|
||||||
}
|
|
||||||
main() {
|
|
||||||
if [ -f "${lock}" ]; then
|
|
||||||
echo "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
|
|
||||||
fi
|
|
||||||
touch "${lock}"
|
|
||||||
case ${1} in
|
|
||||||
install) install_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_local_repo_database "official" ${official}
|
|
||||||
[ -z "${2}" ] && exit 0
|
|
||||||
install_package_from_repo "official" "${2}" ;;
|
|
||||||
upgrade) upgrade "official" ;;
|
|
||||||
help) help ;;
|
|
||||||
version) version ;;
|
|
||||||
list) list ;;
|
|
||||||
*) die "Invalid option ${1}, exiting..." ;;
|
|
||||||
esac
|
|
||||||
rm "${lock}"
|
|
||||||
}
|
|
||||||
main "${1}" "${2}"
|
|
Loading…
Reference in a new issue