snapshot 30.09.2021

This commit is contained in:
Ohio2 2021-09-30 19:35:13 +02:00
parent 46de0ea716
commit 28b70404cb

114
aps
View file

@ -30,18 +30,30 @@ function err(){
function notf(){
echo -e "\e[34m==>\e[36m NOTIFICATION:\e[39m $1"
}
function confirm(){
prn "To install, press ENTER, to cancel, press CTRL+C (unix process break key)"
}
function dbg(){
wrn "This is a debug build, that may not work!"
}
function sources(){
if [ -f sources ]; then
pkg_config_url=$(getopt -o hf:gb -1 help,file:,sources)
pkg_config_url=$(cat sources)
pkg_config_archv=$(echo ${pkg_config_url} | sed 's:.*/::')
curl -fLO ${pkg_config_url}
mkdir --parents pkgex
tar -xvf ${pkg_config_archv} -C pkgex
pkg_config_archv_ft=$(file --extension ${pkg_config_archv_ft})
case $pkg_config_archv_ft in
*.tar*) prn $(tar -xf ${pkg_config_archv} -C pkgex) ;;
*.xz) prn $(cd pkgex && xz -d ../${pkg_config_archv} && cd ..) ;;
*.bz2) prn $(cd pkgex && bzip2 -d ../${pkg_config_archv} && cd ..) ;;
*.gz) prn $(cd pkgex && gzip -d ../${pkg_config_archv} && cd ..) ;;
*.zst) prn $(cd pkgex && zstd -dc && cd ..) ;;
*) wrn "Not a tar! But it will be kept!"
esac
mkdir --parents pkgsrc
cp -r pkgex/*/* pkgsrc
else
err "Sources not found, exiting!"
fi
@ -74,22 +86,22 @@ function pkg_find(){
}
function pkg_local(){
if [ -z "$AL_REPO" ]; then
wrn "Alnux Repo variable is not set, setting to /var/db/repo/core!"
prn "To set the Alnux Repo var, either:"
prn " edit /etc/profile or your shell's profile to include your repo and sub-repos, "
prn " much like this: export AL_REPO=/var/db/repo/core:/var/db/repo/extra OR"
prn " export Alnux Repo var like this: export AL_REPO=/var/db/repo/core:/var/db/repo/extra"
export AL_REPO="/var/aps/repos/official/core"
notf "AL_REPO set to /var/db/repo/core"
prn "Verifying if AL_REPO is set..."
if [ -z $AL_REPO ]; then
err "AL_REPO is not set."
else
prn "$(echo $AL_REPO)... yes."
#wrn "Alnux Repo variable is not set, setting to /var/db/repo/core!"
#prn "To set the Alnux Repo var, either:"
#prn " edit /etc/profile or your shell's profile to include your repo and sub-repos, "
#prn " much like this: export AL_REPO=/var/db/repo/core:/var/db/repo/extra OR"
#prn " export Alnux Repo var like this: export AL_REPO=/var/db/repo/core:/var/db/repo/extra"
#export AL_REPO="/var/aps/repos/official/core"
#notf "AL_REPO set to /var/db/repo/core"
#prn "Verifying if AL_REPO is set..."
#if [ -z $AL_REPO ]; then
# err "AL_REPO is not set."
#else
# prn "$(echo $AL_REPO)... yes."
#fi
err "Alnux Repo variable is not set. Will not continue"
fi
fi
pkg_find $@
pkg_find $1
cp -prv "${1}" "${temp_location}"
# - - - - - #
@ -98,21 +110,61 @@ function pkg_local(){
pkg_name="${1%/}"
pkg_name="${pkg_name##*/}"
pkg_name=$(echo "${pkg_name}" | cut -f 1 -d '.')
# - - - - - - -#
# PKG CONFIG #
# - - - - - - -#
pkg_config_deploy=true
pkg_config_ver="0"
pkg_config_makedepends=""
pkg_config_depends=""
pkg_path="${temp_location}/${pkg_name}"
# - - #
# #
# - - #
mkdir -p "${pkg_path}/payload"
. "${pkg_path}/package"
cd "${pkg_path}"
sources
runbuildsh "build" "${pkg_path}"
runbuildsh "predeploy" "${pkg_path}"
# Old APS code from before the rewrite!
# 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
runbuildsh "postdeploy" "${pkg_path}"
# Yet more old APS code
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
err "Target ${pkg_name} does not have a package script (it's an invalid package!). Exiting..."
fi
# Old Cleanup, might work
rm -r "${pkg_path}"
rm "${temp_location}/${pkg_name}-payloadfiles"
cd "${install_root}" || err "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
prn "Install complete for package ${pkg_name}"
}
sync_local_repo_database() {
# Local database for repo already exists - sync it
cd "${1}" || err "Could not enter local database directory. Exiting..."
git pull
}
install_package_from_repo() { # NOTE(hippoz): This can get a tad confusing... ${1} is the repo and ${2} is the package
prn "Installing package(s) ${2} from ${1} repo"
[ ! -d "${locpkg_database}/${1}/${2}" ] && err "Target not found."
install_local_package "${locpkg_database}/${1}/${2}"
}
function help(){
prn "h|help) prints this message"
prn "v|version) version"
prn "s|sync) install package(s), and sync repositories"
prn "u|update) update"
prn "y|upgrade) upgrade"
prn "i|install) install LOCAL package(s)"
}
function version(){
@ -121,10 +173,12 @@ function version(){
function main(){
dbg
case $1 in
s|sync) pkg_local ${@: -1} ;;
i|install) pkg_local ${@: -1} ;;
u|update) update ;;
y|upgrade) upgrade ;;
s|sync) sync_local_repo_database "official" ${official}
[ -z "${2}" ] && exit 0
install_package_from_repo "official" "${2}" ;;
i|install) pkg_local ${*: -1} ;;
#u|update) update ;;
u|update) err "This feature is currently disabled in APS" ;;
v|version) version ;;
h|help) help ;;
*) err "Invalid option"