Compare commits

...

14 Commits
v0.9 ... 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
4 changed files with 86 additions and 13 deletions

View File

@ -5,13 +5,22 @@
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 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)
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, replace `bash` at the end of the command above with `zsh`***
> **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,7 +107,11 @@ After you run things the first time (or you run the install script), all the log
## Uninstalling AllPac
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.
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!

View File

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

View File

@ -6,6 +6,7 @@ package packagemanager
import (
"fmt"
"time"
"os"
"os/exec"
"os/user"
@ -116,6 +117,7 @@ func CloneAndInstallFromAUR(repoURL string, skipConfirmation bool) (string, erro
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 {
@ -123,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")
@ -133,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)

View File

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