Compare commits
No commits in common. "main" and "pre-release-v0.8" have entirely different histories.
main
...
pre-releas
50
README.md
50
README.md
|
@ -5,22 +5,12 @@
|
|||
AllPac is a command-line utility designed to simplify package management on Arch Linux by combining various package managers into one cohesive tool. With AllPac, users can seamlessly interact with packages from the Snap Store, Flatpak, Pacman, and the Arch User Repository (AUR) using a single interface. This eliminates the need to juggle multiple package managers and provides a unified solution for installing, updating, uninstalling, and searching for packages.
|
||||
|
||||
## Installation
|
||||
### NOTE: The installer should produce ***0 Errors or Warnings***. If it does, please open an Issue and tell us!
|
||||
|
||||
To install AllPac on your Arch Linux system, simply run the following commands to run the install script ([Source](https://git.pixelridgesoftworks.com/PixelRidge-Softworks/Installers/src/branch/main/allpac)):
|
||||
|
||||
```bash
|
||||
wget https://git.pixelridgesoftworks.com/PixelRidge-Softworks/Installers/raw/branch/main/allpac/install.sh
|
||||
chmod +x install.sh
|
||||
./install.sh
|
||||
```
|
||||
or you can use cURL:
|
||||
To install AllPac on your Arch Linux system, simply run the following command to run the install script [Source](https://git.pixelridgesoftworks.com/PixelRidge-Softworks/Installers/src/branch/main/allpac):
|
||||
(if you don't want to use the install script, a pre-built binary can be found [here](https://git.pixelridgesoftworks.com/PixelRidge-Softworks/AllPac/releases))
|
||||
```bash
|
||||
curl -s https://git.pixelridgesoftworks.com/PixelRidge-Softworks/Installers/raw/branch/main/allpac/install.sh | bash
|
||||
```
|
||||
> **If you use `zsh` relace `bash` in the above command with `zsh`**
|
||||
|
||||
(if you don't want to use the install script, a pre-built binary can be found [here](https://git.pixelridgesoftworks.com/PixelRidge-Softworks/AllPac/releases), you will need to run `touch pkg.list && echo "{}" > ./pkg.list` where you want to run the binary from)
|
||||
|
||||
## Features
|
||||
|
||||
|
@ -98,42 +88,6 @@ Once installed, you can use AllPac with the following commands:
|
|||
allpac search <package_name>
|
||||
```
|
||||
|
||||
## Logs and Cache
|
||||
|
||||
After you run things the first time (or you run the install script), all the logs, the package list, the binary, and the updater script will be contained here:
|
||||
```bash
|
||||
/home/{your_user}/.allpac/
|
||||
```
|
||||
|
||||
## Uninstalling AllPac
|
||||
|
||||
To uninstall AllPac is quite simple. You just run the following command (if you used the installer):
|
||||
```bash
|
||||
uninstall-allpac
|
||||
```
|
||||
Otherwise, simply delete `~/.allpac` and `/etc/profile.d/allpac.sh`
|
||||
|
||||
### NOTE: UNINSTALLING AllPac WILL *NOT* UNINSTALL PACKAGES INSTALLED *BY* AllPac!
|
||||
|
||||
## Updating AllPac
|
||||
|
||||
If you used the Installer Script, updating is easy. Just run `allpac-update-system`.
|
||||
|
||||
If you did *NOT* use the Installer Script, updating is still super easy. Just use `wget` to pull down the [updater script](https://git.pixelridgesoftworks.com/PixelRidge-Softworks/Installers/raw/branch/main/allpac/update.sh):
|
||||
```bash
|
||||
wget -O ~/.allpac/bin/allpac-updater.sh "https://git.pixelridgesoftworks.com/PixelRidge-Softworks/Installers/raw/branch/main/allpac/update.sh"
|
||||
```
|
||||
|
||||
Give it the needed permissions:
|
||||
```bash
|
||||
chmod u+rwx ~/.allpac/bin/allpac-updater.sh
|
||||
```
|
||||
|
||||
Then run the updater script:
|
||||
```bash
|
||||
. ~/.allpac/bin/allpac-updater.sh
|
||||
```
|
||||
|
||||
## Feedback and Contributions
|
||||
|
||||
Feedback, bug reports, and contributions are welcome! Feel free to open issues on the [Git repository](https://git.pixelridgesoftworks.com/PixelRidge-Softworks/AllPac/issues) or submit pull requests.
|
||||
|
|
|
@ -1 +1 @@
|
|||
AllPac V0.9.8
|
||||
AllPac V0.8
|
||||
|
|
|
@ -1,12 +1,10 @@
|
|||
package main
|
||||
|
||||
import (
|
||||
"embed"
|
||||
"fmt"
|
||||
"embed"
|
||||
"io/fs"
|
||||
|
||||
"pixelridgesoftworks.com/AllPac/pkg/logger"
|
||||
"pixelridgesoftworks.com/AllPac/pkg/packagemanager"
|
||||
)
|
||||
|
||||
func handleUpdateError(updateOption string, err error) {
|
||||
|
@ -27,13 +25,3 @@ func handleVersion(args []string) {
|
|||
}
|
||||
fmt.Println(string(content))
|
||||
}
|
||||
|
||||
func handleRepair(args []string) {
|
||||
// Assuming GetPkgListPath() returns a string path
|
||||
pkgListPath, _ := packagemanager.GetPkgListPath()
|
||||
|
||||
err :=packagemanager.InitializePkgListFile(pkgListPath)
|
||||
if err != nil {
|
||||
logger.Errorf("Error initializing version file: %v", err)
|
||||
}
|
||||
}
|
||||
|
|
|
@ -45,8 +45,6 @@ func main() {
|
|||
handleToolCheck(args)
|
||||
case "version":
|
||||
handleVersion(args)
|
||||
case "repair":
|
||||
handleRepair(args)
|
||||
default:
|
||||
fmt.Printf("Unknown subcommand: %s\n", command)
|
||||
os.Exit(1)
|
||||
|
@ -59,11 +57,6 @@ func handleUpdate(args []string) {
|
|||
return
|
||||
}
|
||||
|
||||
_, err := packagemanager.ReadPackageList()
|
||||
if err != nil {
|
||||
fmt.Printf("error reading package list. Consider running 'allpac repair': %v", err)
|
||||
}
|
||||
|
||||
updateFuncs := map[string]func() error{
|
||||
"everything": packagemanager.UpdateAllPackages,
|
||||
"snaps": func() error { return packagemanager.UpdateSnapPackages() },
|
||||
|
|
|
@ -6,7 +6,6 @@ package packagemanager
|
|||
|
||||
import (
|
||||
"fmt"
|
||||
"time"
|
||||
"os"
|
||||
"os/exec"
|
||||
"os/user"
|
||||
|
@ -15,9 +14,9 @@ import (
|
|||
"pixelridgesoftworks.com/AllPac/pkg/logger"
|
||||
)
|
||||
|
||||
// installs a package using Pacman and logs the installation
|
||||
// InstallPackagePacman installs a package using Pacman and logs the installation
|
||||
func InstallPackagePacman(packageName string) error {
|
||||
cmd := exec.Command("sudo", "pacman", "-Syu", "--noconfirm", packageName)
|
||||
cmd := exec.Command("sudo", "pacman", "-S", "--noconfirm", packageName)
|
||||
if output, err := cmd.CombinedOutput(); err != nil {
|
||||
logger.Errorf("error installing package with Pacman: %s, %v", output, err)
|
||||
return fmt.Errorf("error installing package with Pacman: %s, %v", output, err)
|
||||
|
@ -36,7 +35,7 @@ func InstallPackagePacman(packageName string) error {
|
|||
return nil
|
||||
}
|
||||
|
||||
// installs a package using Snap and logs the installation
|
||||
// InstallPackageSnap installs a package using Snap and logs the installation
|
||||
func InstallPackageSnap(packageName string) error {
|
||||
cmd := exec.Command("sudo", "snap", "install", packageName)
|
||||
output, err := cmd.CombinedOutput()
|
||||
|
@ -78,7 +77,7 @@ func InstallPackageSnap(packageName string) error {
|
|||
return nil
|
||||
}
|
||||
|
||||
// installs a package using Flatpak and logs the installation
|
||||
// InstallPackageFlatpak installs a package using Flatpak and logs the installation
|
||||
func InstallPackageFlatpak(packageName string) error {
|
||||
cmd := exec.Command("flatpak", "install", "-y", packageName)
|
||||
if output, err := cmd.CombinedOutput(); err != nil {
|
||||
|
@ -99,25 +98,19 @@ func InstallPackageFlatpak(packageName string) error {
|
|||
return nil
|
||||
}
|
||||
|
||||
// clones the given AUR repository and installs it
|
||||
// cloneAndInstallFromAUR clones the given AUR repository and installs it
|
||||
func CloneAndInstallFromAUR(repoURL string, skipConfirmation bool) (string, error) {
|
||||
// System update
|
||||
if !skipConfirmation && !confirmAction("Do you want to update the system before proceeding? (skipping this step may result in partial updates, and break your system)") {
|
||||
logger.Warnf("user aborted the system update")
|
||||
return "", fmt.Errorf("user aborted the system update")
|
||||
// Request root permissions
|
||||
if !skipConfirmation && !requestRootPermissions() {
|
||||
logger.Warnf("root permissions denied")
|
||||
return "", fmt.Errorf("root permissions denied")
|
||||
}
|
||||
|
||||
cmdUpdate := exec.Command("sudo", "pacman", "-Syu", "--noconfirm")
|
||||
if output, err := cmdUpdate.CombinedOutput(); err != nil {
|
||||
logger.Errorf("error updating system: %s, %v", output, err)
|
||||
return "", fmt.Errorf("error updating system: %s, %v", output, err)
|
||||
}
|
||||
// Confirm before proceeding with each step
|
||||
if !skipConfirmation && !confirmAction("Do you want to download and build package from " + repoURL + "?") {
|
||||
logger.Warnf("user aborted the action")
|
||||
return "", fmt.Errorf("user aborted the action")
|
||||
}
|
||||
|
||||
// Get the current user's home directory
|
||||
usr, err := user.Current()
|
||||
if err != nil {
|
||||
|
@ -125,24 +118,6 @@ func CloneAndInstallFromAUR(repoURL string, skipConfirmation bool) (string, erro
|
|||
return "", fmt.Errorf("error getting current user: %v", err)
|
||||
}
|
||||
|
||||
// Determine the name of the package from the repo URL
|
||||
repoName := filepath.Base(repoURL)
|
||||
|
||||
// Remove .git suffix
|
||||
repoName = strings.TrimSuffix(repoName, ".git")
|
||||
|
||||
// Get the current date in YYYYMMDD format
|
||||
currentDate := time.Now().Format("20060102")
|
||||
|
||||
// Define the directory for this specific package clone
|
||||
cloneDir := filepath.Join(usr.HomeDir, ".allpac", "cache", repoName+"-"+currentDate)
|
||||
|
||||
// Ensure the clone directory exists
|
||||
if err := os.MkdirAll(cloneDir, 0755); err != nil {
|
||||
logger.Errorf("error creating clone directory: %v", err)
|
||||
return "", fmt.Errorf("error creating clone directory: %v", err)
|
||||
}
|
||||
|
||||
// Define the base directory for AllPac cache
|
||||
baseDir := filepath.Join(usr.HomeDir, ".allpac", "cache")
|
||||
|
||||
|
@ -153,38 +128,31 @@ func CloneAndInstallFromAUR(repoURL string, skipConfirmation bool) (string, erro
|
|||
}
|
||||
|
||||
// Clone the repository
|
||||
cmdGitClone := exec.Command("git", "clone", repoURL, cloneDir)
|
||||
cmdGitClone := exec.Command("git", "clone", repoURL, baseDir)
|
||||
if output, err := cmdGitClone.CombinedOutput(); err != nil {
|
||||
logger.Errorf("error cloning AUR repo: %s, %v", output, err)
|
||||
return "", fmt.Errorf("error cloning AUR repo: %s, %v", output, err)
|
||||
}
|
||||
|
||||
// Determine the name of the created directory (and the package name)
|
||||
repoName := filepath.Base(repoURL)
|
||||
repoDir := filepath.Join(baseDir, repoName)
|
||||
|
||||
// Change directory to the cloned repository
|
||||
if err := os.Chdir(cloneDir); err != nil {
|
||||
if err := os.Chdir(repoDir); err != nil {
|
||||
logger.Errorf("error changing directory: %v", err)
|
||||
return "", fmt.Errorf("error changing directory: %v", err)
|
||||
}
|
||||
|
||||
// Append environment variables to PKGBUILD
|
||||
cmdAppendEnv := exec.Command("bash", "-c", "echo 'export HOME=$HOME' >> PKGBUILD && echo 'export GOCACHE=$HOME/.cache/go-build' >> PKGBUILD")
|
||||
cmdAppendEnv.Dir = cloneDir // Set the working directory to the cloned repository
|
||||
if _, err := cmdAppendEnv.CombinedOutput(); err != nil {
|
||||
logger.Errorf("error appending environment variables to PKGBUILD: %v", err)
|
||||
return "", fmt.Errorf("error appending environment variables to PKGBUILD: %v", err)
|
||||
}
|
||||
|
||||
// Build the package using makepkg as the non-root user
|
||||
env := append(os.Environ(), "HOME=" + usr.HomeDir)
|
||||
// Build the package using makepkg
|
||||
cmdMakePkg := exec.Command("makepkg", "-si", "--noconfirm")
|
||||
cmdMakePkg.Env = env
|
||||
cmdMakePkg.Dir = cloneDir
|
||||
if output, err := cmdMakePkg.CombinedOutput(); err != nil {
|
||||
logger.Errorf("error building package with makepkg: %s, %v", output, err)
|
||||
return "", fmt.Errorf("error building package with makepkg: %s, %v", output, err)
|
||||
}
|
||||
|
||||
// Extract the version from PKGBUILD
|
||||
version, err := ExtractVersionFromPKGBUILD(cloneDir)
|
||||
version, err := ExtractVersionFromPKGBUILD(repoDir)
|
||||
if err != nil {
|
||||
logger.Errorf("error extracting version from PKGBUILD: %v", err)
|
||||
return "", fmt.Errorf("error extracting version from PKGBUILD: %v", err)
|
||||
|
@ -204,7 +172,7 @@ func CloneAndInstallFromAUR(repoURL string, skipConfirmation bool) (string, erro
|
|||
return version, nil
|
||||
}
|
||||
|
||||
// installs Snap manually from the AUR
|
||||
// InstallSnap installs Snap manually from the AUR
|
||||
func InstallSnap() error {
|
||||
version, err := CloneAndInstallFromAUR("https://aur.archlinux.org/snapd.git", true)
|
||||
if err != nil {
|
||||
|
@ -219,7 +187,7 @@ func InstallSnap() error {
|
|||
return nil
|
||||
}
|
||||
|
||||
// installs Git using Pacman
|
||||
// InstallGit installs Git using Pacman
|
||||
func InstallGit() error {
|
||||
if err := InstallPackagePacman("git"); err != nil {
|
||||
logger.Errorf("error installing Git: %v", err)
|
||||
|
@ -228,7 +196,7 @@ func InstallGit() error {
|
|||
return nil
|
||||
}
|
||||
|
||||
// installs the base-devel group using Pacman
|
||||
// InstallBaseDevel installs the base-devel group using Pacman
|
||||
func InstallBaseDevel() error {
|
||||
if err := InstallPackagePacman("base-devel"); err != nil {
|
||||
logger.Errorf("error installing base-devel: %v", err)
|
||||
|
@ -237,7 +205,7 @@ func InstallBaseDevel() error {
|
|||
return nil
|
||||
}
|
||||
|
||||
// installs the Flatpak package using Pacman
|
||||
// InstallFlatpak installs the Flatpak package using Pacman
|
||||
func InstallFlatpak() error {
|
||||
if err := InstallPackagePacman("flatpak"); err != nil {
|
||||
logger.Errorf("error installing flatpak: %v", err)
|
||||
|
|
|
@ -7,13 +7,9 @@ import (
|
|||
"strings"
|
||||
"fmt"
|
||||
"pixelridgesoftworks.com/AllPac/pkg/logger"
|
||||
"os/exec"
|
||||
"os/user"
|
||||
"strconv"
|
||||
"syscall"
|
||||
)
|
||||
|
||||
// reads the PKGBUILD file and extracts the package version
|
||||
// extractVersionFromPKGBUILD reads the PKGBUILD file and extracts the package version
|
||||
func ExtractVersionFromPKGBUILD(repoDir string) (string, error) {
|
||||
pkgbuildPath := filepath.Join(repoDir, "PKGBUILD")
|
||||
file, err := os.Open(pkgbuildPath)
|
||||
|
@ -40,7 +36,13 @@ func ExtractVersionFromPKGBUILD(repoDir string) (string, error) {
|
|||
return "", fmt.Errorf("pkgver not found in PKGBUILD")
|
||||
}
|
||||
|
||||
// prompts the user with a yes/no question and returns true if the answer is yes
|
||||
// requestRootPermissions prompts the user for root permissions
|
||||
func requestRootPermissions() bool {
|
||||
fmt.Println("Root permissions are required to install AUR packages.")
|
||||
return confirmAction("Do you want to continue with root permissions?")
|
||||
}
|
||||
|
||||
// confirmAction prompts the user with a yes/no question and returns true if the answer is yes
|
||||
func confirmAction(question string) bool {
|
||||
reader := bufio.NewReader(os.Stdin)
|
||||
for {
|
||||
|
@ -60,32 +62,3 @@ func confirmAction(question string) bool {
|
|||
}
|
||||
}
|
||||
}
|
||||
|
||||
// this is unused, just incase I need to do it this way since makepkg is being a pain in the neck
|
||||
func RunMakepkgAsUser(username string) error {
|
||||
// Lookup the non-root user
|
||||
usr, err := user.Lookup(username)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
// Convert UID and GID to integers
|
||||
uid, _ := strconv.Atoi(usr.Uid)
|
||||
gid, _ := strconv.Atoi(usr.Gid)
|
||||
|
||||
// Set UID and GID of the process
|
||||
err = syscall.Setgid(gid)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
err = syscall.Setuid(uid)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
// Now run makepkg as the non-root user
|
||||
cmd := exec.Command("makepkg", "-si", "--noconfirm")
|
||||
cmd.Stdout = os.Stdout
|
||||
cmd.Stderr = os.Stderr
|
||||
return cmd.Run()
|
||||
}
|
||||
|
|
|
@ -41,7 +41,7 @@ func GetPkgListPath() (string, error) {
|
|||
if _, err := os.Stat(pkgListPath); os.IsNotExist(err) {
|
||||
logger.Infof("pkg.list file does not exist, initializing: %s", pkgListPath)
|
||||
// Create and initialize the file if it doesn't exist
|
||||
if err := InitializePkgListFile(pkgListPath); err != nil {
|
||||
if err := initializePkgListFile(pkgListPath); err != nil {
|
||||
return "", err // Error already logged in initializePkgListFile
|
||||
}
|
||||
} else if err != nil {
|
||||
|
@ -55,7 +55,7 @@ func GetPkgListPath() (string, error) {
|
|||
}
|
||||
|
||||
// creates a new pkg.list file with an empty JSON object
|
||||
func InitializePkgListFile(filePath string) error {
|
||||
func initializePkgListFile(filePath string) error {
|
||||
file, err := os.Create(filePath)
|
||||
if err != nil {
|
||||
logger.Errorf("error creating package list file: %v", err)
|
||||
|
|
|
@ -48,7 +48,7 @@ func UpdatePacmanPackages(packageNames ...string) error {
|
|||
}
|
||||
|
||||
if len(packagesToUpdate) > 0 {
|
||||
args := append([]string{"sudo", "pacman", "-Syu", "--noconfirm"}, packagesToUpdate...)
|
||||
args := append([]string{"sudo", "pacman", "-S", "--noconfirm"}, packagesToUpdate...)
|
||||
cmd := exec.Command(args[0], args[1:]...)
|
||||
if output, err := cmd.CombinedOutput(); err != nil {
|
||||
logger.Errorf("error updating Pacman packages: %s, %v", string(output), err)
|
||||
|
|
Loading…
Reference in New Issue
Block a user