diff --git a/aps b/aps index 5e0819d..c7bb9a1 100755 --- a/aps +++ b/aps @@ -28,6 +28,9 @@ function conf_fetch(){ lock="${install_root}/var/aps/lock" official="https://git.hippoz.xyz/alnux/repo" debug=off + #echo $AL_REPO + #AL_REPO=$(echo $AL_REPO | cut -d':') + #echo $AL_REPO fi } case ${debug} in @@ -39,10 +42,6 @@ function prn(){ function wrn(){ echo -e "\e[34m==>\e[33m WARNING:\e[39m $1" } -#function run(){ -# printf '%s\n' "$*" -# "$@" -#} function err(){ echo -e "\e[34m==>\e[31m ERROR:\e[39m $1" && rm ${lock} 2> /dev/null @@ -60,24 +59,30 @@ function confirm(){ #} function sources(){ pkg_config_url="$1" - pkg_config_archv=$(echo ${pkg_config_url} | sed 's:.*/::') - curl -fLO "${pkg_config_url}" - mkdir --parents 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) prwork - esac - mkdir --parents pkgsrc - cp -r pkgex/*/* pkgsrc + pkg_config_url_prefix=$(echo ${pkg_config_url} | cut -d'+' -f1) + pkg_config_url_rest=$(echo ${pkg_config_url} | cut -d+ -f2) + case $pkg_config_url_prefix in + git) mkdir pkgsrc && git clone ${pkg_config_url_rest} pkgsrc ;; + web) pkg_config_archv=$(echo ${pkg_config_url} | sed 's:.*/::') + curl -fLO "${pkg_config_url_rest}" + mkdir --parents 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) prwork + esac + mkdir --parents pkgsrc + cp -r pkgex/*/* pkgsrc ;; + *) wrn "Old Alnux sources is probably used!" + esac } function sha256(){ #sha256sum $sum > $1.sha256sum sha256sum -c "$1" 1>&2 /dev/null - if [ "$?" -ne "0" ]; then + if [ "$?" -eq "0" ]; then prn "OK!" else err "Sha failed!" @@ -181,11 +186,11 @@ sync_local_repo_database() { git pull fi } -install_package_from_repo() { # NOTE(hippoz): This can get a tad confusing... ${1} is the repo and ${2} is the package +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" pkg_local "${locpkg_database}/${1}/${2}" -} [ ! -d "${locpkg_database}/${1}/${2}" ] && err "Target not found." +} update() { prn "Upgrading installed packages" cd "${installed_pkg_database}" || err "Could not enter local installed package database directory. Exiting..." @@ -218,10 +223,10 @@ function version(){ prn "APS Version 0.1.0" } function main(){ - #if [ -f "${lock}" ]; then - # err "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}." - #fi - #touch "${lock}" + if [ -f "${lock}" ]; then + err "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}." + fi + touch "${lock}" #dbg case $1 in s|sync) sync_local_repo_database "${official}" ${official} @@ -234,8 +239,10 @@ function main(){ # confirm "update" ;; v|version) version ;; h|help) help ;; - #tus|tusync) hwclock --systohc ;; + apsinst) if [ $APS_PKG=y ]; then + install -v aps *) err "Invalid option" esac + rm ${lock} } main $1 ${@: -1} \ No newline at end of file