forked from Plemya-x/ALR
Compare commits
6 Commits
fix/migrat
...
master
Author | SHA1 | Date | |
---|---|---|---|
4463a32ae7 | |||
|
52fd4a5a00 | ||
c437346957 | |||
bf1fc0d878 | |||
|
c3f879b379 | ||
aa90dfa983 |
24
build.go
24
build.go
@ -61,19 +61,27 @@ func BuildCmd() *cli.Command {
|
||||
ctx := c.Context
|
||||
|
||||
var script string
|
||||
packageInput := c.String("package")
|
||||
|
||||
if packageInput != "" {
|
||||
// If the package input contains a '/', use it as the full path.
|
||||
// Проверяем, установлен ли флаг script (-s)
|
||||
if c.IsSet("script") {
|
||||
script = c.String("script")
|
||||
} else if c.IsSet("package") {
|
||||
// Если флаг script не установлен, проверяем флаг package (-p)
|
||||
packageInput := c.String("package")
|
||||
// Определяем, содержит ли packageInput символ '/'
|
||||
if filepath.Dir(packageInput) == "." {
|
||||
// No directory specified, use 'default' as a prefix.
|
||||
// Не указана директория репозитория, используем 'default' как префикс
|
||||
script = filepath.Join(config.GetPaths(ctx).RepoDir, "default", packageInput, "alr.sh")
|
||||
} else {
|
||||
// Use the full path specified by the user.
|
||||
// Используем путь с указанным репозиторием
|
||||
script = filepath.Join(config.GetPaths(ctx).RepoDir, packageInput, "alr.sh")
|
||||
}
|
||||
} else {
|
||||
// Ни флаги script, ни package не установлены, используем дефолтный скрипт
|
||||
script = filepath.Join(config.GetPaths(ctx).RepoDir, "alr.sh")
|
||||
}
|
||||
|
||||
// Проверка автоматического пулла репозиториев
|
||||
if config.GetInstance(ctx).AutoPull(ctx) {
|
||||
err := repos.Pull(ctx, config.Config(ctx).Repos)
|
||||
if err != nil {
|
||||
@ -82,12 +90,14 @@ func BuildCmd() *cli.Command {
|
||||
}
|
||||
}
|
||||
|
||||
// Обнаружение менеджера пакетов
|
||||
mgr := manager.Detect()
|
||||
if mgr == nil {
|
||||
slog.Error(gotext.Get("Unable to detect a supported package manager on the system"))
|
||||
os.Exit(1)
|
||||
}
|
||||
|
||||
// Сборка пакета
|
||||
pkgPaths, _, err := build.BuildPackage(ctx, types.BuildOpts{
|
||||
Script: script,
|
||||
Manager: mgr,
|
||||
@ -99,12 +109,14 @@ func BuildCmd() *cli.Command {
|
||||
os.Exit(1)
|
||||
}
|
||||
|
||||
// Получение текущей рабочей директории
|
||||
wd, err := os.Getwd()
|
||||
if err != nil {
|
||||
slog.Error(gotext.Get("Error getting working directory"), "err", err)
|
||||
os.Exit(1)
|
||||
}
|
||||
|
||||
// Перемещение собранных пакетов в рабочую директорию
|
||||
for _, pkgPath := range pkgPaths {
|
||||
name := filepath.Base(pkgPath)
|
||||
err = osutils.Move(pkgPath, filepath.Join(wd, name))
|
||||
@ -117,4 +129,4 @@ func BuildCmd() *cli.Command {
|
||||
return nil
|
||||
},
|
||||
}
|
||||
}
|
||||
}
|
1
go.mod
1
go.mod
@ -73,6 +73,7 @@ require (
|
||||
github.com/golang/groupcache v0.0.0-20210331224755-41bb18bfe9da // indirect
|
||||
github.com/golang/snappy v0.0.4 // indirect
|
||||
github.com/google/rpmpack v0.6.1-0.20240329070804-c2247cbb881a // indirect
|
||||
github.com/google/shlex v0.0.0-20191202100458-e7afc7fbc510 // indirect
|
||||
github.com/google/uuid v1.4.0 // indirect
|
||||
github.com/goreleaser/chglog v0.6.1 // indirect
|
||||
github.com/goreleaser/fileglob v1.3.0 // indirect
|
||||
|
2
go.sum
2
go.sum
@ -196,6 +196,8 @@ github.com/google/pprof v0.0.0-20221118152302-e6195bd50e26/go.mod h1:dDKJzRmX4S3
|
||||
github.com/google/renameio v0.1.0/go.mod h1:KWCgfxg9yswjAJkECMjeO8J8rahYeXnNhOm40UhjYkI=
|
||||
github.com/google/rpmpack v0.6.1-0.20240329070804-c2247cbb881a h1:JJBdjSfqSy3mnDT0940ASQFghwcZ4y4cb6ttjAoXqwE=
|
||||
github.com/google/rpmpack v0.6.1-0.20240329070804-c2247cbb881a/go.mod h1:uqVAUVQLq8UY2hCDfmJ/+rtO3aw7qyhc90rCVEabEfI=
|
||||
github.com/google/shlex v0.0.0-20191202100458-e7afc7fbc510 h1:El6M4kTTCOh6aBiKaUGG7oYTSPP8MxqL4YI3kZKwcP4=
|
||||
github.com/google/shlex v0.0.0-20191202100458-e7afc7fbc510/go.mod h1:pupxD2MaaD3pAXIBCelhxNneeOaAeabZDe5s4K6zSpQ=
|
||||
github.com/google/uuid v1.1.1/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo=
|
||||
github.com/google/uuid v1.4.0 h1:MtMxsa51/r9yyhkyLsVeVt0B+BGQZzpQiTQ4eHZ8bc4=
|
||||
github.com/google/uuid v1.4.0/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo=
|
||||
|
@ -68,6 +68,7 @@ func (m model) Update(msg tea.Msg) (tea.Model, tea.Cmd) {
|
||||
m.remaining = time.Duration(msg.remaining) * time.Second
|
||||
if m.percent >= 1.0 {
|
||||
m.done = true
|
||||
return m, tea.Quit
|
||||
}
|
||||
return m, nil
|
||||
case tea.WindowSizeMsg:
|
||||
|
@ -251,11 +251,11 @@ msgstr ""
|
||||
msgid "Downloading source"
|
||||
msgstr ""
|
||||
|
||||
#: internal/dl/progress_tui.go:99
|
||||
#: internal/dl/progress_tui.go:100
|
||||
msgid "%s: done!\n"
|
||||
msgstr ""
|
||||
|
||||
#: internal/dl/progress_tui.go:103
|
||||
#: internal/dl/progress_tui.go:104
|
||||
msgid "%s %s downloading at %s/s\n"
|
||||
msgstr ""
|
||||
|
||||
|
@ -263,11 +263,11 @@ msgstr "Источник обновлён и связан с пунктом на
|
||||
msgid "Downloading source"
|
||||
msgstr "Скачивание источника"
|
||||
|
||||
#: internal/dl/progress_tui.go:99
|
||||
#: internal/dl/progress_tui.go:100
|
||||
msgid "%s: done!\n"
|
||||
msgstr ""
|
||||
|
||||
#: internal/dl/progress_tui.go:103
|
||||
#: internal/dl/progress_tui.go:104
|
||||
msgid "%s %s downloading at %s/s\n"
|
||||
msgstr ""
|
||||
|
||||
|
@ -36,6 +36,7 @@ import (
|
||||
|
||||
// Импортируем пакеты для поддержки различных форматов пакетов (APK, DEB, RPM и ARCH).
|
||||
|
||||
"github.com/google/shlex"
|
||||
_ "github.com/goreleaser/nfpm/v2/apk"
|
||||
_ "github.com/goreleaser/nfpm/v2/arch"
|
||||
_ "github.com/goreleaser/nfpm/v2/deb"
|
||||
@ -43,7 +44,6 @@ import (
|
||||
"github.com/leonelquinteros/gotext"
|
||||
"mvdan.cc/sh/v3/expand"
|
||||
"mvdan.cc/sh/v3/interp"
|
||||
"mvdan.cc/sh/v3/shell"
|
||||
"mvdan.cc/sh/v3/syntax"
|
||||
|
||||
"github.com/goreleaser/nfpm/v2"
|
||||
@ -537,7 +537,7 @@ func executeFunctions(ctx context.Context, dec *decoder.Decoder, dirs types.Dire
|
||||
return nil, err
|
||||
}
|
||||
|
||||
contents, err := shell.Fields(buf.String(), func(s string) string { return "" })
|
||||
contents, err := shlex.Split(buf.String())
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user