-
Notifications
You must be signed in to change notification settings - Fork 19
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
enh: implement cleanup command (#34)
* mod(rhino-pkg): Hotfix upgrade nala v0.14.0 has affected how upgrades work within Nala, as such we have had to apply some changes to rhino-pkg to accomodate. These flags have already existed in >=v0.13.0 and so are compatible with former versions of Nala according to @volitank * mod(rhino-pkg): Update version number Change to version v0.1.2 * ensure flatpack is sudo'ed * add cleanup option * Update README.md --------- Co-authored-by: ajstrongdev <[email protected]>
- Loading branch information
Showing
2 changed files
with
71 additions
and
8 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -37,14 +37,20 @@ functions: | |
update: Updates all packages accessible to the wrapper - does | ||
not accept <input>, instead use install to update | ||
individual packages. Has confirmation prompt. | ||
individual packages. Has a confirmation prompt. | ||
cleanup: Attempts to repair broken dependencies and remove any | ||
unused packages. Does not accept <input>, but has | ||
a confirmation prompt. | ||
flags: | ||
--help/-h: Display this page | ||
--description/-d: By default, $(basename $0) will only display packages | ||
that contain <input> within their name. Use this flag to increase | ||
range and display packages with <input> in their description. | ||
-y: Makes functions with confirmation prompts run promptless. | ||
input: | ||
Provide a package name or description. | ||
|
@@ -80,7 +86,7 @@ ${c3} ''''''''${c2}kXOM. | |
${c3} .,,:${c2}dXMK | ||
${c3} ${c2}:k | ||
$(basename "$0") 0.1.1 | ||
$(basename "$0") 0.1.2 | ||
A package manager wrapper for Pacstall, APT, Flatpak and snap | ||
Developed by Elsie19 <[email protected]> for | ||
the Rhino Linux distribution." | ||
|
@@ -125,9 +131,9 @@ function search_apt() { | |
|
||
function search_flatpak() { | ||
if [[ -z $DESCRIPTION ]]; then | ||
local contents=("$(LC_ALL=C flatpak search --columns="application" "$*" | grep -i --color=never "$*")") | ||
local contents=("$(LC_ALL=C sudo flatpak search --columns="application" "$*" | grep -i --color=never "$*")") | ||
else | ||
local contents=("$(LC_ALL=C flatpak search --columns="application" "$*")") | ||
local contents=("$(LC_ALL=C sudo flatpak search --columns="application" "$*")") | ||
fi | ||
if [[ ${contents[*]} == "No matches found" ]]; then | ||
return 1 | ||
|
@@ -162,6 +168,14 @@ case "${1}" in | |
REMOVE=true | ||
shift | ||
;; | ||
cleanup) | ||
CLEANUP=true | ||
shift | ||
if [[ $1 == "-y" ]]; then | ||
PROMPTLESS=true | ||
shift | ||
fi | ||
;; | ||
update) | ||
UPDATE=true | ||
shift | ||
|
@@ -202,9 +216,9 @@ if [[ -n $UPDATE ]]; then | |
esac | ||
if command -v nala &> /dev/null; then | ||
if [[ -n $PROMPTLESS ]]; then | ||
sudo nala upgrade -y -o Acquire::AllowReleaseInfoChange="true" | ||
sudo nala upgrade -y --full --no-autoremove -o Acquire::AllowReleaseInfoChange="true" | ||
else | ||
sudo nala upgrade -o Acquire::AllowReleaseInfoChange="true" | ||
sudo nala upgrade --full --no-autoremove -o Acquire::AllowReleaseInfoChange="true" | ||
fi | ||
else | ||
if [[ -n $PROMPTLESS ]]; then | ||
|
@@ -235,6 +249,49 @@ if [[ -n $UPDATE ]]; then | |
exit 0 | ||
fi | ||
|
||
if [[ -n $CLEANUP ]]; then | ||
if [[ -n $* ]]; then | ||
exit 1 | ||
fi | ||
if [[ -z $PROMPTLESS ]]; then | ||
echo -n $"Attempting to repair dependencies and remove unused packages. Continue? (${BGreen}y${NC}/${BRed}N${NC}) " | ||
read -ra read_update | ||
echo -ne "${NC}" | ||
else | ||
read_update=("Y") | ||
fi | ||
case "${read_update[0]}" in | ||
Y* | y*) ;; | ||
*) exit 1 ;; | ||
esac | ||
if command -v nala &> /dev/null; then | ||
if [[ -n $PROMPTLESS ]]; then | ||
sudo nala install --fix-broken && sudo nala autoremove -y | ||
else | ||
sudo nala install --fix-broken && sudo nala autoremove | ||
fi | ||
else | ||
if [[ -n $PROMPTLESS ]]; then | ||
sudo apt --fix-broken install && sudo apt auto-remove -y | ||
else | ||
sudo apt --fix-broken install && sudo apt auto-remove | ||
fi | ||
fi | ||
if command -v flatpak &> /dev/null; then | ||
if [[ -n $PROMPTLESS ]]; then | ||
sudo flatpak repair && sudo flatpak uninstall --unused -y | ||
else | ||
sudo flatpak repair && sudo flatpak uninstall --unused | ||
fi | ||
fi | ||
if command -v snap &> /dev/null; then | ||
if [[ -z "$(LANG=C snap list --all | while read snapname ver rev trk pub notes; do if [[ "$notes" == *disabled* ]]; then sudo snap remove "$snapname" --revision="$rev"; fi; done)" ]]; then | ||
echo "Nothing for snap to clean." | ||
fi | ||
fi | ||
exit 0 | ||
fi | ||
# Lowercase the rest of input | ||
set -- "${*,,}" | ||
|
@@ -341,7 +398,7 @@ esac | |
for i in "${entered_input[@]}"; do | ||
case "${pkgrepo[i]}" in | ||
flatpak) | ||
flatpak "${flatpak_cmd}" "${pkgs[i]}" -y | ||
sudo flatpak "${flatpak_cmd}" "${pkgs[i]}" -y | ||
ret=$? | ||
;; | ||
apt) | ||
|