Compare commits

...

23 Commits
v0.8 ... main

Author SHA1 Message Date
da7ff16829 Update README.md
Signed-off-by: Connor C <ceo@pixelridgesoftworks.com>
2024-01-09 19:53:16 -07:00
VetheonGames
f44c6d8d53 update readme 2024-01-08 18:47:12 -07:00
VetheonGames
95b0d9dbf1 Update readme 2024-01-08 18:44:43 -07:00
VetheonGames
7191d4d114 Update Readme 2024-01-08 18:42:45 -07:00
VetheonGames
28c3d57dec Minor Patch, finally fixed AUR building so that makepkg's environment handling doesn't crash AllPac 2024-01-08 17:27:22 -07:00
VetheonGames
409345289e Still trying to get Makepkg to stop yelling about root perms it doesn't really have 2024-01-08 15:37:27 -07:00
VetheonGames
a4f05b2ac4 Forgot to change the minor version again 2024-01-08 15:35:05 -07:00
VetheonGames
fb8059dd48 remove code that shouldn't be there 2024-01-08 15:34:48 -07:00
VetheonGames
8a6550db9a Forgot to update the version 2024-01-08 15:33:14 -07:00
VetheonGames
a3cc14f9df Minor update to patch new issue with AUR logic 2024-01-08 15:32:43 -07:00
VetheonGames
779ce34013 Minor patch to fix issue with makepkg occasionally running as the root user 2024-01-08 15:24:05 -07:00
VetheonGames
2697ad9b1c Minor Update to patch bug with AUR logic appending .git to package names 2024-01-08 15:18:41 -07:00
VetheonGames
3ddd1336c0 Update readme for better formatting 2024-01-08 14:46:34 -07:00
VetheonGames
75b1ec8a7c Update readme with new install instructions for the new install script 2024-01-08 14:45:52 -07:00
VetheonGames
9f21313942 Major Update 7 (Pre-Release Binary 0.9)
Update version

Refactor Pacman to always use `-Syu` regardless of what operation it's doing.
I did this solely to prevent partial updates from even being possible. Unlike pacman, which let's you do bad commands with no warning.

Remove un-needed Root question from AUR Installer

Set up AUR installer to update the system before cloning and building (to be safe, we add a warning about partial updates. See, it isn't that hard Pacman!)

Add repair command that will fix issues with the pkg.list file

Add a check to the handleUpdate function that advises the user to run `repair` if it has a problem reading the pkg.list
2024-01-08 14:30:51 -07:00
VetheonGames
84099a8afc Update readme for accurate pre-built binary installation 2024-01-07 20:32:55 -07:00
VetheonGames
d728f45bfc Fix readme for hopefully the final time 2024-01-07 20:06:39 -07:00
VetheonGames
aa05519432 Fix typo in readme 2024-01-07 19:58:01 -07:00
VetheonGames
2aafba25a5 Update readme 2024-01-07 19:57:21 -07:00
VetheonGames
ac61e6d999 Reword the readme uninstall section 2024-01-07 19:48:30 -07:00
VetheonGames
83c42f3a9d Update readme 2024-01-07 19:47:46 -07:00
VetheonGames
606d1cb052 Update readme formatting 2024-01-07 19:43:43 -07:00
VetheonGames
8773dff7b1 Re-arrange readme, add link to prebuilt binary 2024-01-07 18:41:32 -07:00
8 changed files with 166 additions and 41 deletions

View File

@ -4,6 +4,24 @@
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:
```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
### 1. Unified Package Management
@ -42,13 +60,6 @@ Quickly find packages across Snap Store, Flatpak, Pacman, and AUR using the inte
allpac search
```
## Installation
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):
```bash
curl -s https://git.pixelridgesoftworks.com/PixelRidge-Softworks/Installers/raw/branch/main/allpac/install.sh | bash
```
## Usage
Once installed, you can use AllPac with the following commands:
@ -87,6 +98,42 @@ 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.

View File

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

View File

@ -1,10 +1,12 @@
package main
import (
"fmt"
"embed"
"fmt"
"io/fs"
"pixelridgesoftworks.com/AllPac/pkg/logger"
"pixelridgesoftworks.com/AllPac/pkg/packagemanager"
)
func handleUpdateError(updateOption string, err error) {
@ -25,3 +27,13 @@ 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)
}
}

View File

@ -45,6 +45,8 @@ func main() {
handleToolCheck(args)
case "version":
handleVersion(args)
case "repair":
handleRepair(args)
default:
fmt.Printf("Unknown subcommand: %s\n", command)
os.Exit(1)
@ -57,6 +59,11 @@ 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() },

