commit 88a6cbf4149c4e46cd547f906d948df802e08b92 Author: Penelope Gwen Date: Fri Mar 1 22:50:13 2024 -0700 first commit diff --git a/README.md b/README.md new file mode 100644 index 0000000..356d21b --- /dev/null +++ b/README.md @@ -0,0 +1 @@ +# Sapphic-Package-Manager diff --git a/debian/changelog b/debian/changelog new file mode 100644 index 0000000..ef6159a --- /dev/null +++ b/debian/changelog @@ -0,0 +1,5 @@ +pogupdate (1.0-1) UNRELEASED; urgency=medium + + * Initial release. + + -- Penelope Gwen Thu, 29 Feb 2024 13:45:02 -0700 diff --git a/debian/control b/debian/control new file mode 100644 index 0000000..9f5b9e4 --- /dev/null +++ b/debian/control @@ -0,0 +1,11 @@ +Source: pogupdate +Maintainer: Penelope Gwen +Section: utils +Priority: standard +Standards-Version: 4.6.2 +Build-Depends: debhelper-compat (= 13) + +Package: pogupdate +Architecture: all +Depends: ${shlibs:Depends}, ${misc:Depends} +Description: update apt, flatpak, and pipx packages quickly diff --git a/debian/copyright b/debian/copyright new file mode 100644 index 0000000..e69de29 diff --git a/debian/rules b/debian/rules new file mode 100755 index 0000000..c705567 --- /dev/null +++ b/debian/rules @@ -0,0 +1,3 @@ +#!/usr/bin/make -f +%: + dh $@ diff --git a/debian/source/format b/debian/source/format new file mode 100644 index 0000000..89ae9db --- /dev/null +++ b/debian/source/format @@ -0,0 +1 @@ +3.0 (native) diff --git a/etc/bash_completion.d/spm b/etc/bash_completion.d/spm new file mode 100644 index 0000000..8d1c8b6 --- /dev/null +++ b/etc/bash_completion.d/spm @@ -0,0 +1 @@ + diff --git a/test b/test new file mode 100644 index 0000000..2d32e89 --- /dev/null +++ b/test @@ -0,0 +1,12 @@ +Reading package lists... Done +Building dependency tree... Done +Reading state information... Done +The following packages will be REMOVED: + libnsl-dev libtirpc-dev +0 upgraded, 0 newly installed, 2 to remove and 127 not upgraded. +After this operation, 1164 kB disk space will be freed. +Do you want to continue? [Y/n] y +(Reading database ... 280244 files and directories currently installed.) +Removing libnsl-dev:arm64 (1.3.0-3) ... +Removing libtirpc-dev:arm64 (1.3.4+ds-1) ... +Processing triggers for man-db (2.12.0-3) ... diff --git a/usr/bin/spm b/usr/bin/spm new file mode 100755 index 0000000..79f15e7 --- /dev/null +++ b/usr/bin/spm @@ -0,0 +1,45 @@ +#!/bin/bash + +_completions() +{ + COMPREPLY+=("now") + COMPREPLY+=("tomorrow") + COMPREPLY+=("never") +} + +COMMAND="${1}" +#VERSION=$(cat /lib/spm/version) + + +upgrade() { + spm_upgrade $@ +} + +clean() { + spm_clean $@ +} + +search() { + spm_search $@ +} + +usage() { + echo "Sapphic Package Manager v${VERSION}" + cat ./usr/share/doc/spm/spm + sed -e 's/^/ /' ./usr/share/doc/spm/spm_upgrade + sed -e 's/^/ /' ./usr/share/doc/spm/spm_search + sed -e 's/^/ /' ./usr/share/doc/spm/spm_clean +} + +case $COMMAND in + upgrade|search|clean ) + shift 1;;& + upgrade ) + upgrade $@;; + clean ) + clean $@;; + search ) + search $@;; + *|usage ) + usage;; +esac diff --git a/usr/bin/spm_clean b/usr/bin/spm_clean new file mode 100755 index 0000000..eb1b21c --- /dev/null +++ b/usr/bin/spm_clean @@ -0,0 +1,46 @@ +#!/bin/bash + +isroot=false +issudo=false +if [ "$EUID" -eq 0 ];then isroot=true;fi +if [ -n "$SUDO_USER" ]; then issudo=true;fi + +usage(){ + echo -n "spm " + cat ./usr/share/doc/spm/spm_clean +} + +yn="" +while getopts 'hYyNnafp' flag; do + case "${flag}" in + [YyNnafp] ) yn="${yn}${flag}" ;; + h|* ) usage;exit 1 ;; + esac +done + + +if $isroot; then + echo -e "\033[1mUpdating apt sources...\033[0m" + apt -qqq update + echo -e "\033[1mThe following packages were automatically installed and are no longer required:\033[0m" + apt list '?garbage' +fi +echo -e "\033[1mUnable to preview unused flatpak packages\033[0m" +echo -e "\033[1mUnable to clean pipx packages\033[0m" +while true; do + if [ -z "$yn" ];then + echo "Yy: Clean all" + echo "Nn: Clean nothing" + if $isroot; then echo "Aa: Remove unused apt packages";fi + echo "Ff: Remove unused flatpak packages" + read -p "Clean packages? " yn + fi + case $yn in + *[Nn]* ) exit;; + *[Yya]* ) if $isroot; then echo -e "\033[1mRemoving unused apt packages...\033[0m";apt -y autoremove;fi;;& + *[Yyf]* ) if $issudo; then echo -e "\033[1mRemoving unused flatpak packages...\033[0m";sudo -u $SUDO_USER flatpak uninstall -y --unused;else flatpak uninstall -y --unused;fi;;& + *[p]* ) echo -e "\033[1mUnable to clean pipx packages\033[0m";;& + *[Yyafp]* ) break;; + * ) yn=""; echo "Please select a valid option.";; + esac +done diff --git a/usr/bin/spm_search b/usr/bin/spm_search new file mode 100755 index 0000000..68c45a0 --- /dev/null +++ b/usr/bin/spm_search @@ -0,0 +1,48 @@ +#!/bin/bash + +isroot=false +issudo=false +if [ "$EUID" -eq 0 ];then isroot=true;fi +if [ -n "$SUDO_USER" ]; then issudo=true;suggestsudo="sudo ";fi + +usage(){ + echo -n "spm " + cat ./usr/share/doc/spm/spm_search +} + +yn="" +while getopts 'hafp' flag; do + case "${flag}" in + [afp] ) yn="${yn}${flag}" ;; + h|* ) usage + exit 1 ;; + esac +done +shift $((OPTIND - 1)) +if [ -z "$yn" ];then + yn="Y" +fi + +if [ -z "${1}" ];then + echo -e "\033[1mYou must specific a package name!\033[0m" + usage + exit 1 +fi + +case $yn in + *[Nn]* ) exit;; + *[Yya]* ) if $isroot; then + echo -e "\033[1mUpdating apt sources...\033[0m" + apt -qqq update + echo -e "\033[1mSearching for apt packages...\033[0m" + dpkg-query --show --showformat='${Package;-35}\t${Version;-15}\t${binary:Synopsis}\n' *"${1}"* + echo -e "\033[1mApt packages can be installed with \`\033[0m${suggestsudo}apt install [Package Name]\033[1m\`. A package's name can be found in the left column\033[0m" + fi;;& + *[Yyf]* ) echo -e "\033[1mSearching for flatpak packages...\033[0m" + flatpak search --columns=application,version,description ${1} + echo -e "\033[1mFlatpak packages can be installed with \`\033[0m${suggestsudo}flatpak install [Application ID]\033[1m\'. A package's Application ID can be found in the left column.\033[0m";;& + *[p]* ) echo -e "\033[1mUnable to search for pipx packages\033[0m";;& + *[Yyafp]* ) exit 0;; + * ) echo "bad search options";exit 1;; +esac + diff --git a/usr/bin/spm_upgrade b/usr/bin/spm_upgrade new file mode 100755 index 0000000..7f0c9d4 --- /dev/null +++ b/usr/bin/spm_upgrade @@ -0,0 +1,57 @@ +#!/bin/bash + +isroot=false +issudo=false +if [ "$EUID" -eq 0 ];then isroot=true;fi +if [ -n "$SUDO_USER" ]; then issudo=true;fi + +usage(){ + echo -n "spm " + cat ./usr/share/doc/spm/spm_upgrade +} + +yn="" +while getopts 'hYyNnafp' flag; do + case "${flag}" in + [YyNnafp] ) yn="${yn}${flag}" ;; + h|* ) usage + exit 1 ;; + esac +done + +if $isroot; then + echo -e "\033[1mUpdating apt sources...\033[0m" + apt -qqq update + echo -e "\033[1mapt upgrade summary:\033[0m" + apt -qq upgrade --dry-run +fi +echo -e "\033[1mWill check and install updates for the following pipx packages:\033[0m" +if $issudo;then + sudo -u $SUDO_USER pipx list --short +else + pipx list --short +fi +echo -e "\033[1mFlatpak update summary:\033[0m" +if $issudo;then + sudo -u $SUDO_USER flatpak remote-ls --updates +else + flatpak remote-ls --updates +fi +while true; do + if [ -z "$yn" ];then + echo "Yy: Update All" + echo "Nn: Update nothing" + if $isroot; then echo "a: Upgrade apt packages";fi + echo "f: Update flatpak packages" + echo "p: Update pipx packages" + read -p "Install updates? " yn + fi + case $yn in + *[Nn]* ) exit;; + *[Yya]* ) if $isroot; then echo -e "\033[1mUpgrading apt packages...\033[0m";apt -y upgrade;fi;;& + *[Yyf]* ) if $issudo; then echo -e "\033[1mUpdating flatpak packages...\033[0m";sudo -u $SUDO_USER flatpak update -y;else flatpak update -y;fi;;& + *[Yyp]* ) if $issudo; then echo -e "\033[1mUpgrading pipx packages...\033[0m";sudo -u $SUDO_USER pipx upgrade-all;else pipx upgrade-all;fi;;& + *[Yyafp]* ) break;; + * ) yn=""; echo "Please select a valid option.";; + esac +done diff --git a/usr/share/doc/spm/spm b/usr/share/doc/spm/spm new file mode 100644 index 0000000..4157563 --- /dev/null +++ b/usr/share/doc/spm/spm @@ -0,0 +1,6 @@ +Usage: spm command [options] + +Sapphic Package Manager is not a package manager- it is a congregate frontend for apt, flatpak, and pipx intended for use on Sapphian Linux + +Commands: + usage: Print this dialogue diff --git a/usr/share/doc/spm/spm_clean b/usr/share/doc/spm/spm_clean new file mode 100644 index 0000000..6c9a327 --- /dev/null +++ b/usr/share/doc/spm/spm_clean @@ -0,0 +1,9 @@ +clean: Remove unused packages that were previously installed via apt and flatpak + usage: + spm clean -[h|Nn|Yyaf] + options: + -Yy: Skip confirmation and approve all cleanup + -Nn: Skip confirmation and approve no cleanup + -a: Requires root, skip confirmation and approve apt cleanup. Redundant when used with -Yy + -f: Skip confirmation and approve flatpak cleanup. Redundant when used with -Yy + -h: Print usage dialogue diff --git a/usr/share/doc/spm/spm_search b/usr/share/doc/spm/spm_search new file mode 100644 index 0000000..ef080ee --- /dev/null +++ b/usr/share/doc/spm/spm_search @@ -0,0 +1,7 @@ +search: Search for packages available via apt or flatpak + usage: + spm search -[h|af] query + options: + -a: Disable default search-all behavior and whitelist apt for search + -f: Disable default search-all behavior and whitelist flatpak for search + -h: Print usage dialogue diff --git a/usr/share/doc/spm/spm_upgrade b/usr/share/doc/spm/spm_upgrade new file mode 100644 index 0000000..4e35bdc --- /dev/null +++ b/usr/share/doc/spm/spm_upgrade @@ -0,0 +1,10 @@ +upgrade: Update packages installed via apt, flatpak, and pipx + usage: + spm upgrade -[h|Nn|Yyafp] + options: + -Yy: Skip confirmation and approve all upgrades + -Nn: Skip confirmation and approve no upgrades + -a: Requires root, skip confirmation and approve apt upgrades. Redundant when used with -Yy + -f: Skip confirmation and approve flatpak updates. Redundant when used with -Yy + -p: Skip confirmation and approve pipx updates. Redundant when used with -Yy + -h: Print usage dialogue