Compare commits

..

No commits in common. "main" and "v0.9" have entirely different histories.
main ... v0.9

4 changed files with 13 additions and 86 deletions

View File

@ -5,22 +5,13 @@
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. 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 ## 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)): 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), you will need to run `touch pkg.list && echo "{}" > ./pkg.list` where you want to run the binary from)
```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:
```bash ```bash
curl -s https://git.pixelridgesoftworks.com/PixelRidge-Softworks/Installers/raw/branch/main/allpac/install.sh | 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 use zsh, replace `bash` at the end of the command above 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 ## Features
@ -107,11 +98,7 @@ After you run things the first time (or you run the install script), all the log
## Uninstalling AllPac ## Uninstalling AllPac
To uninstall AllPac is quite simple. You just run the following command (if you used the installer): To uninstall AllPac is quite simple. You just remove the `.allpac` directory. As the directory contains all the files associated with AllPac, removing the directory will completely remove AllPac.
```bash
uninstall-allpac
```
Otherwise, simply delete `~/.allpac` and `/etc/profile.d/allpac.sh`
### NOTE: UNINSTALLING AllPac WILL *NOT* UNINSTALL PACKAGES INSTALLED *BY* AllPac! ### NOTE: UNINSTALLING AllPac WILL *NOT* UNINSTALL PACKAGES INSTALLED *BY* AllPac!

View File

@ -1 +1 @@
AllPac V0.9.8 AllPac V0.9

View File

@ -6,7 +6,6 @@ package packagemanager
import ( import (
"fmt" "fmt"
"time"
"os" "os"
"os/exec" "os/exec"
"os/user" "os/user"
@ -117,7 +116,6 @@ func CloneAndInstallFromAUR(repoURL string, skipConfirmation bool) (string, erro
logger.Warnf("user aborted the action") logger.Warnf("user aborted the action")
return "", fmt.Errorf("user aborted the action") return "", fmt.Errorf("user aborted the action")
} }
// Get the current user's home directory // Get the current user's home directory
usr, err := user.Current() usr, err := user.Current()
if err != nil { if err != nil {
@ -125,24 +123,6 @@ func CloneAndInstallFromAUR(repoURL string, skipConfirmation bool) (string, erro
return "", fmt.Errorf("error getting current user: %v", err) 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 // Define the base directory for AllPac cache
baseDir := filepath.Join(usr.HomeDir, ".allpac", "cache") baseDir := filepath.Join(usr.HomeDir, ".allpac", "cache")
@ -153,38 +133,31 @@ func CloneAndInstallFromAUR(repoURL string, skipConfirmation bool) (string, erro
} }
// Clone the repository // Clone the repository
cmdGitClone := exec.Command("git", "clone", repoURL, cloneDir) cmdGitClone := exec.Command("git", "clone", repoURL, baseDir)
if output, err := cmdGitClone.CombinedOutput(); err != nil { if output, err := cmdGitClone.CombinedOutput(); err != nil {
logger.Errorf("error cloning AUR repo: %s, %v", output, err) logger.Errorf("error cloning AUR repo: %s, %v", output, err)
return "", fmt.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 // 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) logger.Errorf("error changing directory: %v", err)
return "", fmt.Errorf("error changing directory: %v", err) return "", fmt.Errorf("error changing directory: %v", err)
} }
// Append environment variables to PKGBUILD // Build the package using makepkg
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)
cmdMakePkg := exec.Command("makepkg", "-si", "--noconfirm") cmdMakePkg := exec.Command("makepkg", "-si", "--noconfirm")
cmdMakePkg.Env = env
cmdMakePkg.Dir = cloneDir
if output, err := cmdMakePkg.CombinedOutput(); err != nil { if output, err := cmdMakePkg.CombinedOutput(); err != nil {
logger.Errorf("error building package with makepkg: %s, %v", output, err) logger.Errorf("error building package with makepkg: %s, %v", output, err)
return "", fmt.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 // Extract the version from PKGBUILD
version, err := ExtractVersionFromPKGBUILD(cloneDir) version, err := ExtractVersionFromPKGBUILD(repoDir)
if err != nil { if err != nil {
logger.Errorf("error extracting version from PKGBUILD: %v", err) logger.Errorf("error extracting version from PKGBUILD: %v", err)
return "", fmt.Errorf("error extracting version from PKGBUILD: %v", err) return "", fmt.Errorf("error extracting version from PKGBUILD: %v", err)

View File

@ -7,10 +7,6 @@ import (
"strings" "strings"
"fmt" "fmt"
"pixelridgesoftworks.com/AllPac/pkg/logger" "pixelridgesoftworks.com/AllPac/pkg/logger"
"os/exec"
"os/user"
"strconv"
"syscall"
) )
// reads the PKGBUILD file and extracts the package version // reads the PKGBUILD file and extracts the package version
@ -60,32 +56,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()
}