View File

@ -6,6 +6,7 @@ package packagemanager
import (
"fmt"
"time"
"os"
"os/exec"
"os/user"
@ -14,9 +15,9 @@ import (
"pixelridgesoftworks.com/AllPac/pkg/logger"
)
// InstallPackagePacman installs a package using Pacman and logs the installation
// installs a package using Pacman and logs the installation
func InstallPackagePacman(packageName string) error {
cmd := exec.Command("sudo", "pacman", "-S", "--noconfirm", packageName)
cmd := exec.Command("sudo", "pacman", "-Syu", "--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)
@ -35,7 +36,7 @@ func InstallPackagePacman(packageName string) error {
return nil
}
// InstallPackageSnap installs a package using Snap and logs the installation
// 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()
@ -77,7 +78,7 @@ func InstallPackageSnap(packageName string) error {
return nil
}
// InstallPackageFlatpak installs a package using Flatpak and logs the installation
// 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 {
@ -98,19 +99,25 @@ func InstallPackageFlatpak(packageName string) error {
return nil
}
// cloneAndInstallFromAUR clones the given AUR repository and installs it
// clones the given AUR repository and installs it
func CloneAndInstallFromAUR(repoURL string, skipConfirmation bool) (string, error) {
// Request root permissions
if !skipConfirmation && !requestRootPermissions() {
logger.Warnf("root permissions denied")
return "", fmt.Errorf("root permissions denied")
// 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")
}
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 {
@ -118,6 +125,24 @@ 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")
@ -128,31 +153,38 @@ func CloneAndInstallFromAUR(repoURL string, skipConfirmation bool) (string, erro
}
// Clone the repository
cmdGitClone := exec.Command("git", "clone", repoURL, baseDir)
cmdGitClone := exec.Command("git", "clone", repoURL, cloneDir)
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(repoDir); err != nil {
if err := os.Chdir(cloneDir); err != nil {
logger.Errorf("error changing directory: %v", err)
return "", fmt.Errorf("error changing directory: %v", err)
}
// Build the package using makepkg
// 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)
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(repoDir)
version, err := ExtractVersionFromPKGBUILD(cloneDir)
if err != nil {
logger.Errorf("error extracting version from PKGBUILD: %v", err)
return "", fmt.Errorf("error extracting version from PKGBUILD: %v", err)
@ -172,7 +204,7 @@ func CloneAndInstallFromAUR(repoURL string, skipConfirmation bool) (string, erro
return version, nil
}
// InstallSnap installs Snap manually from the AUR
// installs Snap manually from the AUR
func InstallSnap() error {
version, err := CloneAndInstallFromAUR("https://aur.archlinux.org/snapd.git", true)
if err != nil {
@ -187,7 +219,7 @@ func InstallSnap() error {
return nil
}
// InstallGit installs Git using Pacman
// installs Git using Pacman
func InstallGit() error {
if err := InstallPackagePacman("git"); err != nil {
logger.Errorf("error installing Git: %v", err)
@ -196,7 +228,7 @@ func InstallGit() error {
return nil
}
// InstallBaseDevel installs the base-devel group using Pacman
// 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)
@ -205,7 +237,7 @@ func InstallBaseDevel() error {
return nil
}
// InstallFlatpak installs the Flatpak package using Pacman
// installs the Flatpak package using Pacman
func InstallFlatpak() error {
if err := InstallPackagePacman("flatpak"); err != nil {
logger.Errorf("error installing flatpak: %v", err)

View File

@ -7,9 +7,13 @@ import (
"strings"
"fmt"
"pixelridgesoftworks.com/AllPac/pkg/logger"
"os/exec"
"os/user"
"strconv"
"syscall"
)
// extractVersionFromPKGBUILD reads the PKGBUILD file and extracts the package version
// 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)
@ -36,13 +40,7 @@ func ExtractVersionFromPKGBUILD(repoDir string) (string, error) {
return "", fmt.Errorf("pkgver not found in PKGBUILD")
}
// 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
// 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 {
@ -62,3 +60,32 @@ 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()
}

View File

@ -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)

View File

@ -48,7 +48,7 @@ func UpdatePacmanPackages(packageNames ...string) error {
}
if len(packagesToUpdate) > 0 {
args := append([]string{"sudo", "pacman", "-S", "--noconfirm"}, packagesToUpdate...)
args := append([]string{"sudo", "pacman", "-Syu", "--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)