fixed deps inst
This commit is contained in:
1 parent
c6fef39af5
commit
d64b4f3983
2 files changed
+45
-24
No files matched your search
@@ -4,19 +4,19 @@ import (
|
|||||||
"fmt"
|
"fmt"
|
||||||
"os"
|
"os"
|
||||||
"path/filepath"
|
"path/filepath"
|
||||||
|
paths "qulay/config"
|
||||||
"qulay/database"
|
"qulay/database"
|
||||||
"qulay/config"
|
|
||||||
"qulay/package"
|
|
||||||
"qulay/helpers"
|
"qulay/helpers"
|
||||||
|
pkg "qulay/package"
|
||||||
"slices"
|
"slices"
|
||||||
"strings"
|
"strings"
|
||||||
)
|
)
|
||||||
|
|
||||||
var _name string = filepath.Base(os.Args[0])
|
var _name string = filepath.Base(os.Args[0])
|
||||||
var _cmds = []string{"h", "+", "-", "g", "s", "p", "u", "r", "q", "v"}
|
var _cmds = []string{"h", "+", "-", "g", "s", "p", "u", "r", "q", "f", "v"}
|
||||||
var _root_cmds = []string{"+", "-", "u", "i"}
|
var _root_cmds = []string{"+", "-", "u", "i"}
|
||||||
|
|
||||||
const _version string = "0.6"
|
const _version string = "0.7"
|
||||||
const _help string = `{_name}: command-line interface to the Qulay Package Manager
|
const _help string = `{_name}: command-line interface to the Qulay Package Manager
|
||||||
Usage:
|
Usage:
|
||||||
{_name} h -> help menu
|
{_name} h -> help menu
|
||||||
@@ -28,12 +28,14 @@ Usage:
|
|||||||
{_name} u -> update all repositories
|
{_name} u -> update all repositories
|
||||||
{_name} r -> get all repositories URLs
|
{_name} r -> get all repositories URLs
|
||||||
{_name} q -> get all installed packages
|
{_name} q -> get all installed packages
|
||||||
|
{_name} f -> get files path for destDir
|
||||||
{_name} v -> get {_name} version
|
{_name} v -> get {_name} version
|
||||||
Options:
|
Options:
|
||||||
:v -> verbose output
|
:v -> verbose output
|
||||||
:a -> ask before doing
|
:a -> ask before doing
|
||||||
:nl -> disable recording in databases and logs
|
:nl -> disable recording in databases and logs
|
||||||
:nd -> do not download deps
|
:nd -> do not download deps
|
||||||
|
:nrc -> disable uid 0 (root) checks
|
||||||
:r -> reinstall already installed deps
|
:r -> reinstall already installed deps
|
||||||
Vars:
|
Vars:
|
||||||
DESTDIR -> path where the package will be installed/removed`
|
DESTDIR -> path where the package will be installed/removed`
|
||||||
@@ -66,12 +68,18 @@ func main() {
|
|||||||
destDir = "/"
|
destDir = "/"
|
||||||
}
|
}
|
||||||
|
|
||||||
|
absDestDir, err := filepath.Abs(destDir)
|
||||||
|
if err != nil {
|
||||||
|
fmt.Fprintf(os.Stderr, "!! failed to get absolute path of destDir: %v\n", err)
|
||||||
|
os.Exit(1)
|
||||||
|
}
|
||||||
|
|
||||||
if len(args) == 0 || len(cmds) == 0 {
|
if len(args) == 0 || len(cmds) == 0 {
|
||||||
printHelp()
|
printHelp()
|
||||||
os.Exit(1)
|
os.Exit(1)
|
||||||
}
|
}
|
||||||
|
|
||||||
if os.Getuid() != 0 && slices.Contains(_root_cmds, cmds[0]) {
|
if os.Getuid() != 0 && slices.Contains(_root_cmds, cmds[0]) && !slices.Contains(opts, ":nrc") {
|
||||||
fmt.Println("!! this command is root-only. run this with root privileges")
|
fmt.Println("!! this command is root-only. run this with root privileges")
|
||||||
os.Exit(1)
|
os.Exit(1)
|
||||||
}
|
}
|
||||||
@@ -85,7 +93,7 @@ func main() {
|
|||||||
os.Exit(1)
|
os.Exit(1)
|
||||||
}
|
}
|
||||||
for _, n := range oths {
|
for _, n := range oths {
|
||||||
err := pkg.Install(n, opts, destDir)
|
err := pkg.Install(n, opts, absDestDir)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
fmt.Println("!!", err)
|
fmt.Println("!!", err)
|
||||||
os.Exit(1)
|
os.Exit(1)
|
||||||
@@ -97,36 +105,35 @@ func main() {
|
|||||||
os.Exit(1)
|
os.Exit(1)
|
||||||
}
|
}
|
||||||
for _, n := range oths {
|
for _, n := range oths {
|
||||||
err := pkg.Remove(n, opts, destDir)
|
err := pkg.Remove(n, opts, absDestDir)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
fmt.Println("!!", err)
|
fmt.Println("!!", err)
|
||||||
os.Exit(1)
|
os.Exit(1)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else if cmds[0] == "u" {
|
} else if cmds[0] == "u" {
|
||||||
database.DownloadRepos(database.GetReposUrls(destDir), destDir)
|
database.DownloadRepos(database.GetReposUrls(absDestDir), absDestDir)
|
||||||
} else if cmds[0] == "g" {
|
} else if cmds[0] == "g" {
|
||||||
if len(oths) < 1 {
|
if len(oths) < 1 {
|
||||||
fmt.Println("!! no package(s) received")
|
fmt.Println("!! no package(s) received")
|
||||||
os.Exit(1)
|
os.Exit(1)
|
||||||
}
|
}
|
||||||
for _, name := range oths {
|
for _, name := range oths {
|
||||||
fmt.Println(database.GetPackageVersion(name, destDir))
|
fmt.Println(database.GetPackageVersion(name, absDestDir))
|
||||||
}
|
}
|
||||||
} else if cmds[0] == "r" {
|
} else if cmds[0] == "r" {
|
||||||
for _, url := range database.GetReposUrls(destDir) {
|
for _, url := range database.GetReposUrls(absDestDir) {
|
||||||
fmt.Println(url)
|
fmt.Println(url)
|
||||||
}
|
}
|
||||||
} else if cmds[0] == "q" {
|
} else if cmds[0] == "q" {
|
||||||
for name, version := range database.ReadInstalled(destDir) {
|
for name, version := range database.ReadInstalled(absDestDir) {
|
||||||
fmt.Println(name, "-", version[0])
|
fmt.Println(name, "-", version[0])
|
||||||
}
|
}
|
||||||
} else if cmds[0] == "s" {
|
} else if cmds[0] == "s" {
|
||||||
if len(oths) < 1 {
|
if len(oths) < 1 {
|
||||||
pkgs := pkg.GetPackages(destDir)
|
pkgs := pkg.GetPackages(absDestDir)
|
||||||
fmt.Println(pkgs)
|
|
||||||
for _, p := range pkgs {
|
for _, p := range pkgs {
|
||||||
if database.IsInstalled(p.Repo + "/" + p.Name, destDir) {
|
if database.IsInstalled(p.Repo+"/"+p.Name, absDestDir) {
|
||||||
fmt.Printf("[+] %s/%s - %v - %v\n", p.Repo, p.Name, p.Data[0], p.Data[1])
|
fmt.Printf("[+] %s/%s - %v - %v\n", p.Repo, p.Name, p.Data[0], p.Data[1])
|
||||||
} else {
|
} else {
|
||||||
fmt.Printf(" %s/%s - %v - %v\n", p.Repo, p.Name, p.Data[0], p.Data[1])
|
fmt.Printf(" %s/%s - %v - %v\n", p.Repo, p.Name, p.Data[0], p.Data[1])
|
||||||
@@ -134,9 +141,9 @@ func main() {
|
|||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
for _, n := range oths {
|
for _, n := range oths {
|
||||||
pkgs := pkg.FindPackages(n, destDir)
|
pkgs := pkg.FindPackages(n, absDestDir)
|
||||||
for _, p := range pkgs {
|
for _, p := range pkgs {
|
||||||
if database.IsInstalled(p.Repo + "/" + p.Name, destDir) {
|
if database.IsInstalled(p.Repo+"/"+p.Name, absDestDir) {
|
||||||
fmt.Printf("[+] %s/%s - %v - %v\n", p.Repo, p.Name, p.Data[0], p.Data[1])
|
fmt.Printf("[+] %s/%s - %v - %v\n", p.Repo, p.Name, p.Data[0], p.Data[1])
|
||||||
} else {
|
} else {
|
||||||
fmt.Printf(" %s/%s - %v - %v\n", p.Repo, p.Name, p.Data[0], p.Data[1])
|
fmt.Printf(" %s/%s - %v - %v\n", p.Repo, p.Name, p.Data[0], p.Data[1])
|
||||||
@@ -152,7 +159,7 @@ func main() {
|
|||||||
}
|
}
|
||||||
if len(oths) >= 1 {
|
if len(oths) >= 1 {
|
||||||
for _, n := range oths {
|
for _, n := range oths {
|
||||||
err := database.PurgeRepository(n, destDir)
|
err := database.PurgeRepository(n, absDestDir)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
fmt.Println("!!", err)
|
fmt.Println("!!", err)
|
||||||
os.Exit(1)
|
os.Exit(1)
|
||||||
@@ -161,6 +168,13 @@ func main() {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
} else if cmds[0] == "f" {
|
||||||
|
fmt.Printf("dest dir: %v\n", destDir)
|
||||||
|
fmt.Printf("abs dest dir: %v\n", absDestDir)
|
||||||
|
fmt.Printf("is abs: %v\n", filepath.IsAbs(destDir))
|
||||||
|
fmt.Printf("repos urls file: %v\n", filepath.Join(absDestDir, paths.ReposUrlsFile))
|
||||||
|
fmt.Printf("repos dir: %v\n", filepath.Join(absDestDir, paths.ReposDir))
|
||||||
|
fmt.Printf("installed pkgs database: %v\n", filepath.Join(absDestDir, paths.InstalledFile))
|
||||||
} else if cmds[0] == "v" {
|
} else if cmds[0] == "v" {
|
||||||
fmt.Println(_version)
|
fmt.Println(_version)
|
||||||
} else {
|
} else {
|
||||||
|
|||||||
+14
-7
@@ -1,19 +1,20 @@
|
|||||||
package pkg
|
package pkg
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"fmt"
|
|
||||||
"bufio"
|
"bufio"
|
||||||
|
"errors"
|
||||||
|
"fmt"
|
||||||
"slices"
|
"slices"
|
||||||
"strings"
|
"strings"
|
||||||
"errors"
|
|
||||||
// "slices"
|
// "slices"
|
||||||
// "strconv"
|
// "strconv"
|
||||||
"os"
|
"os"
|
||||||
"os/exec"
|
"os/exec"
|
||||||
"path/filepath"
|
"path/filepath"
|
||||||
|
paths "qulay/config"
|
||||||
"qulay/database"
|
"qulay/database"
|
||||||
"qulay/helpers"
|
"qulay/helpers"
|
||||||
"qulay/config"
|
|
||||||
|
|
||||||
"codeberg.org/UzbekLinux/uzbekdb-go"
|
"codeberg.org/UzbekLinux/uzbekdb-go"
|
||||||
)
|
)
|
||||||
@@ -150,7 +151,6 @@ func Install(name string, args []string, destDir string) error {
|
|||||||
// verbose := slices.Contains(args, ":v")
|
// verbose := slices.Contains(args, ":v")
|
||||||
reinstall := slices.Contains(args, ":r")
|
reinstall := slices.Contains(args, ":r")
|
||||||
disableDeps := slices.Contains(args, ":nd")
|
disableDeps := slices.Contains(args, ":nd")
|
||||||
|
|
||||||
pkg, err := getPackage(name, destDir)
|
pkg, err := getPackage(name, destDir)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
@@ -183,8 +183,15 @@ func Install(name string, args []string, destDir string) error {
|
|||||||
}
|
}
|
||||||
if !disableDeps {
|
if !disableDeps {
|
||||||
for _, dep := range depends {
|
for _, dep := range depends {
|
||||||
if !database.IsInstalled(dep, destDir) || reinstall {
|
depPkg, err := getPackage(dep, destDir)
|
||||||
err := Install(dep, args, destDir)
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
|
||||||
|
fullName := depPkg.Repo + "/" + depPkg.Name
|
||||||
|
|
||||||
|
if !database.IsInstalled(fullName, destDir) || reinstall {
|
||||||
|
err := Install(fullName, args, destDir)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
@@ -195,7 +202,7 @@ func Install(name string, args []string, destDir string) error {
|
|||||||
if !isNewFormat(pkgPath) {
|
if !isNewFormat(pkgPath) {
|
||||||
cmd := exec.Command("sh", "install.sh")
|
cmd := exec.Command("sh", "install.sh")
|
||||||
cmd.Dir = pkgPath
|
cmd.Dir = pkgPath
|
||||||
cmd.Env = os.Environ()
|
cmd.Env = append(os.Environ(), "DESTDIR="+destDir)
|
||||||
cmd.Stdout = os.Stdout
|
cmd.Stdout = os.Stdout
|
||||||
cmd.Stderr = os.Stderr
|
cmd.Stderr = os.Stderr
|
||||||
err := cmd.Run()
|
err := cmd.Run()
|
||||||
|
|||||||
Reference in new issue
Block a user