forked from Plemya-x/ALR
refactor
This commit is contained in:
parent
f26b72b2a2
commit
b8cb7af3bb
@ -11,7 +11,7 @@
|
|||||||
<g fill="#fff" text-anchor="middle" font-family="DejaVu Sans,Verdana,Geneva,sans-serif" font-size="11">
|
<g fill="#fff" text-anchor="middle" font-family="DejaVu Sans,Verdana,Geneva,sans-serif" font-size="11">
|
||||||
<text x="33.5" y="15" fill="#010101" fill-opacity=".3">coverage</text>
|
<text x="33.5" y="15" fill="#010101" fill-opacity=".3">coverage</text>
|
||||||
<text x="33.5" y="14">coverage</text>
|
<text x="33.5" y="14">coverage</text>
|
||||||
<text x="86" y="15" fill="#010101" fill-opacity=".3">15.8%</text>
|
<text x="86" y="15" fill="#010101" fill-opacity=".3">16.1%</text>
|
||||||
<text x="86" y="14">15.8%</text>
|
<text x="86" y="14">16.1%</text>
|
||||||
</g>
|
</g>
|
||||||
</svg>
|
</svg>
|
||||||
|
Before Width: | Height: | Size: 926 B After Width: | Height: | Size: 926 B |
38
build.go
38
build.go
@ -30,6 +30,7 @@ import (
|
|||||||
"github.com/leonelquinteros/gotext"
|
"github.com/leonelquinteros/gotext"
|
||||||
"github.com/urfave/cli/v2"
|
"github.com/urfave/cli/v2"
|
||||||
|
|
||||||
|
"gitea.plemya-x.ru/Plemya-x/ALR/internal/cliutils"
|
||||||
"gitea.plemya-x.ru/Plemya-x/ALR/internal/config"
|
"gitea.plemya-x.ru/Plemya-x/ALR/internal/config"
|
||||||
database "gitea.plemya-x.ru/Plemya-x/ALR/internal/db"
|
database "gitea.plemya-x.ru/Plemya-x/ALR/internal/db"
|
||||||
"gitea.plemya-x.ru/Plemya-x/ALR/internal/osutils"
|
"gitea.plemya-x.ru/Plemya-x/ALR/internal/osutils"
|
||||||
@ -71,13 +72,11 @@ func BuildCmd() *cli.Command {
|
|||||||
Action: func(c *cli.Context) error {
|
Action: func(c *cli.Context) error {
|
||||||
wd, err := os.Getwd()
|
wd, err := os.Getwd()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
slog.Error(gotext.Get("Error getting working directory"), "err", err)
|
return cliutils.FormatCliExit(gotext.Get("Error getting working directory"), err)
|
||||||
os.Exit(1)
|
|
||||||
}
|
}
|
||||||
executable, err := os.Executable()
|
executable, err := os.Executable()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
slog.Error(gotext.Get("Error getting working directory"), "err", err)
|
return cliutils.FormatCliExit(gotext.Get("Error getting working directory"), err)
|
||||||
os.Exit(1)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
cmd := exec.Command(executable, "_internal-mount", wd)
|
cmd := exec.Command(executable, "_internal-mount", wd)
|
||||||
@ -86,8 +85,7 @@ func BuildCmd() *cli.Command {
|
|||||||
cmd.Stderr = os.Stderr
|
cmd.Stderr = os.Stderr
|
||||||
err = cmd.Run()
|
err = cmd.Run()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
slog.Error(gotext.Get("Error getting working directory"), "err", err)
|
return cliutils.FormatCliExit(gotext.Get("Error getting working directory"), err)
|
||||||
os.Exit(1)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
wd = stdout.String()
|
wd = stdout.String()
|
||||||
@ -99,37 +97,29 @@ func BuildCmd() *cli.Command {
|
|||||||
cmd.Stdout = &stdout
|
cmd.Stdout = &stdout
|
||||||
cmd.Stderr = os.Stderr
|
cmd.Stderr = os.Stderr
|
||||||
err = cmd.Run()
|
err = cmd.Run()
|
||||||
if err != nil {
|
|
||||||
slog.Error(gotext.Get("Error getting working directory"), "err", err)
|
|
||||||
os.Exit(1)
|
|
||||||
}
|
|
||||||
}()
|
}()
|
||||||
|
|
||||||
err = utils.DropCapsToAlrUser()
|
err = utils.DropCapsToAlrUser()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
slog.Error(gotext.Get("Error dropping capabilities"), "err", err)
|
return cliutils.FormatCliExit(gotext.Get("Error dropping capabilities"), err)
|
||||||
os.Exit(1)
|
|
||||||
}
|
}
|
||||||
_, err = os.Stat(wd)
|
_, err = os.Stat(wd)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
slog.Error(gotext.Get("Error dropping capabilities"), "err", err)
|
return cliutils.FormatCliExit(gotext.Get("Error dropping capabilities"), err)
|
||||||
os.Exit(1)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
ctx := c.Context
|
ctx := c.Context
|
||||||
cfg := config.New()
|
cfg := config.New()
|
||||||
err = cfg.Load()
|
err = cfg.Load()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
slog.Error(gotext.Get("Error loading config"), "err", err)
|
return cliutils.FormatCliExit(gotext.Get("Error loading config"), err)
|
||||||
os.Exit(1)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
db := database.New(cfg)
|
db := database.New(cfg)
|
||||||
rs := repos.New(cfg, db)
|
rs := repos.New(cfg, db)
|
||||||
err = db.Init(ctx)
|
err = db.Init(ctx)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
slog.Error(gotext.Get("Error initialization database"), "err", err)
|
return cliutils.FormatCliExit(gotext.Get("Error initialization database"), err)
|
||||||
os.Exit(1)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
var script string
|
var script string
|
||||||
@ -144,8 +134,7 @@ func BuildCmd() *cli.Command {
|
|||||||
|
|
||||||
info, err := distro.ParseOSRelease(ctx)
|
info, err := distro.ParseOSRelease(ctx)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
slog.Error(gotext.Get("Error parsing os release"), "err", err)
|
return cliutils.FormatCliExit(gotext.Get("Error parsing os release"), err)
|
||||||
os.Exit(1)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
builder := build.NewMainBuilder(
|
builder := build.NewMainBuilder(
|
||||||
@ -176,8 +165,7 @@ func BuildCmd() *cli.Command {
|
|||||||
},
|
},
|
||||||
)
|
)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
slog.Error(gotext.Get("Error building package"), "err", err)
|
return cliutils.FormatCliExit(gotext.Get("Error building package"), err)
|
||||||
os.Exit(1)
|
|
||||||
}
|
}
|
||||||
case c.IsSet("package"):
|
case c.IsSet("package"):
|
||||||
// TODO: handle multiple packages
|
// TODO: handle multiple packages
|
||||||
@ -218,8 +206,7 @@ func BuildCmd() *cli.Command {
|
|||||||
},
|
},
|
||||||
)
|
)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
slog.Error(gotext.Get("Error building package"), "err", err)
|
return cliutils.FormatCliExit(gotext.Get("Error building package"), err)
|
||||||
os.Exit(1)
|
|
||||||
}
|
}
|
||||||
default:
|
default:
|
||||||
slog.Error(gotext.Get("Nothing to build"))
|
slog.Error(gotext.Get("Nothing to build"))
|
||||||
@ -231,8 +218,7 @@ func BuildCmd() *cli.Command {
|
|||||||
name := filepath.Base(pkgPath)
|
name := filepath.Base(pkgPath)
|
||||||
err = osutils.Move(pkgPath, filepath.Join(wd, name))
|
err = osutils.Move(pkgPath, filepath.Join(wd, name))
|
||||||
if err != nil {
|
if err != nil {
|
||||||
slog.Error(gotext.Get("Error moving the package"), "err", err)
|
return cliutils.FormatCliExit(gotext.Get("Error moving the package"), err)
|
||||||
os.Exit(1)
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
15
fix.go
15
fix.go
@ -27,6 +27,7 @@ import (
|
|||||||
"github.com/leonelquinteros/gotext"
|
"github.com/leonelquinteros/gotext"
|
||||||
"github.com/urfave/cli/v2"
|
"github.com/urfave/cli/v2"
|
||||||
|
|
||||||
|
"gitea.plemya-x.ru/Plemya-x/ALR/internal/cliutils"
|
||||||
appbuilder "gitea.plemya-x.ru/Plemya-x/ALR/internal/cliutils/app_builder"
|
appbuilder "gitea.plemya-x.ru/Plemya-x/ALR/internal/cliutils/app_builder"
|
||||||
"gitea.plemya-x.ru/Plemya-x/ALR/internal/utils"
|
"gitea.plemya-x.ru/Plemya-x/ALR/internal/utils"
|
||||||
)
|
)
|
||||||
@ -60,22 +61,19 @@ func FixCmd() *cli.Command {
|
|||||||
|
|
||||||
dir, err := os.Open(paths.CacheDir)
|
dir, err := os.Open(paths.CacheDir)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
slog.Error(gotext.Get("Unable to open cache directory"))
|
return cliutils.FormatCliExit(gotext.Get("Unable to open cache directory"), err)
|
||||||
return cli.Exit(err, 1)
|
|
||||||
}
|
}
|
||||||
defer dir.Close()
|
defer dir.Close()
|
||||||
|
|
||||||
entries, err := dir.Readdirnames(-1)
|
entries, err := dir.Readdirnames(-1)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
slog.Error(gotext.Get("Unable to read cache directory contents"))
|
return cliutils.FormatCliExit(gotext.Get("Unable to read cache directory contents"), err)
|
||||||
return cli.Exit(err, 1)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
for _, entry := range entries {
|
for _, entry := range entries {
|
||||||
err = os.RemoveAll(filepath.Join(paths.CacheDir, entry))
|
err = os.RemoveAll(filepath.Join(paths.CacheDir, entry))
|
||||||
if err != nil {
|
if err != nil {
|
||||||
slog.Error(gotext.Get("Unable to remove cache item"), "item", entry)
|
return cliutils.FormatCliExit(gotext.Get("Unable to remove cache item (%s)", entry), err)
|
||||||
return cli.Exit(err, 1)
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -83,15 +81,14 @@ func FixCmd() *cli.Command {
|
|||||||
|
|
||||||
err = os.MkdirAll(paths.CacheDir, 0o755)
|
err = os.MkdirAll(paths.CacheDir, 0o755)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
slog.Error(gotext.Get("Unable to create new cache directory"))
|
return cliutils.FormatCliExit(gotext.Get("Unable to create new cache directory"), err)
|
||||||
return cli.Exit(err, 1)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
deps, err = appbuilder.
|
deps, err = appbuilder.
|
||||||
New(ctx).
|
New(ctx).
|
||||||
WithConfig().
|
WithConfig().
|
||||||
WithDB().
|
WithDB().
|
||||||
WithRepos().
|
WithReposForcePull().
|
||||||
Build()
|
Build()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return cli.Exit(err, 1)
|
return cli.Exit(err, 1)
|
||||||
|
@ -30,6 +30,7 @@ import (
|
|||||||
"mvdan.cc/sh/v3/expand"
|
"mvdan.cc/sh/v3/expand"
|
||||||
"mvdan.cc/sh/v3/interp"
|
"mvdan.cc/sh/v3/interp"
|
||||||
|
|
||||||
|
"gitea.plemya-x.ru/Plemya-x/ALR/internal/cliutils"
|
||||||
"gitea.plemya-x.ru/Plemya-x/ALR/internal/cpu"
|
"gitea.plemya-x.ru/Plemya-x/ALR/internal/cpu"
|
||||||
"gitea.plemya-x.ru/Plemya-x/ALR/internal/shutils/helpers"
|
"gitea.plemya-x.ru/Plemya-x/ALR/internal/shutils/helpers"
|
||||||
"gitea.plemya-x.ru/Plemya-x/ALR/pkg/distro"
|
"gitea.plemya-x.ru/Plemya-x/ALR/pkg/distro"
|
||||||
@ -76,14 +77,12 @@ func HelperCmd() *cli.Command {
|
|||||||
|
|
||||||
wd, err := os.Getwd()
|
wd, err := os.Getwd()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
slog.Error(gotext.Get("Error getting working directory"))
|
return cliutils.FormatCliExit(gotext.Get("Error getting working directory"), err)
|
||||||
return cli.Exit(err, 1)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
info, err := distro.ParseOSRelease(ctx)
|
info, err := distro.ParseOSRelease(ctx)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
slog.Error(gotext.Get("Error parsing os-release file"))
|
return cliutils.FormatCliExit(gotext.Get("Error parsing os-release file"), err)
|
||||||
return cli.Exit(err, 1)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
hc := interp.HandlerContext{
|
hc := interp.HandlerContext{
|
||||||
|
28
info.go
28
info.go
@ -21,7 +21,6 @@ package main
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
"fmt"
|
"fmt"
|
||||||
"log/slog"
|
|
||||||
"os"
|
"os"
|
||||||
|
|
||||||
"github.com/jeandeaual/go-locale"
|
"github.com/jeandeaual/go-locale"
|
||||||
@ -66,8 +65,7 @@ func InfoCmd() *cli.Command {
|
|||||||
|
|
||||||
result, err := deps.DB.GetPkgs(c.Context, "true")
|
result, err := deps.DB.GetPkgs(c.Context, "true")
|
||||||
if err != nil {
|
if err != nil {
|
||||||
slog.Error(gotext.Get("Error getting packages"))
|
return cliutils.FormatCliExit(gotext.Get("Error getting packages"), err)
|
||||||
return cli.Exit(err, 1)
|
|
||||||
}
|
}
|
||||||
defer result.Close()
|
defer result.Close()
|
||||||
|
|
||||||
@ -75,8 +73,7 @@ func InfoCmd() *cli.Command {
|
|||||||
var pkg database.Package
|
var pkg database.Package
|
||||||
err = result.StructScan(&pkg)
|
err = result.StructScan(&pkg)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
slog.Error(gotext.Get("Error iterating over packages"))
|
return cliutils.FormatCliExit(gotext.Get("Error iterating over packages"), err)
|
||||||
return cli.Exit(err, 1)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
fmt.Println(pkg.Name)
|
fmt.Println(pkg.Name)
|
||||||
@ -110,13 +107,11 @@ func InfoCmd() *cli.Command {
|
|||||||
|
|
||||||
found, _, err := rs.FindPkgs(ctx, args.Slice())
|
found, _, err := rs.FindPkgs(ctx, args.Slice())
|
||||||
if err != nil {
|
if err != nil {
|
||||||
slog.Error(gotext.Get("Error finding packages"))
|
return cliutils.FormatCliExit(gotext.Get("Error finding packages"), err)
|
||||||
return cli.Exit(err, 1)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if len(found) == 0 {
|
if len(found) == 0 {
|
||||||
slog.Error(gotext.Get("Package not found"))
|
return cliutils.FormatCliExit(gotext.Get("Package not found"), err)
|
||||||
return cli.Exit(err, 1)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
pkgs := cliutils.FlattenPkgs(ctx, found, "show", c.Bool("interactive"))
|
pkgs := cliutils.FlattenPkgs(ctx, found, "show", c.Bool("interactive"))
|
||||||
@ -126,8 +121,7 @@ func InfoCmd() *cli.Command {
|
|||||||
|
|
||||||
systemLang, err := locale.GetLanguage()
|
systemLang, err := locale.GetLanguage()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
slog.Error(gotext.Get("Can't detect system language"))
|
return cliutils.FormatCliExit(gotext.Get("Can't detect system language"), err)
|
||||||
return cli.Exit(err, 1)
|
|
||||||
}
|
}
|
||||||
if systemLang == "" {
|
if systemLang == "" {
|
||||||
systemLang = "en"
|
systemLang = "en"
|
||||||
@ -136,8 +130,7 @@ func InfoCmd() *cli.Command {
|
|||||||
if !all {
|
if !all {
|
||||||
info, err := distro.ParseOSRelease(ctx)
|
info, err := distro.ParseOSRelease(ctx)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
slog.Error(gotext.Get("Error parsing os-release file"))
|
return cliutils.FormatCliExit(gotext.Get("Error parsing os-release file"), err)
|
||||||
return cli.Exit(err, 1)
|
|
||||||
}
|
}
|
||||||
names, err = overrides.Resolve(
|
names, err = overrides.Resolve(
|
||||||
info,
|
info,
|
||||||
@ -145,8 +138,7 @@ func InfoCmd() *cli.Command {
|
|||||||
WithLanguages([]string{systemLang}),
|
WithLanguages([]string{systemLang}),
|
||||||
)
|
)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
slog.Error(gotext.Get("Error resolving overrides"))
|
return cliutils.FormatCliExit(gotext.Get("Error resolving overrides"), err)
|
||||||
return cli.Exit(err, 1)
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -154,14 +146,12 @@ func InfoCmd() *cli.Command {
|
|||||||
if !all {
|
if !all {
|
||||||
err = yaml.NewEncoder(os.Stdout).Encode(overrides.ResolvePackage(&pkg, names))
|
err = yaml.NewEncoder(os.Stdout).Encode(overrides.ResolvePackage(&pkg, names))
|
||||||
if err != nil {
|
if err != nil {
|
||||||
slog.Error(gotext.Get("Error encoding script variables"))
|
return cliutils.FormatCliExit(gotext.Get("Error encoding script variables"), err)
|
||||||
return cli.Exit(err, 1)
|
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
err = yaml.NewEncoder(os.Stdout).Encode(pkg)
|
err = yaml.NewEncoder(os.Stdout).Encode(pkg)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
slog.Error(gotext.Get("Error encoding script variables"))
|
return cliutils.FormatCliExit(gotext.Get("Error encoding script variables"), err)
|
||||||
return cli.Exit(err, 1)
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
61
install.go
61
install.go
@ -27,6 +27,7 @@ import (
|
|||||||
"github.com/leonelquinteros/gotext"
|
"github.com/leonelquinteros/gotext"
|
||||||
"github.com/urfave/cli/v2"
|
"github.com/urfave/cli/v2"
|
||||||
|
|
||||||
|
"gitea.plemya-x.ru/Plemya-x/ALR/internal/cliutils"
|
||||||
"gitea.plemya-x.ru/Plemya-x/ALR/internal/config"
|
"gitea.plemya-x.ru/Plemya-x/ALR/internal/config"
|
||||||
database "gitea.plemya-x.ru/Plemya-x/ALR/internal/db"
|
database "gitea.plemya-x.ru/Plemya-x/ALR/internal/db"
|
||||||
"gitea.plemya-x.ru/Plemya-x/ALR/internal/types"
|
"gitea.plemya-x.ru/Plemya-x/ALR/internal/types"
|
||||||
@ -67,22 +68,19 @@ func InstallCmd() *cli.Command {
|
|||||||
cfg := config.New()
|
cfg := config.New()
|
||||||
err := cfg.Load()
|
err := cfg.Load()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
slog.Error(gotext.Get("Error loading config"), "err", err)
|
return cliutils.FormatCliExit(gotext.Get("Error loading config"), err)
|
||||||
os.Exit(1)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
db := database.New(cfg)
|
db := database.New(cfg)
|
||||||
rs := repos.New(cfg, db)
|
rs := repos.New(cfg, db)
|
||||||
err = db.Init(ctx)
|
err = db.Init(ctx)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
slog.Error(gotext.Get("Error initialization database"), "err", err)
|
return cliutils.FormatCliExit(gotext.Get("Error initialization database"), err)
|
||||||
os.Exit(1)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
err = utils.DropCapsToAlrUser()
|
err = utils.DropCapsToAlrUser()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
slog.Error(gotext.Get("Error dropping capabilities"), "err", err)
|
return cliutils.FormatCliExit(gotext.Get("Error dropping capabilities"), err)
|
||||||
os.Exit(1)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
builder := build.NewMainBuilder(
|
builder := build.NewMainBuilder(
|
||||||
@ -93,15 +91,13 @@ func InstallCmd() *cli.Command {
|
|||||||
if cfg.AutoPull() {
|
if cfg.AutoPull() {
|
||||||
err := rs.Pull(ctx, cfg.Repos())
|
err := rs.Pull(ctx, cfg.Repos())
|
||||||
if err != nil {
|
if err != nil {
|
||||||
slog.Error(gotext.Get("Error pulling repositories"), "err", err)
|
return cliutils.FormatCliExit(gotext.Get("Error pulling repositories"), err)
|
||||||
os.Exit(1)
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
info, err := distro.ParseOSRelease(ctx)
|
info, err := distro.ParseOSRelease(ctx)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
slog.Error(gotext.Get("Error parsing os release"), "err", err)
|
return cliutils.FormatCliExit(gotext.Get("Error parsing os release"), err)
|
||||||
os.Exit(1)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
err = builder.InstallPkgs(
|
err = builder.InstallPkgs(
|
||||||
@ -117,30 +113,26 @@ func InstallCmd() *cli.Command {
|
|||||||
args.Slice(),
|
args.Slice(),
|
||||||
)
|
)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
slog.Error(gotext.Get("Error parsing os release"), "err", err)
|
return cliutils.FormatCliExit(gotext.Get("Error parsing os release"), err)
|
||||||
os.Exit(1)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return nil
|
return nil
|
||||||
},
|
},
|
||||||
BashComplete: func(c *cli.Context) {
|
BashComplete: cliutils.BashCompleteWithError(func(c *cli.Context) error {
|
||||||
cfg := config.New()
|
cfg := config.New()
|
||||||
err := cfg.Load()
|
err := cfg.Load()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
slog.Error(gotext.Get("Error loading config"), "err", err)
|
return cliutils.FormatCliExit(gotext.Get("Error loading config"), err)
|
||||||
os.Exit(1)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
db := database.New(cfg)
|
db := database.New(cfg)
|
||||||
err = db.Init(c.Context)
|
err = db.Init(c.Context)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
slog.Error(gotext.Get("Error initialization database"), "err", err)
|
return cliutils.FormatCliExit(gotext.Get("Error initialization database"), err)
|
||||||
os.Exit(1)
|
|
||||||
}
|
}
|
||||||
result, err := db.GetPkgs(c.Context, "true")
|
result, err := db.GetPkgs(c.Context, "true")
|
||||||
if err != nil {
|
if err != nil {
|
||||||
slog.Error(gotext.Get("Error getting packages"), "err", err)
|
return cliutils.FormatCliExit(gotext.Get("Error getting packages"), err)
|
||||||
os.Exit(1)
|
|
||||||
}
|
}
|
||||||
defer result.Close()
|
defer result.Close()
|
||||||
|
|
||||||
@ -148,13 +140,14 @@ func InstallCmd() *cli.Command {
|
|||||||
var pkg database.Package
|
var pkg database.Package
|
||||||
err = result.StructScan(&pkg)
|
err = result.StructScan(&pkg)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
slog.Error(gotext.Get("Error iterating over packages"), "err", err)
|
return cliutils.FormatCliExit(gotext.Get("Error iterating over packages"), err)
|
||||||
os.Exit(1)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
fmt.Println(pkg.Name)
|
fmt.Println(pkg.Name)
|
||||||
}
|
}
|
||||||
},
|
|
||||||
|
return nil
|
||||||
|
}),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -163,19 +156,17 @@ func RemoveCmd() *cli.Command {
|
|||||||
Name: "remove",
|
Name: "remove",
|
||||||
Usage: gotext.Get("Remove an installed package"),
|
Usage: gotext.Get("Remove an installed package"),
|
||||||
Aliases: []string{"rm"},
|
Aliases: []string{"rm"},
|
||||||
BashComplete: func(c *cli.Context) {
|
BashComplete: cliutils.BashCompleteWithError(func(c *cli.Context) error {
|
||||||
cfg := config.New()
|
cfg := config.New()
|
||||||
err := cfg.Load()
|
err := cfg.Load()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
slog.Error(gotext.Get("Error loading config"), "err", err)
|
return cliutils.FormatCliExit(gotext.Get("Error loading config"), err)
|
||||||
os.Exit(1)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
db := database.New(cfg)
|
db := database.New(cfg)
|
||||||
err = db.Init(c.Context)
|
err = db.Init(c.Context)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
slog.Error(gotext.Get("Error initialization database"), "err", err)
|
return cliutils.FormatCliExit(gotext.Get("Error initialization database"), err)
|
||||||
os.Exit(1)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
installedAlrPackages := map[string]string{}
|
installedAlrPackages := map[string]string{}
|
||||||
@ -186,8 +177,7 @@ func RemoveCmd() *cli.Command {
|
|||||||
}
|
}
|
||||||
installed, err := mgr.ListInstalled(&manager.Opts{AsRoot: false})
|
installed, err := mgr.ListInstalled(&manager.Opts{AsRoot: false})
|
||||||
if err != nil {
|
if err != nil {
|
||||||
slog.Error(gotext.Get("Error listing installed packages"), "err", err)
|
return cliutils.FormatCliExit(gotext.Get("Error listing installed packages"), err)
|
||||||
os.Exit(1)
|
|
||||||
}
|
}
|
||||||
for pkgName, version := range installed {
|
for pkgName, version := range installed {
|
||||||
matches := build.RegexpALRPackageName.FindStringSubmatch(pkgName)
|
matches := build.RegexpALRPackageName.FindStringSubmatch(pkgName)
|
||||||
@ -200,8 +190,7 @@ func RemoveCmd() *cli.Command {
|
|||||||
|
|
||||||
result, err := db.GetPkgs(c.Context, "true")
|
result, err := db.GetPkgs(c.Context, "true")
|
||||||
if err != nil {
|
if err != nil {
|
||||||
slog.Error(gotext.Get("Error getting packages"), "err", err)
|
return cliutils.FormatCliExit(gotext.Get("Error getting packages"), err)
|
||||||
os.Exit(1)
|
|
||||||
}
|
}
|
||||||
defer result.Close()
|
defer result.Close()
|
||||||
|
|
||||||
@ -209,8 +198,7 @@ func RemoveCmd() *cli.Command {
|
|||||||
var pkg database.Package
|
var pkg database.Package
|
||||||
err = result.StructScan(&pkg)
|
err = result.StructScan(&pkg)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
slog.Error(gotext.Get("Error iterating over packages"), "err", err)
|
return cliutils.FormatCliExit(gotext.Get("Error iterating over packages"), err)
|
||||||
os.Exit(1)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
_, ok := installedAlrPackages[fmt.Sprintf("%s/%s", pkg.Repository, pkg.Name)]
|
_, ok := installedAlrPackages[fmt.Sprintf("%s/%s", pkg.Repository, pkg.Name)]
|
||||||
@ -220,7 +208,9 @@ func RemoveCmd() *cli.Command {
|
|||||||
|
|
||||||
fmt.Println(pkg.Name)
|
fmt.Println(pkg.Name)
|
||||||
}
|
}
|
||||||
},
|
|
||||||
|
return nil
|
||||||
|
}),
|
||||||
Action: func(c *cli.Context) error {
|
Action: func(c *cli.Context) error {
|
||||||
args := c.Args()
|
args := c.Args()
|
||||||
if args.Len() < 1 {
|
if args.Len() < 1 {
|
||||||
@ -239,8 +229,7 @@ func RemoveCmd() *cli.Command {
|
|||||||
NoConfirm: !c.Bool("interactive"),
|
NoConfirm: !c.Bool("interactive"),
|
||||||
}, c.Args().Slice()...)
|
}, c.Args().Slice()...)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
slog.Error(gotext.Get("Error removing packages"), "err", err)
|
return cliutils.FormatCliExit(gotext.Get("Error removing packages"), err)
|
||||||
os.Exit(1)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return nil
|
return nil
|
||||||
|
10
internal.go
10
internal.go
@ -31,6 +31,7 @@ import (
|
|||||||
"github.com/leonelquinteros/gotext"
|
"github.com/leonelquinteros/gotext"
|
||||||
"github.com/urfave/cli/v2"
|
"github.com/urfave/cli/v2"
|
||||||
|
|
||||||
|
"gitea.plemya-x.ru/Plemya-x/ALR/internal/cliutils"
|
||||||
"gitea.plemya-x.ru/Plemya-x/ALR/internal/config"
|
"gitea.plemya-x.ru/Plemya-x/ALR/internal/config"
|
||||||
database "gitea.plemya-x.ru/Plemya-x/ALR/internal/db"
|
database "gitea.plemya-x.ru/Plemya-x/ALR/internal/db"
|
||||||
"gitea.plemya-x.ru/Plemya-x/ALR/internal/logger"
|
"gitea.plemya-x.ru/Plemya-x/ALR/internal/logger"
|
||||||
@ -55,8 +56,7 @@ func InternalBuildCmd() *cli.Command {
|
|||||||
cfg := config.New()
|
cfg := config.New()
|
||||||
err = cfg.Load()
|
err = cfg.Load()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
slog.Error(gotext.Get("Error loading config"), "err", err)
|
return cliutils.FormatCliExit(gotext.Get("Error loading config"), err)
|
||||||
os.Exit(1)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
logger := hclog.New(&hclog.LoggerOptions{
|
logger := hclog.New(&hclog.LoggerOptions{
|
||||||
@ -96,16 +96,14 @@ func InternalInstallCmd() *cli.Command {
|
|||||||
cfg := config.New()
|
cfg := config.New()
|
||||||
err = cfg.Load()
|
err = cfg.Load()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
slog.Error(gotext.Get("Error loading config"), "err", err)
|
return cliutils.FormatCliExit(gotext.Get("Error loading config"), err)
|
||||||
os.Exit(1)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
db := database.New(cfg)
|
db := database.New(cfg)
|
||||||
rs := repos.New(cfg, db)
|
rs := repos.New(cfg, db)
|
||||||
err = db.Init(c.Context)
|
err = db.Init(c.Context)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
slog.Error(gotext.Get("Error initialization database"), "err", err)
|
return cliutils.FormatCliExit(gotext.Get("Error initialization database"), err)
|
||||||
os.Exit(1)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
logger := hclog.New(&hclog.LoggerOptions{
|
logger := hclog.New(&hclog.LoggerOptions{
|
||||||
|
@ -46,3 +46,11 @@ func HandleExitCoder(err error) {
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func FormatCliExit(msg string, err error) cli.ExitCoder {
|
||||||
|
return FormatCliExitWithCode(msg, err, 1)
|
||||||
|
}
|
||||||
|
|
||||||
|
func FormatCliExitWithCode(msg string, err error, exitCode int) cli.ExitCoder {
|
||||||
|
return cli.Exit(fmt.Errorf("%s: %w", msg, err), exitCode)
|
||||||
|
}
|
||||||
|
@ -9,76 +9,76 @@ msgstr ""
|
|||||||
"Content-Transfer-Encoding: 8bit\n"
|
"Content-Transfer-Encoding: 8bit\n"
|
||||||
"Plural-Forms: nplurals=2; plural=(n != 1);\n"
|
"Plural-Forms: nplurals=2; plural=(n != 1);\n"
|
||||||
|
|
||||||
#: build.go:47
|
#: build.go:48
|
||||||
msgid "Build a local package"
|
msgid "Build a local package"
|
||||||
msgstr ""
|
msgstr ""
|
||||||
|
|
||||||
#: build.go:53
|
#: build.go:54
|
||||||
msgid "Path to the build script"
|
msgid "Path to the build script"
|
||||||
msgstr ""
|
msgstr ""
|
||||||
|
|
||||||
#: build.go:58
|
#: build.go:59
|
||||||
msgid "Specify subpackage in script (for multi package script only)"
|
msgid "Specify subpackage in script (for multi package script only)"
|
||||||
msgstr ""
|
msgstr ""
|
||||||
|
|
||||||
#: build.go:63
|
#: build.go:64
|
||||||
msgid "Name of the package to build and its repo (example: default/go-bin)"
|
msgid "Name of the package to build and its repo (example: default/go-bin)"
|
||||||
msgstr ""
|
msgstr ""
|
||||||
|
|
||||||
#: build.go:68
|
#: build.go:69
|
||||||
msgid ""
|
msgid ""
|
||||||
"Build package from scratch even if there's an already built package available"
|
"Build package from scratch even if there's an already built package available"
|
||||||
msgstr ""
|
msgstr ""
|
||||||
|
|
||||||
#: build.go:74 build.go:79 build.go:89 build.go:103
|
#: build.go:75 build.go:79 build.go:88
|
||||||
msgid "Error getting working directory"
|
msgid "Error getting working directory"
|
||||||
msgstr ""
|
msgstr ""
|
||||||
|
|
||||||
#: build.go:110 build.go:115
|
#: build.go:104 build.go:108
|
||||||
msgid "Error dropping capabilities"
|
msgid "Error dropping capabilities"
|
||||||
msgstr ""
|
msgstr ""
|
||||||
|
|
||||||
#: build.go:123
|
#: build.go:115
|
||||||
msgid "Error loading config"
|
msgid "Error loading config"
|
||||||
msgstr ""
|
msgstr ""
|
||||||
|
|
||||||
#: build.go:131
|
#: build.go:122
|
||||||
msgid "Error initialization database"
|
msgid "Error initialization database"
|
||||||
msgstr ""
|
msgstr ""
|
||||||
|
|
||||||
#: build.go:141
|
#: build.go:131
|
||||||
msgid "Unable to detect a supported package manager on the system"
|
msgid "Unable to detect a supported package manager on the system"
|
||||||
msgstr ""
|
msgstr ""
|
||||||
|
|
||||||
#: build.go:147
|
#: build.go:137
|
||||||
msgid "Error parsing os release"
|
msgid "Error parsing os release"
|
||||||
msgstr ""
|
msgstr ""
|
||||||
|
|
||||||
#: build.go:179 build.go:221
|
#: build.go:168 build.go:209
|
||||||
msgid "Error building package"
|
msgid "Error building package"
|
||||||
msgstr ""
|
msgstr ""
|
||||||
|
|
||||||
#: build.go:197
|
#: build.go:185
|
||||||
msgid "Package not found"
|
msgid "Package not found"
|
||||||
msgstr ""
|
msgstr ""
|
||||||
|
|
||||||
#: build.go:225
|
#: build.go:212
|
||||||
msgid "Nothing to build"
|
msgid "Nothing to build"
|
||||||
msgstr ""
|
msgstr ""
|
||||||
|
|
||||||
#: build.go:234
|
#: build.go:221
|
||||||
msgid "Error moving the package"
|
msgid "Error moving the package"
|
||||||
msgstr ""
|
msgstr ""
|
||||||
|
|
||||||
#: fix.go:37
|
#: fix.go:38
|
||||||
msgid "Attempt to fix problems with ALR"
|
msgid "Attempt to fix problems with ALR"
|
||||||
msgstr ""
|
msgstr ""
|
||||||
|
|
||||||
#: fix.go:58
|
#: fix.go:59
|
||||||
msgid "Clearing cache directory"
|
msgid "Clearing cache directory"
|
||||||
msgstr ""
|
msgstr ""
|
||||||
|
|
||||||
#: fix.go:63
|
#: fix.go:64
|
||||||
msgid "Unable to open cache directory"
|
msgid "Unable to open cache directory"
|
||||||
msgstr ""
|
msgstr ""
|
||||||
|
|
||||||
@ -86,19 +86,19 @@ msgstr ""
|
|||||||
msgid "Unable to read cache directory contents"
|
msgid "Unable to read cache directory contents"
|
||||||
msgstr ""
|
msgstr ""
|
||||||
|
|
||||||
#: fix.go:77
|
#: fix.go:76
|
||||||
msgid "Unable to remove cache item"
|
msgid "Unable to remove cache item (%s)"
|
||||||
msgstr ""
|
msgstr ""
|
||||||
|
|
||||||
#: fix.go:82
|
#: fix.go:80
|
||||||
msgid "Rebuilding cache"
|
msgid "Rebuilding cache"
|
||||||
msgstr ""
|
msgstr ""
|
||||||
|
|
||||||
#: fix.go:86
|
#: fix.go:84
|
||||||
msgid "Unable to create new cache directory"
|
msgid "Unable to create new cache directory"
|
||||||
msgstr ""
|
msgstr ""
|
||||||
|
|
||||||
#: fix.go:101
|
#: fix.go:98
|
||||||
msgid "Done"
|
msgid "Done"
|
||||||
msgstr ""
|
msgstr ""
|
||||||
|
|
||||||
@ -110,19 +110,19 @@ msgstr ""
|
|||||||
msgid "Generate a ALR script for a pip module"
|
msgid "Generate a ALR script for a pip module"
|
||||||
msgstr ""
|
msgstr ""
|
||||||
|
|
||||||
#: helper.go:41
|
#: helper.go:42
|
||||||
msgid "List all the available helper commands"
|
msgid "List all the available helper commands"
|
||||||
msgstr ""
|
msgstr ""
|
||||||
|
|
||||||
#: helper.go:53
|
#: helper.go:54
|
||||||
msgid "Run a ALR helper command"
|
msgid "Run a ALR helper command"
|
||||||
msgstr ""
|
msgstr ""
|
||||||
|
|
||||||
#: helper.go:60
|
#: helper.go:61
|
||||||
msgid "The directory that the install commands will install to"
|
msgid "The directory that the install commands will install to"
|
||||||
msgstr ""
|
msgstr ""
|
||||||
|
|
||||||
#: helper.go:73 helper.go:74
|
#: helper.go:74 helper.go:75
|
||||||
msgid "No such helper command"
|
msgid "No such helper command"
|
||||||
msgstr ""
|
msgstr ""
|
||||||
|
|
||||||
@ -130,67 +130,67 @@ msgstr ""
|
|||||||
msgid "Error parsing os-release file"
|
msgid "Error parsing os-release file"
|
||||||
msgstr ""
|
msgstr ""
|
||||||
|
|
||||||
#: info.go:43
|
#: info.go:42
|
||||||
msgid "Print information about a package"
|
msgid "Print information about a package"
|
||||||
msgstr ""
|
msgstr ""
|
||||||
|
|
||||||
#: info.go:48
|
#: info.go:47
|
||||||
msgid "Show all information, not just for the current distro"
|
msgid "Show all information, not just for the current distro"
|
||||||
msgstr ""
|
msgstr ""
|
||||||
|
|
||||||
#: info.go:69
|
#: info.go:68
|
||||||
msgid "Error getting packages"
|
msgid "Error getting packages"
|
||||||
msgstr ""
|
msgstr ""
|
||||||
|
|
||||||
#: info.go:78
|
#: info.go:76
|
||||||
msgid "Error iterating over packages"
|
msgid "Error iterating over packages"
|
||||||
msgstr ""
|
msgstr ""
|
||||||
|
|
||||||
#: info.go:93
|
#: info.go:90
|
||||||
msgid "Command info expected at least 1 argument, got %d"
|
msgid "Command info expected at least 1 argument, got %d"
|
||||||
msgstr ""
|
msgstr ""
|
||||||
|
|
||||||
#: info.go:113
|
#: info.go:110
|
||||||
msgid "Error finding packages"
|
msgid "Error finding packages"
|
||||||
msgstr ""
|
msgstr ""
|
||||||
|
|
||||||
#: info.go:129
|
#: info.go:124
|
||||||
msgid "Can't detect system language"
|
msgid "Can't detect system language"
|
||||||
msgstr ""
|
msgstr ""
|
||||||
|
|
||||||
#: info.go:148
|
#: info.go:141
|
||||||
msgid "Error resolving overrides"
|
msgid "Error resolving overrides"
|
||||||
msgstr ""
|
msgstr ""
|
||||||
|
|
||||||
#: info.go:157 info.go:163
|
#: info.go:149 info.go:154
|
||||||
msgid "Error encoding script variables"
|
msgid "Error encoding script variables"
|
||||||
msgstr ""
|
msgstr ""
|
||||||
|
|
||||||
#: install.go:43
|
#: install.go:44
|
||||||
msgid "Install a new package"
|
msgid "Install a new package"
|
||||||
msgstr ""
|
msgstr ""
|
||||||
|
|
||||||
#: install.go:57
|
#: install.go:58
|
||||||
msgid "Command install expected at least 1 argument, got %d"
|
msgid "Command install expected at least 1 argument, got %d"
|
||||||
msgstr ""
|
msgstr ""
|
||||||
|
|
||||||
#: install.go:96
|
#: install.go:94
|
||||||
msgid "Error pulling repositories"
|
msgid "Error pulling repositories"
|
||||||
msgstr ""
|
msgstr ""
|
||||||
|
|
||||||
#: install.go:164
|
#: install.go:157
|
||||||
msgid "Remove an installed package"
|
msgid "Remove an installed package"
|
||||||
msgstr ""
|
msgstr ""
|
||||||
|
|
||||||
#: install.go:189
|
#: install.go:180
|
||||||
msgid "Error listing installed packages"
|
msgid "Error listing installed packages"
|
||||||
msgstr ""
|
msgstr ""
|
||||||
|
|
||||||
#: install.go:227
|
#: install.go:217
|
||||||
msgid "Command remove expected at least 1 argument, got %d"
|
msgid "Command remove expected at least 1 argument, got %d"
|
||||||
msgstr ""
|
msgstr ""
|
||||||
|
|
||||||
#: install.go:242
|
#: install.go:232
|
||||||
msgid "Error removing packages"
|
msgid "Error removing packages"
|
||||||
msgstr ""
|
msgstr ""
|
||||||
|
|
||||||
@ -315,7 +315,7 @@ msgstr ""
|
|||||||
msgid "You need to be root to perform this action"
|
msgid "You need to be root to perform this action"
|
||||||
msgstr ""
|
msgstr ""
|
||||||
|
|
||||||
#: list.go:40
|
#: list.go:41
|
||||||
msgid "List ALR repo packages"
|
msgid "List ALR repo packages"
|
||||||
msgstr ""
|
msgstr ""
|
||||||
|
|
||||||
@ -419,51 +419,51 @@ msgid ""
|
|||||||
"updating ALR if something doesn't work."
|
"updating ALR if something doesn't work."
|
||||||
msgstr ""
|
msgstr ""
|
||||||
|
|
||||||
#: repo.go:42
|
#: repo.go:43
|
||||||
msgid "Add a new repository"
|
msgid "Add a new repository"
|
||||||
msgstr ""
|
msgstr ""
|
||||||
|
|
||||||
#: repo.go:49
|
#: repo.go:50
|
||||||
msgid "Name of the new repo"
|
msgid "Name of the new repo"
|
||||||
msgstr ""
|
msgstr ""
|
||||||
|
|
||||||
#: repo.go:55
|
#: repo.go:56
|
||||||
msgid "URL of the new repo"
|
msgid "URL of the new repo"
|
||||||
msgstr ""
|
msgstr ""
|
||||||
|
|
||||||
#: repo.go:93 repo.go:173
|
#: repo.go:93 repo.go:169
|
||||||
msgid "Error saving config"
|
msgid "Error saving config"
|
||||||
msgstr ""
|
msgstr ""
|
||||||
|
|
||||||
#: repo.go:98
|
#: repo.go:97
|
||||||
msgid "Can't drop privileges"
|
msgid "Can't drop privileges"
|
||||||
msgstr ""
|
msgstr ""
|
||||||
|
|
||||||
#: repo.go:105 repo.go:111
|
#: repo.go:104 repo.go:110
|
||||||
msgid "Error pulling repos"
|
msgid "Error pulling repos"
|
||||||
msgstr ""
|
msgstr ""
|
||||||
|
|
||||||
#: repo.go:123
|
#: repo.go:121
|
||||||
msgid "Remove an existing repository"
|
msgid "Remove an existing repository"
|
||||||
msgstr ""
|
msgstr ""
|
||||||
|
|
||||||
#: repo.go:130
|
#: repo.go:128
|
||||||
msgid "Name of the repo to be deleted"
|
msgid "Name of the repo to be deleted"
|
||||||
msgstr ""
|
msgstr ""
|
||||||
|
|
||||||
#: repo.go:159
|
#: repo.go:156
|
||||||
msgid "Repo does not exist"
|
msgid "Repo does not exist"
|
||||||
msgstr ""
|
msgstr ""
|
||||||
|
|
||||||
#: repo.go:167
|
#: repo.go:164
|
||||||
msgid "Error removing repo directory"
|
msgid "Error removing repo directory"
|
||||||
msgstr ""
|
msgstr ""
|
||||||
|
|
||||||
#: repo.go:184
|
#: repo.go:179
|
||||||
msgid "Error removing packages from database"
|
msgid "Error removing packages from database"
|
||||||
msgstr ""
|
msgstr ""
|
||||||
|
|
||||||
#: repo.go:196
|
#: repo.go:190
|
||||||
msgid "Pull all repositories that have changed"
|
msgid "Pull all repositories that have changed"
|
||||||
msgstr ""
|
msgstr ""
|
||||||
|
|
||||||
@ -495,22 +495,22 @@ msgstr ""
|
|||||||
msgid "Error while executing search"
|
msgid "Error while executing search"
|
||||||
msgstr ""
|
msgstr ""
|
||||||
|
|
||||||
#: search.go:105
|
#: search.go:104
|
||||||
msgid "Error parsing format template"
|
msgid "Error parsing format template"
|
||||||
msgstr ""
|
msgstr ""
|
||||||
|
|
||||||
#: search.go:114
|
#: search.go:112
|
||||||
msgid "Error executing template"
|
msgid "Error executing template"
|
||||||
msgstr ""
|
msgstr ""
|
||||||
|
|
||||||
#: upgrade.go:48
|
#: upgrade.go:49
|
||||||
msgid "Upgrade all installed packages"
|
msgid "Upgrade all installed packages"
|
||||||
msgstr ""
|
msgstr ""
|
||||||
|
|
||||||
#: upgrade.go:111 upgrade.go:129
|
#: upgrade.go:107 upgrade.go:124
|
||||||
msgid "Error checking for updates"
|
msgid "Error checking for updates"
|
||||||
msgstr ""
|
msgstr ""
|
||||||
|
|
||||||
#: upgrade.go:133
|
#: upgrade.go:127
|
||||||
msgid "There is nothing to do."
|
msgid "There is nothing to do."
|
||||||
msgstr ""
|
msgstr ""
|
||||||
|
@ -16,80 +16,80 @@ msgstr ""
|
|||||||
"%10<=4 && (n%100<10 || n%100>=20) ? 1 : 2);\n"
|
"%10<=4 && (n%100<10 || n%100>=20) ? 1 : 2);\n"
|
||||||
"X-Generator: Gtranslator 47.1\n"
|
"X-Generator: Gtranslator 47.1\n"
|
||||||
|
|
||||||
#: build.go:47
|
#: build.go:48
|
||||||
msgid "Build a local package"
|
msgid "Build a local package"
|
||||||
msgstr "Сборка локального пакета"
|
msgstr "Сборка локального пакета"
|
||||||
|
|
||||||
#: build.go:53
|
#: build.go:54
|
||||||
msgid "Path to the build script"
|
msgid "Path to the build script"
|
||||||
msgstr "Путь к скрипту сборки"
|
msgstr "Путь к скрипту сборки"
|
||||||
|
|
||||||
#: build.go:58
|
#: build.go:59
|
||||||
msgid "Specify subpackage in script (for multi package script only)"
|
msgid "Specify subpackage in script (for multi package script only)"
|
||||||
msgstr "Укажите подпакет в скрипте (только для многопакетного скрипта)"
|
msgstr "Укажите подпакет в скрипте (только для многопакетного скрипта)"
|
||||||
|
|
||||||
#: build.go:63
|
#: build.go:64
|
||||||
msgid "Name of the package to build and its repo (example: default/go-bin)"
|
msgid "Name of the package to build and its repo (example: default/go-bin)"
|
||||||
msgstr "Имя пакета для сборки и его репозиторий (пример: default/go-bin)"
|
msgstr "Имя пакета для сборки и его репозиторий (пример: default/go-bin)"
|
||||||
|
|
||||||
#: build.go:68
|
#: build.go:69
|
||||||
msgid ""
|
msgid ""
|
||||||
"Build package from scratch even if there's an already built package available"
|
"Build package from scratch even if there's an already built package available"
|
||||||
msgstr "Создайте пакет с нуля, даже если уже имеется готовый пакет"
|
msgstr "Создайте пакет с нуля, даже если уже имеется готовый пакет"
|
||||||
|
|
||||||
#: build.go:74 build.go:79 build.go:89 build.go:103
|
#: build.go:75 build.go:79 build.go:88
|
||||||
msgid "Error getting working directory"
|
msgid "Error getting working directory"
|
||||||
msgstr "Ошибка при получении рабочего каталога"
|
msgstr "Ошибка при получении рабочего каталога"
|
||||||
|
|
||||||
#: build.go:110 build.go:115
|
#: build.go:104 build.go:108
|
||||||
#, fuzzy
|
#, fuzzy
|
||||||
msgid "Error dropping capabilities"
|
msgid "Error dropping capabilities"
|
||||||
msgstr "Ошибка при открытии базы данных"
|
msgstr "Ошибка при открытии базы данных"
|
||||||
|
|
||||||
#: build.go:123
|
#: build.go:115
|
||||||
#, fuzzy
|
#, fuzzy
|
||||||
msgid "Error loading config"
|
msgid "Error loading config"
|
||||||
msgstr "Ошибка при кодировании конфигурации"
|
msgstr "Ошибка при кодировании конфигурации"
|
||||||
|
|
||||||
#: build.go:131
|
#: build.go:122
|
||||||
msgid "Error initialization database"
|
msgid "Error initialization database"
|
||||||
msgstr "Ошибка инициализации базы данных"
|
msgstr "Ошибка инициализации базы данных"
|
||||||
|
|
||||||
#: build.go:141
|
#: build.go:131
|
||||||
msgid "Unable to detect a supported package manager on the system"
|
msgid "Unable to detect a supported package manager on the system"
|
||||||
msgstr "Не удалось обнаружить поддерживаемый менеджер пакетов в системе"
|
msgstr "Не удалось обнаружить поддерживаемый менеджер пакетов в системе"
|
||||||
|
|
||||||
#: build.go:147
|
#: build.go:137
|
||||||
msgid "Error parsing os release"
|
msgid "Error parsing os release"
|
||||||
msgstr "Ошибка при разборе файла выпуска операционной системы"
|
msgstr "Ошибка при разборе файла выпуска операционной системы"
|
||||||
|
|
||||||
#: build.go:179 build.go:221
|
#: build.go:168 build.go:209
|
||||||
msgid "Error building package"
|
msgid "Error building package"
|
||||||
msgstr "Ошибка при сборке пакета"
|
msgstr "Ошибка при сборке пакета"
|
||||||
|
|
||||||
#: build.go:197
|
#: build.go:185
|
||||||
msgid "Package not found"
|
msgid "Package not found"
|
||||||
msgstr "Пакет не найден"
|
msgstr "Пакет не найден"
|
||||||
|
|
||||||
#: build.go:225
|
#: build.go:212
|
||||||
#, fuzzy
|
#, fuzzy
|
||||||
msgid "Nothing to build"
|
msgid "Nothing to build"
|
||||||
msgstr "Исполнение build()"
|
msgstr "Исполнение build()"
|
||||||
|
|
||||||
#: build.go:234
|
#: build.go:221
|
||||||
msgid "Error moving the package"
|
msgid "Error moving the package"
|
||||||
msgstr "Ошибка при перемещении пакета"
|
msgstr "Ошибка при перемещении пакета"
|
||||||
|
|
||||||
#: fix.go:37
|
#: fix.go:38
|
||||||
msgid "Attempt to fix problems with ALR"
|
msgid "Attempt to fix problems with ALR"
|
||||||
msgstr "Попытка устранить проблемы с ALR"
|
msgstr "Попытка устранить проблемы с ALR"
|
||||||
|
|
||||||
#: fix.go:58
|
#: fix.go:59
|
||||||
#, fuzzy
|
#, fuzzy
|
||||||
msgid "Clearing cache directory"
|
msgid "Clearing cache directory"
|
||||||
msgstr "Удаление каталога кэша"
|
msgstr "Удаление каталога кэша"
|
||||||
|
|
||||||
#: fix.go:63
|
#: fix.go:64
|
||||||
#, fuzzy
|
#, fuzzy
|
||||||
msgid "Unable to open cache directory"
|
msgid "Unable to open cache directory"
|
||||||
msgstr "Не удалось удалить каталог кэша"
|
msgstr "Не удалось удалить каталог кэша"
|
||||||
@ -99,20 +99,20 @@ msgstr "Не удалось удалить каталог кэша"
|
|||||||
msgid "Unable to read cache directory contents"
|
msgid "Unable to read cache directory contents"
|
||||||
msgstr "Не удалось удалить каталог кэша"
|
msgstr "Не удалось удалить каталог кэша"
|
||||||
|
|
||||||
#: fix.go:77
|
#: fix.go:76
|
||||||
#, fuzzy
|
#, fuzzy
|
||||||
msgid "Unable to remove cache item"
|
msgid "Unable to remove cache item (%s)"
|
||||||
msgstr "Не удалось удалить каталог кэша"
|
msgstr "Не удалось удалить каталог кэша"
|
||||||
|
|
||||||
#: fix.go:82
|
#: fix.go:80
|
||||||
msgid "Rebuilding cache"
|
msgid "Rebuilding cache"
|
||||||
msgstr "Восстановление кэша"
|
msgstr "Восстановление кэша"
|
||||||
|
|
||||||
#: fix.go:86
|
#: fix.go:84
|
||||||
msgid "Unable to create new cache directory"
|
msgid "Unable to create new cache directory"
|
||||||
msgstr "Не удалось создать новый каталог кэша"
|
msgstr "Не удалось создать новый каталог кэша"
|
||||||
|
|
||||||
#: fix.go:101
|
#: fix.go:98
|
||||||
msgid "Done"
|
msgid "Done"
|
||||||
msgstr "Сделано"
|
msgstr "Сделано"
|
||||||
|
|
||||||
@ -124,19 +124,19 @@ msgstr "Генерация скрипта ALR из шаблона"
|
|||||||
msgid "Generate a ALR script for a pip module"
|
msgid "Generate a ALR script for a pip module"
|
||||||
msgstr "Генерация скрипта ALR для модуля pip"
|
msgstr "Генерация скрипта ALR для модуля pip"
|
||||||
|
|
||||||
#: helper.go:41
|
#: helper.go:42
|
||||||
msgid "List all the available helper commands"
|
msgid "List all the available helper commands"
|
||||||
msgstr "Список всех доступных вспомогательных команды"
|
msgstr "Список всех доступных вспомогательных команды"
|
||||||
|
|
||||||
#: helper.go:53
|
#: helper.go:54
|
||||||
msgid "Run a ALR helper command"
|
msgid "Run a ALR helper command"
|
||||||
msgstr "Запустить вспомогательную команду ALR"
|
msgstr "Запустить вспомогательную команду ALR"
|
||||||
|
|
||||||
#: helper.go:60
|
#: helper.go:61
|
||||||
msgid "The directory that the install commands will install to"
|
msgid "The directory that the install commands will install to"
|
||||||
msgstr "Каталог, в который будут устанавливать команды установки"
|
msgstr "Каталог, в который будут устанавливать команды установки"
|
||||||
|
|
||||||
#: helper.go:73 helper.go:74
|
#: helper.go:74 helper.go:75
|
||||||
msgid "No such helper command"
|
msgid "No such helper command"
|
||||||
msgstr "Такой вспомогательной команды нет"
|
msgstr "Такой вспомогательной команды нет"
|
||||||
|
|
||||||
@ -144,68 +144,68 @@ msgstr "Такой вспомогательной команды нет"
|
|||||||
msgid "Error parsing os-release file"
|
msgid "Error parsing os-release file"
|
||||||
msgstr "Ошибка при разборе файла выпуска операционной системы"
|
msgstr "Ошибка при разборе файла выпуска операционной системы"
|
||||||
|
|
||||||
#: info.go:43
|
#: info.go:42
|
||||||
msgid "Print information about a package"
|
msgid "Print information about a package"
|
||||||
msgstr "Отобразить информацию о пакете"
|
msgstr "Отобразить информацию о пакете"
|
||||||
|
|
||||||
#: info.go:48
|
#: info.go:47
|
||||||
msgid "Show all information, not just for the current distro"
|
msgid "Show all information, not just for the current distro"
|
||||||
msgstr "Показывать всю информацию, не только для текущего дистрибутива"
|
msgstr "Показывать всю информацию, не только для текущего дистрибутива"
|
||||||
|
|
||||||
#: info.go:69
|
#: info.go:68
|
||||||
msgid "Error getting packages"
|
msgid "Error getting packages"
|
||||||
msgstr "Ошибка при получении пакетов"
|
msgstr "Ошибка при получении пакетов"
|
||||||
|
|
||||||
#: info.go:78
|
#: info.go:76
|
||||||
msgid "Error iterating over packages"
|
msgid "Error iterating over packages"
|
||||||
msgstr "Ошибка при переборе пакетов"
|
msgstr "Ошибка при переборе пакетов"
|
||||||
|
|
||||||
#: info.go:93
|
#: info.go:90
|
||||||
msgid "Command info expected at least 1 argument, got %d"
|
msgid "Command info expected at least 1 argument, got %d"
|
||||||
msgstr "Для команды info ожидался хотя бы 1 аргумент, получено %d"
|
msgstr "Для команды info ожидался хотя бы 1 аргумент, получено %d"
|
||||||
|
|
||||||
#: info.go:113
|
#: info.go:110
|
||||||
msgid "Error finding packages"
|
msgid "Error finding packages"
|
||||||
msgstr "Ошибка при поиске пакетов"
|
msgstr "Ошибка при поиске пакетов"
|
||||||
|
|
||||||
#: info.go:129
|
#: info.go:124
|
||||||
#, fuzzy
|
#, fuzzy
|
||||||
msgid "Can't detect system language"
|
msgid "Can't detect system language"
|
||||||
msgstr "Ошибка при парсинге языка системы"
|
msgstr "Ошибка при парсинге языка системы"
|
||||||
|
|
||||||
#: info.go:148
|
#: info.go:141
|
||||||
msgid "Error resolving overrides"
|
msgid "Error resolving overrides"
|
||||||
msgstr "Ошибка устранения переорпеделений"
|
msgstr "Ошибка устранения переорпеделений"
|
||||||
|
|
||||||
#: info.go:157 info.go:163
|
#: info.go:149 info.go:154
|
||||||
msgid "Error encoding script variables"
|
msgid "Error encoding script variables"
|
||||||
msgstr "Ошибка кодирования переменных скрита"
|
msgstr "Ошибка кодирования переменных скрита"
|
||||||
|
|
||||||
#: install.go:43
|
#: install.go:44
|
||||||
msgid "Install a new package"
|
msgid "Install a new package"
|
||||||
msgstr "Установить новый пакет"
|
msgstr "Установить новый пакет"
|
||||||
|
|
||||||
#: install.go:57
|
#: install.go:58
|
||||||
msgid "Command install expected at least 1 argument, got %d"
|
msgid "Command install expected at least 1 argument, got %d"
|
||||||
msgstr "Для команды install ожидался хотя бы 1 аргумент, получено %d"
|
msgstr "Для команды install ожидался хотя бы 1 аргумент, получено %d"
|
||||||
|
|
||||||
#: install.go:96
|
#: install.go:94
|
||||||
msgid "Error pulling repositories"
|
msgid "Error pulling repositories"
|
||||||
msgstr "Ошибка при извлечении репозиториев"
|
msgstr "Ошибка при извлечении репозиториев"
|
||||||
|
|
||||||
#: install.go:164
|
#: install.go:157
|
||||||
msgid "Remove an installed package"
|
msgid "Remove an installed package"
|
||||||
msgstr "Удалить установленный пакет"
|
msgstr "Удалить установленный пакет"
|
||||||
|
|
||||||
#: install.go:189
|
#: install.go:180
|
||||||
msgid "Error listing installed packages"
|
msgid "Error listing installed packages"
|
||||||
msgstr "Ошибка при составлении списка установленных пакетов"
|
msgstr "Ошибка при составлении списка установленных пакетов"
|
||||||
|
|
||||||
#: install.go:227
|
#: install.go:217
|
||||||
msgid "Command remove expected at least 1 argument, got %d"
|
msgid "Command remove expected at least 1 argument, got %d"
|
||||||
msgstr "Для команды remove ожидался хотя бы 1 аргумент, получено %d"
|
msgstr "Для команды remove ожидался хотя бы 1 аргумент, получено %d"
|
||||||
|
|
||||||
#: install.go:242
|
#: install.go:232
|
||||||
msgid "Error removing packages"
|
msgid "Error removing packages"
|
||||||
msgstr "Ошибка при удалении пакетов"
|
msgstr "Ошибка при удалении пакетов"
|
||||||
|
|
||||||
@ -331,7 +331,7 @@ msgstr "ОШИБКА"
|
|||||||
msgid "You need to be root to perform this action"
|
msgid "You need to be root to perform this action"
|
||||||
msgstr ""
|
msgstr ""
|
||||||
|
|
||||||
#: list.go:40
|
#: list.go:41
|
||||||
msgid "List ALR repo packages"
|
msgid "List ALR repo packages"
|
||||||
msgstr "Список пакетов репозитория ALR"
|
msgstr "Список пакетов репозитория ALR"
|
||||||
|
|
||||||
@ -441,52 +441,52 @@ msgstr ""
|
|||||||
"Минимальная версия ALR для ALR-репозитория выше текущей версии. Попробуйте "
|
"Минимальная версия ALR для ALR-репозитория выше текущей версии. Попробуйте "
|
||||||
"обновить ALR, если что-то не работает."
|
"обновить ALR, если что-то не работает."
|
||||||
|
|
||||||
#: repo.go:42
|
#: repo.go:43
|
||||||
msgid "Add a new repository"
|
msgid "Add a new repository"
|
||||||
msgstr "Добавить новый репозиторий"
|
msgstr "Добавить новый репозиторий"
|
||||||
|
|
||||||
#: repo.go:49
|
#: repo.go:50
|
||||||
msgid "Name of the new repo"
|
msgid "Name of the new repo"
|
||||||
msgstr "Название нового репозитория"
|
msgstr "Название нового репозитория"
|
||||||
|
|
||||||
#: repo.go:55
|
#: repo.go:56
|
||||||
msgid "URL of the new repo"
|
msgid "URL of the new repo"
|
||||||
msgstr "URL-адрес нового репозитория"
|
msgstr "URL-адрес нового репозитория"
|
||||||
|
|
||||||
#: repo.go:93 repo.go:173
|
#: repo.go:93 repo.go:169
|
||||||
#, fuzzy
|
#, fuzzy
|
||||||
msgid "Error saving config"
|
msgid "Error saving config"
|
||||||
msgstr "Ошибка при кодировании конфигурации"
|
msgstr "Ошибка при кодировании конфигурации"
|
||||||
|
|
||||||
#: repo.go:98
|
#: repo.go:97
|
||||||
msgid "Can't drop privileges"
|
msgid "Can't drop privileges"
|
||||||
msgstr ""
|
msgstr ""
|
||||||
|
|
||||||
#: repo.go:105 repo.go:111
|
#: repo.go:104 repo.go:110
|
||||||
msgid "Error pulling repos"
|
msgid "Error pulling repos"
|
||||||
msgstr "Ошибка при извлечении репозиториев"
|
msgstr "Ошибка при извлечении репозиториев"
|
||||||
|
|
||||||
#: repo.go:123
|
#: repo.go:121
|
||||||
msgid "Remove an existing repository"
|
msgid "Remove an existing repository"
|
||||||
msgstr "Удалить существующий репозиторий"
|
msgstr "Удалить существующий репозиторий"
|
||||||
|
|
||||||
#: repo.go:130
|
#: repo.go:128
|
||||||
msgid "Name of the repo to be deleted"
|
msgid "Name of the repo to be deleted"
|
||||||
msgstr "Название репозитория удалён"
|
msgstr "Название репозитория удалён"
|
||||||
|
|
||||||
#: repo.go:159
|
#: repo.go:156
|
||||||
msgid "Repo does not exist"
|
msgid "Repo does not exist"
|
||||||
msgstr "Репозитория не существует"
|
msgstr "Репозитория не существует"
|
||||||
|
|
||||||
#: repo.go:167
|
#: repo.go:164
|
||||||
msgid "Error removing repo directory"
|
msgid "Error removing repo directory"
|
||||||
msgstr "Ошибка при удалении каталога репозитория"
|
msgstr "Ошибка при удалении каталога репозитория"
|
||||||
|
|
||||||
#: repo.go:184
|
#: repo.go:179
|
||||||
msgid "Error removing packages from database"
|
msgid "Error removing packages from database"
|
||||||
msgstr "Ошибка при удалении пакетов из базы данных"
|
msgstr "Ошибка при удалении пакетов из базы данных"
|
||||||
|
|
||||||
#: repo.go:196
|
#: repo.go:190
|
||||||
msgid "Pull all repositories that have changed"
|
msgid "Pull all repositories that have changed"
|
||||||
msgstr "Скачать все изменённые репозитории"
|
msgstr "Скачать все изменённые репозитории"
|
||||||
|
|
||||||
@ -519,23 +519,23 @@ msgstr "Формат выходных данных с использование
|
|||||||
msgid "Error while executing search"
|
msgid "Error while executing search"
|
||||||
msgstr "Ошибка при запуске приложения"
|
msgstr "Ошибка при запуске приложения"
|
||||||
|
|
||||||
#: search.go:105
|
#: search.go:104
|
||||||
msgid "Error parsing format template"
|
msgid "Error parsing format template"
|
||||||
msgstr "Ошибка при разборе шаблона"
|
msgstr "Ошибка при разборе шаблона"
|
||||||
|
|
||||||
#: search.go:114
|
#: search.go:112
|
||||||
msgid "Error executing template"
|
msgid "Error executing template"
|
||||||
msgstr "Ошибка при выполнении шаблона"
|
msgstr "Ошибка при выполнении шаблона"
|
||||||
|
|
||||||
#: upgrade.go:48
|
#: upgrade.go:49
|
||||||
msgid "Upgrade all installed packages"
|
msgid "Upgrade all installed packages"
|
||||||
msgstr "Обновить все установленные пакеты"
|
msgstr "Обновить все установленные пакеты"
|
||||||
|
|
||||||
#: upgrade.go:111 upgrade.go:129
|
#: upgrade.go:107 upgrade.go:124
|
||||||
msgid "Error checking for updates"
|
msgid "Error checking for updates"
|
||||||
msgstr "Ошибка при проверке обновлений"
|
msgstr "Ошибка при проверке обновлений"
|
||||||
|
|
||||||
#: upgrade.go:133
|
#: upgrade.go:127
|
||||||
msgid "There is nothing to do."
|
msgid "There is nothing to do."
|
||||||
msgstr "Здесь нечего делать."
|
msgstr "Здесь нечего делать."
|
||||||
|
|
||||||
|
4
list.go
4
list.go
@ -27,6 +27,7 @@ import (
|
|||||||
"github.com/urfave/cli/v2"
|
"github.com/urfave/cli/v2"
|
||||||
"golang.org/x/exp/slices"
|
"golang.org/x/exp/slices"
|
||||||
|
|
||||||
|
"gitea.plemya-x.ru/Plemya-x/ALR/internal/cliutils"
|
||||||
appbuilder "gitea.plemya-x.ru/Plemya-x/ALR/internal/cliutils/app_builder"
|
appbuilder "gitea.plemya-x.ru/Plemya-x/ALR/internal/cliutils/app_builder"
|
||||||
database "gitea.plemya-x.ru/Plemya-x/ALR/internal/db"
|
database "gitea.plemya-x.ru/Plemya-x/ALR/internal/db"
|
||||||
"gitea.plemya-x.ru/Plemya-x/ALR/internal/utils"
|
"gitea.plemya-x.ru/Plemya-x/ALR/internal/utils"
|
||||||
@ -76,8 +77,7 @@ func ListCmd() *cli.Command {
|
|||||||
|
|
||||||
result, err := db.GetPkgs(ctx, where, args...)
|
result, err := db.GetPkgs(ctx, where, args...)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
slog.Error(gotext.Get("Error getting packages"))
|
return cliutils.FormatCliExit(gotext.Get("Error getting packages"), err)
|
||||||
return cli.Exit(err, 1)
|
|
||||||
}
|
}
|
||||||
defer result.Close()
|
defer result.Close()
|
||||||
|
|
||||||
|
22
repo.go
22
repo.go
@ -28,6 +28,7 @@ import (
|
|||||||
"github.com/urfave/cli/v2"
|
"github.com/urfave/cli/v2"
|
||||||
"golang.org/x/exp/slices"
|
"golang.org/x/exp/slices"
|
||||||
|
|
||||||
|
"gitea.plemya-x.ru/Plemya-x/ALR/internal/cliutils"
|
||||||
appbuilder "gitea.plemya-x.ru/Plemya-x/ALR/internal/cliutils/app_builder"
|
appbuilder "gitea.plemya-x.ru/Plemya-x/ALR/internal/cliutils/app_builder"
|
||||||
"gitea.plemya-x.ru/Plemya-x/ALR/internal/config"
|
"gitea.plemya-x.ru/Plemya-x/ALR/internal/config"
|
||||||
database "gitea.plemya-x.ru/Plemya-x/ALR/internal/db"
|
database "gitea.plemya-x.ru/Plemya-x/ALR/internal/db"
|
||||||
@ -69,8 +70,7 @@ func AddRepoCmd() *cli.Command {
|
|||||||
cfg := config.New()
|
cfg := config.New()
|
||||||
err = cfg.Load()
|
err = cfg.Load()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
slog.Error(gotext.Get("Error loading config"), "err", err)
|
return cliutils.FormatCliExit(gotext.Get("Error loading config"), err)
|
||||||
os.Exit(1)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
reposSlice := cfg.Repos()
|
reposSlice := cfg.Repos()
|
||||||
@ -90,8 +90,7 @@ func AddRepoCmd() *cli.Command {
|
|||||||
|
|
||||||
err = cfg.SaveUserConfig()
|
err = cfg.SaveUserConfig()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
slog.Error(gotext.Get("Error saving config"), "err", err)
|
return cliutils.FormatCliExit(gotext.Get("Error saving config"), err)
|
||||||
os.Exit(1)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if utils.DropCapsToAlrUser() != nil {
|
if utils.DropCapsToAlrUser() != nil {
|
||||||
@ -108,8 +107,7 @@ func AddRepoCmd() *cli.Command {
|
|||||||
rs := repos.New(cfg, db)
|
rs := repos.New(cfg, db)
|
||||||
err = rs.Pull(ctx, cfg.Repos())
|
err = rs.Pull(ctx, cfg.Repos())
|
||||||
if err != nil {
|
if err != nil {
|
||||||
slog.Error(gotext.Get("Error pulling repos"), "err", err)
|
return cliutils.FormatCliExit(gotext.Get("Error pulling repos"), err)
|
||||||
os.Exit(1)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return nil
|
return nil
|
||||||
@ -142,8 +140,7 @@ func RemoveRepoCmd() *cli.Command {
|
|||||||
cfg := config.New()
|
cfg := config.New()
|
||||||
err = cfg.Load()
|
err = cfg.Load()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
slog.Error(gotext.Get("Error loading config"), "err", err)
|
return cliutils.FormatCliExit(gotext.Get("Error loading config"), err)
|
||||||
os.Exit(1)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
found := false
|
found := false
|
||||||
@ -164,14 +161,12 @@ func RemoveRepoCmd() *cli.Command {
|
|||||||
|
|
||||||
err = os.RemoveAll(filepath.Join(cfg.GetPaths().RepoDir, name))
|
err = os.RemoveAll(filepath.Join(cfg.GetPaths().RepoDir, name))
|
||||||
if err != nil {
|
if err != nil {
|
||||||
slog.Error(gotext.Get("Error removing repo directory"), "err", err)
|
return cliutils.FormatCliExit(gotext.Get("Error removing repo directory"), err)
|
||||||
os.Exit(1)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
err = cfg.SaveUserConfig()
|
err = cfg.SaveUserConfig()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
slog.Error(gotext.Get("Error saving config"), "err", err)
|
return cliutils.FormatCliExit(gotext.Get("Error saving config"), err)
|
||||||
os.Exit(1)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
db := database.New(cfg)
|
db := database.New(cfg)
|
||||||
@ -181,8 +176,7 @@ func RemoveRepoCmd() *cli.Command {
|
|||||||
}
|
}
|
||||||
err = db.DeletePkgs(ctx, "repository = ?", name)
|
err = db.DeletePkgs(ctx, "repository = ?", name)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
slog.Error(gotext.Get("Error removing packages from database"), "err", err)
|
return cliutils.FormatCliExit(gotext.Get("Error removing packages from database"), err)
|
||||||
os.Exit(1)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return nil
|
return nil
|
||||||
|
11
search.go
11
search.go
@ -18,13 +18,13 @@ package main
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
"fmt"
|
"fmt"
|
||||||
"log/slog"
|
|
||||||
"os"
|
"os"
|
||||||
"text/template"
|
"text/template"
|
||||||
|
|
||||||
"github.com/leonelquinteros/gotext"
|
"github.com/leonelquinteros/gotext"
|
||||||
"github.com/urfave/cli/v2"
|
"github.com/urfave/cli/v2"
|
||||||
|
|
||||||
|
"gitea.plemya-x.ru/Plemya-x/ALR/internal/cliutils"
|
||||||
appbuilder "gitea.plemya-x.ru/Plemya-x/ALR/internal/cliutils/app_builder"
|
appbuilder "gitea.plemya-x.ru/Plemya-x/ALR/internal/cliutils/app_builder"
|
||||||
"gitea.plemya-x.ru/Plemya-x/ALR/internal/utils"
|
"gitea.plemya-x.ru/Plemya-x/ALR/internal/utils"
|
||||||
"gitea.plemya-x.ru/Plemya-x/ALR/pkg/search"
|
"gitea.plemya-x.ru/Plemya-x/ALR/pkg/search"
|
||||||
@ -93,8 +93,7 @@ func SearchCmd() *cli.Command {
|
|||||||
Build(),
|
Build(),
|
||||||
)
|
)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
slog.Error(gotext.Get("Error while executing search"))
|
return cliutils.FormatCliExit(gotext.Get("Error while executing search"), err)
|
||||||
return cli.Exit(err, 1)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
format := c.String("format")
|
format := c.String("format")
|
||||||
@ -102,8 +101,7 @@ func SearchCmd() *cli.Command {
|
|||||||
if format != "" {
|
if format != "" {
|
||||||
tmpl, err = template.New("format").Parse(format)
|
tmpl, err = template.New("format").Parse(format)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
slog.Error(gotext.Get("Error parsing format template"))
|
return cliutils.FormatCliExit(gotext.Get("Error parsing format template"), err)
|
||||||
return cli.Exit(err, 1)
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -111,8 +109,7 @@ func SearchCmd() *cli.Command {
|
|||||||
if tmpl != nil {
|
if tmpl != nil {
|
||||||
err = tmpl.Execute(os.Stdout, dbPkg)
|
err = tmpl.Execute(os.Stdout, dbPkg)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
slog.Error(gotext.Get("Error executing template"))
|
return cliutils.FormatCliExit(gotext.Get("Error executing template"), err)
|
||||||
return cli.Exit(err, 1)
|
|
||||||
}
|
}
|
||||||
fmt.Println()
|
fmt.Println()
|
||||||
} else {
|
} else {
|
||||||
|
22
upgrade.go
22
upgrade.go
@ -30,6 +30,7 @@ import (
|
|||||||
"go.elara.ws/vercmp"
|
"go.elara.ws/vercmp"
|
||||||
"golang.org/x/exp/maps"
|
"golang.org/x/exp/maps"
|
||||||
|
|
||||||
|
"gitea.plemya-x.ru/Plemya-x/ALR/internal/cliutils"
|
||||||
"gitea.plemya-x.ru/Plemya-x/ALR/internal/config"
|
"gitea.plemya-x.ru/Plemya-x/ALR/internal/config"
|
||||||
database "gitea.plemya-x.ru/Plemya-x/ALR/internal/db"
|
database "gitea.plemya-x.ru/Plemya-x/ALR/internal/db"
|
||||||
"gitea.plemya-x.ru/Plemya-x/ALR/internal/overrides"
|
"gitea.plemya-x.ru/Plemya-x/ALR/internal/overrides"
|
||||||
@ -57,8 +58,7 @@ func UpgradeCmd() *cli.Command {
|
|||||||
Action: func(c *cli.Context) error {
|
Action: func(c *cli.Context) error {
|
||||||
err := utils.DropCapsToAlrUser()
|
err := utils.DropCapsToAlrUser()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
slog.Error(gotext.Get("Error dropping capabilities"), "err", err)
|
return cliutils.FormatCliExit(gotext.Get("Error dropping capabilities"), err)
|
||||||
os.Exit(1)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
ctx := c.Context
|
ctx := c.Context
|
||||||
@ -66,16 +66,14 @@ func UpgradeCmd() *cli.Command {
|
|||||||
cfg := config.New()
|
cfg := config.New()
|
||||||
err = cfg.Load()
|
err = cfg.Load()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
slog.Error(gotext.Get("Error loading config"), "err", err)
|
return cliutils.FormatCliExit(gotext.Get("Error loading config"), err)
|
||||||
os.Exit(1)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
db := database.New(cfg)
|
db := database.New(cfg)
|
||||||
rs := repos.New(cfg, db)
|
rs := repos.New(cfg, db)
|
||||||
err = db.Init(ctx)
|
err = db.Init(ctx)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
slog.Error(gotext.Get("Error initialization database"), "err", err)
|
return cliutils.FormatCliExit(gotext.Get("Error initialization database"), err)
|
||||||
os.Exit(1)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
slog.Debug("builder setup")
|
slog.Debug("builder setup")
|
||||||
@ -87,8 +85,7 @@ func UpgradeCmd() *cli.Command {
|
|||||||
info, err := distro.ParseOSRelease(ctx)
|
info, err := distro.ParseOSRelease(ctx)
|
||||||
slog.Debug("ParseOSRelease", "err", err)
|
slog.Debug("ParseOSRelease", "err", err)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
slog.Error(gotext.Get("Error parsing os-release file"), "err", err)
|
return cliutils.FormatCliExit(gotext.Get("Error parsing os-release file"), err)
|
||||||
os.Exit(1)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
mgr := manager.Detect()
|
mgr := manager.Detect()
|
||||||
@ -101,15 +98,13 @@ func UpgradeCmd() *cli.Command {
|
|||||||
slog.Debug("autopull")
|
slog.Debug("autopull")
|
||||||
err = rs.Pull(ctx, cfg.Repos())
|
err = rs.Pull(ctx, cfg.Repos())
|
||||||
if err != nil {
|
if err != nil {
|
||||||
slog.Error(gotext.Get("Error pulling repos"), "err", err)
|
return cliutils.FormatCliExit(gotext.Get("Error pulling repos"), err)
|
||||||
os.Exit(1)
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
updates, err := checkForUpdates(ctx, mgr, cfg, db, rs, info)
|
updates, err := checkForUpdates(ctx, mgr, cfg, db, rs, info)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
slog.Error(gotext.Get("Error checking for updates"), "err", err)
|
return cliutils.FormatCliExit(gotext.Get("Error checking for updates"), err)
|
||||||
os.Exit(1)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if len(updates) > 0 {
|
if len(updates) > 0 {
|
||||||
@ -126,8 +121,7 @@ func UpgradeCmd() *cli.Command {
|
|||||||
updates,
|
updates,
|
||||||
)
|
)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
slog.Error(gotext.Get("Error checking for updates"), "err", err)
|
return cliutils.FormatCliExit(gotext.Get("Error checking for updates"), err)
|
||||||
os.Exit(1)
|
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
slog.Info(gotext.Get("There is nothing to do."))
|
slog.Info(gotext.Get("There is nothing to do."))
|
||||||
|
Loading…
Reference in New Issue
Block a user