From 817623fcba4f620d3f871645595cb6b805a1fb16 Mon Sep 17 00:00:00 2001 From: Arkagedon Date: Thu, 4 Aug 2022 18:14:32 +0000 Subject: [PATCH] Adding content & readme --- README.md | 33 ++++++++++++++++ packageManager.sh | 99 +++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 132 insertions(+) create mode 100644 README.md create mode 100755 packageManager.sh diff --git a/README.md b/README.md new file mode 100644 index 0000000..c518a13 --- /dev/null +++ b/README.md @@ -0,0 +1,33 @@ +# Package Saver +------------- + +![Release](https://img.shields.io/badge/Release-v1.0-brightgreen?style=for-the-badge) +![Language](https://img.shields.io/badge/Language-Bash-blue?style=for-the-badge) +![Size](https://img.shields.io/github/repo-size/ARKAGEDON/PackageSaver?label=SIZE&style=for-the-badge) +![Licence](https://img.shields.io/github/license/ARKAGEDON/PackageSaver?style=for-the-badge) +![OpenSource](https://img.shields.io/badge/OpenSource-blue?style=for-the-badge&logo=opencollective&logoColor=white) + +## Package Saver what is it ? + +It's a tools to save the package you want to keep for your reinstallation. They are all in a txt file, just need paste them after your reinstallation to have it back + +## What is automated ? + +Currently the only automed thing is the detection and the parsing of your package manager (for the moment only pacman and apk are parsed and working). Later I will work on a GUI and a way to just use this programs to reinstall package from a list of packages. + +## How to use it ? + +1) Make sure you have the correct permission to use it + +> chmod 777 packageManager.sh + +2) Just run it and say yes or no if you want to keep this package (by default it's no so just need to write Y or y if you want to keep it) + +> ./packageManager.sh + +## How to contribute ? + +Everyone is free to contribute, just clone the project, make your modification and make a pull request with an explanaition of your changes + +## Licence: +This project is under the GNU GPL v3.0 licence, basically you are free to copy this project, modify it \ No newline at end of file diff --git a/packageManager.sh b/packageManager.sh new file mode 100755 index 0000000..f5cc12d --- /dev/null +++ b/packageManager.sh @@ -0,0 +1,99 @@ +#!/bin/bash + +echo -e " + + ██████╗ ██╗ ██╗ ██████╗ ███████╗ █████╗ ██╗ ██╗███████╗██████╗ + ██╔══██╗██║ ██╔╝██╔════╝ ██╔════╝██╔══██╗██║ ██║██╔════╝██╔══██╗ + ██████╔╝█████╔╝ ██║ ███╗███████╗███████║██║ ██║█████╗ ██████╔╝ + ██╔═══╝ ██╔═██╗ ██║ ██║╚════██║██╔══██║╚██╗ ██╔╝██╔══╝ ██╔══██╗ + ██║ ██║ ██╗╚██████╔╝███████║██║ ██║ ╚████╔╝ ███████╗██║ ██║ + ╚═╝ ╚═╝ ╚═╝ ╚═════╝ ╚══════╝╚═╝ ╚═╝ ╚═══╝ ╚══════╝╚═╝ ╚═╝ + +" + +echo -e " Welcome to the Package Saver\n It will allow you to have a list of package to reinstall to your new OS setup\n" + + +# Checking the package Manager +case "$(command -v apk apt-get dkpg dnf zypper pacman rpm snap flatpak)" in + +# If the Package Manager is apk +*apk*) pkgCount=$(apk info | wc -l) + pkgManager="apk" + ;; + +# If the Package Manager is apt +*apt-get*) pkgCount=$(apt list --installed | wc -l) + pkgMan="apt" + ;; + +# If the Package Manager is dkpg +*dkpg*) pkgCount=$(dpkg -l | wc -l) + pkgMan="dpkg" + ;; + +# If the Package Manager is dnf +*dnf*) pkgCount=$(dnf list installed | wc -l) + pkgMan="dnf" + ;; + +# If the Package Manager is zypper +*zypper*) pkgCount=$(zypper se --installed-only | wc -l) + pkgMan="zypper" + ;; + +# If the Package Manager is pacman +*pacman*) pkgCount=$(pacman -Q | wc -l) + pkgMan="pacman" + ;; + +# If the Package Manager is rpm +*rpm*) pkgCount=$(rpm -qa | wc -l) + pkgMan="rpm" + ;; + +# If the Package Manager is snap +*snap*) pkgCount=$(snap list | wc -l) + pkgMan="snap" + ;; + +# If the Package Manager is flatpak +*flatpak*) pkgCount=$(flatpak list --app | wc -l) + pkgMan="flatpak" + + ;; + +*) echo "FAILED TO FOUND PACKAGES: Package manager not found. You must install one of the basics package manager" + + ;; + +esac + +echo -e "NUMBER OF PACKAGES: $pkgCount\nPackage Manager: $pkgMan\n" + +# Asking if you want to keep this package and adding it to the file +for (( pkgI=1; pkgI<=pkgCount; pkgI++ )) +do + + #Parse the package name, different for each package manager + case "$pkgMan" in + #Apk is the package manager + apk) currPkg=$(apk info | sed -n "${pkgI}p") + ;; + + #Pacman is the package manager + pacman) currPkg=$(pacman -Q | sed -n "${pkgI}p" | cut -d" " -f1) + ;; + + esac + + read -p "Do you want to keep $currPkg? [y/N] " input + #If we input y or Y + if [ ${#input} -gt 0 ] && [ ${input,,} == "y" ]; + then + printf "%s " $currPkg >> "packageToKeep.txt" + echo "[V] Added" #DEBUG + else + echo "[X] Not added" #DEBUG + fi +done \ No newline at end of file