forked from Plemya-x/ALR
Compare commits
8 Commits
v0.0.3
...
3f428ab7b5
Author | SHA1 | Date | |
---|---|---|---|
3f428ab7b5 | |||
5b7af1f6b5 | |||
3224d7c6e4 | |||
5d1d3d7c45 | |||
a711edbcc0 | |||
d5636e8094 | |||
5d17875813 | |||
41eec2fc98 |
30
.golangci.yml
Normal file
30
.golangci.yml
Normal file
@@ -0,0 +1,30 @@
|
||||
run:
|
||||
timeout: 5m
|
||||
|
||||
linters-settings:
|
||||
goimports:
|
||||
local-prefixes: "plemya-x.ru/alr"
|
||||
gofmt:
|
||||
simplify: true
|
||||
gofumpt:
|
||||
extra-rules: true
|
||||
|
||||
linters:
|
||||
enable:
|
||||
- gofmt
|
||||
- gofumpt
|
||||
- goimports
|
||||
- gocritic
|
||||
- govet
|
||||
- staticcheck
|
||||
- unused
|
||||
- errcheck
|
||||
- typecheck
|
||||
# - forbidigo
|
||||
|
||||
issues:
|
||||
fix: true
|
||||
exclude-rules:
|
||||
- path: _test\.go
|
||||
linters:
|
||||
- errcheck
|
12
Makefile
12
Makefile
@@ -11,6 +11,9 @@ ZSH_COMPLETION := $(COMPLETIONS_DIR)/zsh
|
||||
INSTALLED_BASH_COMPLETION := $(DESTDIR)$(PREFIX)/share/bash-completion/completions/$(NAME)
|
||||
INSTALLED_ZSH_COMPLETION := $(DESTDIR)$(PREFIX)/share/zsh/site-functions/_$(NAME)
|
||||
|
||||
ADD_LICENSE_BIN := go run github.com/google/addlicense@4caba19b7ed7818bb86bc4cd20411a246aa4a524
|
||||
GOLANGCI_LINT_BIN := go run github.com/golangci/golangci-lint/cmd/golangci-lint@v1.62.2
|
||||
|
||||
.PHONY: build install clean clear uninstall check-no-root
|
||||
|
||||
build: check-no-root $(BIN)
|
||||
@@ -48,3 +51,12 @@ uninstall:
|
||||
|
||||
clean clear:
|
||||
rm -f $(BIN)
|
||||
|
||||
OLD_FILES=$$(< old-files)
|
||||
IGNORE_OLD_FILES := $(foreach file,$(shell cat old-files),-ignore $(file))
|
||||
update-license:
|
||||
$(ADD_LICENSE_BIN) -v -f license-header-old-files.tmpl $(OLD_FILES)
|
||||
$(ADD_LICENSE_BIN) -v -f license-header.tmpl $(IGNORE_OLD_FILES) .
|
||||
|
||||
fmt:
|
||||
$(GOLANGCI_LINT_BIN) run --fix
|
||||
|
@@ -222,7 +222,7 @@ func extractFile(r io.Reader, format archiver.Format, name string, opts Options)
|
||||
}
|
||||
|
||||
if f.IsDir() {
|
||||
err = os.Mkdir(path, 0o755)
|
||||
err = os.MkdirAll(path, 0o755)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
18
license-header-old-files.tmpl
Normal file
18
license-header-old-files.tmpl
Normal file
@@ -0,0 +1,18 @@
|
||||
This file was originally part of the project "LURE - Linux User REpository", created by Elara Musayelyan.
|
||||
It has been modified as part of "ALR - Any Linux Repository" by Евгений Храмов.
|
||||
|
||||
ALR - Any Linux Repository
|
||||
Copyright (C) {{ .Year }} Евгений Храмов
|
||||
|
||||
This program is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation, either version 3 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
15
license-header.tmpl
Normal file
15
license-header.tmpl
Normal file
@@ -0,0 +1,15 @@
|
||||
ALR - Any Linux Repository
|
||||
Copyright (C) {{ .Year }} Евгений Храмов
|
||||
|
||||
This program is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation, either version 3 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
83
old-files
Normal file
83
old-files
Normal file
@@ -0,0 +1,83 @@
|
||||
./.github/FUNDING.yml
|
||||
./.gitignore
|
||||
./.goreleaser.yaml
|
||||
./.woodpecker.yml
|
||||
./LICENSE
|
||||
./Makefile
|
||||
./README.md
|
||||
./assets/logo.png
|
||||
./build.go
|
||||
./docs/README.md
|
||||
./docs/configuration.md
|
||||
./docs/packages/README.md
|
||||
./docs/packages/adding-packages.md
|
||||
./docs/packages/build-scripts.md
|
||||
./docs/packages/conventions.md
|
||||
./docs/usage.md
|
||||
./fix.go
|
||||
./gen.go
|
||||
./go.mod
|
||||
./go.sum
|
||||
./helper.go
|
||||
./info.go
|
||||
./install.go
|
||||
./internal/cliutils/prompt.go
|
||||
./internal/config/config.go
|
||||
./internal/config/lang.go
|
||||
./internal/config/paths.go
|
||||
./internal/config/version.go
|
||||
./internal/cpu/cpu.go
|
||||
./internal/db/db.go
|
||||
./internal/db/db_test.go
|
||||
./internal/dl/dl.go
|
||||
./internal/dl/file.go
|
||||
./internal/dl/git.go
|
||||
./internal/dl/torrent.go
|
||||
./internal/dlcache/dlcache.go
|
||||
./internal/dlcache/dlcache_test.go
|
||||
./internal/osutils/move.go
|
||||
./internal/overrides/overrides.go
|
||||
./internal/overrides/overrides_test.go
|
||||
./internal/pager/highlighting.go
|
||||
./internal/pager/pager.go
|
||||
./internal/shutils/decoder/decoder.go
|
||||
./internal/shutils/decoder/decoder_test.go
|
||||
./internal/shutils/handlers/exec.go
|
||||
./internal/shutils/handlers/exec_test.go
|
||||
./internal/shutils/handlers/fakeroot.go
|
||||
./internal/shutils/handlers/nop.go
|
||||
./internal/shutils/handlers/nop_test.go
|
||||
./internal/shutils/handlers/restricted.go
|
||||
./internal/shutils/helpers/helpers.go
|
||||
./internal/translations/files/lure.en.toml
|
||||
./internal/translations/files/lure.ru.toml
|
||||
./internal/translations/translations.go
|
||||
./internal/types/build.go
|
||||
./internal/types/config.go
|
||||
./internal/types/repo.go
|
||||
./list.go
|
||||
./main.go
|
||||
./pkg/build/build.go
|
||||
./pkg/build/install.go
|
||||
./pkg/distro/osrelease.go
|
||||
./pkg/gen/funcs.go
|
||||
./pkg/gen/pip.go
|
||||
./pkg/gen/tmpls/pip.tmpl.sh
|
||||
./pkg/loggerctx/log.go
|
||||
./pkg/manager/apk.go
|
||||
./pkg/manager/apt.go
|
||||
./pkg/manager/dnf.go
|
||||
./pkg/manager/managers.go
|
||||
./pkg/manager/pacman.go
|
||||
./pkg/manager/yum.go
|
||||
./pkg/manager/zypper.go
|
||||
./pkg/repos/find.go
|
||||
./pkg/repos/find_test.go
|
||||
./pkg/repos/pull.go
|
||||
./pkg/repos/pull_test.go
|
||||
./pkg/search/search.go
|
||||
./repo.go
|
||||
./scripts/completion/bash
|
||||
./scripts/completion/zsh
|
||||
./scripts/install.sh
|
||||
./upgrade.go
|
@@ -170,7 +170,7 @@ func BuildPackage(ctx context.Context, opts types.BuildOpts) ([]string, []string
|
||||
|
||||
pkgFormat := getPkgFormat(opts.Manager) // Получаем формат пакета
|
||||
|
||||
pkgInfo, err := buildPkgMetadata(vars, dirs, pkgFormat, info, append(repoDeps, builtNames...)) // Собираем метаданные пакета
|
||||
pkgInfo, err := buildPkgMetadata(ctx, vars, dirs, pkgFormat, info, append(repoDeps, builtNames...)) // Собираем метаданные пакета
|
||||
if err != nil {
|
||||
return nil, nil, err
|
||||
}
|
||||
@@ -502,7 +502,7 @@ func executeFunctions(ctx context.Context, dec *decoder.Decoder, dirs types.Dire
|
||||
}
|
||||
|
||||
// Функция buildPkgMetadata создает метаданные для пакета, который будет собран.
|
||||
func buildPkgMetadata(vars *types.BuildVars, dirs types.Directories, pkgFormat string, info *distro.OSRelease, deps []string) (*nfpm.Info, error) {
|
||||
func buildPkgMetadata(ctx context.Context, vars *types.BuildVars, dirs types.Directories, pkgFormat string, info *distro.OSRelease, deps []string) (*nfpm.Info, error) {
|
||||
pkgInfo := getBasePkgInfo(vars)
|
||||
pkgInfo.Description = vars.Description
|
||||
pkgInfo.Platform = "linux"
|
||||
@@ -543,6 +543,17 @@ func buildPkgMetadata(vars *types.BuildVars, dirs types.Directories, pkgFormat s
|
||||
}
|
||||
pkgInfo.Overridables.Contents = contents
|
||||
|
||||
if pkgFormat == "rpm" {
|
||||
err = rpmFindProvides(ctx, pkgInfo, dirs)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
err = rpmFindRequires(ctx, pkgInfo, dirs)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
}
|
||||
|
||||
return pkgInfo, nil
|
||||
}
|
||||
|
||||
|
80
pkg/build/findDeps.go
Normal file
80
pkg/build/findDeps.go
Normal file
@@ -0,0 +1,80 @@
|
||||
package build
|
||||
|
||||
import (
|
||||
"bytes"
|
||||
"context"
|
||||
"os/exec"
|
||||
"path"
|
||||
"strings"
|
||||
|
||||
"github.com/goreleaser/nfpm/v2"
|
||||
"plemya-x.ru/alr/internal/types"
|
||||
"plemya-x.ru/alr/pkg/loggerctx"
|
||||
)
|
||||
|
||||
func rpmFindDependencies(ctx context.Context, pkgInfo *nfpm.Info, dirs types.Directories, command string, updateFunc func(string)) error {
|
||||
log := loggerctx.From(ctx)
|
||||
|
||||
if _, err := exec.LookPath(command); err != nil {
|
||||
log.Info("Command not found on the system").Str("command", command).Send()
|
||||
return nil
|
||||
}
|
||||
|
||||
var paths []string
|
||||
for _, content := range pkgInfo.Contents {
|
||||
if content.Type != "dir" {
|
||||
paths = append(paths,
|
||||
path.Join(dirs.PkgDir, content.Destination),
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
if len(paths) == 0 {
|
||||
return nil
|
||||
}
|
||||
|
||||
cmd := exec.Command(command)
|
||||
cmd.Stdin = bytes.NewBufferString(strings.Join(paths, "\n"))
|
||||
cmd.Env = append(cmd.Env,
|
||||
"RPM_BUILD_ROOT="+dirs.PkgDir,
|
||||
"RPM_FINDPROV_METHOD=",
|
||||
"RPM_FINDREQ_METHOD=",
|
||||
"RPM_DATADIR=",
|
||||
"RPM_SUBPACKAGE_NAME=",
|
||||
)
|
||||
var out bytes.Buffer
|
||||
var stderr bytes.Buffer
|
||||
cmd.Stdout = &out
|
||||
cmd.Stderr = &stderr
|
||||
if err := cmd.Run(); err != nil {
|
||||
log.Error(stderr.String())
|
||||
return err
|
||||
}
|
||||
|
||||
dependencies := strings.Split(strings.TrimSpace(out.String()), "\n")
|
||||
for _, dep := range dependencies {
|
||||
if dep != "" {
|
||||
updateFunc(dep)
|
||||
}
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
func rpmFindProvides(ctx context.Context, pkgInfo *nfpm.Info, dirs types.Directories) error {
|
||||
log := loggerctx.From(ctx)
|
||||
|
||||
return rpmFindDependencies(ctx, pkgInfo, dirs, "/usr/lib/rpm/find-provides", func(dep string) {
|
||||
log.Info("Provided dependency found").Str("dep", dep).Send()
|
||||
pkgInfo.Overridables.Provides = append(pkgInfo.Overridables.Provides, dep)
|
||||
})
|
||||
}
|
||||
|
||||
func rpmFindRequires(ctx context.Context, pkgInfo *nfpm.Info, dirs types.Directories) error {
|
||||
log := loggerctx.From(ctx)
|
||||
|
||||
return rpmFindDependencies(ctx, pkgInfo, dirs, "/usr/lib/rpm/find-requires", func(dep string) {
|
||||
log.Info("Required dependency found").Str("dep", dep).Send()
|
||||
pkgInfo.Overridables.Depends = append(pkgInfo.Overridables.Depends, dep)
|
||||
})
|
||||
}
|
Reference in New Issue
Block a user