Compare commits
1 Commits
v0.0.14
...
a3c2e2d64b
Author | SHA1 | Date | |
---|---|---|---|
a3c2e2d64b |
@@ -1,57 +0,0 @@
|
|||||||
# ALR - Any Linux Repository
|
|
||||||
# Copyright (C) 2025 The ALR Authors
|
|
||||||
#
|
|
||||||
# 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/>.
|
|
||||||
|
|
||||||
name: E2E
|
|
||||||
|
|
||||||
on:
|
|
||||||
push:
|
|
||||||
branches: [ main ]
|
|
||||||
pull_request:
|
|
||||||
|
|
||||||
|
|
||||||
jobs:
|
|
||||||
tests:
|
|
||||||
runs-on: ubuntu-latest
|
|
||||||
|
|
||||||
container:
|
|
||||||
image: altlinux.space/maks1ms/actions-container-runner:latest
|
|
||||||
|
|
||||||
steps:
|
|
||||||
- name: Checkout
|
|
||||||
uses: https://github.com/actions/checkout@v4
|
|
||||||
with:
|
|
||||||
fetch-depth: 0
|
|
||||||
|
|
||||||
- name: Set up Go
|
|
||||||
uses: https://github.com/actions/setup-go@v5
|
|
||||||
with:
|
|
||||||
go-version: '1.24'
|
|
||||||
|
|
||||||
- name: Cache Podman images
|
|
||||||
uses: actions/cache@v4
|
|
||||||
with:
|
|
||||||
path: |
|
|
||||||
~/.local/share/containers/storage
|
|
||||||
/var/lib/containers/storage
|
|
||||||
key: ${{ runner.os }}-primes
|
|
||||||
|
|
||||||
- name: Run E2E tests
|
|
||||||
env:
|
|
||||||
DOCKER_HOST: unix:///tmp/podman.sock
|
|
||||||
IGNORE_ROOT_CHECK: 1
|
|
||||||
run: |
|
|
||||||
podman system service -t 0 unix:///tmp/podman.sock &
|
|
||||||
make e2e-test
|
|
@@ -42,7 +42,7 @@ jobs:
|
|||||||
python-version: '3.12'
|
python-version: '3.12'
|
||||||
|
|
||||||
- name: Install deps
|
- name: Install deps
|
||||||
run: apt-get update && apt-get install -y gettext bc
|
run: apt-get update && apt-get install gettext bc
|
||||||
|
|
||||||
- run: pip install pre-commit
|
- run: pip install pre-commit
|
||||||
- run: pre-commit install
|
- run: pre-commit install
|
||||||
|
@@ -1,67 +0,0 @@
|
|||||||
# ALR - Any Linux Repository
|
|
||||||
# Copyright (C) 2025 The ALR Authors
|
|
||||||
#
|
|
||||||
# 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/>.
|
|
||||||
|
|
||||||
name: Create Release
|
|
||||||
|
|
||||||
on:
|
|
||||||
push:
|
|
||||||
tags:
|
|
||||||
- 'v[0-9]+.[0-9]+.[0-9]+'
|
|
||||||
|
|
||||||
jobs:
|
|
||||||
changelog:
|
|
||||||
runs-on: ubuntu-latest
|
|
||||||
steps:
|
|
||||||
- name: Checkout this repository
|
|
||||||
uses: actions/checkout@v4
|
|
||||||
with:
|
|
||||||
fetch-depth: 0
|
|
||||||
|
|
||||||
- name: Set up Go
|
|
||||||
uses: actions/setup-go@v5
|
|
||||||
with:
|
|
||||||
go-version: '1.24'
|
|
||||||
|
|
||||||
- name: Get Changes between Tags
|
|
||||||
id: changes
|
|
||||||
uses: simbo/changes-between-tags-action@v1
|
|
||||||
|
|
||||||
- name: Set version
|
|
||||||
run: |
|
|
||||||
version=$(echo "${GITHUB_REF##*/}" | sed 's/^v//')
|
|
||||||
echo "Version - $version"
|
|
||||||
echo "VERSION=$version" >> $GITHUB_ENV
|
|
||||||
|
|
||||||
- name: Build alr binary
|
|
||||||
run: |
|
|
||||||
CGO_ENABLED=0 go build -ldflags "-X gitea.plemya-x.ru/Plemya-x/ALR/internal/config.Version=${{ env.VERSION }}" -o alr
|
|
||||||
|
|
||||||
- name: Create tar.gz
|
|
||||||
run: |
|
|
||||||
mkdir -p ./out/completion
|
|
||||||
cp alr ./out
|
|
||||||
cp scripts/completion/bash ./out/completion/alr
|
|
||||||
cp scripts/completion/zsh ./out/completion/_alr
|
|
||||||
|
|
||||||
( cd out && tar -czvf ../alr-${{ env.VERSION }}-linux-x86_64.tar.gz * )
|
|
||||||
|
|
||||||
- name: Release
|
|
||||||
uses: akkuman/gitea-release-action@v1
|
|
||||||
with:
|
|
||||||
body: ${{ steps.changes.outputs.changes }}
|
|
||||||
files: |-
|
|
||||||
alr-${{ env.VERSION }}-linux-x86_64.tar.gz
|
|
||||||
|
|
11
Makefile
11
Makefile
@@ -1,6 +1,6 @@
|
|||||||
NAME := alr
|
NAME := alr
|
||||||
GIT_VERSION = $(shell git describe --tags )
|
GIT_VERSION = $(shell git describe --tags )
|
||||||
IGNORE_ROOT_CHECK ?= 0
|
|
||||||
DESTDIR ?=
|
DESTDIR ?=
|
||||||
PREFIX ?= /usr/local
|
PREFIX ?= /usr/local
|
||||||
BIN := ./$(NAME)
|
BIN := ./$(NAME)
|
||||||
@@ -24,9 +24,8 @@ $(BIN):
|
|||||||
go build -ldflags="-X 'gitea.plemya-x.ru/Plemya-x/ALR/internal/config.Version=$(GIT_VERSION)'" -o $@
|
go build -ldflags="-X 'gitea.plemya-x.ru/Plemya-x/ALR/internal/config.Version=$(GIT_VERSION)'" -o $@
|
||||||
|
|
||||||
check-no-root:
|
check-no-root:
|
||||||
@if [[ "$(IGNORE_ROOT_CHECK)" != "1" ]] && [[ "$$(whoami)" == 'root' ]]; then \
|
@if [[ "$$(whoami)" == 'root' ]]; then \
|
||||||
echo "This target shouldn't run as root" 1>&2; \
|
echo "This target shouldn't run as root" 1>&2; \
|
||||||
echo "Set IGNORE_ROOT_CHECK=1 to override" 1>&2; \
|
|
||||||
exit 1; \
|
exit 1; \
|
||||||
fi
|
fi
|
||||||
|
|
||||||
@@ -55,7 +54,7 @@ uninstall:
|
|||||||
clean clear:
|
clean clear:
|
||||||
rm -f $(BIN)
|
rm -f $(BIN)
|
||||||
|
|
||||||
OLD_FILES=$(shell cat old-files)
|
OLD_FILES=$$(< old-files)
|
||||||
IGNORE_OLD_FILES := $(foreach file,$(shell cat old-files),-ignore $(file))
|
IGNORE_OLD_FILES := $(foreach file,$(shell cat old-files),-ignore $(file))
|
||||||
update-license:
|
update-license:
|
||||||
$(ADD_LICENSE_BIN) -v -f license-header-old-files.tmpl $(OLD_FILES)
|
$(ADD_LICENSE_BIN) -v -f license-header-old-files.tmpl $(OLD_FILES)
|
||||||
@@ -77,9 +76,7 @@ test-coverage:
|
|||||||
update-deps-cve:
|
update-deps-cve:
|
||||||
bash scripts/update-deps-cve.sh
|
bash scripts/update-deps-cve.sh
|
||||||
|
|
||||||
prepare-for-e2e-test: clean build
|
e2e-test: clean build
|
||||||
rm -f ./e2e-tests/alr
|
rm -f ./e2e-tests/alr
|
||||||
cp alr e2e-tests
|
cp alr e2e-tests
|
||||||
|
|
||||||
e2e-test: prepare-for-e2e-test
|
|
||||||
go test -tags=e2e ./...
|
go test -tags=e2e ./...
|
@@ -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">16.9%</text>
|
<text x="86" y="15" fill="#010101" fill-opacity=".3">17.0%</text>
|
||||||
<text x="86" y="14">16.9%</text>
|
<text x="86" y="14">17.0%</text>
|
||||||
</g>
|
</g>
|
||||||
</svg>
|
</svg>
|
||||||
|
Before Width: | Height: | Size: 926 B After Width: | Height: | Size: 926 B |
6
build.go
6
build.go
@@ -118,11 +118,7 @@ func BuildCmd() *cli.Command {
|
|||||||
return cliutils.FormatCliExit(gotext.Get("Cannot get absolute script path"), err)
|
return cliutils.FormatCliExit(gotext.Get("Cannot get absolute script path"), err)
|
||||||
}
|
}
|
||||||
|
|
||||||
subpackage := c.String("subpackage")
|
packages = append(packages, c.String("script-package"))
|
||||||
|
|
||||||
if subpackage != "" {
|
|
||||||
packages = append(packages, subpackage)
|
|
||||||
}
|
|
||||||
|
|
||||||
scriptArgs = &build.BuildPackageFromScriptArgs{
|
scriptArgs = &build.BuildPackageFromScriptArgs{
|
||||||
Script: script,
|
Script: script,
|
||||||
|
@@ -21,6 +21,7 @@ package e2etests_test
|
|||||||
import (
|
import (
|
||||||
"testing"
|
"testing"
|
||||||
|
|
||||||
|
"github.com/alecthomas/assert/v2"
|
||||||
"github.com/efficientgo/e2e"
|
"github.com/efficientgo/e2e"
|
||||||
)
|
)
|
||||||
|
|
||||||
@@ -30,7 +31,10 @@ func TestE2EBashCompletion(t *testing.T) {
|
|||||||
"bash-completion",
|
"bash-completion",
|
||||||
COMMON_SYSTEMS,
|
COMMON_SYSTEMS,
|
||||||
func(t *testing.T, r e2e.Runnable) {
|
func(t *testing.T, r e2e.Runnable) {
|
||||||
execShouldNoError(t, r, "alr", "install", "--generate-bash-completion")
|
err := r.Exec(e2e.NewCommand(
|
||||||
|
"alr", "install", "--generate-bash-completion",
|
||||||
|
))
|
||||||
|
assert.NoError(t, err)
|
||||||
},
|
},
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
@@ -25,6 +25,7 @@ import (
|
|||||||
"io"
|
"io"
|
||||||
"log"
|
"log"
|
||||||
"os"
|
"os"
|
||||||
|
"os/exec"
|
||||||
"testing"
|
"testing"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
@@ -120,6 +121,29 @@ var COMMON_SYSTEMS []string = []string{
|
|||||||
"ubuntu-24.04",
|
"ubuntu-24.04",
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func init() {
|
||||||
|
for _, id := range ALL_SYSTEMS {
|
||||||
|
buildAlrTestImage(id)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
func buildAlrTestImage(id string) {
|
||||||
|
cmd := exec.Command(
|
||||||
|
"docker",
|
||||||
|
"build",
|
||||||
|
"-t", fmt.Sprintf("alr-testimage-%s", id),
|
||||||
|
"-f", fmt.Sprintf("images/Dockerfile.%s", id),
|
||||||
|
".",
|
||||||
|
)
|
||||||
|
cmd.Stdout = os.Stdout
|
||||||
|
cmd.Stderr = os.Stderr
|
||||||
|
err := cmd.Run()
|
||||||
|
if err != nil {
|
||||||
|
fmt.Println("Error:", err)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
func dockerMultipleRun(t *testing.T, name string, ids []string, f func(t *testing.T, runnable e2e.Runnable)) {
|
func dockerMultipleRun(t *testing.T, name string, ids []string, f func(t *testing.T, runnable e2e.Runnable)) {
|
||||||
t.Run(name, func(t *testing.T) {
|
t.Run(name, func(t *testing.T) {
|
||||||
for _, id := range ids {
|
for _, id := range ids {
|
||||||
@@ -134,39 +158,23 @@ func dockerMultipleRun(t *testing.T, name string, ids []string, f func(t *testin
|
|||||||
e, err := e2e.New(e2e.WithVerbose(), e2e.WithName(fmt.Sprintf("alr-%s", truncatedHash)))
|
e, err := e2e.New(e2e.WithVerbose(), e2e.WithName(fmt.Sprintf("alr-%s", truncatedHash)))
|
||||||
assert.NoError(t, err)
|
assert.NoError(t, err)
|
||||||
t.Cleanup(e.Close)
|
t.Cleanup(e.Close)
|
||||||
imageId := fmt.Sprintf("ghcr.io/maks1ms/alr-e2e-test-image-%s", id)
|
imageId := fmt.Sprintf("alr-testimage-%s", id)
|
||||||
runnable := e.Runnable(dockerName).Init(
|
runnable := e.Runnable(dockerName).Init(
|
||||||
e2e.StartOptions{
|
e2e.StartOptions{
|
||||||
Image: imageId,
|
Image: imageId,
|
||||||
Volumes: []string{
|
Volumes: []string{
|
||||||
"./alr:/tmp/alr",
|
// "./alr:/usr/bin/alr",
|
||||||
},
|
},
|
||||||
Privileged: true,
|
Privileged: true,
|
||||||
},
|
},
|
||||||
)
|
)
|
||||||
assert.NoError(t, e2e.StartAndWaitReady(runnable))
|
assert.NoError(t, e2e.StartAndWaitReady(runnable))
|
||||||
err = runnable.Exec(e2e.NewCommand("/bin/alr-test-setup", "alr-install"))
|
|
||||||
if err != nil {
|
|
||||||
panic(err)
|
|
||||||
}
|
|
||||||
err = runnable.Exec(e2e.NewCommand("/bin/alr-test-setup", "passwordless-sudo-setup"))
|
|
||||||
if err != nil {
|
|
||||||
panic(err)
|
|
||||||
}
|
|
||||||
f(t, runnable)
|
f(t, runnable)
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
func execShouldNoError(t *testing.T, r e2e.Runnable, cmd string, args ...string) {
|
|
||||||
assert.NoError(t, r.Exec(e2e.NewCommand(cmd, args...)))
|
|
||||||
}
|
|
||||||
|
|
||||||
func execShouldError(t *testing.T, r e2e.Runnable, cmd string, args ...string) {
|
|
||||||
assert.Error(t, r.Exec(e2e.NewCommand(cmd, args...)))
|
|
||||||
}
|
|
||||||
|
|
||||||
func runTestCommands(t *testing.T, r e2e.Runnable, timeout time.Duration, expects []expect.Batcher) {
|
func runTestCommands(t *testing.T, r e2e.Runnable, timeout time.Duration, expects []expect.Batcher) {
|
||||||
exp, _, err, _ := e2eSpawn(
|
exp, _, err, _ := e2eSpawn(
|
||||||
r,
|
r,
|
||||||
@@ -180,23 +188,3 @@ func runTestCommands(t *testing.T, r e2e.Runnable, timeout time.Duration, expect
|
|||||||
)
|
)
|
||||||
assert.NoError(t, err)
|
assert.NoError(t, err)
|
||||||
}
|
}
|
||||||
|
|
||||||
const REPO_NAME_FOR_E2E_TESTS = "alr-repo"
|
|
||||||
const REPO_URL_FOR_E2E_TESTS = "https://gitea.plemya-x.ru/Maks1mS/repo-for-tests.git"
|
|
||||||
|
|
||||||
func defaultPrepare(t *testing.T, r e2e.Runnable) {
|
|
||||||
execShouldNoError(t, r,
|
|
||||||
"sudo",
|
|
||||||
"alr",
|
|
||||||
"repo",
|
|
||||||
"add",
|
|
||||||
REPO_NAME_FOR_E2E_TESTS,
|
|
||||||
REPO_URL_FOR_E2E_TESTS,
|
|
||||||
)
|
|
||||||
|
|
||||||
execShouldNoError(t, r,
|
|
||||||
"sudo",
|
|
||||||
"alr",
|
|
||||||
"ref",
|
|
||||||
)
|
|
||||||
}
|
|
||||||
|
@@ -21,6 +21,7 @@ package e2etests_test
|
|||||||
import (
|
import (
|
||||||
"testing"
|
"testing"
|
||||||
|
|
||||||
|
"github.com/alecthomas/assert/v2"
|
||||||
"github.com/efficientgo/e2e"
|
"github.com/efficientgo/e2e"
|
||||||
)
|
)
|
||||||
|
|
||||||
@@ -30,9 +31,26 @@ func TestE2EGroupAndSummaryField(t *testing.T) {
|
|||||||
"group-and-summary-field",
|
"group-and-summary-field",
|
||||||
RPM_SYSTEMS,
|
RPM_SYSTEMS,
|
||||||
func(t *testing.T, r e2e.Runnable) {
|
func(t *testing.T, r e2e.Runnable) {
|
||||||
defaultPrepare(t, r)
|
err := r.Exec(e2e.NewCommand(
|
||||||
execShouldNoError(t, r, "sh", "-c", "alr search --name test-group-and-summary --format \"{{.Group}}\" | grep ^System/Base$")
|
"sudo",
|
||||||
execShouldNoError(t, r, "sh", "-c", "alr search --name test-group-and-summary --format \"{{.Summary}}\" | grep \"^Custom summary$\"")
|
"alr",
|
||||||
|
"addrepo",
|
||||||
|
"--name",
|
||||||
|
"alr-repo",
|
||||||
|
"--url",
|
||||||
|
"https://gitea.plemya-x.ru/Maks1mS/repo-for-tests.git",
|
||||||
|
))
|
||||||
|
assert.NoError(t, err)
|
||||||
|
|
||||||
|
err = r.Exec(e2e.NewCommand(
|
||||||
|
"sh", "-c", "alr search --name test-group-and-summary --format \"{{.Group}}\" | grep ^System/Base$",
|
||||||
|
))
|
||||||
|
assert.NoError(t, err)
|
||||||
|
|
||||||
|
err = r.Exec(e2e.NewCommand(
|
||||||
|
"sh", "-c", "alr search --name test-group-and-summary --format \"{{.Summary}}\" | grep \"^Custom summary$\"",
|
||||||
|
))
|
||||||
|
assert.NoError(t, err)
|
||||||
},
|
},
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
4
e2e-tests/images/Dockerfile.alpine
Normal file
4
e2e-tests/images/Dockerfile.alpine
Normal file
@@ -0,0 +1,4 @@
|
|||||||
|
FROM alpine:latest
|
||||||
|
RUN adduser -s /bin/bash alr-user
|
||||||
|
USER alr-user
|
||||||
|
ENTRYPOINT ["tail", "-f", "/dev/null"]
|
6
e2e-tests/images/Dockerfile.alt-sisyphus
Normal file
6
e2e-tests/images/Dockerfile.alt-sisyphus
Normal file
@@ -0,0 +1,6 @@
|
|||||||
|
FROM registry.altlinux.org/sisyphus/alt:latest
|
||||||
|
RUN apt-get update && apt-get install -y ca-certificates rpm-build
|
||||||
|
RUN useradd -m -s /bin/bash alr-user
|
||||||
|
USER alr-user
|
||||||
|
WORKDIR /home/alr-user
|
||||||
|
ENTRYPOINT ["tail", "-f", "/dev/null"]
|
4
e2e-tests/images/Dockerfile.archlinux
Normal file
4
e2e-tests/images/Dockerfile.archlinux
Normal file
@@ -0,0 +1,4 @@
|
|||||||
|
FROM archlinux:latest
|
||||||
|
RUN useradd -m -s /bin/bash alr-user
|
||||||
|
USER alr-user
|
||||||
|
ENTRYPOINT ["tail", "-f", "/dev/null"]
|
18
e2e-tests/images/Dockerfile.fedora-41
Normal file
18
e2e-tests/images/Dockerfile.fedora-41
Normal file
@@ -0,0 +1,18 @@
|
|||||||
|
FROM fedora:41
|
||||||
|
RUN dnf install -y ca-certificates sudo rpm-build bindfs
|
||||||
|
RUN <<EOF
|
||||||
|
useradd -m -s /bin/bash -G wheel user
|
||||||
|
echo "user ALL=(ALL) NOPASSWD:ALL" >> /etc/sudoers.d/user
|
||||||
|
chmod 0440 /etc/sudoers.d/user
|
||||||
|
|
||||||
|
useradd -m -s /bin/bash alr
|
||||||
|
mkdir -p /var/cache/alr /etc/alr
|
||||||
|
chown alr:alr /var/cache/alr /etc/alr
|
||||||
|
EOF
|
||||||
|
COPY ./alr /usr/bin
|
||||||
|
RUN <<EOF
|
||||||
|
setcap cap_setuid,cap_setgid+ep /usr/bin/alr
|
||||||
|
EOF
|
||||||
|
USER user
|
||||||
|
WORKDIR /home/user
|
||||||
|
ENTRYPOINT ["tail", "-f", "/dev/null"]
|
4
e2e-tests/images/Dockerfile.opensuse-leap
Normal file
4
e2e-tests/images/Dockerfile.opensuse-leap
Normal file
@@ -0,0 +1,4 @@
|
|||||||
|
FROM opensuse/leap:latest
|
||||||
|
RUN useradd -m -s /bin/bash alr-user
|
||||||
|
USER alr-user
|
||||||
|
ENTRYPOINT ["tail", "-f", "/dev/null"]
|
4
e2e-tests/images/Dockerfile.redos-8
Normal file
4
e2e-tests/images/Dockerfile.redos-8
Normal file
@@ -0,0 +1,4 @@
|
|||||||
|
FROM registry.red-soft.ru/ubi8/ubi:latest
|
||||||
|
RUN useradd -m -s /bin/bash alr-user
|
||||||
|
USER alr-user
|
||||||
|
ENTRYPOINT ["tail", "-f", "/dev/null"]
|
17
e2e-tests/images/Dockerfile.ubuntu-24.04
Normal file
17
e2e-tests/images/Dockerfile.ubuntu-24.04
Normal file
@@ -0,0 +1,17 @@
|
|||||||
|
FROM ubuntu:24.10
|
||||||
|
RUN apt-get update && apt-get install -y --no-install-recommends ca-certificates sudo libcap2-bin
|
||||||
|
RUN <<EOF
|
||||||
|
useradd -m -s /bin/bash user
|
||||||
|
echo "user ALL=(ALL) NOPASSWD:ALL" >> /etc/sudoers.d/user
|
||||||
|
chmod 0440 /etc/sudoers.d/user
|
||||||
|
|
||||||
|
useradd -m -s /bin/bash alr
|
||||||
|
mkdir -p /var/cache/alr /etc/alr
|
||||||
|
chown alr:alr /var/cache/alr /etc/alr
|
||||||
|
EOF
|
||||||
|
COPY ./alr /usr/bin
|
||||||
|
RUN <<EOF
|
||||||
|
setcap cap_setuid,cap_setgid+ep /usr/bin/alr
|
||||||
|
EOF
|
||||||
|
USER user
|
||||||
|
ENTRYPOINT ["tail", "-f", "/dev/null"]
|
@@ -21,6 +21,7 @@ package e2etests_test
|
|||||||
import (
|
import (
|
||||||
"testing"
|
"testing"
|
||||||
|
|
||||||
|
"github.com/alecthomas/assert/v2"
|
||||||
"github.com/efficientgo/e2e"
|
"github.com/efficientgo/e2e"
|
||||||
)
|
)
|
||||||
|
|
||||||
@@ -30,11 +31,21 @@ func TestE2EIssue32Interactive(t *testing.T) {
|
|||||||
"issue-32-interactive",
|
"issue-32-interactive",
|
||||||
COMMON_SYSTEMS,
|
COMMON_SYSTEMS,
|
||||||
func(t *testing.T, r e2e.Runnable) {
|
func(t *testing.T, r e2e.Runnable) {
|
||||||
execShouldNoError(t, r, "alr", "--interactive=false", "remove", "ca-certificates")
|
assert.NoError(t, r.Exec(e2e.NewCommand(
|
||||||
execShouldNoError(t, r, "sudo", "alr", "--interactive=false", "remove", "openssl")
|
"sudo", "alr", "--interactive=false", "remove", "ca-certificates",
|
||||||
execShouldNoError(t, r, "alr", "fix")
|
)))
|
||||||
execShouldNoError(t, r, "sudo", "apt-get", "update")
|
|
||||||
execShouldNoError(t, r, "sudo", "alr", "--interactive=false", "install", "ca-certificates")
|
assert.NoError(t, r.Exec(e2e.NewCommand(
|
||||||
|
"sudo", "alr", "--interactive=false", "remove", "openssl",
|
||||||
|
)))
|
||||||
|
|
||||||
|
assert.NoError(t, r.Exec(e2e.NewCommand(
|
||||||
|
"alr", "fix",
|
||||||
|
)))
|
||||||
|
|
||||||
|
assert.NoError(t, r.Exec(e2e.NewCommand(
|
||||||
|
"sudo", "alr", "--interactive=false", "install", "ca-certificates",
|
||||||
|
)))
|
||||||
},
|
},
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
@@ -21,6 +21,7 @@ package e2etests_test
|
|||||||
import (
|
import (
|
||||||
"testing"
|
"testing"
|
||||||
|
|
||||||
|
"github.com/alecthomas/assert/v2"
|
||||||
"github.com/efficientgo/e2e"
|
"github.com/efficientgo/e2e"
|
||||||
)
|
)
|
||||||
|
|
||||||
@@ -30,11 +31,51 @@ func TestE2EIssue41AutoreqSkiplist(t *testing.T) {
|
|||||||
"issue-41-autoreq-skiplist",
|
"issue-41-autoreq-skiplist",
|
||||||
AUTOREQ_AUTOPROV_SYSTEMS,
|
AUTOREQ_AUTOPROV_SYSTEMS,
|
||||||
func(t *testing.T, r e2e.Runnable) {
|
func(t *testing.T, r e2e.Runnable) {
|
||||||
defaultPrepare(t, r)
|
err := r.Exec(e2e.NewCommand(
|
||||||
execShouldNoError(t, r, "alr", "build", "-p", "alr-repo/test-autoreq-autoprov")
|
"sudo",
|
||||||
execShouldNoError(t, r, "sh", "-c", "rpm -qp --requires *.rpm | grep \"^/bin/sh$\"")
|
"alr",
|
||||||
execShouldError(t, r, "sh", "-c", "rpm -qp --requires *.rpm | grep \"^/bin/bash$\"")
|
"addrepo",
|
||||||
execShouldError(t, r, "sh", "-c", "rpm -qp --requires *.rpm | grep \"^/bin/zsh$\"")
|
"--name",
|
||||||
|
"alr-repo",
|
||||||
|
"--url",
|
||||||
|
"https://gitea.plemya-x.ru/Maks1mS/repo-for-tests.git",
|
||||||
|
))
|
||||||
|
assert.NoError(t, err)
|
||||||
|
|
||||||
|
err = r.Exec(e2e.NewCommand(
|
||||||
|
"alr",
|
||||||
|
"ref",
|
||||||
|
))
|
||||||
|
assert.NoError(t, err)
|
||||||
|
|
||||||
|
err = r.Exec(e2e.NewCommand(
|
||||||
|
"alr",
|
||||||
|
"build",
|
||||||
|
"-p",
|
||||||
|
"alr-repo/test-autoreq-autoprov",
|
||||||
|
))
|
||||||
|
assert.NoError(t, err)
|
||||||
|
|
||||||
|
err = r.Exec(e2e.NewCommand(
|
||||||
|
"sh",
|
||||||
|
"-c",
|
||||||
|
"rpm -qp --requires *.rpm | grep \"^/bin/sh$\"",
|
||||||
|
))
|
||||||
|
assert.NoError(t, err)
|
||||||
|
|
||||||
|
err = r.Exec(e2e.NewCommand(
|
||||||
|
"sh",
|
||||||
|
"-c",
|
||||||
|
"rpm -qp --requires *.rpm | grep \"^/bin/bash$\"",
|
||||||
|
))
|
||||||
|
assert.Error(t, err)
|
||||||
|
|
||||||
|
err = r.Exec(e2e.NewCommand(
|
||||||
|
"sh",
|
||||||
|
"-c",
|
||||||
|
"rpm -qp --requires *.rpm | grep \"^/bin/zsh$\"",
|
||||||
|
))
|
||||||
|
assert.Error(t, err)
|
||||||
},
|
},
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
@@ -21,6 +21,7 @@ package e2etests_test
|
|||||||
import (
|
import (
|
||||||
"testing"
|
"testing"
|
||||||
|
|
||||||
|
"github.com/alecthomas/assert/v2"
|
||||||
"github.com/efficientgo/e2e"
|
"github.com/efficientgo/e2e"
|
||||||
)
|
)
|
||||||
|
|
||||||
@@ -30,10 +31,26 @@ func TestE2EIssue50InstallMultiple(t *testing.T) {
|
|||||||
"issue-50-install-multiple",
|
"issue-50-install-multiple",
|
||||||
COMMON_SYSTEMS,
|
COMMON_SYSTEMS,
|
||||||
func(t *testing.T, r e2e.Runnable) {
|
func(t *testing.T, r e2e.Runnable) {
|
||||||
defaultPrepare(t, r)
|
err := r.Exec(e2e.NewCommand(
|
||||||
execShouldNoError(t, r, "sudo", "alr", "in", "foo-pkg", "bar-pkg")
|
"sudo",
|
||||||
execShouldNoError(t, r, "cat", "/opt/foo")
|
"alr",
|
||||||
execShouldNoError(t, r, "cat", "/opt/bar")
|
"addrepo",
|
||||||
|
"--name",
|
||||||
|
"alr-repo",
|
||||||
|
"--url",
|
||||||
|
"https://gitea.plemya-x.ru/Maks1mS/repo-for-tests.git",
|
||||||
|
))
|
||||||
|
assert.NoError(t, err)
|
||||||
|
|
||||||
|
err = r.Exec(e2e.NewCommand(
|
||||||
|
"sudo", "alr", "in", "foo-pkg", "bar-pkg",
|
||||||
|
))
|
||||||
|
assert.NoError(t, err)
|
||||||
|
|
||||||
|
err = r.Exec(e2e.NewCommand("cat", "/opt/foo"))
|
||||||
|
assert.NoError(t, err)
|
||||||
|
err = r.Exec(e2e.NewCommand("cat", "/opt/bar"))
|
||||||
|
assert.NoError(t, err)
|
||||||
},
|
},
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
@@ -21,6 +21,7 @@ package e2etests_test
|
|||||||
import (
|
import (
|
||||||
"testing"
|
"testing"
|
||||||
|
|
||||||
|
"github.com/alecthomas/assert/v2"
|
||||||
"github.com/efficientgo/e2e"
|
"github.com/efficientgo/e2e"
|
||||||
)
|
)
|
||||||
|
|
||||||
@@ -30,8 +31,23 @@ func TestE2EIssue53LcAllCInfo(t *testing.T) {
|
|||||||
"issue-53-lc-all-c-info",
|
"issue-53-lc-all-c-info",
|
||||||
COMMON_SYSTEMS,
|
COMMON_SYSTEMS,
|
||||||
func(t *testing.T, r e2e.Runnable) {
|
func(t *testing.T, r e2e.Runnable) {
|
||||||
defaultPrepare(t, r)
|
err := r.Exec(e2e.NewCommand(
|
||||||
execShouldNoError(t, r, "bash", "-c", "LANG=C alr info foo-pkg")
|
"sudo",
|
||||||
|
"alr",
|
||||||
|
"addrepo",
|
||||||
|
"--name",
|
||||||
|
"alr-repo",
|
||||||
|
"--url",
|
||||||
|
"https://gitea.plemya-x.ru/Plemya-x/alr-repo.git",
|
||||||
|
))
|
||||||
|
assert.NoError(t, err)
|
||||||
|
|
||||||
|
err = r.Exec(e2e.NewCommand(
|
||||||
|
"bash",
|
||||||
|
"-c",
|
||||||
|
"LANG=C alr info alr-bin",
|
||||||
|
))
|
||||||
|
assert.NoError(t, err)
|
||||||
},
|
},
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
@@ -21,6 +21,7 @@ package e2etests_test
|
|||||||
import (
|
import (
|
||||||
"testing"
|
"testing"
|
||||||
|
|
||||||
|
"github.com/alecthomas/assert/v2"
|
||||||
"github.com/efficientgo/e2e"
|
"github.com/efficientgo/e2e"
|
||||||
)
|
)
|
||||||
|
|
||||||
@@ -30,11 +31,28 @@ func TestE2EIssue59RmCompletion(t *testing.T) {
|
|||||||
"issue-59-rm-completion",
|
"issue-59-rm-completion",
|
||||||
COMMON_SYSTEMS,
|
COMMON_SYSTEMS,
|
||||||
func(t *testing.T, r e2e.Runnable) {
|
func(t *testing.T, r e2e.Runnable) {
|
||||||
defaultPrepare(t, r)
|
err := r.Exec(e2e.NewCommand(
|
||||||
execShouldNoError(t, r, "sudo", "alr", "in", "foo-pkg", "bar-pkg")
|
"sudo",
|
||||||
execShouldNoError(t, r, "sh", "-c", "alr rm --generate-bash-completion | grep ^foo-pkg$")
|
"alr",
|
||||||
execShouldNoError(t, r, "sh", "-c", "alr rm --generate-bash-completion | grep ^bar-pkg$")
|
"addrepo",
|
||||||
execShouldError(t, r, "sh", "-c", "alr rm --generate-bash-completion | grep ^test-autoreq-autoprov$")
|
"--name",
|
||||||
|
"alr-repo",
|
||||||
|
"--url",
|
||||||
|
"https://gitea.plemya-x.ru/Maks1mS/repo-for-tests.git",
|
||||||
|
))
|
||||||
|
assert.NoError(t, err)
|
||||||
|
|
||||||
|
err = r.Exec(e2e.NewCommand(
|
||||||
|
"sudo", "alr", "in", "foo-pkg", "bar-pkg",
|
||||||
|
))
|
||||||
|
assert.NoError(t, err)
|
||||||
|
|
||||||
|
err = r.Exec(e2e.NewCommand("sh", "-c", "alr rm --generate-bash-completion | grep ^foo-pkg$"))
|
||||||
|
assert.NoError(t, err)
|
||||||
|
err = r.Exec(e2e.NewCommand("sh", "-c", "alr rm --generate-bash-completion | grep ^bar-pkg$"))
|
||||||
|
assert.NoError(t, err)
|
||||||
|
err = r.Exec(e2e.NewCommand("sh", "-c", "alr rm --generate-bash-completion | grep ^test-autoreq-autoprov$"))
|
||||||
|
assert.Error(t, err)
|
||||||
},
|
},
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
@@ -21,6 +21,7 @@ package e2etests_test
|
|||||||
import (
|
import (
|
||||||
"testing"
|
"testing"
|
||||||
|
|
||||||
|
"github.com/alecthomas/assert/v2"
|
||||||
"github.com/efficientgo/e2e"
|
"github.com/efficientgo/e2e"
|
||||||
)
|
)
|
||||||
|
|
||||||
@@ -30,8 +31,21 @@ func TestE2EIssue72InstallWithDeps(t *testing.T) {
|
|||||||
"issue-72-install-with-deps",
|
"issue-72-install-with-deps",
|
||||||
COMMON_SYSTEMS,
|
COMMON_SYSTEMS,
|
||||||
func(t *testing.T, r e2e.Runnable) {
|
func(t *testing.T, r e2e.Runnable) {
|
||||||
defaultPrepare(t, r)
|
err := r.Exec(e2e.NewCommand(
|
||||||
execShouldNoError(t, r, "sudo", "alr", "in", "test-app-with-lib")
|
"sudo",
|
||||||
|
"alr",
|
||||||
|
"addrepo",
|
||||||
|
"--name",
|
||||||
|
"alr-repo",
|
||||||
|
"--url",
|
||||||
|
"https://gitea.plemya-x.ru/Maks1mS/repo-for-tests.git",
|
||||||
|
))
|
||||||
|
assert.NoError(t, err)
|
||||||
|
|
||||||
|
err = r.Exec(e2e.NewCommand(
|
||||||
|
"sudo", "alr", "in", "test-app-with-lib",
|
||||||
|
))
|
||||||
|
assert.NoError(t, err)
|
||||||
},
|
},
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
@@ -1,43 +0,0 @@
|
|||||||
// ALR - Any Linux Repository
|
|
||||||
// Copyright (C) 2025 The ALR Authors
|
|
||||||
//
|
|
||||||
// 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/>.
|
|
||||||
|
|
||||||
//go:build e2e
|
|
||||||
|
|
||||||
package e2etests_test
|
|
||||||
|
|
||||||
import (
|
|
||||||
"testing"
|
|
||||||
|
|
||||||
"github.com/efficientgo/e2e"
|
|
||||||
)
|
|
||||||
|
|
||||||
func TestE2EIssue74Upgradable(t *testing.T) {
|
|
||||||
dockerMultipleRun(
|
|
||||||
t,
|
|
||||||
"issue-74-upgradable",
|
|
||||||
COMMON_SYSTEMS,
|
|
||||||
func(t *testing.T, r e2e.Runnable) {
|
|
||||||
defaultPrepare(t, r)
|
|
||||||
execShouldNoError(t, r, "sudo", "alr", "repo", "set-ref", "alr-repo", "bd26236cd7")
|
|
||||||
execShouldNoError(t, r, "alr", "ref")
|
|
||||||
execShouldNoError(t, r, "sudo", "alr", "in", "bar-pkg")
|
|
||||||
execShouldNoError(t, r, "sh", "-c", "test $(alr list -U | wc -l) -eq 0 || exit 1")
|
|
||||||
execShouldNoError(t, r, "sudo", "alr", "repo", "set-ref", "alr-repo", "d9a3541561")
|
|
||||||
execShouldNoError(t, r, "sudo", "alr", "ref")
|
|
||||||
execShouldNoError(t, r, "sh", "-c", "test $(alr list -U | wc -l) -eq 1 || exit 1")
|
|
||||||
},
|
|
||||||
)
|
|
||||||
}
|
|
@@ -21,6 +21,7 @@ package e2etests_test
|
|||||||
import (
|
import (
|
||||||
"testing"
|
"testing"
|
||||||
|
|
||||||
|
"github.com/alecthomas/assert/v2"
|
||||||
"github.com/efficientgo/e2e"
|
"github.com/efficientgo/e2e"
|
||||||
)
|
)
|
||||||
|
|
||||||
@@ -30,9 +31,32 @@ func TestE2EIssue75InstallWithDeps(t *testing.T) {
|
|||||||
"issue-75-ref-specify",
|
"issue-75-ref-specify",
|
||||||
COMMON_SYSTEMS,
|
COMMON_SYSTEMS,
|
||||||
func(t *testing.T, r e2e.Runnable) {
|
func(t *testing.T, r e2e.Runnable) {
|
||||||
defaultPrepare(t, r)
|
err := r.Exec(e2e.NewCommand(
|
||||||
execShouldNoError(t, r, "sudo", "alr", "repo", "set-ref", "alr-repo", "bd26236cd7")
|
"sudo",
|
||||||
execShouldNoError(t, r, "sh", "-c", "test $(alr list | wc -l) -eq 2 || exit 1")
|
"alr",
|
||||||
|
"addrepo",
|
||||||
|
"--name",
|
||||||
|
"alr-repo",
|
||||||
|
"--url",
|
||||||
|
"https://gitea.plemya-x.ru/Maks1mS/repo-for-tests.git",
|
||||||
|
))
|
||||||
|
assert.NoError(t, err)
|
||||||
|
|
||||||
|
err = r.Exec(e2e.NewCommand(
|
||||||
|
"sudo", "alr", "ref",
|
||||||
|
))
|
||||||
|
assert.NoError(t, err)
|
||||||
|
|
||||||
|
// TODO: replace with alr command when it be added
|
||||||
|
err = r.Exec(e2e.NewCommand(
|
||||||
|
"sudo", "sh", "-c", "sed -i 's/ref = .*/ref = \"bd26236cd7\"/' /etc/alr/alr.toml",
|
||||||
|
))
|
||||||
|
assert.NoError(t, err)
|
||||||
|
|
||||||
|
err = r.Exec(e2e.NewCommand(
|
||||||
|
"sh", "-c", "test $(alr list | wc -l) -eq 2 || exit 1",
|
||||||
|
))
|
||||||
|
assert.NoError(t, err)
|
||||||
},
|
},
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
@@ -1,38 +0,0 @@
|
|||||||
// ALR - Any Linux Repository
|
|
||||||
// Copyright (C) 2025 The ALR Authors
|
|
||||||
//
|
|
||||||
// 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/>.
|
|
||||||
|
|
||||||
//go:build e2e
|
|
||||||
|
|
||||||
package e2etests_test
|
|
||||||
|
|
||||||
import (
|
|
||||||
"testing"
|
|
||||||
|
|
||||||
"github.com/efficientgo/e2e"
|
|
||||||
)
|
|
||||||
|
|
||||||
func TestE2EIssue81MultiplePackages(t *testing.T) {
|
|
||||||
dockerMultipleRun(
|
|
||||||
t,
|
|
||||||
"issue-81-multiple-packages",
|
|
||||||
COMMON_SYSTEMS,
|
|
||||||
func(t *testing.T, r e2e.Runnable) {
|
|
||||||
defaultPrepare(t, r)
|
|
||||||
execShouldNoError(t, r, "sudo", "alr", "in", "first-package-with-dashes")
|
|
||||||
execShouldNoError(t, r, "cat", "/opt/first-package")
|
|
||||||
},
|
|
||||||
)
|
|
||||||
}
|
|
@@ -1,40 +0,0 @@
|
|||||||
// ALR - Any Linux Repository
|
|
||||||
// Copyright (C) 2025 The ALR Authors
|
|
||||||
//
|
|
||||||
// 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/>.
|
|
||||||
|
|
||||||
//go:build e2e
|
|
||||||
|
|
||||||
package e2etests_test
|
|
||||||
|
|
||||||
import (
|
|
||||||
"testing"
|
|
||||||
|
|
||||||
"github.com/efficientgo/e2e"
|
|
||||||
)
|
|
||||||
|
|
||||||
func TestE2EIssue91MultiplePackages(t *testing.T) {
|
|
||||||
dockerMultipleRun(
|
|
||||||
t,
|
|
||||||
"issue-91-set-repo-ref",
|
|
||||||
COMMON_SYSTEMS,
|
|
||||||
func(t *testing.T, r e2e.Runnable) {
|
|
||||||
defaultPrepare(t, r)
|
|
||||||
execShouldError(t, r, "sudo", "alr", "repo", "set-ref")
|
|
||||||
execShouldError(t, r, "sudo", "alr", "repo", "set-ref", "alr-repo")
|
|
||||||
execShouldNoError(t, r, "sudo", "alr", "repo", "set-ref", "alr-repo", "bd26236cd7")
|
|
||||||
execShouldNoError(t, r, "sh", "-c", "test $(alr list | wc -l) -eq 2 || exit 1")
|
|
||||||
},
|
|
||||||
)
|
|
||||||
}
|
|
@@ -21,7 +21,6 @@ import (
|
|||||||
"fmt"
|
"fmt"
|
||||||
"log/slog"
|
"log/slog"
|
||||||
|
|
||||||
"github.com/leonelquinteros/gotext"
|
|
||||||
"github.com/urfave/cli/v2"
|
"github.com/urfave/cli/v2"
|
||||||
)
|
)
|
||||||
|
|
||||||
@@ -62,11 +61,3 @@ func FormatCliExitWithCode(msg string, err error, exitCode int) cli.ExitCoder {
|
|||||||
}
|
}
|
||||||
return cli.Exit(fmt.Errorf("%s: %w", msg, err), exitCode)
|
return cli.Exit(fmt.Errorf("%s: %w", msg, err), exitCode)
|
||||||
}
|
}
|
||||||
|
|
||||||
func WarnLegacyCommand(newSyntax string) {
|
|
||||||
slog.Warn(
|
|
||||||
gotext.Get(
|
|
||||||
"This command is deprecated and would be removed in the future, use \"%s\" instead!", newSyntax,
|
|
||||||
),
|
|
||||||
)
|
|
||||||
}
|
|
||||||
|
@@ -104,7 +104,7 @@ func Resolve(info *distro.OSRelease, opts *Opts) ([]string, error) {
|
|||||||
out = append(out, opts.Name)
|
out = append(out, opts.Name)
|
||||||
|
|
||||||
for index, item := range out {
|
for index, item := range out {
|
||||||
out[index] = strings.TrimPrefix(item, "_")
|
out[index] = strings.TrimPrefix(strings.ReplaceAll(item, "-", "_"), "_")
|
||||||
}
|
}
|
||||||
|
|
||||||
return out, nil
|
return out, nil
|
||||||
|
@@ -38,23 +38,23 @@ msgstr ""
|
|||||||
msgid "Cannot get absolute script path"
|
msgid "Cannot get absolute script path"
|
||||||
msgstr ""
|
msgstr ""
|
||||||
|
|
||||||
#: build.go:152
|
#: build.go:148
|
||||||
msgid "Package not found"
|
msgid "Package not found"
|
||||||
msgstr ""
|
msgstr ""
|
||||||
|
|
||||||
#: build.go:165
|
#: build.go:161
|
||||||
msgid "Nothing to build"
|
msgid "Nothing to build"
|
||||||
msgstr ""
|
msgstr ""
|
||||||
|
|
||||||
#: build.go:222
|
#: build.go:218
|
||||||
msgid "Error building package"
|
msgid "Error building package"
|
||||||
msgstr ""
|
msgstr ""
|
||||||
|
|
||||||
#: build.go:229
|
#: build.go:225
|
||||||
msgid "Error moving the package"
|
msgid "Error moving the package"
|
||||||
msgstr ""
|
msgstr ""
|
||||||
|
|
||||||
#: build.go:233
|
#: build.go:229
|
||||||
msgid "Done"
|
msgid "Done"
|
||||||
msgstr ""
|
msgstr ""
|
||||||
|
|
||||||
@@ -278,12 +278,6 @@ msgstr ""
|
|||||||
msgid "OPTIONS"
|
msgid "OPTIONS"
|
||||||
msgstr ""
|
msgstr ""
|
||||||
|
|
||||||
#: internal/cliutils/utils.go:69
|
|
||||||
msgid ""
|
|
||||||
"This command is deprecated and would be removed in the future, use \"%s\" "
|
|
||||||
"instead!"
|
|
||||||
msgstr ""
|
|
||||||
|
|
||||||
#: internal/db/db.go:137
|
#: internal/db/db.go:137
|
||||||
msgid "Database version mismatch; resetting"
|
msgid "Database version mismatch; resetting"
|
||||||
msgstr ""
|
msgstr ""
|
||||||
@@ -333,30 +327,10 @@ 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:43
|
#: list.go:41
|
||||||
msgid "List ALR repo packages"
|
msgid "List ALR repo packages"
|
||||||
msgstr ""
|
msgstr ""
|
||||||
|
|
||||||
#: list.go:57
|
|
||||||
msgid "Format output using a Go template"
|
|
||||||
msgstr ""
|
|
||||||
|
|
||||||
#: list.go:89
|
|
||||||
msgid "Error getting packages for upgrade"
|
|
||||||
msgstr ""
|
|
||||||
|
|
||||||
#: list.go:92
|
|
||||||
msgid "No packages for upgrade"
|
|
||||||
msgstr ""
|
|
||||||
|
|
||||||
#: list.go:102 list.go:187
|
|
||||||
msgid "Error parsing format template"
|
|
||||||
msgstr ""
|
|
||||||
|
|
||||||
#: list.go:108 list.go:191
|
|
||||||
msgid "Error executing template"
|
|
||||||
msgstr ""
|
|
||||||
|
|
||||||
#: main.go:45
|
#: main.go:45
|
||||||
msgid "Print the current ALR version and exit"
|
msgid "Print the current ALR version and exit"
|
||||||
msgstr ""
|
msgstr ""
|
||||||
@@ -369,11 +343,11 @@ msgstr ""
|
|||||||
msgid "Enable interactive questions and prompts"
|
msgid "Enable interactive questions and prompts"
|
||||||
msgstr ""
|
msgstr ""
|
||||||
|
|
||||||
#: main.go:146
|
#: main.go:145
|
||||||
msgid "Show help"
|
msgid "Show help"
|
||||||
msgstr ""
|
msgstr ""
|
||||||
|
|
||||||
#: main.go:150
|
#: main.go:149
|
||||||
msgid "Error while running app"
|
msgid "Error while running app"
|
||||||
msgstr ""
|
msgstr ""
|
||||||
|
|
||||||
@@ -423,104 +397,84 @@ msgstr ""
|
|||||||
msgid "AutoReq is not implemented for this package format, so it's skipped"
|
msgid "AutoReq is not implemented for this package format, so it's skipped"
|
||||||
msgstr ""
|
msgstr ""
|
||||||
|
|
||||||
#: pkg/build/script_executor.go:241
|
#: pkg/build/script_executor.go:237
|
||||||
msgid "Building package metadata"
|
msgid "Building package metadata"
|
||||||
msgstr ""
|
msgstr ""
|
||||||
|
|
||||||
#: pkg/build/script_executor.go:372
|
#: pkg/build/script_executor.go:368
|
||||||
msgid "Executing prepare()"
|
msgid "Executing prepare()"
|
||||||
msgstr ""
|
msgstr ""
|
||||||
|
|
||||||
#: pkg/build/script_executor.go:381
|
#: pkg/build/script_executor.go:377
|
||||||
msgid "Executing build()"
|
msgid "Executing build()"
|
||||||
msgstr ""
|
msgstr ""
|
||||||
|
|
||||||
#: pkg/build/script_executor.go:410 pkg/build/script_executor.go:430
|
#: pkg/build/script_executor.go:406 pkg/build/script_executor.go:426
|
||||||
msgid "Executing %s()"
|
msgid "Executing %s()"
|
||||||
msgstr ""
|
msgstr ""
|
||||||
|
|
||||||
#: pkg/repos/pull.go:77
|
#: pkg/repos/pull.go:80
|
||||||
msgid "Pulling repository"
|
msgid "Pulling repository"
|
||||||
msgstr ""
|
msgstr ""
|
||||||
|
|
||||||
#: pkg/repos/pull.go:113
|
#: pkg/repos/pull.go:116
|
||||||
msgid "Repository up to date"
|
msgid "Repository up to date"
|
||||||
msgstr ""
|
msgstr ""
|
||||||
|
|
||||||
#: pkg/repos/pull.go:204
|
#: pkg/repos/pull.go:207
|
||||||
msgid "Git repository does not appear to be a valid ALR repo"
|
msgid "Git repository does not appear to be a valid ALR repo"
|
||||||
msgstr ""
|
msgstr ""
|
||||||
|
|
||||||
#: pkg/repos/pull.go:220
|
#: pkg/repos/pull.go:223
|
||||||
msgid ""
|
msgid ""
|
||||||
"ALR repo's minimum ALR version is greater than the current version. Try "
|
"ALR repo's minimum ALR version is greater than the current version. Try "
|
||||||
"updating ALR if something doesn't work."
|
"updating ALR if something doesn't work."
|
||||||
msgstr ""
|
msgstr ""
|
||||||
|
|
||||||
#: refresh.go:30
|
|
||||||
msgid "Pull all repositories that have changed"
|
|
||||||
msgstr ""
|
|
||||||
|
|
||||||
#: repo.go:39
|
#: repo.go:39
|
||||||
msgid "Manage repos"
|
|
||||||
msgstr ""
|
|
||||||
|
|
||||||
#: repo.go:51 repo.go:269
|
|
||||||
msgid "Remove an existing repository"
|
|
||||||
msgstr ""
|
|
||||||
|
|
||||||
#: repo.go:53
|
|
||||||
msgid "<name>"
|
|
||||||
msgstr ""
|
|
||||||
|
|
||||||
#: repo.go:83
|
|
||||||
msgid "Repo \"%s\" does not exist"
|
|
||||||
msgstr ""
|
|
||||||
|
|
||||||
#: repo.go:90
|
|
||||||
msgid "Error removing repo directory"
|
|
||||||
msgstr ""
|
|
||||||
|
|
||||||
#: repo.go:94 repo.go:161 repo.go:219
|
|
||||||
msgid "Error saving config"
|
|
||||||
msgstr ""
|
|
||||||
|
|
||||||
#: repo.go:113
|
|
||||||
msgid "Error removing packages from database"
|
|
||||||
msgstr ""
|
|
||||||
|
|
||||||
#: repo.go:124 repo.go:239
|
|
||||||
msgid "Add a new repository"
|
msgid "Add a new repository"
|
||||||
msgstr ""
|
msgstr ""
|
||||||
|
|
||||||
#: repo.go:125
|
#: repo.go:46
|
||||||
msgid "<name> <url>"
|
|
||||||
msgstr ""
|
|
||||||
|
|
||||||
#: repo.go:150
|
|
||||||
msgid "Repo \"%s\" already exists"
|
|
||||||
msgstr ""
|
|
||||||
|
|
||||||
#: repo.go:187
|
|
||||||
msgid "Set the reference of the repository"
|
|
||||||
msgstr ""
|
|
||||||
|
|
||||||
#: repo.go:188
|
|
||||||
msgid "<name> <ref>"
|
|
||||||
msgstr ""
|
|
||||||
|
|
||||||
#: repo.go:246
|
|
||||||
msgid "Name of the new repo"
|
msgid "Name of the new repo"
|
||||||
msgstr ""
|
msgstr ""
|
||||||
|
|
||||||
#: repo.go:252
|
#: repo.go:52
|
||||||
msgid "URL of the new repo"
|
msgid "URL of the new repo"
|
||||||
msgstr ""
|
msgstr ""
|
||||||
|
|
||||||
#: repo.go:276
|
#: repo.go:75
|
||||||
|
msgid "Repo \"%s\" already exists"
|
||||||
|
msgstr ""
|
||||||
|
|
||||||
|
#: repo.go:86 repo.go:159
|
||||||
|
msgid "Error saving config"
|
||||||
|
msgstr ""
|
||||||
|
|
||||||
|
#: repo.go:112
|
||||||
|
msgid "Remove an existing repository"
|
||||||
|
msgstr ""
|
||||||
|
|
||||||
|
#: repo.go:119
|
||||||
msgid "Name of the repo to be deleted"
|
msgid "Name of the repo to be deleted"
|
||||||
msgstr ""
|
msgstr ""
|
||||||
|
|
||||||
|
#: repo.go:148
|
||||||
|
msgid "Repo \"%s\" does not exist"
|
||||||
|
msgstr ""
|
||||||
|
|
||||||
|
#: repo.go:155
|
||||||
|
msgid "Error removing repo directory"
|
||||||
|
msgstr ""
|
||||||
|
|
||||||
|
#: repo.go:178
|
||||||
|
msgid "Error removing packages from database"
|
||||||
|
msgstr ""
|
||||||
|
|
||||||
|
#: repo.go:189
|
||||||
|
msgid "Pull all repositories that have changed"
|
||||||
|
msgstr ""
|
||||||
|
|
||||||
#: search.go:40
|
#: search.go:40
|
||||||
msgid "Search packages"
|
msgid "Search packages"
|
||||||
msgstr ""
|
msgstr ""
|
||||||
@@ -541,10 +495,22 @@ msgstr ""
|
|||||||
msgid "Search by provides"
|
msgid "Search by provides"
|
||||||
msgstr ""
|
msgstr ""
|
||||||
|
|
||||||
|
#: search.go:71
|
||||||
|
msgid "Format output using a Go template"
|
||||||
|
msgstr ""
|
||||||
|
|
||||||
#: search.go:130
|
#: search.go:130
|
||||||
msgid "Error while executing search"
|
msgid "Error while executing search"
|
||||||
msgstr ""
|
msgstr ""
|
||||||
|
|
||||||
|
#: search.go:138
|
||||||
|
msgid "Error parsing format template"
|
||||||
|
msgstr ""
|
||||||
|
|
||||||
|
#: search.go:153
|
||||||
|
msgid "Error executing template"
|
||||||
|
msgstr ""
|
||||||
|
|
||||||
#: upgrade.go:47
|
#: upgrade.go:47
|
||||||
msgid "Upgrade all installed packages"
|
msgid "Upgrade all installed packages"
|
||||||
msgstr ""
|
msgstr ""
|
||||||
|
@@ -5,15 +5,15 @@
|
|||||||
msgid ""
|
msgid ""
|
||||||
msgstr ""
|
msgstr ""
|
||||||
"Project-Id-Version: unnamed project\n"
|
"Project-Id-Version: unnamed project\n"
|
||||||
"PO-Revision-Date: 2025-05-16 20:47+0300\n"
|
"PO-Revision-Date: 2025-04-27 18:27+0300\n"
|
||||||
"Last-Translator: Maxim Slipenko <maks1ms@alt-gnome.ru>\n"
|
"Last-Translator: Maxim Slipenko <maks1ms@alt-gnome.ru>\n"
|
||||||
"Language-Team: Russian\n"
|
"Language-Team: Russian\n"
|
||||||
"Language: ru\n"
|
"Language: ru\n"
|
||||||
"MIME-Version: 1.0\n"
|
"MIME-Version: 1.0\n"
|
||||||
"Content-Type: text/plain; charset=UTF-8\n"
|
"Content-Type: text/plain; charset=UTF-8\n"
|
||||||
"Content-Transfer-Encoding: 8bit\n"
|
"Content-Transfer-Encoding: 8bit\n"
|
||||||
"Plural-Forms: nplurals=3; plural=(n%10==1 && n%100!=11 ? 0 : n%10>=2 && "
|
"Plural-Forms: nplurals=3; plural=(n%10==1 && n%100!=11 ? 0 : n%10>=2 && n"
|
||||||
"n%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 48.0\n"
|
"X-Generator: Gtranslator 48.0\n"
|
||||||
|
|
||||||
#: build.go:42
|
#: build.go:42
|
||||||
@@ -45,23 +45,23 @@ msgstr "Ошибка при получении рабочего каталога
|
|||||||
msgid "Cannot get absolute script path"
|
msgid "Cannot get absolute script path"
|
||||||
msgstr "Невозможно получить абсолютный путь к скрипту"
|
msgstr "Невозможно получить абсолютный путь к скрипту"
|
||||||
|
|
||||||
#: build.go:152
|
#: build.go:148
|
||||||
msgid "Package not found"
|
msgid "Package not found"
|
||||||
msgstr "Пакет не найден"
|
msgstr "Пакет не найден"
|
||||||
|
|
||||||
#: build.go:165
|
#: build.go:161
|
||||||
msgid "Nothing to build"
|
msgid "Nothing to build"
|
||||||
msgstr "Нечего собирать"
|
msgstr "Нечего собирать"
|
||||||
|
|
||||||
#: build.go:222
|
#: build.go:218
|
||||||
msgid "Error building package"
|
msgid "Error building package"
|
||||||
msgstr "Ошибка при сборке пакета"
|
msgstr "Ошибка при сборке пакета"
|
||||||
|
|
||||||
#: build.go:229
|
#: build.go:225
|
||||||
msgid "Error moving the package"
|
msgid "Error moving the package"
|
||||||
msgstr "Ошибка при перемещении пакета"
|
msgstr "Ошибка при перемещении пакета"
|
||||||
|
|
||||||
#: build.go:233
|
#: build.go:229
|
||||||
msgid "Done"
|
msgid "Done"
|
||||||
msgstr "Сделано"
|
msgstr "Сделано"
|
||||||
|
|
||||||
@@ -285,14 +285,6 @@ msgstr "КАТЕГОРИЯ"
|
|||||||
msgid "OPTIONS"
|
msgid "OPTIONS"
|
||||||
msgstr "ПАРАМЕТРЫ"
|
msgstr "ПАРАМЕТРЫ"
|
||||||
|
|
||||||
#: internal/cliutils/utils.go:69
|
|
||||||
msgid ""
|
|
||||||
"This command is deprecated and would be removed in the future, use \"%s\" "
|
|
||||||
"instead!"
|
|
||||||
msgstr ""
|
|
||||||
"Эта команда устарела и будет удалена в будущем, используйте вместо нее "
|
|
||||||
"\"%s\"!"
|
|
||||||
|
|
||||||
#: internal/db/db.go:137
|
#: internal/db/db.go:137
|
||||||
msgid "Database version mismatch; resetting"
|
msgid "Database version mismatch; resetting"
|
||||||
msgstr "Несоответствие версий базы данных; сброс настроек"
|
msgstr "Несоответствие версий базы данных; сброс настроек"
|
||||||
@@ -343,30 +335,10 @@ msgstr "Вы должны быть членом %s чтобы выполнить
|
|||||||
msgid "You need to be root to perform this action"
|
msgid "You need to be root to perform this action"
|
||||||
msgstr "Вы должны быть root чтобы выполнить это"
|
msgstr "Вы должны быть root чтобы выполнить это"
|
||||||
|
|
||||||
#: list.go:43
|
#: list.go:41
|
||||||
msgid "List ALR repo packages"
|
msgid "List ALR repo packages"
|
||||||
msgstr "Список пакетов репозитория ALR"
|
msgstr "Список пакетов репозитория ALR"
|
||||||
|
|
||||||
#: list.go:57
|
|
||||||
msgid "Format output using a Go template"
|
|
||||||
msgstr "Формат выходных данных с использованием шаблона Go"
|
|
||||||
|
|
||||||
#: list.go:89
|
|
||||||
msgid "Error getting packages for upgrade"
|
|
||||||
msgstr "Ошибка при получении пакетов для обновления"
|
|
||||||
|
|
||||||
#: list.go:92
|
|
||||||
msgid "No packages for upgrade"
|
|
||||||
msgstr "Нет пакетов к обновлению"
|
|
||||||
|
|
||||||
#: list.go:102 list.go:187
|
|
||||||
msgid "Error parsing format template"
|
|
||||||
msgstr "Ошибка при разборе шаблона"
|
|
||||||
|
|
||||||
#: list.go:108 list.go:191
|
|
||||||
msgid "Error executing template"
|
|
||||||
msgstr "Ошибка при выполнении шаблона"
|
|
||||||
|
|
||||||
#: main.go:45
|
#: main.go:45
|
||||||
msgid "Print the current ALR version and exit"
|
msgid "Print the current ALR version and exit"
|
||||||
msgstr "Показать текущую версию ALR и выйти"
|
msgstr "Показать текущую версию ALR и выйти"
|
||||||
@@ -379,11 +351,11 @@ msgstr "Аргументы, которые будут переданы мене
|
|||||||
msgid "Enable interactive questions and prompts"
|
msgid "Enable interactive questions and prompts"
|
||||||
msgstr "Включение интерактивных вопросов и запросов"
|
msgstr "Включение интерактивных вопросов и запросов"
|
||||||
|
|
||||||
#: main.go:146
|
#: main.go:145
|
||||||
msgid "Show help"
|
msgid "Show help"
|
||||||
msgstr "Показать справку"
|
msgstr "Показать справку"
|
||||||
|
|
||||||
#: main.go:150
|
#: main.go:149
|
||||||
msgid "Error while running app"
|
msgid "Error while running app"
|
||||||
msgstr "Ошибка при запуске приложения"
|
msgstr "Ошибка при запуске приложения"
|
||||||
|
|
||||||
@@ -437,35 +409,35 @@ msgid "AutoReq is not implemented for this package format, so it's skipped"
|
|||||||
msgstr ""
|
msgstr ""
|
||||||
"AutoReq не реализовано для этого формата пакета, поэтому будет пропущено"
|
"AutoReq не реализовано для этого формата пакета, поэтому будет пропущено"
|
||||||
|
|
||||||
#: pkg/build/script_executor.go:241
|
#: pkg/build/script_executor.go:237
|
||||||
msgid "Building package metadata"
|
msgid "Building package metadata"
|
||||||
msgstr "Сборка метаданных пакета"
|
msgstr "Сборка метаданных пакета"
|
||||||
|
|
||||||
#: pkg/build/script_executor.go:372
|
#: pkg/build/script_executor.go:368
|
||||||
msgid "Executing prepare()"
|
msgid "Executing prepare()"
|
||||||
msgstr "Выполнение prepare()"
|
msgstr "Выполнение prepare()"
|
||||||
|
|
||||||
#: pkg/build/script_executor.go:381
|
#: pkg/build/script_executor.go:377
|
||||||
msgid "Executing build()"
|
msgid "Executing build()"
|
||||||
msgstr "Выполнение build()"
|
msgstr "Выполнение build()"
|
||||||
|
|
||||||
#: pkg/build/script_executor.go:410 pkg/build/script_executor.go:430
|
#: pkg/build/script_executor.go:406 pkg/build/script_executor.go:426
|
||||||
msgid "Executing %s()"
|
msgid "Executing %s()"
|
||||||
msgstr "Выполнение %s()"
|
msgstr "Выполнение %s()"
|
||||||
|
|
||||||
#: pkg/repos/pull.go:77
|
#: pkg/repos/pull.go:80
|
||||||
msgid "Pulling repository"
|
msgid "Pulling repository"
|
||||||
msgstr "Скачивание репозитория"
|
msgstr "Скачивание репозитория"
|
||||||
|
|
||||||
#: pkg/repos/pull.go:113
|
#: pkg/repos/pull.go:116
|
||||||
msgid "Repository up to date"
|
msgid "Repository up to date"
|
||||||
msgstr "Репозиторий уже обновлён"
|
msgstr "Репозиторий уже обновлён"
|
||||||
|
|
||||||
#: pkg/repos/pull.go:204
|
#: pkg/repos/pull.go:207
|
||||||
msgid "Git repository does not appear to be a valid ALR repo"
|
msgid "Git repository does not appear to be a valid ALR repo"
|
||||||
msgstr "Репозиторий Git не поддерживается репозиторием ALR"
|
msgstr "Репозиторий Git не поддерживается репозиторием ALR"
|
||||||
|
|
||||||
#: pkg/repos/pull.go:220
|
#: pkg/repos/pull.go:223
|
||||||
msgid ""
|
msgid ""
|
||||||
"ALR repo's minimum ALR version is greater than the current version. Try "
|
"ALR repo's minimum ALR version is greater than the current version. Try "
|
||||||
"updating ALR if something doesn't work."
|
"updating ALR if something doesn't work."
|
||||||
@@ -473,70 +445,50 @@ msgstr ""
|
|||||||
"Минимальная версия ALR для ALR-репозитория выше текущей версии. Попробуйте "
|
"Минимальная версия ALR для ALR-репозитория выше текущей версии. Попробуйте "
|
||||||
"обновить ALR, если что-то не работает."
|
"обновить ALR, если что-то не работает."
|
||||||
|
|
||||||
#: refresh.go:30
|
|
||||||
msgid "Pull all repositories that have changed"
|
|
||||||
msgstr "Скачать все изменённые репозитории"
|
|
||||||
|
|
||||||
#: repo.go:39
|
#: repo.go:39
|
||||||
msgid "Manage repos"
|
|
||||||
msgstr "Управление репозиториями"
|
|
||||||
|
|
||||||
#: repo.go:51 repo.go:269
|
|
||||||
msgid "Remove an existing repository"
|
|
||||||
msgstr "Удалить существующий репозиторий"
|
|
||||||
|
|
||||||
#: repo.go:53
|
|
||||||
msgid "<name>"
|
|
||||||
msgstr "<имя>"
|
|
||||||
|
|
||||||
#: repo.go:83
|
|
||||||
msgid "Repo \"%s\" does not exist"
|
|
||||||
msgstr "Репозитория \"%s\" не существует"
|
|
||||||
|
|
||||||
#: repo.go:90
|
|
||||||
msgid "Error removing repo directory"
|
|
||||||
msgstr "Ошибка при удалении каталога репозитория"
|
|
||||||
|
|
||||||
#: repo.go:94 repo.go:161 repo.go:219
|
|
||||||
msgid "Error saving config"
|
|
||||||
msgstr "Ошибка при сохранении конфигурации"
|
|
||||||
|
|
||||||
#: repo.go:113
|
|
||||||
msgid "Error removing packages from database"
|
|
||||||
msgstr "Ошибка при удалении пакетов из базы данных"
|
|
||||||
|
|
||||||
#: repo.go:124 repo.go:239
|
|
||||||
msgid "Add a new repository"
|
msgid "Add a new repository"
|
||||||
msgstr "Добавить новый репозиторий"
|
msgstr "Добавить новый репозиторий"
|
||||||
|
|
||||||
#: repo.go:125
|
#: repo.go:46
|
||||||
msgid "<name> <url>"
|
|
||||||
msgstr "<имя> <url>"
|
|
||||||
|
|
||||||
#: repo.go:150
|
|
||||||
msgid "Repo \"%s\" already exists"
|
|
||||||
msgstr "Репозиторий \"%s\" уже существует"
|
|
||||||
|
|
||||||
#: repo.go:187
|
|
||||||
msgid "Set the reference of the repository"
|
|
||||||
msgstr "Установить ссылку на версию репозитория"
|
|
||||||
|
|
||||||
#: repo.go:188
|
|
||||||
msgid "<name> <ref>"
|
|
||||||
msgstr "<имя> <ссылка_на_версию>"
|
|
||||||
|
|
||||||
#: repo.go:246
|
|
||||||
msgid "Name of the new repo"
|
msgid "Name of the new repo"
|
||||||
msgstr "Название нового репозитория"
|
msgstr "Название нового репозитория"
|
||||||
|
|
||||||
#: repo.go:252
|
#: repo.go:52
|
||||||
msgid "URL of the new repo"
|
msgid "URL of the new repo"
|
||||||
msgstr "URL-адрес нового репозитория"
|
msgstr "URL-адрес нового репозитория"
|
||||||
|
|
||||||
#: repo.go:276
|
#: repo.go:75
|
||||||
|
msgid "Repo \"%s\" already exists"
|
||||||
|
msgstr "Репозиторий \"%s\" уже существует"
|
||||||
|
|
||||||
|
#: repo.go:86 repo.go:159
|
||||||
|
msgid "Error saving config"
|
||||||
|
msgstr "Ошибка при сохранении конфигурации"
|
||||||
|
|
||||||
|
#: repo.go:112
|
||||||
|
msgid "Remove an existing repository"
|
||||||
|
msgstr "Удалить существующий репозиторий"
|
||||||
|
|
||||||
|
#: repo.go:119
|
||||||
msgid "Name of the repo to be deleted"
|
msgid "Name of the repo to be deleted"
|
||||||
msgstr "Название репозитория удалён"
|
msgstr "Название репозитория удалён"
|
||||||
|
|
||||||
|
#: repo.go:148
|
||||||
|
msgid "Repo \"%s\" does not exist"
|
||||||
|
msgstr "Репозитория \"%s\" не существует"
|
||||||
|
|
||||||
|
#: repo.go:155
|
||||||
|
msgid "Error removing repo directory"
|
||||||
|
msgstr "Ошибка при удалении каталога репозитория"
|
||||||
|
|
||||||
|
#: repo.go:178
|
||||||
|
msgid "Error removing packages from database"
|
||||||
|
msgstr "Ошибка при удалении пакетов из базы данных"
|
||||||
|
|
||||||
|
#: repo.go:189
|
||||||
|
msgid "Pull all repositories that have changed"
|
||||||
|
msgstr "Скачать все изменённые репозитории"
|
||||||
|
|
||||||
#: search.go:40
|
#: search.go:40
|
||||||
msgid "Search packages"
|
msgid "Search packages"
|
||||||
msgstr "Поиск пакетов"
|
msgstr "Поиск пакетов"
|
||||||
@@ -557,10 +509,22 @@ msgstr "Искать по репозиторию"
|
|||||||
msgid "Search by provides"
|
msgid "Search by provides"
|
||||||
msgstr "Иcкать по provides"
|
msgstr "Иcкать по provides"
|
||||||
|
|
||||||
|
#: search.go:71
|
||||||
|
msgid "Format output using a Go template"
|
||||||
|
msgstr "Формат выходных данных с использованием шаблона Go"
|
||||||
|
|
||||||
#: search.go:130
|
#: search.go:130
|
||||||
msgid "Error while executing search"
|
msgid "Error while executing search"
|
||||||
msgstr "Ошибка при выполнении поиска"
|
msgstr "Ошибка при выполнении поиска"
|
||||||
|
|
||||||
|
#: search.go:138
|
||||||
|
msgid "Error parsing format template"
|
||||||
|
msgstr "Ошибка при разборе шаблона"
|
||||||
|
|
||||||
|
#: search.go:153
|
||||||
|
msgid "Error executing template"
|
||||||
|
msgstr "Ошибка при выполнении шаблона"
|
||||||
|
|
||||||
#: upgrade.go:47
|
#: upgrade.go:47
|
||||||
msgid "Upgrade all installed packages"
|
msgid "Upgrade all installed packages"
|
||||||
msgstr "Обновить все установленные пакеты"
|
msgstr "Обновить все установленные пакеты"
|
||||||
|
72
list.go
72
list.go
@@ -22,12 +22,10 @@ package main
|
|||||||
import (
|
import (
|
||||||
"fmt"
|
"fmt"
|
||||||
"log/slog"
|
"log/slog"
|
||||||
"os"
|
|
||||||
"slices"
|
|
||||||
"text/template"
|
|
||||||
|
|
||||||
"github.com/leonelquinteros/gotext"
|
"github.com/leonelquinteros/gotext"
|
||||||
"github.com/urfave/cli/v2"
|
"github.com/urfave/cli/v2"
|
||||||
|
"golang.org/x/exp/slices"
|
||||||
|
|
||||||
"gitea.plemya-x.ru/Plemya-x/ALR/internal/cliutils"
|
"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"
|
||||||
@@ -47,15 +45,6 @@ func ListCmd() *cli.Command {
|
|||||||
Name: "installed",
|
Name: "installed",
|
||||||
Aliases: []string{"I"},
|
Aliases: []string{"I"},
|
||||||
},
|
},
|
||||||
&cli.BoolFlag{
|
|
||||||
Name: "upgradable",
|
|
||||||
Aliases: []string{"U"},
|
|
||||||
},
|
|
||||||
&cli.StringFlag{
|
|
||||||
Name: "format",
|
|
||||||
Aliases: []string{"f"},
|
|
||||||
Usage: gotext.Get("Format output using a Go template"),
|
|
||||||
},
|
|
||||||
},
|
},
|
||||||
Action: func(c *cli.Context) error {
|
Action: func(c *cli.Context) error {
|
||||||
if err := utils.ExitIfCantDropCapsToAlrUserNoPrivs(); err != nil {
|
if err := utils.ExitIfCantDropCapsToAlrUserNoPrivs(); err != nil {
|
||||||
@@ -68,10 +57,8 @@ func ListCmd() *cli.Command {
|
|||||||
New(ctx).
|
New(ctx).
|
||||||
WithConfig().
|
WithConfig().
|
||||||
WithDB().
|
WithDB().
|
||||||
WithManager().
|
|
||||||
// autoPull only
|
// autoPull only
|
||||||
WithRepos().
|
WithRepos().
|
||||||
WithDistroInfo().
|
|
||||||
Build()
|
Build()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
@@ -80,39 +67,6 @@ func ListCmd() *cli.Command {
|
|||||||
|
|
||||||
cfg := deps.Cfg
|
cfg := deps.Cfg
|
||||||
db := deps.DB
|
db := deps.DB
|
||||||
mgr := deps.Manager
|
|
||||||
info := deps.Info
|
|
||||||
|
|
||||||
if c.Bool("upgradable") {
|
|
||||||
updates, err := checkForUpdates(ctx, mgr, db, info)
|
|
||||||
if err != nil {
|
|
||||||
return cliutils.FormatCliExit(gotext.Get("Error getting packages for upgrade"), err)
|
|
||||||
}
|
|
||||||
if len(updates) == 0 {
|
|
||||||
slog.Info(gotext.Get("No packages for upgrade"))
|
|
||||||
return nil
|
|
||||||
}
|
|
||||||
|
|
||||||
format := c.String("format")
|
|
||||||
if format == "" {
|
|
||||||
format = "{{.Package.Repository}}/{{.Package.Name}} {{.FromVersion}} -> {{.ToVersion}}\n"
|
|
||||||
}
|
|
||||||
tmpl, err := template.New("format").Parse(format)
|
|
||||||
if err != nil {
|
|
||||||
return cliutils.FormatCliExit(gotext.Get("Error parsing format template"), err)
|
|
||||||
}
|
|
||||||
|
|
||||||
for _, updateInfo := range updates {
|
|
||||||
err = tmpl.Execute(os.Stdout, updateInfo)
|
|
||||||
if err != nil {
|
|
||||||
return cliutils.FormatCliExit(gotext.Get("Error executing template"), err)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return nil
|
|
||||||
}
|
|
||||||
|
|
||||||
// TODO: refactor code below
|
|
||||||
|
|
||||||
where := "true"
|
where := "true"
|
||||||
args := []any(nil)
|
args := []any(nil)
|
||||||
@@ -161,35 +115,17 @@ func ListCmd() *cli.Command {
|
|||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
|
|
||||||
type packageInfo struct {
|
version := pkg.Version
|
||||||
Package *database.Package
|
|
||||||
Version string
|
|
||||||
}
|
|
||||||
|
|
||||||
pkgInfo := &packageInfo{}
|
|
||||||
pkgInfo.Package = &pkg
|
|
||||||
pkgInfo.Version = pkg.Version
|
|
||||||
if c.Bool("installed") {
|
if c.Bool("installed") {
|
||||||
instVersion, ok := installedAlrPackages[fmt.Sprintf("%s/%s", pkg.Repository, pkg.Name)]
|
instVersion, ok := installedAlrPackages[fmt.Sprintf("%s/%s", pkg.Repository, pkg.Name)]
|
||||||
if !ok {
|
if !ok {
|
||||||
continue
|
continue
|
||||||
} else {
|
} else {
|
||||||
pkgInfo.Version = instVersion
|
version = instVersion
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
format := c.String("format")
|
fmt.Printf("%s/%s %s\n", pkg.Repository, pkg.Name, version)
|
||||||
if format == "" {
|
|
||||||
format = "{{.Package.Repository}}/{{.Package.Name}} {{.Version}}\n"
|
|
||||||
}
|
|
||||||
tmpl, err := template.New("format").Parse(format)
|
|
||||||
if err != nil {
|
|
||||||
return cliutils.FormatCliExit(gotext.Get("Error parsing format template"), err)
|
|
||||||
}
|
|
||||||
err = tmpl.Execute(os.Stdout, pkgInfo)
|
|
||||||
if err != nil {
|
|
||||||
return cliutils.FormatCliExit(gotext.Get("Error executing template"), err)
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return nil
|
return nil
|
||||||
|
5
main.go
5
main.go
@@ -74,15 +74,14 @@ func GetApp() *cli.App {
|
|||||||
InfoCmd(),
|
InfoCmd(),
|
||||||
ListCmd(),
|
ListCmd(),
|
||||||
BuildCmd(),
|
BuildCmd(),
|
||||||
LegacyAddRepoCmd(),
|
AddRepoCmd(),
|
||||||
LegacyRemoveRepoCmd(),
|
RemoveRepoCmd(),
|
||||||
RefreshCmd(),
|
RefreshCmd(),
|
||||||
FixCmd(),
|
FixCmd(),
|
||||||
GenCmd(),
|
GenCmd(),
|
||||||
HelperCmd(),
|
HelperCmd(),
|
||||||
VersionCmd(),
|
VersionCmd(),
|
||||||
SearchCmd(),
|
SearchCmd(),
|
||||||
RepoCmd(),
|
|
||||||
// Internal commands
|
// Internal commands
|
||||||
InternalBuildCmd(),
|
InternalBuildCmd(),
|
||||||
InternalInstallCmd(),
|
InternalInstallCmd(),
|
||||||
|
@@ -118,20 +118,16 @@ func (e *LocalScriptExecutor) ExecuteFirstPass(ctx context.Context, input *Build
|
|||||||
return vars.Name, varsOfPackages, nil
|
return vars.Name, varsOfPackages, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
var pkgNames []string
|
if len(input.packages) == 0 {
|
||||||
|
return "", nil, errors.New("script has multiple packages but package is not specified")
|
||||||
if len(input.packages) != 0 {
|
|
||||||
pkgNames = input.packages
|
|
||||||
} else {
|
|
||||||
pkgNames = pkgs.Names
|
|
||||||
}
|
}
|
||||||
|
|
||||||
for _, pkgName := range pkgNames {
|
for _, pkgName := range input.packages {
|
||||||
var preVars types.BuildVarsPre
|
var preVars types.BuildVarsPre
|
||||||
funcName := fmt.Sprintf("meta_%s", pkgName)
|
funcName := fmt.Sprintf("meta_%s", pkgName)
|
||||||
meta, ok := dec.GetFuncWithSubshell(funcName)
|
meta, ok := dec.GetFuncWithSubshell(funcName)
|
||||||
if !ok {
|
if !ok {
|
||||||
return "", nil, fmt.Errorf("func %s is missing", funcName)
|
return "", nil, errors.New("func is missing")
|
||||||
}
|
}
|
||||||
r, err := meta(ctx)
|
r, err := meta(ctx)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
@@ -1,38 +0,0 @@
|
|||||||
// ALR - Any Linux Repository
|
|
||||||
// Copyright (C) 2025 The ALR Authors
|
|
||||||
//
|
|
||||||
// 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/>.
|
|
||||||
|
|
||||||
package parser
|
|
||||||
|
|
||||||
import (
|
|
||||||
"fmt"
|
|
||||||
|
|
||||||
"gitea.plemya-x.ru/Plemya-x/ALR/internal/shutils/decoder"
|
|
||||||
)
|
|
||||||
|
|
||||||
type PackageNames struct {
|
|
||||||
BasePkgName string `sh:"basepkg_name"`
|
|
||||||
Names []string `sh:"name"`
|
|
||||||
}
|
|
||||||
|
|
||||||
func ParseNames(dec *decoder.Decoder) (*PackageNames, error) {
|
|
||||||
var pkgs PackageNames
|
|
||||||
err := dec.DecodeVars(&pkgs)
|
|
||||||
if err != nil {
|
|
||||||
return nil, fmt.Errorf("fail parse names: %w", err)
|
|
||||||
}
|
|
||||||
|
|
||||||
return &pkgs, nil
|
|
||||||
}
|
|
@@ -43,8 +43,11 @@ import (
|
|||||||
"mvdan.cc/sh/v3/syntax"
|
"mvdan.cc/sh/v3/syntax"
|
||||||
|
|
||||||
"gitea.plemya-x.ru/Plemya-x/ALR/internal/config"
|
"gitea.plemya-x.ru/Plemya-x/ALR/internal/config"
|
||||||
|
"gitea.plemya-x.ru/Plemya-x/ALR/internal/db"
|
||||||
|
"gitea.plemya-x.ru/Plemya-x/ALR/internal/shutils/decoder"
|
||||||
"gitea.plemya-x.ru/Plemya-x/ALR/internal/shutils/handlers"
|
"gitea.plemya-x.ru/Plemya-x/ALR/internal/shutils/handlers"
|
||||||
"gitea.plemya-x.ru/Plemya-x/ALR/internal/types"
|
"gitea.plemya-x.ru/Plemya-x/ALR/internal/types"
|
||||||
|
"gitea.plemya-x.ru/Plemya-x/ALR/pkg/distro"
|
||||||
)
|
)
|
||||||
|
|
||||||
type actionType uint8
|
type actionType uint8
|
||||||
@@ -228,19 +231,79 @@ func (rs *Repos) Pull(ctx context.Context, repos []types.Repo) error {
|
|||||||
func (rs *Repos) updatePkg(ctx context.Context, repo types.Repo, runner *interp.Runner, scriptFl io.ReadCloser) error {
|
func (rs *Repos) updatePkg(ctx context.Context, repo types.Repo, runner *interp.Runner, scriptFl io.ReadCloser) error {
|
||||||
parser := syntax.NewParser()
|
parser := syntax.NewParser()
|
||||||
|
|
||||||
pkgs, err := parseScript(ctx, repo, parser, runner, scriptFl)
|
defer scriptFl.Close()
|
||||||
|
fl, err := parser.Parse(scriptFl, "alr.sh")
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
for _, pkg := range pkgs {
|
runner.Reset()
|
||||||
err = rs.db.InsertPackage(ctx, *pkg)
|
err = runner.Run(ctx, fl)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return nil
|
type packages struct {
|
||||||
|
BasePkgName string `sh:"basepkg_name"`
|
||||||
|
Names []string `sh:"name"`
|
||||||
|
}
|
||||||
|
|
||||||
|
var pkgs packages
|
||||||
|
|
||||||
|
d := decoder.New(&distro.OSRelease{}, runner)
|
||||||
|
d.Overrides = false
|
||||||
|
d.LikeDistros = false
|
||||||
|
err = d.DecodeVars(&pkgs)
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
|
||||||
|
if len(pkgs.Names) > 1 {
|
||||||
|
if pkgs.BasePkgName == "" {
|
||||||
|
pkgs.BasePkgName = pkgs.Names[0]
|
||||||
|
}
|
||||||
|
for _, pkgName := range pkgs.Names {
|
||||||
|
pkgInfo := PackageInfo{}
|
||||||
|
funcName := fmt.Sprintf("meta_%s", pkgName)
|
||||||
|
runner.Reset()
|
||||||
|
err = runner.Run(ctx, fl)
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
meta, ok := d.GetFuncWithSubshell(funcName)
|
||||||
|
if !ok {
|
||||||
|
return errors.New("func is missing")
|
||||||
|
}
|
||||||
|
r, err := meta(ctx)
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
d := decoder.New(&distro.OSRelease{}, r)
|
||||||
|
d.Overrides = false
|
||||||
|
d.LikeDistros = false
|
||||||
|
err = d.DecodeVars(&pkgInfo)
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
pkg := pkgInfo.ToPackage(repo.Name)
|
||||||
|
resolveOverrides(r, pkg)
|
||||||
|
pkg.Name = pkgName
|
||||||
|
pkg.BasePkgName = pkgs.BasePkgName
|
||||||
|
err = rs.db.InsertPackage(ctx, *pkg)
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|
||||||
|
pkg := EmptyPackage(repo.Name)
|
||||||
|
err = d.DecodeVars(pkg)
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
resolveOverrides(runner, pkg)
|
||||||
|
return rs.db.InsertPackage(ctx, *pkg)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (rs *Repos) processRepoChangesRunner(repoDir, scriptDir string) (*interp.Runner, error) {
|
func (rs *Repos) processRepoChangesRunner(repoDir, scriptDir string) (*interp.Runner, error) {
|
||||||
@@ -336,16 +399,15 @@ func (rs *Repos) processRepoChanges(ctx context.Context, repo types.Repo, r *git
|
|||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
pkgs, err := parseScript(ctx, repo, parser, runner, r)
|
var pkg db.Package
|
||||||
|
err = parseScript(ctx, parser, runner, r, &pkg)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
for _, pkg := range pkgs {
|
err = rs.db.DeletePkgs(ctx, "name = ? AND repository = ?", pkg.Name, repo.Name)
|
||||||
err = rs.db.DeletePkgs(ctx, "name = ? AND repository = ?", pkg.Name, repo.Name)
|
if err != nil {
|
||||||
if err != nil {
|
return err
|
||||||
return err
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
case actionUpdate:
|
case actionUpdate:
|
||||||
if filepath.Base(action.File) != "alr.sh" {
|
if filepath.Base(action.File) != "alr.sh" {
|
||||||
|
@@ -18,7 +18,6 @@ package repos
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
"context"
|
"context"
|
||||||
"errors"
|
|
||||||
"fmt"
|
"fmt"
|
||||||
"io"
|
"io"
|
||||||
"path/filepath"
|
"path/filepath"
|
||||||
@@ -36,9 +35,7 @@ import (
|
|||||||
|
|
||||||
"gitea.plemya-x.ru/Plemya-x/ALR/internal/db"
|
"gitea.plemya-x.ru/Plemya-x/ALR/internal/db"
|
||||||
"gitea.plemya-x.ru/Plemya-x/ALR/internal/shutils/decoder"
|
"gitea.plemya-x.ru/Plemya-x/ALR/internal/shutils/decoder"
|
||||||
"gitea.plemya-x.ru/Plemya-x/ALR/internal/types"
|
|
||||||
"gitea.plemya-x.ru/Plemya-x/ALR/pkg/distro"
|
"gitea.plemya-x.ru/Plemya-x/ALR/pkg/distro"
|
||||||
"gitea.plemya-x.ru/Plemya-x/ALR/pkg/parser"
|
|
||||||
)
|
)
|
||||||
|
|
||||||
// isValid makes sure the path of the file being updated is valid.
|
// isValid makes sure the path of the file being updated is valid.
|
||||||
@@ -57,85 +54,23 @@ func isValid(from, to diff.File) bool {
|
|||||||
return match
|
return match
|
||||||
}
|
}
|
||||||
|
|
||||||
func parseScript(
|
func parseScript(ctx context.Context, parser *syntax.Parser, runner *interp.Runner, r io.ReadCloser, pkg *db.Package) error {
|
||||||
ctx context.Context,
|
defer r.Close()
|
||||||
repo types.Repo,
|
fl, err := parser.Parse(r, "alr.sh")
|
||||||
syntaxParser *syntax.Parser,
|
|
||||||
runner *interp.Runner,
|
|
||||||
r io.ReadCloser,
|
|
||||||
) ([]*db.Package, error) {
|
|
||||||
fl, err := syntaxParser.Parse(r, "alr.sh")
|
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
runner.Reset()
|
runner.Reset()
|
||||||
err = runner.Run(ctx, fl)
|
err = runner.Run(ctx, fl)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
d := decoder.New(&distro.OSRelease{}, runner)
|
d := decoder.New(&distro.OSRelease{}, runner)
|
||||||
d.Overrides = false
|
d.Overrides = false
|
||||||
d.LikeDistros = false
|
d.LikeDistros = false
|
||||||
|
return d.DecodeVars(pkg)
|
||||||
pkgNames, err := parser.ParseNames(d)
|
|
||||||
if err != nil {
|
|
||||||
return nil, fmt.Errorf("failed parsing package names: %w", err)
|
|
||||||
}
|
|
||||||
|
|
||||||
if len(pkgNames.Names) == 0 {
|
|
||||||
return nil, errors.New("package name is missing")
|
|
||||||
}
|
|
||||||
|
|
||||||
var dbPkgs []*db.Package
|
|
||||||
|
|
||||||
if len(pkgNames.Names) > 1 {
|
|
||||||
if pkgNames.BasePkgName == "" {
|
|
||||||
pkgNames.BasePkgName = pkgNames.Names[0]
|
|
||||||
}
|
|
||||||
for _, pkgName := range pkgNames.Names {
|
|
||||||
pkgInfo := PackageInfo{}
|
|
||||||
funcName := fmt.Sprintf("meta_%s", pkgName)
|
|
||||||
runner.Reset()
|
|
||||||
err = runner.Run(ctx, fl)
|
|
||||||
if err != nil {
|
|
||||||
return nil, err
|
|
||||||
}
|
|
||||||
meta, ok := d.GetFuncWithSubshell(funcName)
|
|
||||||
if !ok {
|
|
||||||
return nil, fmt.Errorf("func %s is missing", funcName)
|
|
||||||
}
|
|
||||||
r, err := meta(ctx)
|
|
||||||
if err != nil {
|
|
||||||
return nil, err
|
|
||||||
}
|
|
||||||
d := decoder.New(&distro.OSRelease{}, r)
|
|
||||||
d.Overrides = false
|
|
||||||
d.LikeDistros = false
|
|
||||||
err = d.DecodeVars(&pkgInfo)
|
|
||||||
if err != nil {
|
|
||||||
return nil, err
|
|
||||||
}
|
|
||||||
pkg := pkgInfo.ToPackage(repo.Name)
|
|
||||||
resolveOverrides(r, pkg)
|
|
||||||
pkg.Name = pkgName
|
|
||||||
pkg.BasePkgName = pkgNames.BasePkgName
|
|
||||||
dbPkgs = append(dbPkgs, pkg)
|
|
||||||
}
|
|
||||||
|
|
||||||
return dbPkgs, nil
|
|
||||||
}
|
|
||||||
|
|
||||||
pkg := EmptyPackage(repo.Name)
|
|
||||||
err = d.DecodeVars(pkg)
|
|
||||||
if err != nil {
|
|
||||||
return nil, err
|
|
||||||
}
|
|
||||||
resolveOverrides(runner, pkg)
|
|
||||||
dbPkgs = append(dbPkgs, pkg)
|
|
||||||
|
|
||||||
return dbPkgs, nil
|
|
||||||
}
|
}
|
||||||
|
|
||||||
type PackageInfo struct {
|
type PackageInfo struct {
|
||||||
|
52
refresh.go
52
refresh.go
@@ -1,52 +0,0 @@
|
|||||||
// ALR - Any Linux Repository
|
|
||||||
// Copyright (C) 2025 The ALR Authors
|
|
||||||
//
|
|
||||||
// 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/>.
|
|
||||||
|
|
||||||
package main
|
|
||||||
|
|
||||||
import (
|
|
||||||
"github.com/leonelquinteros/gotext"
|
|
||||||
"github.com/urfave/cli/v2"
|
|
||||||
|
|
||||||
appbuilder "gitea.plemya-x.ru/Plemya-x/ALR/internal/cliutils/app_builder"
|
|
||||||
"gitea.plemya-x.ru/Plemya-x/ALR/internal/utils"
|
|
||||||
)
|
|
||||||
|
|
||||||
func RefreshCmd() *cli.Command {
|
|
||||||
return &cli.Command{
|
|
||||||
Name: "refresh",
|
|
||||||
Usage: gotext.Get("Pull all repositories that have changed"),
|
|
||||||
Aliases: []string{"ref"},
|
|
||||||
Action: func(c *cli.Context) error {
|
|
||||||
if err := utils.ExitIfCantDropCapsToAlrUser(); err != nil {
|
|
||||||
return err
|
|
||||||
}
|
|
||||||
|
|
||||||
ctx := c.Context
|
|
||||||
|
|
||||||
deps, err := appbuilder.
|
|
||||||
New(ctx).
|
|
||||||
WithConfig().
|
|
||||||
WithDB().
|
|
||||||
WithReposForcePull().
|
|
||||||
Build()
|
|
||||||
if err != nil {
|
|
||||||
return err
|
|
||||||
}
|
|
||||||
defer deps.Defer()
|
|
||||||
return nil
|
|
||||||
},
|
|
||||||
}
|
|
||||||
}
|
|
249
repo.go
249
repo.go
@@ -33,32 +33,97 @@ import (
|
|||||||
"gitea.plemya-x.ru/Plemya-x/ALR/internal/utils"
|
"gitea.plemya-x.ru/Plemya-x/ALR/internal/utils"
|
||||||
)
|
)
|
||||||
|
|
||||||
func RepoCmd() *cli.Command {
|
func AddRepoCmd() *cli.Command {
|
||||||
return &cli.Command{
|
return &cli.Command{
|
||||||
Name: "repo",
|
Name: "addrepo",
|
||||||
Usage: gotext.Get("Manage repos"),
|
Usage: gotext.Get("Add a new repository"),
|
||||||
Subcommands: []*cli.Command{
|
Aliases: []string{"ar"},
|
||||||
RemoveRepoCmd(),
|
Flags: []cli.Flag{
|
||||||
AddRepoCmd(),
|
&cli.StringFlag{
|
||||||
SetRepoRefCmd(),
|
Name: "name",
|
||||||
|
Aliases: []string{"n"},
|
||||||
|
Required: true,
|
||||||
|
Usage: gotext.Get("Name of the new repo"),
|
||||||
|
},
|
||||||
|
&cli.StringFlag{
|
||||||
|
Name: "url",
|
||||||
|
Aliases: []string{"u"},
|
||||||
|
Required: true,
|
||||||
|
Usage: gotext.Get("URL of the new repo"),
|
||||||
|
},
|
||||||
},
|
},
|
||||||
|
Action: utils.RootNeededAction(func(c *cli.Context) error {
|
||||||
|
name := c.String("name")
|
||||||
|
repoURL := c.String("url")
|
||||||
|
|
||||||
|
ctx := c.Context
|
||||||
|
|
||||||
|
deps, err := appbuilder.
|
||||||
|
New(ctx).
|
||||||
|
WithConfig().
|
||||||
|
Build()
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
defer deps.Defer()
|
||||||
|
|
||||||
|
cfg := deps.Cfg
|
||||||
|
|
||||||
|
reposSlice := cfg.Repos()
|
||||||
|
for _, repo := range reposSlice {
|
||||||
|
if repo.URL == repoURL || repo.Name == name {
|
||||||
|
return cliutils.FormatCliExit(gotext.Get("Repo \"%s\" already exists", repo.Name), nil)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
reposSlice = append(reposSlice, types.Repo{
|
||||||
|
Name: name,
|
||||||
|
URL: repoURL,
|
||||||
|
})
|
||||||
|
cfg.SetRepos(reposSlice)
|
||||||
|
|
||||||
|
err = cfg.SaveUserConfig()
|
||||||
|
if err != nil {
|
||||||
|
return cliutils.FormatCliExit(gotext.Get("Error saving config"), err)
|
||||||
|
}
|
||||||
|
|
||||||
|
if err := utils.ExitIfCantDropCapsToAlrUserNoPrivs(); err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
|
||||||
|
deps, err = appbuilder.
|
||||||
|
New(ctx).
|
||||||
|
UseConfig(cfg).
|
||||||
|
WithDB().
|
||||||
|
WithReposForcePull().
|
||||||
|
Build()
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
defer deps.Defer()
|
||||||
|
|
||||||
|
return nil
|
||||||
|
}),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func RemoveRepoCmd() *cli.Command {
|
func RemoveRepoCmd() *cli.Command {
|
||||||
return &cli.Command{
|
return &cli.Command{
|
||||||
Name: "remove",
|
Name: "removerepo",
|
||||||
Usage: gotext.Get("Remove an existing repository"),
|
Usage: gotext.Get("Remove an existing repository"),
|
||||||
Aliases: []string{"rm"},
|
Aliases: []string{"rr"},
|
||||||
ArgsUsage: gotext.Get("<name>"),
|
Flags: []cli.Flag{
|
||||||
|
&cli.StringFlag{
|
||||||
|
Name: "name",
|
||||||
|
Aliases: []string{"n"},
|
||||||
|
Required: true,
|
||||||
|
Usage: gotext.Get("Name of the repo to be deleted"),
|
||||||
|
},
|
||||||
|
},
|
||||||
Action: utils.RootNeededAction(func(c *cli.Context) error {
|
Action: utils.RootNeededAction(func(c *cli.Context) error {
|
||||||
if c.Args().Len() < 1 {
|
|
||||||
return cliutils.FormatCliExit("missing args", nil)
|
|
||||||
}
|
|
||||||
name := c.Args().Get(0)
|
|
||||||
|
|
||||||
ctx := c.Context
|
ctx := c.Context
|
||||||
|
|
||||||
|
name := c.String("name")
|
||||||
|
|
||||||
deps, err := appbuilder.
|
deps, err := appbuilder.
|
||||||
New(ctx).
|
New(ctx).
|
||||||
WithConfig().
|
WithConfig().
|
||||||
@@ -118,56 +183,21 @@ func RemoveRepoCmd() *cli.Command {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func AddRepoCmd() *cli.Command {
|
func RefreshCmd() *cli.Command {
|
||||||
return &cli.Command{
|
return &cli.Command{
|
||||||
Name: "add",
|
Name: "refresh",
|
||||||
Usage: gotext.Get("Add a new repository"),
|
Usage: gotext.Get("Pull all repositories that have changed"),
|
||||||
ArgsUsage: gotext.Get("<name> <url>"),
|
Aliases: []string{"ref"},
|
||||||
Action: utils.RootNeededAction(func(c *cli.Context) error {
|
Action: func(c *cli.Context) error {
|
||||||
if c.Args().Len() < 2 {
|
if err := utils.ExitIfCantDropCapsToAlrUser(); err != nil {
|
||||||
return cliutils.FormatCliExit("missing args", nil)
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
name := c.Args().Get(0)
|
|
||||||
repoURL := c.Args().Get(1)
|
|
||||||
|
|
||||||
ctx := c.Context
|
ctx := c.Context
|
||||||
|
|
||||||
deps, err := appbuilder.
|
deps, err := appbuilder.
|
||||||
New(ctx).
|
New(ctx).
|
||||||
WithConfig().
|
WithConfig().
|
||||||
Build()
|
|
||||||
if err != nil {
|
|
||||||
return err
|
|
||||||
}
|
|
||||||
defer deps.Defer()
|
|
||||||
|
|
||||||
cfg := deps.Cfg
|
|
||||||
|
|
||||||
reposSlice := cfg.Repos()
|
|
||||||
for _, repo := range reposSlice {
|
|
||||||
if repo.URL == repoURL || repo.Name == name {
|
|
||||||
return cliutils.FormatCliExit(gotext.Get("Repo \"%s\" already exists", repo.Name), nil)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
reposSlice = append(reposSlice, types.Repo{
|
|
||||||
Name: name,
|
|
||||||
URL: repoURL,
|
|
||||||
})
|
|
||||||
cfg.SetRepos(reposSlice)
|
|
||||||
|
|
||||||
err = cfg.SaveUserConfig()
|
|
||||||
if err != nil {
|
|
||||||
return cliutils.FormatCliExit(gotext.Get("Error saving config"), err)
|
|
||||||
}
|
|
||||||
|
|
||||||
if err := utils.ExitIfCantDropCapsToAlrUserNoPrivs(); err != nil {
|
|
||||||
return err
|
|
||||||
}
|
|
||||||
|
|
||||||
deps, err = appbuilder.
|
|
||||||
New(ctx).
|
|
||||||
UseConfig(cfg).
|
|
||||||
WithDB().
|
WithDB().
|
||||||
WithReposForcePull().
|
WithReposForcePull().
|
||||||
Build()
|
Build()
|
||||||
@@ -175,110 +205,7 @@ func AddRepoCmd() *cli.Command {
|
|||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
defer deps.Defer()
|
defer deps.Defer()
|
||||||
|
|
||||||
return nil
|
return nil
|
||||||
}),
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
func SetRepoRefCmd() *cli.Command {
|
|
||||||
return &cli.Command{
|
|
||||||
Name: "set-ref",
|
|
||||||
Usage: gotext.Get("Set the reference of the repository"),
|
|
||||||
ArgsUsage: gotext.Get("<name> <ref>"),
|
|
||||||
Action: utils.RootNeededAction(func(c *cli.Context) error {
|
|
||||||
if c.Args().Len() < 2 {
|
|
||||||
return cliutils.FormatCliExit("missing args", nil)
|
|
||||||
}
|
|
||||||
|
|
||||||
name := c.Args().Get(0)
|
|
||||||
ref := c.Args().Get(1)
|
|
||||||
|
|
||||||
deps, err := appbuilder.
|
|
||||||
New(c.Context).
|
|
||||||
WithConfig().
|
|
||||||
WithDB().
|
|
||||||
WithReposNoPull().
|
|
||||||
Build()
|
|
||||||
if err != nil {
|
|
||||||
return err
|
|
||||||
}
|
|
||||||
defer deps.Defer()
|
|
||||||
|
|
||||||
repos := deps.Cfg.Repos()
|
|
||||||
newRepos := []types.Repo{}
|
|
||||||
for _, repo := range repos {
|
|
||||||
if repo.Name == name {
|
|
||||||
repo.Ref = ref
|
|
||||||
}
|
|
||||||
newRepos = append(newRepos, repo)
|
|
||||||
}
|
|
||||||
deps.Cfg.SetRepos(newRepos)
|
|
||||||
err = deps.Cfg.SaveUserConfig()
|
|
||||||
if err != nil {
|
|
||||||
return cliutils.FormatCliExit(gotext.Get("Error saving config"), err)
|
|
||||||
}
|
|
||||||
|
|
||||||
err = deps.Repos.Pull(c.Context, newRepos)
|
|
||||||
if err != nil {
|
|
||||||
return cliutils.FormatCliExit(gotext.Get("Error pulling repositories"), err)
|
|
||||||
}
|
|
||||||
|
|
||||||
return nil
|
|
||||||
}),
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// TODO: remove
|
|
||||||
//
|
|
||||||
// Deprecated: use "alr repo add"
|
|
||||||
func LegacyAddRepoCmd() *cli.Command {
|
|
||||||
return &cli.Command{
|
|
||||||
Hidden: true,
|
|
||||||
Name: "addrepo",
|
|
||||||
Usage: gotext.Get("Add a new repository"),
|
|
||||||
Aliases: []string{"ar"},
|
|
||||||
Flags: []cli.Flag{
|
|
||||||
&cli.StringFlag{
|
|
||||||
Name: "name",
|
|
||||||
Aliases: []string{"n"},
|
|
||||||
Required: true,
|
|
||||||
Usage: gotext.Get("Name of the new repo"),
|
|
||||||
},
|
|
||||||
&cli.StringFlag{
|
|
||||||
Name: "url",
|
|
||||||
Aliases: []string{"u"},
|
|
||||||
Required: true,
|
|
||||||
Usage: gotext.Get("URL of the new repo"),
|
|
||||||
},
|
|
||||||
},
|
},
|
||||||
Action: utils.RootNeededAction(func(c *cli.Context) error {
|
|
||||||
cliutils.WarnLegacyCommand("alr repo add <name> <url>")
|
|
||||||
return c.App.RunContext(c.Context, []string{"", "repo", "add", c.String("name"), c.String("url")})
|
|
||||||
}),
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// TODO: remove
|
|
||||||
//
|
|
||||||
// Deprecated: use "alr repo rm"
|
|
||||||
func LegacyRemoveRepoCmd() *cli.Command {
|
|
||||||
return &cli.Command{
|
|
||||||
Hidden: true,
|
|
||||||
Name: "removerepo",
|
|
||||||
Usage: gotext.Get("Remove an existing repository"),
|
|
||||||
Aliases: []string{"rr"},
|
|
||||||
Flags: []cli.Flag{
|
|
||||||
&cli.StringFlag{
|
|
||||||
Name: "name",
|
|
||||||
Aliases: []string{"n"},
|
|
||||||
Required: true,
|
|
||||||
Usage: gotext.Get("Name of the repo to be deleted"),
|
|
||||||
},
|
|
||||||
},
|
|
||||||
Action: utils.RootNeededAction(func(c *cli.Context) error {
|
|
||||||
cliutils.WarnLegacyCommand("alr repo remove <name>")
|
|
||||||
return c.App.RunContext(c.Context, []string{"", "repo", "remove", c.String("name")})
|
|
||||||
}),
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
32
upgrade.go
32
upgrade.go
@@ -116,7 +116,7 @@ func UpgradeCmd() *cli.Command {
|
|||||||
Info: deps.Info,
|
Info: deps.Info,
|
||||||
PkgFormat_: build.GetPkgFormat(deps.Manager),
|
PkgFormat_: build.GetPkgFormat(deps.Manager),
|
||||||
},
|
},
|
||||||
mapUptatesInfoToPackages(updates),
|
updates,
|
||||||
)
|
)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return cliutils.FormatCliExit(gotext.Get("Error checking for updates"), err)
|
return cliutils.FormatCliExit(gotext.Get("Error checking for updates"), err)
|
||||||
@@ -130,27 +130,12 @@ func UpgradeCmd() *cli.Command {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func mapUptatesInfoToPackages(updates []UpdateInfo) []database.Package {
|
|
||||||
var pkgs []database.Package
|
|
||||||
for _, info := range updates {
|
|
||||||
pkgs = append(pkgs, *info.Package)
|
|
||||||
}
|
|
||||||
return pkgs
|
|
||||||
}
|
|
||||||
|
|
||||||
type UpdateInfo struct {
|
|
||||||
Package *database.Package
|
|
||||||
|
|
||||||
FromVersion string
|
|
||||||
ToVersion string
|
|
||||||
}
|
|
||||||
|
|
||||||
func checkForUpdates(
|
func checkForUpdates(
|
||||||
ctx context.Context,
|
ctx context.Context,
|
||||||
mgr manager.Manager,
|
mgr manager.Manager,
|
||||||
db *database.Database,
|
db *database.Database,
|
||||||
info *distro.OSRelease,
|
info *distro.OSRelease,
|
||||||
) ([]UpdateInfo, error) {
|
) ([]database.Package, error) {
|
||||||
installed, err := mgr.ListInstalled(nil)
|
installed, err := mgr.ListInstalled(nil)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
@@ -160,7 +145,7 @@ func checkForUpdates(
|
|||||||
|
|
||||||
s := search.New(db)
|
s := search.New(db)
|
||||||
|
|
||||||
var out []UpdateInfo
|
var out []database.Package
|
||||||
for _, pkgName := range pkgNames {
|
for _, pkgName := range pkgNames {
|
||||||
matches := build.RegexpALRPackageName.FindStringSubmatch(pkgName)
|
matches := build.RegexpALRPackageName.FindStringSubmatch(pkgName)
|
||||||
if matches != nil {
|
if matches != nil {
|
||||||
@@ -194,13 +179,10 @@ func checkForUpdates(
|
|||||||
}
|
}
|
||||||
|
|
||||||
c := vercmp.Compare(repoVer, installed[pkgName])
|
c := vercmp.Compare(repoVer, installed[pkgName])
|
||||||
|
if c == 0 || c == -1 {
|
||||||
if c == 1 {
|
continue
|
||||||
out = append(out, UpdateInfo{
|
} else if c == 1 {
|
||||||
Package: &pkg,
|
out = append(out, pkg)
|
||||||
FromVersion: installed[pkgName],
|
|
||||||
ToVersion: repoVer,
|
|
||||||
})
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user