alr изменения

This commit is contained in:
2024-05-05 13:32:08 +03:00
parent b94c39ccff
commit d427b37e23
73 changed files with 411 additions and 1213 deletions

View File

@ -1,6 +1,6 @@
/*
* LURE - Linux User REpository
* Copyright (C) 2023 Elara Musayelyan
* ALR - Any Linux Repository
* Copyright (C) 2024 Евгений Храмов
*
* 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
@ -39,19 +39,19 @@ import (
"github.com/goreleaser/nfpm/v2"
"github.com/goreleaser/nfpm/v2/files"
"lure.sh/lure/internal/cliutils"
"lure.sh/lure/internal/config"
"lure.sh/lure/internal/cpu"
"lure.sh/lure/internal/db"
"lure.sh/lure/internal/dl"
"lure.sh/lure/internal/shutils/decoder"
"lure.sh/lure/internal/shutils/handlers"
"lure.sh/lure/internal/shutils/helpers"
"lure.sh/lure/internal/types"
"lure.sh/lure/pkg/distro"
"lure.sh/lure/pkg/loggerctx"
"lure.sh/lure/pkg/manager"
"lure.sh/lure/pkg/repos"
"plemya-x.ru/alr/internal/cliutils"
"plemya-x.ru/alr/internal/config"
"plemya-x.ru/alr/internal/cpu"
"plemya-x.ru/alr/internal/db"
"plemya-x.ru/alr/internal/dl"
"plemya-x.ru/alr/internal/shutils/decoder"
"plemya-x.ru/alr/internal/shutils/handlers"
"plemya-x.ru/alr/internal/shutils/helpers"
"plemya-x.ru/alr/internal/types"
"plemya-x.ru/alr/pkg/distro"
"plemya-x.ru/alr/pkg/loggerctx"
"plemya-x.ru/alr/pkg/manager"
"plemya-x.ru/alr/pkg/repos"
"mvdan.cc/sh/v3/expand"
"mvdan.cc/sh/v3/interp"
"mvdan.cc/sh/v3/syntax"
@ -140,7 +140,7 @@ func BuildPackage(ctx context.Context, opts types.BuildOpts) ([]string, []string
return nil, nil, err
}
builtPaths, builtNames, repoDeps, err := buildLUREDeps(ctx, opts, vars)
builtPaths, builtNames, repoDeps, err := buildALRDeps(ctx, opts, vars)
if err != nil {
return nil, nil, err
}
@ -213,7 +213,7 @@ func parseScript(info *distro.OSRelease, script string) (*syntax.File, error) {
}
defer fl.Close()
file, err := syntax.NewParser().Parse(fl, "lure.sh")
file, err := syntax.NewParser().Parse(fl, "alr.sh")
if err != nil {
return nil, err
}
@ -373,10 +373,10 @@ func installOptDeps(ctx context.Context, vars *types.BuildVars, opts types.Build
return nil
}
// buildLUREDeps builds all the LURE dependencies of the package. It returns the paths and names
// of the packages it built, as well as all the dependencies it didn't find in the LURE repo so
// buildALRDeps builds all the ALR dependencies of the package. It returns the paths and names
// of the packages it built, as well as all the dependencies it didn't find in the ALR repo so
// they can be installed from the system repos.
func buildLUREDeps(ctx context.Context, opts types.BuildOpts, vars *types.BuildVars) (builtPaths, builtNames, repoDeps []string, err error) {
func buildALRDeps(ctx context.Context, opts types.BuildOpts, vars *types.BuildVars) (builtPaths, builtNames, repoDeps []string, err error) {
log := loggerctx.From(ctx)
if len(vars.Depends) > 0 {
log.Info("Installing dependencies").Send()
@ -417,7 +417,7 @@ func buildLUREDeps(ctx context.Context, opts types.BuildOpts, vars *types.BuildV
return builtPaths, builtNames, repoDeps, nil
}
// executeFunctions executes the special LURE functions, such as version(), prepare(), etc.
// executeFunctions executes the special ALR functions, such as version(), prepare(), etc.
func executeFunctions(ctx context.Context, dec *decoder.Decoder, dirs types.Directories, vars *types.BuildVars) (err error) {
log := loggerctx.From(ctx)
version, ok := dec.GetFunc("version")
@ -663,10 +663,10 @@ func pkgFileName(vars *types.BuildVars, pkgFormat string) (string, error) {
}
// getPkgFormat returns the package format of the package manager,
// or LURE_PKG_FORMAT if that's set.
// or ALR_PKG_FORMAT if that's set.
func getPkgFormat(mgr manager.Manager) string {
pkgFormat := mgr.Format()
if format, ok := os.LookupEnv("LURE_PKG_FORMAT"); ok {
if format, ok := os.LookupEnv("ALR_PKG_FORMAT"); ok {
pkgFormat = format
}
return pkgFormat

View File

@ -1,6 +1,6 @@
/*
* LURE - Linux User REpository
* Copyright (C) 2023 Elara Musayelyan
* ALR - Any Linux Repository
* Copyright (C) 2024 Евгений Храмов
*
* 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
@ -22,15 +22,15 @@ import (
"context"
"path/filepath"
"lure.sh/lure/internal/config"
"lure.sh/lure/internal/db"
"lure.sh/lure/internal/types"
"lure.sh/lure/pkg/loggerctx"
"plemya-x.ru/alr/internal/config"
"plemya-x.ru/alr/internal/db"
"plemya-x.ru/alr/internal/types"
"plemya-x.ru/alr/pkg/loggerctx"
)
// InstallPkgs installs native packages via the package manager,
// then builds and installs the LURE packages
func InstallPkgs(ctx context.Context, lurePkgs []db.Package, nativePkgs []string, opts types.BuildOpts) {
// then builds and installs the ALR packages
func InstallPkgs(ctx context.Context, alrPkgs []db.Package, nativePkgs []string, opts types.BuildOpts) {
log := loggerctx.From(ctx)
if len(nativePkgs) > 0 {
@ -40,7 +40,7 @@ func InstallPkgs(ctx context.Context, lurePkgs []db.Package, nativePkgs []string
}
}
InstallScripts(ctx, GetScriptPaths(ctx, lurePkgs), opts)
InstallScripts(ctx, GetScriptPaths(ctx, alrPkgs), opts)
}
// GetScriptPaths returns a slice of script paths corresponding to the
@ -48,13 +48,13 @@ func InstallPkgs(ctx context.Context, lurePkgs []db.Package, nativePkgs []string
func GetScriptPaths(ctx context.Context, pkgs []db.Package) []string {
var scripts []string
for _, pkg := range pkgs {
scriptPath := filepath.Join(config.GetPaths(ctx).RepoDir, pkg.Repository, pkg.Name, "lure.sh")
scriptPath := filepath.Join(config.GetPaths(ctx).RepoDir, pkg.Repository, pkg.Name, "alr.sh")
scripts = append(scripts, scriptPath)
}
return scripts
}
// InstallScripts builds and installs the given LURE build scripts
// InstallScripts builds and installs the given alr build scripts
func InstallScripts(ctx context.Context, scripts []string, opts types.BuildOpts) {
log := loggerctx.From(ctx)
for _, script := range scripts {

View File

@ -1,6 +1,6 @@
/*
* LURE - Linux User REpository
* Copyright (C) 2023 Elara Musayelyan
* ALR - Any Linux Repository
* Copyright (C) 2024 Евгений Храмов
*
* 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
@ -23,7 +23,7 @@ import (
"os"
"strings"
"lure.sh/lure/internal/shutils/handlers"
"plemya-x.ru/alr/internal/shutils/handlers"
"mvdan.cc/sh/v3/expand"
"mvdan.cc/sh/v3/interp"
"mvdan.cc/sh/v3/syntax"
@ -103,11 +103,11 @@ func ParseOSRelease(ctx context.Context) (*OSRelease, error) {
}
distroUpdated := false
if distID, ok := os.LookupEnv("LURE_DISTRO"); ok {
if distID, ok := os.LookupEnv("ALR_DISTRO"); ok {
out.ID = distID
}
if distLike, ok := os.LookupEnv("LURE_DISTRO_LIKE"); ok {
if distLike, ok := os.LookupEnv("ALR_DISTRO_LIKE"); ok {
out.Like = strings.Split(distLike, " ")
} else if runner.Vars["ID_LIKE"].IsSet() && !distroUpdated {
out.Like = strings.Split(runner.Vars["ID_LIKE"].Str, " ")

View File

@ -1,6 +1,6 @@
/*
* LURE - Linux User REpository
* Copyright (C) 2023 Elara Musayelyan
* ALR - Any Linux Repository
* Copyright (C) 2024 Евгений Храмов
*
* 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

View File

@ -1,6 +1,6 @@
/*
* LURE - Linux User REpository
* Copyright (C) 2023 Elara Musayelyan
* ALR - Any Linux Repository
* Copyright (C) 2024 Евгений Храмов
*
* 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

View File

@ -1,6 +1,6 @@
/*
* LURE - Linux User REpository
* Copyright (C) 2023 Elara Musayelyan
* ALR - Any Linux Repository
* Copyright (C) 2024 Евгений Храмов
*
* 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

View File

@ -1,6 +1,6 @@
/*
* LURE - Linux User REpository
* Copyright (C) 2023 Elara Musayelyan
* ALR - Any Linux Repository
* Copyright (C) 2024 Евгений Храмов
*
* 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

View File

@ -1,6 +1,6 @@
/*
* LURE - Linux User REpository
* Copyright (C) 2023 Elara Musayelyan
* ALR - Any Linux Repository
* Copyright (C) 2024 Евгений Храмов
*
* 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

View File

@ -1,6 +1,6 @@
/*
* LURE - Linux User REpository
* Copyright (C) 2023 Elara Musayelyan
* ALR - Any Linux Repository
* Copyright (C) 2024 Евгений Храмов
*
* 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

View File

@ -1,6 +1,6 @@
/*
* LURE - Linux User REpository
* Copyright (C) 2023 Elara Musayelyan
* ALR - Any Linux Repository
* Copyright (C) 2024 Евгений Храмов
*
* 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

View File

@ -1,6 +1,6 @@
/*
* LURE - Linux User REpository
* Copyright (C) 2023 Elara Musayelyan
* ALR - Any Linux Repository
* Copyright (C) 2024 Евгений Храмов
*
* 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
@ -21,7 +21,7 @@ package repos
import (
"context"
"lure.sh/lure/internal/db"
"plemya-x.ru/alr/internal/db"
)
// FindPkgs looks for packages matching the inputs inside the database.

View File

@ -1,6 +1,6 @@
/*
* LURE - Linux User REpository
* Copyright (C) 2023 Elara Musayelyan
* ALR - Any Linux Repository
* Copyright (C) 2024 Евгений Храмов
*
* 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
@ -24,9 +24,9 @@ import (
"strings"
"testing"
"lure.sh/lure/internal/db"
"lure.sh/lure/internal/types"
"lure.sh/lure/pkg/repos"
"plemya-x.ru/alr/internal/db"
"plemya-x.ru/alr/internal/types"
"plemya-x.ru/alr/pkg/repos"
)
func TestFindPkgs(t *testing.T) {
@ -44,7 +44,7 @@ func TestFindPkgs(t *testing.T) {
err = repos.Pull(ctx, []types.Repo{
{
Name: "default",
URL: "https://github.com/Arsen6331/lure-repo.git",
URL: "https://gitflic.ru/project/xpamych/xpamych-alr-repo.git",
},
})
if err != nil {

View File

@ -1,6 +1,6 @@
/*
* LURE - Linux User REpository
* Copyright (C) 2023 Elara Musayelyan
* ALR - Any Linux Repository
* Copyright (C) 2024 Евгений Храмов
*
* 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
@ -35,13 +35,13 @@ import (
"github.com/go-git/go-git/v5/plumbing/format/diff"
"github.com/pelletier/go-toml/v2"
"go.elara.ws/vercmp"
"lure.sh/lure/internal/config"
"lure.sh/lure/internal/db"
"lure.sh/lure/internal/shutils/decoder"
"lure.sh/lure/internal/shutils/handlers"
"lure.sh/lure/internal/types"
"lure.sh/lure/pkg/distro"
"lure.sh/lure/pkg/loggerctx"
"plemya-x.ru/alr/internal/config"
"plemya-x.ru/alr/internal/db"
"plemya-x.ru/alr/internal/shutils/decoder"
"plemya-x.ru/alr/internal/shutils/handlers"
"plemya-x.ru/alr/internal/types"
"plemya-x.ru/alr/pkg/distro"
"plemya-x.ru/alr/pkg/loggerctx"
"mvdan.cc/sh/v3/expand"
"mvdan.cc/sh/v3/interp"
"mvdan.cc/sh/v3/syntax"
@ -50,7 +50,7 @@ import (
// Pull pulls the provided repositories. If a repo doesn't exist, it will be cloned
// and its packages will be written to the DB. If it does exist, it will be pulled.
// In this case, only changed packages will be processed if possible.
// If repos is set to nil, the repos in the LURE config will be used.
// If repos is set to nil, the repos in the ALR config will be used.
func Pull(ctx context.Context, repos []types.Repo) error {
log := loggerctx.From(ctx)
@ -143,9 +143,9 @@ func Pull(ctx context.Context, repos []types.Repo) error {
repoFS = osfs.New(repoDir)
}
fl, err := repoFS.Open("lure-repo.toml")
fl, err := repoFS.Open("alr-repo.toml")
if err != nil {
log.Warn("Git repository does not appear to be a valid LURE repo").Str("repo", repo.Name).Send()
log.Warn("Git repository does not appear to be a valid ALR repo").Str("repo", repo.Name).Send()
continue
}
@ -161,7 +161,7 @@ func Pull(ctx context.Context, repos []types.Repo) error {
// to compare it to the repo version, so only compare versions with the "v".
if strings.HasPrefix(config.Version, "v") {
if vercmp.Compare(config.Version, repoCfg.Repo.MinVersion) == -1 {
log.Warn("LURE repo's minumum LURE version is greater than the current version. Try updating LURE if something doesn't work.").Str("repo", repo.Name).Send()
log.Warn("ALR repo's minumum ALR version is greater than the current version. Try updating ALR if something doesn't work.").Str("repo", repo.Name).Send()
}
}
}
@ -255,7 +255,7 @@ func processRepoChanges(ctx context.Context, repo types.Repo, r *git.Repository,
switch action.Type {
case actionDelete:
if filepath.Base(action.File) != "lure.sh" {
if filepath.Base(action.File) != "alr.sh" {
continue
}
@ -280,8 +280,8 @@ func processRepoChanges(ctx context.Context, repo types.Repo, r *git.Repository,
return err
}
case actionUpdate:
if filepath.Base(action.File) != "lure.sh" {
action.File = filepath.Join(filepath.Dir(action.File), "lure.sh")
if filepath.Base(action.File) != "alr.sh" {
action.File = filepath.Join(filepath.Dir(action.File), "alr.sh")
}
scriptFl, err := newCommit.File(action.File)
@ -322,7 +322,7 @@ func processRepoChanges(ctx context.Context, repo types.Repo, r *git.Repository,
// isValid makes sure the path of the file being updated is valid.
// It checks to make sure the file is not within a nested directory
// and that it is called lure.sh.
// and that it is called alr.sh.
func isValid(from, to diff.File) bool {
var path string
if from != nil {
@ -337,7 +337,7 @@ func isValid(from, to diff.File) bool {
}
func processRepoFull(ctx context.Context, repo types.Repo, repoDir string) error {
glob := filepath.Join(repoDir, "/*/lure.sh")
glob := filepath.Join(repoDir, "/*/alr.sh")
matches, err := filepath.Glob(glob)
if err != nil {
return err
@ -391,7 +391,7 @@ func processRepoFull(ctx context.Context, repo types.Repo, repoDir string) error
func parseScript(ctx context.Context, parser *syntax.Parser, runner *interp.Runner, r io.ReadCloser, pkg *db.Package) error {
defer r.Close()
fl, err := parser.Parse(r, "lure.sh")
fl, err := parser.Parse(r, "alr.sh")
if err != nil {
return err
}

View File

@ -1,6 +1,6 @@
/*
* LURE - Linux User REpository
* Copyright (C) 2023 Elara Musayelyan
* alr - Any Linux Repository
* Copyright (C) 2024 Евгений Храмов
*
* 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
@ -24,10 +24,10 @@ import (
"path/filepath"
"testing"
"lure.sh/lure/internal/config"
"lure.sh/lure/internal/db"
"lure.sh/lure/internal/types"
"lure.sh/lure/pkg/repos"
"plemya-x.ru/alr/internal/config"
"plemya-x.ru/alr/internal/db"
"plemya-x.ru/alr/internal/types"
"plemya-x.ru/alr/pkg/repos"
)
func setCfgDirs(t *testing.T) {
@ -36,7 +36,7 @@ func setCfgDirs(t *testing.T) {
paths := config.GetPaths()
var err error
paths.CacheDir, err = os.MkdirTemp("/tmp", "lure-pull-test.*")
paths.CacheDir, err = os.MkdirTemp("/tmp", "alr-pull-test.*")
if err != nil {
t.Fatalf("Expected no error, got %s", err)
}
@ -81,7 +81,7 @@ func TestPull(t *testing.T) {
err = repos.Pull(ctx, []types.Repo{
{
Name: "default",
URL: "https://github.com/Arsen6331/lure-repo.git",
URL: "https://gitflic.ru/project/xpamych/xpamych-alr-repo.git",
},
})
if err != nil {

View File

@ -10,8 +10,8 @@ import (
"strconv"
"strings"
"lure.sh/lure/internal/config"
"lure.sh/lure/internal/db"
"plemya-x.ru/alr/internal/config"
"plemya-x.ru/alr/internal/db"
)
// Filter represents search filters.
@ -35,7 +35,7 @@ const (
SortByVersion
)
// Package represents a package from LURE's database
// Package represents a package from ALR's database
type Package struct {
Name string
Version string
@ -155,7 +155,7 @@ func GetScript(ctx context.Context, repo, name string) (io.ReadCloser, error) {
return nil, ErrInvalidArgument
}
scriptPath := filepath.Join(config.GetPaths(ctx).RepoDir, repo, name, "lure.sh")
scriptPath := filepath.Join(config.GetPaths(ctx).RepoDir, repo, name, "alr.sh")
fl, err := os.Open(scriptPath)
if errors.Is(err, fs.ErrNotExist) {
return nil, ErrScriptNotFound