diff --git a/aps b/aps new file mode 100644 index 0000000..a7f9ad3 --- /dev/null +++ b/aps @@ -0,0 +1,138 @@ +#!/bin/sh +temp_location="/tmp" +install_root="/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" +[ ! -d "${installed_pkg_database}" ] && mkdir -p "${installed_pkg_database}" +die() { + echo "${1}" + rm "${lock}" + exit 2 +} +run_package_script() { # --- $2 is the package path, and $1 is the script to run + { + 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 "[E] File ${1} does not exist. Exiting..." + # Extract the package + echo "[*] Copying package ${1} into temporary location ${temp_location}..." + 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="" + # Install package + . "${pkg_path}/package" + run_package_script "build" "${pkg_path}" + 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}" + echo "[*] Install complete for target ${pkg_name}" + # 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 "[E] Target ${pkg_name} does not have a package script (it's an invalid package!). Exiting..." + fi + # Cleanup + echo "[*] Cleaning up after target ${pkg_name}..." + 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 +} +remove_local_package() { + 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..." + echo ":: Removing target ${1}..." + 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 + echo ":: Local database for repo ${1} does not exist, cloning..." + git clone "${2}" "${locpkg_database}/${1}" + else + echo ":: Local database for repo ${1} exists, updating..." + cd "${locpkg_database}/${1}" || die "Could not enter local database. 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 "[E] Target not found." + install_local_package "${locpkg_database}/${1}/${2}" +} +upgrade() { + echo ":: Upgrading installed packages..." + unset_config_values + cd "${installed_pkg_database}" || die "Could not enter installed package database. 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 "[E] Package ${pkg_name} was not found in ${1}, exiting..." + . "${locpkg_database}/${1}/${pkg_name}/package" + if [ ! "${already_installed_version}" = "${pkg_config_ver}" ]; then + echo ":: Package ${pkg_name} is out of date, updating..." + 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 +} +main() { + if [ -f "${lock}" ]; then + echo "[E] A lock file already exists. 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) + sync_local_repo_database "official" ${official} + [ -z "${2}" ] && die "[*] No targets specified." + install_package_from_repo "official" "${2}" ;; + upgrade) upgrade "official" ;; + *) die "[E] Invalid option ${1}, exiting..." ;; + esac + rm "${lock}" +} +main "${1}" "${2}" diff --git a/autoconf/build b/autoconf/build index 6c7840e..c5ed388 100755 --- a/autoconf/build +++ b/autoconf/build @@ -1,4 +1,4 @@ -wget https://ftp.gnu.org/gnu/autoconf/autoconf-2.71.tar.xz +curl -# https://ftp.gnu.org/gnu/autoconf/autoconf-2.71.tar.xz tar -xf autoconf-2.71.tar.xz cd autoconf-2.71 diff --git a/automake/build b/automake/build index f55b429..afe0e71 100755 --- a/automake/build +++ b/automake/build @@ -1,4 +1,4 @@ -wget https://ftp.gnu.org/gnu/automake/automake-1.16.3.tar.xz +curl -# https://ftp.gnu.org/gnu/automake/automake-1.16.3.tar.xz tar -xf automake-1.16.3.tar.xz cd automake-1.16.3 diff --git a/bash/build b/bash/build index ceaa300..1be7983 100755 --- a/bash/build +++ b/bash/build @@ -1,4 +1,4 @@ -wget https://ftp.gnu.org/gnu/bash/bash-5.1.8.tar.gz +curl -# https://ftp.gnu.org/gnu/bash/bash-5.1.8.tar.gz tar -xf bash-5.1.8.tar.gz cd bash-5.1.8 diff --git a/binutils/build b/binutils/build index 58f79ee..ef6a602 100755 --- a/binutils/build +++ b/binutils/build @@ -1,4 +1,4 @@ -wget -O binutils-2.36.1.tar.xz https://ftp.gnu.org/gnu/binutils/binutils-2.36.1.tar.xz +curl -# -O binutils-2.36.1.tar.xz https://ftp.gnu.org/gnu/binutils/binutils-2.36.1.tar.xz tar -xf binutils-2.36.1.tar.xz cd binutils-2.36.1 diff --git a/bison/build b/bison/build index 36b3e81..bf5109a 100755 --- a/bison/build +++ b/bison/build @@ -1,4 +1,4 @@ -wget https://ftp.gnu.org/gnu/bison/bison-3.7.6.tar.xz +curl -# https://ftp.gnu.org/gnu/bison/bison-3.7.6.tar.xz tar -xf bison-3.7.6.tar.xz cd bison-3.7.6 diff --git a/busybox/build b/busybox/build index 2a2aca2..3290c3a 100755 --- a/busybox/build +++ b/busybox/build @@ -1,4 +1,4 @@ -wget -O busybox-1.33.1.tar.bz2 https://busybox.net/downloads/busybox-1.33.1.tar.bz2 +curl -# -O busybox-1.33.1.tar.bz2 https://busybox.net/downloads/busybox-1.33.1.tar.bz2 tar -xf busybox-1.33.1.tar.bz2 cd busybox-1.33.1 diff --git a/bzip2/build b/bzip2/build index ab9cc2a..7162086 100755 --- a/bzip2/build +++ b/bzip2/build @@ -1,4 +1,4 @@ -wget -O bzip2-1.0.8.tar.gz https://sourceware.org/pub/bzip2/bzip2-1.0.8.tar.gz +curl -# -O bzip2-1.0.8.tar.gz https://sourceware.org/pub/bzip2/bzip2-1.0.8.tar.gz tar -xf bzip2-1.0.8.tar.gz cd bzip2-1.0.8 diff --git a/cmake/build b/cmake/build index 1c924ad..7d91aa4 100755 --- a/cmake/build +++ b/cmake/build @@ -1,4 +1,4 @@ -wget https://github.com/Kitware/CMake/releases/download/v3.21.0-rc2/cmake-3.21.0-rc2.tar.gz +curl -# https://github.com/Kitware/CMake/releases/download/v3.21.0-rc2/cmake-3.21.0-rc2.tar.gz tar -xf cmake-3.21.0-rc2.tar.gz cd cmake-3.21.0-rc2.tar.gz diff --git a/curses-lib/build b/curses-lib/build index 295ac0c..5e3f2ff 100755 --- a/curses-lib/build +++ b/curses-lib/build @@ -1,4 +1,4 @@ -wget https://ftp.gnu.org/pub/gnu/ncurses/ncurses-6.2.tar.gz +curl -# https://ftp.gnu.org/pub/gnu/ncurses/ncurses-6.2.tar.gz tar -xf ncurses-6.2.tar.gz cd ncurses-6.2 diff --git a/expat/build b/expat/build index a0829f0..ef56104 100755 --- a/expat/build +++ b/expat/build @@ -1,4 +1,4 @@ -wget http://downloads.sourceforge.net/expat/expat-2.1.0.tar.gz +curl -# http://downloads.sourceforge.net/expat/expat-2.1.0.tar.gz tar -xf expat-2.1.0.tar.gz cd expat-2.1.0 diff --git a/flex/build b/flex/build index d499d01..e0a51c2 100755 --- a/flex/build +++ b/flex/build @@ -1,4 +1,4 @@ -wget https://github.com/westes/flex/releases/download/v2.6.4/flex-2.6.4.tar.gz +curl -# https://github.com/westes/flex/releases/download/v2.6.4/flex-2.6.4.tar.gz tar -xf flex-2.6.4.tar.gz cd flex-2.6.4 diff --git a/fontconfig/build b/fontconfig/build index d4bf292..2b46b50 100755 --- a/fontconfig/build +++ b/fontconfig/build @@ -1,4 +1,4 @@ -wget https://www.freedesktop.org/software/fontconfig/release/fontconfig-2.13.1.tar.bz2 +curl -# https://www.freedesktop.org/software/fontconfig/release/fontconfig-2.13.1.tar.bz2 tar -xf fontconfig-2.13.1.tar.bz2 cd fontconfig-2.13.1 diff --git a/freetype2/build b/freetype2/build index a93b61b..15c9545 100755 --- a/freetype2/build +++ b/freetype2/build @@ -1,4 +1,4 @@ -wget https://downloads.sourceforge.net/freetype/freetype-2.10.4.tar.xz +curl -# https://downloads.sourceforge.net/freetype/freetype-2.10.4.tar.xz tar -xf freetype-2.10.4.tar.xz cd freetype-2.10.4 diff --git a/gcc/build b/gcc/build index d82aa23..8f77606 100755 --- a/gcc/build +++ b/gcc/build @@ -1,4 +1,4 @@ -wget -O gcc-11.1.0.tar.gz https://gcc.gnu.org/pub/gcc/releases/gcc-11.1.0/gcc-11.1.0.tar.xz +curl -# -O gcc-11.1.0.tar.gz https://gcc.gnu.org/pub/gcc/releases/gcc-11.1.0/gcc-11.1.0.tar.xz tar -xf gcc-11.1.0.tar.gz cd gcc-11.1.0 diff --git a/gettext/build b/gettext/build index 2517b7d..0fa5733 100755 --- a/gettext/build +++ b/gettext/build @@ -1,4 +1,4 @@ -wget https://ftp.gnu.org/pub/gnu/gettext/gettext-0.21.tar.gz +curl -# https://ftp.gnu.org/pub/gnu/gettext/gettext-0.21.tar.gz tar -xf gettext-0.21.tar.gz cd gettext-0.21 diff --git a/git/build b/git/build index 29eff2c..d82af3f 100755 --- a/git/build +++ b/git/build @@ -1,4 +1,4 @@ -wget https://mirrors.edge.kernel.org/pub/software/scm/git/git-2.9.5.tar.xz +curl -# https://mirrors.edge.kernel.org/pub/software/scm/git/git-2.9.5.tar.xz tar -xf git-2.9.5.tar.xz cd git-2.9.5 diff --git a/glibc/build b/glibc/build index 9010df0..f6c2a4a 100755 --- a/glibc/build +++ b/glibc/build @@ -1,4 +1,4 @@ -wget https://ftp.gnu.org/gnu/libc/glibc-2.33.tar.gz +curl -# https://ftp.gnu.org/gnu/libc/glibc-2.33.tar.gz tar -xf glibc-2.33.tar.gz cd glibc-2.33 diff --git a/gperf/build b/gperf/build index c792e77..3da1798 100755 --- a/gperf/build +++ b/gperf/build @@ -1,4 +1,4 @@ -wget http://ftp.gnu.org/pub/gnu/gperf/gperf-3.1.tar.gz +curl -# http://ftp.gnu.org/pub/gnu/gperf/gperf-3.1.tar.gz tar -xf gperf-3.1.tar.gz cd gperf-3.1 diff --git a/grub/build b/grub/build index 62303e2..28e0fad 100755 --- a/grub/build +++ b/grub/build @@ -1,4 +1,4 @@ -wget https://ftp.gnu.org/gnu/grub/grub-2.06.tar.xz +curl -# https://ftp.gnu.org/gnu/grub/grub-2.06.tar.xz tar -xf grub-2.06.tar.xz cd grub-2.06 diff --git a/gzip/build b/gzip/build index c4b6873..27dd4de 100755 --- a/gzip/build +++ b/gzip/build @@ -1,4 +1,4 @@ -wget https://mirrors.nav.ro/gnu/gzip/gzip-1.10.tar.gz +curl -# https://mirrors.nav.ro/gnu/gzip/gzip-1.10.tar.gz tar -xf gzip-1.10.tar.gz cd gzip-1.10 diff --git a/intltool/build b/intltool/build index 24562a3..1fc40c9 100755 --- a/intltool/build +++ b/intltool/build @@ -1,4 +1,4 @@ -wget https://launchpad.net/intltool/trunk/0.51.0/+download/intltool-0.51.0.tar.gz +curl -# https://launchpad.net/intltool/trunk/0.51.0/+download/intltool-0.51.0.tar.gz tar -xf intltool-0.51.0.tar.gz cd intltool-0.51.0 diff --git a/libdrm/build b/libdrm/build index 3947ea4..3e9a851 100755 --- a/libdrm/build +++ b/libdrm/build @@ -1,4 +1,4 @@ -wget https://dri.freedesktop.org/libdrm/libdrm-2.4.104.tar.xz +curl -# https://dri.freedesktop.org/libdrm/libdrm-2.4.104.tar.xz tar -xf libdrm-2.4.104.tar.xz cd libdrm-2.4.104 diff --git a/libpng/build b/libpng/build index 53ce610..83fde33 100755 --- a/libpng/build +++ b/libpng/build @@ -1,4 +1,4 @@ -wget https://github.com/glennrp/libpng/archive/v1.6.37.tar.gz +curl -# https://github.com/glennrp/libpng/archive/v1.6.37.tar.gz tar -xf v1.6.37.tar.gz cd libpng-1.6.37 diff --git a/libtool/build b/libtool/build index d887035..182afa8 100755 --- a/libtool/build +++ b/libtool/build @@ -1,4 +1,4 @@ -wget https://ftp.gnu.org/gnu/libtool/libtool-2.4.6.tar.xz +curl -# https://ftp.gnu.org/gnu/libtool/libtool-2.4.6.tar.xz tar -xf libtool-2.4.6.tar.xz cd libtool-2.4.6 diff --git a/libudev/build b/libudev/build index 6a614d6..49a43cd 100755 --- a/libudev/build +++ b/libudev/build @@ -1,4 +1,4 @@ -wget https://ftp.osuosl.org/pub/lfs/lfs-packages/8.2/udev-lfs-20171102.tar.bz2 udev.tar.bz2 +curl -# https://ftp.osuosl.org/pub/lfs/lfs-packages/8.2/udev-lfs-20171102.tar.bz2 udev.tar.bz2 tar -xf udev.tar.bz2 udev cd udev diff --git a/m4/build b/m4/build index 6c79b96..5647e7b 100755 --- a/m4/build +++ b/m4/build @@ -1,4 +1,4 @@ -wget https://ftp.gnu.org/gnu/m4/m4-1.4.19.tar.xz +curl -# https://ftp.gnu.org/gnu/m4/m4-1.4.19.tar.xz tar -xf m4-1.4.19.tar.xz cd m4-1.4.19 diff --git a/make/build b/make/build index 520f721..2bd1f62 100755 --- a/make/build +++ b/make/build @@ -1,4 +1,4 @@ -wget https://ftp.gnu.org/gnu/make/make-4.3.tar.gz +curl -# https://ftp.gnu.org/gnu/make/make-4.3.tar.gz tar -xf make-4.3.tar.gz cd make-4.3 diff --git a/mesa/build b/mesa/build index 991c91e..b8e6453 100755 --- a/mesa/build +++ b/mesa/build @@ -1,4 +1,4 @@ -wget https://archive.mesa3d.org//mesa-21.2.0-rc1.tar.xz +curl -# https://archive.mesa3d.org//mesa-21.2.0-rc1.tar.xz tar -xf mesa-21.2.0-rc1.tar.xz cd mesa-21.2.0-rc1 diff --git a/mtdev/build b/mtdev/build index 64dd775..a308bba 100755 --- a/mtdev/build +++ b/mtdev/build @@ -1,4 +1,4 @@ -wget https://bitmath.org/code/mtdev/mtdev-1.1.6.tar.bz2 +curl -# https://bitmath.org/code/mtdev/mtdev-1.1.6.tar.bz2 tar -xf mtdev-1.1.6.tar.bz2 cd mtdev-1.1.6 diff --git a/nano/build b/nano/build index 7a3ffa6..3b91d36 100755 --- a/nano/build +++ b/nano/build @@ -1,4 +1,4 @@ -wget https://www.nano-editor.org/dist/v5/nano-5.8.tar.xz +curl -# https://www.nano-editor.org/dist/v5/nano-5.8.tar.xz tar -xf nano-5.8.tar.xz cd nano-5.8 diff --git a/openssl/build b/openssl/build index 58b6a71..11c176c 100755 --- a/openssl/build +++ b/openssl/build @@ -1,4 +1,4 @@ -wget https://www.openssl.org/source/openssl-3.0.0-beta1.tar.gz +curl -# https://www.openssl.org/source/openssl-3.0.0-beta1.tar.gz tar -xf openssl-3.0.0-beta1.tar.gz cd openssl-3.0.0-beta1 chmod +x ./config diff --git a/perl/build b/perl/build index 9c4e2b4..e06981f 100755 --- a/perl/build +++ b/perl/build @@ -1,4 +1,4 @@ -wget https://www.cpan.org/src/5.0/perl-5.34.0.tar.gz +curl -# https://www.cpan.org/src/5.0/perl-5.34.0.tar.gz tar -xf perl-5.34.0.tar.gz cd perl-5.34.0 diff --git a/pkg-config-fd/build b/pkg-config-fd/build index 1c734b4..20f061f 100755 --- a/pkg-config-fd/build +++ b/pkg-config-fd/build @@ -1,4 +1,4 @@ -wget https://pkgconfig.freedesktop.org/releases/pkg-config-0.29.2.tar.gz +curl -# https://pkgconfig.freedesktop.org/releases/pkg-config-0.29.2.tar.gz tar -xf pkg-config-0.29.2.tar.gz cd pkg-config-0.29.2 diff --git a/pthread/build b/pthread/build index 59dabbc..c940de5 100755 --- a/pthread/build +++ b/pthread/build @@ -1,4 +1,4 @@ -wget https://ftp.gnu.org/gnu/pth/pth-2.0.7.tar.gz +curl -# https://ftp.gnu.org/gnu/pth/pth-2.0.7.tar.gz tar -xf pth-2.0.7.tar.gz cd pth-2.0.7 diff --git a/python/build b/python/build index ebd5271..ae6d43b 100755 --- a/python/build +++ b/python/build @@ -1,4 +1,4 @@ -wget https://www.python.org/ftp/python/3.9.6/Python-3.9.6.tar.xz +curl -# https://www.python.org/ftp/python/3.9.6/Python-3.9.6.tar.xz tar -xf Python-3.9.6.tar.xz cd Python-3.9.6 diff --git a/talloc-lib/build b/talloc-lib/build index a1d3122..6620fd1 100755 --- a/talloc-lib/build +++ b/talloc-lib/build @@ -1,4 +1,4 @@ -wget https://www.samba.org/ftp/talloc/talloc-2.3.3.tar.gz +curl -# https://www.samba.org/ftp/talloc/talloc-2.3.3.tar.gz tar -xf talloc-2.3.3.tar.gz cd talloc-2.3.3 diff --git a/tar/build b/tar/build index d2070e5..dba9041 100755 --- a/tar/build +++ b/tar/build @@ -1,4 +1,4 @@ -wget https://ftp.gnu.org/gnu/tar/tar-1.34.tar.xz +curl -# https://ftp.gnu.org/gnu/tar/tar-1.34.tar.xz tar -xf tar-1.34 cd tar-1.34 diff --git a/vim/build b/vim/build index dea7678..ac238a2 100755 --- a/vim/build +++ b/vim/build @@ -1,4 +1,4 @@ -wget https://anduin.linuxfromscratch.org/BLFS/vim/vim-8.2.2890.tar.gz +curl -# https://anduin.linuxfromscratch.org/BLFS/vim/vim-8.2.2890.tar.gz tar -xf vim-8.2.2890.tar.gz cd vim-8.2.2890 diff --git a/xz/build b/xz/build index 11068e8..d2d0193 100755 --- a/xz/build +++ b/xz/build @@ -1,4 +1,4 @@ -wget https://tukaani.org/xz/xz-5.2.5.tar.gz +curl -# https://tukaani.org/xz/xz-5.2.5.tar.gz tar -xf xz-5.2.5.tar.gz cd xz-5.2.5 diff --git a/zlib/build b/zlib/build index 60be936..c13c230 100755 --- a/zlib/build +++ b/zlib/build @@ -1,4 +1,4 @@ -wget https://zlib.net/zlib-1.2.11.tar.gz +curl -# https://zlib.net/zlib-1.2.11.tar.gz tar -xf zlib-1.2.11.tar.gz cd zlib-1.2.11 diff --git a/zsh/build b/zsh/build index 2fdc3b8..9addb44 100755 --- a/zsh/build +++ b/zsh/build @@ -1,4 +1,4 @@ -wget https://www.zsh.org/pub/zsh-5.8.tar.xz +curl -# https://www.zsh.org/pub/zsh-5.8.tar.xz tar -xf zsh-5.8.tar.xz cd zsh-5.8 diff --git a/zstd/build b/zstd/build index 3e82fcf..e932778 100755 --- a/zstd/build +++ b/zstd/build @@ -1,4 +1,4 @@ -wget https://github.com/facebook/zstd/releases/download/v1.5.0/zstd-1.5.0.tar.gz +curl -# https://github.com/facebook/zstd/releases/download/v1.5.0/zstd-1.5.0.tar.gz tar -xf zstd-1.5.0.tar.gz cd zstd-1.5.0