diff --git a/.gitignore b/.gitignore index 89b3859..a1536ac 100644 --- a/.gitignore +++ b/.gitignore @@ -9,4 +9,5 @@ *.out -e2e-tests/alr \ No newline at end of file +e2e-tests/alr +commit_msg.txt \ No newline at end of file diff --git a/Makefile b/Makefile index c1bed44..c6ee88b 100644 --- a/Makefile +++ b/Makefile @@ -73,6 +73,9 @@ test-coverage: go test ./... -v -coverpkg=./... -coverprofile=coverage.out bash scripts/coverage-badge.sh +update-deps-cve: + bash scripts/update-deps-cve.sh + e2e-test: clean build rm -f ./e2e-tests/alr cp alr e2e-tests diff --git a/assets/coverage-badge.svg b/assets/coverage-badge.svg index d9be4c1..1a4a8cc 100644 --- a/assets/coverage-badge.svg +++ b/assets/coverage-badge.svg @@ -11,7 +11,7 @@ coverage coverage - 16.3% - 16.3% + 16.4% + 16.4% diff --git a/e2e-tests/common_test.go b/e2e-tests/common_test.go index ee02aec..cb65bd6 100644 --- a/e2e-tests/common_test.go +++ b/e2e-tests/common_test.go @@ -113,6 +113,10 @@ var AUTOREQ_AUTOPROV_SYSTEMS []string = []string{ "fedora-41", } +var RPM_SYSTEMS []string = []string{ + "fedora-41", +} + var COMMON_SYSTEMS []string = []string{ "ubuntu-24.04", } diff --git a/e2e-tests/group_and_summary_field_test.go b/e2e-tests/group_and_summary_field_test.go new file mode 100644 index 0000000..a2563f2 --- /dev/null +++ b/e2e-tests/group_and_summary_field_test.go @@ -0,0 +1,56 @@ +// ALR - Any Linux Repository +// Copyright (C) 2025 Евгений Храмов +// +// 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 . + +//go:build e2e + +package e2etests_test + +import ( + "testing" + + "github.com/alecthomas/assert/v2" + "github.com/efficientgo/e2e" +) + +func TestE2EGroupAndSummaryField(t *testing.T) { + dockerMultipleRun( + t, + "group-and-summary-field", + RPM_SYSTEMS, + func(t *testing.T, r e2e.Runnable) { + err := r.Exec(e2e.NewCommand( + "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( + "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) + }, + ) +} diff --git a/e2e-tests/issue_50_install_multiple_test.go b/e2e-tests/issue_50_install_multiple_test.go index b0d1f75..695bf3c 100644 --- a/e2e-tests/issue_50_install_multiple_test.go +++ b/e2e-tests/issue_50_install_multiple_test.go @@ -43,7 +43,7 @@ func TestE2EIssue50InstallMultiple(t *testing.T) { assert.NoError(t, err) err = r.Exec(e2e.NewCommand( - "alr", "in", "foo-pkg", "bar-pkg", + "sudo", "alr", "in", "foo-pkg", "bar-pkg", )) assert.NoError(t, err) diff --git a/e2e-tests/issue_59_rm_completion_test.go b/e2e-tests/issue_59_rm_completion_test.go index de2f13e..d00f973 100644 --- a/e2e-tests/issue_59_rm_completion_test.go +++ b/e2e-tests/issue_59_rm_completion_test.go @@ -43,7 +43,7 @@ func TestE2EIssue59RmCompletion(t *testing.T) { assert.NoError(t, err) err = r.Exec(e2e.NewCommand( - "alr", "in", "foo-pkg", "bar-pkg", + "sudo", "alr", "in", "foo-pkg", "bar-pkg", )) assert.NoError(t, err) diff --git a/go.mod b/go.mod index 6438685..007dbec 100644 --- a/go.mod +++ b/go.mod @@ -1,10 +1,11 @@ module gitea.plemya-x.ru/Plemya-x/ALR -go 1.22 +go 1.23.0 -toolchain go1.23.5 +toolchain go1.24.2 require ( + gitea.plemya-x.ru/Plemya-x/fakeroot v0.0.2-0.20250408104831-427aaa7713c3 github.com/AlecAivazis/survey/v2 v2.3.7 github.com/PuerkitoBio/purell v1.2.0 github.com/alecthomas/assert/v2 v2.2.1 @@ -15,8 +16,8 @@ require ( github.com/charmbracelet/lipgloss v1.0.0 github.com/charmbracelet/log v0.4.0 github.com/efficientgo/e2e v0.14.1-0.20240418111536-97db25a0c6c0 - github.com/go-git/go-billy/v5 v5.5.0 - github.com/go-git/go-git/v5 v5.12.0 + github.com/go-git/go-billy/v5 v5.6.0 + github.com/go-git/go-git/v5 v5.13.0 github.com/google/shlex v0.0.0-20191202100458-e7afc7fbc510 github.com/goreleaser/nfpm/v2 v2.41.0 github.com/hashicorp/go-hclog v0.14.1 @@ -34,10 +35,10 @@ require ( github.com/urfave/cli/v2 v2.25.7 github.com/vmihailenco/msgpack/v5 v5.3.5 go.elara.ws/vercmp v0.0.0-20230622214216-0b2b067575c4 - golang.org/x/crypto v0.32.0 - golang.org/x/exp v0.0.0-20231206192017-f3f8817b8deb - golang.org/x/sys v0.29.0 - golang.org/x/text v0.21.0 + golang.org/x/crypto v0.36.0 + golang.org/x/exp v0.0.0-20240719175910-8a7402abbf56 + golang.org/x/sys v0.31.0 + golang.org/x/text v0.23.0 gopkg.in/yaml.v3 v3.0.1 modernc.org/sqlite v1.25.0 mvdan.cc/sh/v3 v3.10.0 @@ -50,7 +51,7 @@ require ( github.com/Masterminds/semver/v3 v3.3.0 // indirect github.com/Masterminds/sprig/v3 v3.2.3 // indirect github.com/Microsoft/go-winio v0.6.1 // indirect - github.com/ProtonMail/go-crypto v1.0.0 // indirect + github.com/ProtonMail/go-crypto v1.1.3 // indirect github.com/alecthomas/repr v0.2.0 // indirect github.com/andybalholm/brotli v1.0.4 // indirect github.com/aymanbagabas/go-osc52/v2 v2.0.1 // indirect @@ -66,7 +67,7 @@ require ( github.com/connesc/cipherio v0.2.1 // indirect github.com/cpuguy83/go-md2man/v2 v2.0.4 // indirect github.com/creack/pty v1.1.24 // indirect - github.com/cyphar/filepath-securejoin v0.2.4 // indirect + github.com/cyphar/filepath-securejoin v0.2.5 // indirect github.com/davecgh/go-spew v1.1.1 // indirect github.com/dlclark/regexp2 v1.10.0 // indirect github.com/dsnet/compress v0.0.1 // indirect @@ -117,7 +118,7 @@ require ( github.com/russross/blackfriday/v2 v2.1.0 // indirect github.com/sergi/go-diff v1.3.2-0.20230802210424-5b0b94c5c0d3 // indirect github.com/shopspring/decimal v1.2.0 // indirect - github.com/skeema/knownhosts v1.2.2 // indirect + github.com/skeema/knownhosts v1.3.0 // indirect github.com/spf13/cast v1.6.0 // indirect github.com/therootcompany/xz v1.0.1 // indirect github.com/ulikunitz/xz v0.5.12 // indirect @@ -126,11 +127,11 @@ require ( github.com/xrash/smetrics v0.0.0-20201216005158-039620a65673 // indirect gitlab.com/digitalxero/go-conventional-commit v1.0.7 // indirect go4.org v0.0.0-20200411211856-f5505b9728dd // indirect - golang.org/x/mod v0.18.0 // indirect - golang.org/x/net v0.34.0 // indirect - golang.org/x/sync v0.10.0 // indirect - golang.org/x/term v0.28.0 // indirect - golang.org/x/tools v0.22.0 // indirect + golang.org/x/mod v0.19.0 // indirect + golang.org/x/net v0.38.0 // indirect + golang.org/x/sync v0.12.0 // indirect + golang.org/x/term v0.30.0 // indirect + golang.org/x/tools v0.23.0 // indirect google.golang.org/genproto/googleapis/rpc v0.0.0-20230711160842-782d3b101e98 // indirect google.golang.org/grpc v1.58.3 // indirect google.golang.org/protobuf v1.36.1 // indirect diff --git a/go.sum b/go.sum index c738cd0..05dd647 100644 --- a/go.sum +++ b/go.sum @@ -17,6 +17,8 @@ cloud.google.com/go/storage v1.5.0/go.mod h1:tpKbwo567HUNpVclU5sGELwQWBDZ8gh0Zeo dario.cat/mergo v1.0.1 h1:Ra4+bf83h2ztPIQYNP99R6m+Y7KfnARDfID+a+vLl4s= dario.cat/mergo v1.0.1/go.mod h1:uNxQE+84aUszobStD9th8a29P2fMDhsBdgRYvZOxGmk= dmitri.shuralyov.com/gpu/mtl v0.0.0-20190408044501-666a987793e9/go.mod h1:H6x//7gZCb22OMCxBHrMx7a5I7Hp++hsVxbQ4BYO7hU= +gitea.plemya-x.ru/Plemya-x/fakeroot v0.0.2-0.20250408104831-427aaa7713c3 h1:56BjRJJ2Sv50DfSvNUydUMJwwFuiBMWC1uYtH2GYjk8= +gitea.plemya-x.ru/Plemya-x/fakeroot v0.0.2-0.20250408104831-427aaa7713c3/go.mod h1:iKQM6uttMJgE5CFrPw6SQqAV7TKtlJNICRAie/dTciw= github.com/AlecAivazis/survey/v2 v2.3.7 h1:6I/u8FvytdGsgonrYsVn2t8t4QiRnh6QSTqkkhIiSjQ= github.com/AlecAivazis/survey/v2 v2.3.7/go.mod h1:xUTIdE4KCOIjsBAE1JYsUPoCqYdZ1reCfTwbto0Fduo= github.com/AlekSi/pointer v1.2.0 h1:glcy/gc4h8HnG2Z3ZECSzZ1IX1x2JxRVuDzaJwQE0+w= @@ -37,8 +39,8 @@ github.com/Microsoft/go-winio v0.6.1 h1:9/kr64B9VUZrLm5YYwbGtUJnMgqWVOdUAXu6Migc github.com/Microsoft/go-winio v0.6.1/go.mod h1:LRdKpFKfdobln8UmuiYcKPot9D2v6svN5+sAH+4kjUM= github.com/Netflix/go-expect v0.0.0-20220104043353-73e0943537d2 h1:+vx7roKuyA63nhn5WAunQHLTznkw5W8b1Xc0dNjp83s= github.com/Netflix/go-expect v0.0.0-20220104043353-73e0943537d2/go.mod h1:HBCaDeC1lPdgDeDbhX8XFpy1jqjK0IBG8W5K+xYqA0w= -github.com/ProtonMail/go-crypto v1.0.0 h1:LRuvITjQWX+WIfr930YHG2HNfjR1uOfyf5vE0kC2U78= -github.com/ProtonMail/go-crypto v1.0.0/go.mod h1:EjAoLdwvbIOoOQr3ihjnSoLZRtE8azugULFRteWMNc0= +github.com/ProtonMail/go-crypto v1.1.3 h1:nRBOetoydLeUb4nHajyO2bKqMLfWQ/ZPwkXqXxPxCFk= +github.com/ProtonMail/go-crypto v1.1.3/go.mod h1:rA3QumHc/FZ8pAHreoekgiAbzpNsfQAosU5td4SnOrE= github.com/ProtonMail/go-mime v0.0.0-20230322103455-7d82a3887f2f h1:tCbYj7/299ekTTXpdwKYF8eBlsYsDVoggDAuAjoK66k= github.com/ProtonMail/go-mime v0.0.0-20230322103455-7d82a3887f2f/go.mod h1:gcr0kNtGBqin9zDW9GOHcVntrwnjrK+qdJ06mWYBybw= github.com/ProtonMail/gopenpgp/v2 v2.7.1 h1:Awsg7MPc2gD3I7IFac2qE3Gdls0lZW8SzrFZ3k1oz0s= @@ -71,7 +73,6 @@ github.com/bodgit/windows v1.0.0 h1:rLQ/XjsleZvx4fR1tB/UxQrK+SJ2OFHzfPjLWWOhDIA= github.com/bodgit/windows v1.0.0/go.mod h1:a6JLwrB4KrTR5hBpp8FI9/9W9jJfeQ2h4XDXU74ZCdM= github.com/bufbuild/protocompile v0.4.0 h1:LbFKd2XowZvQ/kajzguUp2DC9UEIQhIq77fZZlaQsNA= github.com/bufbuild/protocompile v0.4.0/go.mod h1:3v93+mbWn/v3xzN+31nwkJfrEpAUwp+BagBSZWx+TP8= -github.com/bwesterb/go-ristretto v1.2.3/go.mod h1:fUIoIZaG73pV5biE2Blr2xEzDoMj7NFEuV9ekS419A0= github.com/caarlos0/env v3.5.0+incompatible h1:Yy0UN8o9Wtr/jGHZDpCBLpNrzcFLLM2yixi/rBrKyJs= github.com/caarlos0/env v3.5.0+incompatible/go.mod h1:tdCsowwCzMLdkqRYDlHpZCp2UooDD3MspDBjZ2AD02Y= github.com/caarlos0/testfs v0.4.4 h1:3PHvzHi5Lt+g332CiShwS8ogTgS3HjrmzZxCm6JCDr8= @@ -99,7 +100,6 @@ github.com/chzyer/logex v1.1.10/go.mod h1:+Ywpsq7O8HXn0nuIou7OrIPyXbp3wmkHB+jjWR github.com/chzyer/readline v0.0.0-20180603132655-2972be24d48e/go.mod h1:nSuG5e5PlCu98SY8svDHJxuZscDgtXS6KTTbou5AhLI= github.com/chzyer/test v0.0.0-20180213035817-a1ea475d72b1/go.mod h1:Q3SI9o4m/ZMnBNeIyt5eFwwo7qiLfzFZmjNmxjkiQlU= github.com/client9/misspell v0.3.4/go.mod h1:qj6jICC3Q7zFZvVWo7KLAzC3yx5G7kyvSDkc90ppPyw= -github.com/cloudflare/circl v1.3.3/go.mod h1:5XYMA4rFBvNIrhs50XuiBJ15vF2pZn4nnUKZrLbUZFA= github.com/cloudflare/circl v1.3.8 h1:j+V8jJt09PoeMFIu2uh5JUyEaIHTXVOHslFoLNAKqwI= github.com/cloudflare/circl v1.3.8/go.mod h1:PDRU+oXvdD7KCtgKxW95M5Z8BpSCJXQORiZFnBQS5QU= github.com/connesc/cipherio v0.2.1 h1:FGtpTPMbKNNWByNrr9aEBtaJtXjqOzkIXNYJp6OEycw= @@ -109,8 +109,8 @@ github.com/cpuguy83/go-md2man/v2 v2.0.4/go.mod h1:tgQtvFlXSQOSOSIRvRPT7W67SCa46t github.com/creack/pty v1.1.17/go.mod h1:MOBLtS5ELjhRRrroQr9kyvTxUAFNvYEK993ew/Vr4O4= github.com/creack/pty v1.1.24 h1:bJrF4RRfyJnbTJqzRLHzcGaZK1NeM5kTC9jGgovnR1s= github.com/creack/pty v1.1.24/go.mod h1:08sCNb52WyoAwi2QDyzUCTgcvVFhUzewun7wtTfvcwE= -github.com/cyphar/filepath-securejoin v0.2.4 h1:Ugdm7cg7i6ZK6x3xDF1oEu1nfkyfH53EtKeQYTC3kyg= -github.com/cyphar/filepath-securejoin v0.2.4/go.mod h1:aPGpWjXOXUn2NCNjFvBE6aRxGGx79pTxQpKOJNYHHl4= +github.com/cyphar/filepath-securejoin v0.2.5 h1:6iR5tXJ/e6tJZzzdMc1km3Sa7RRIVBKAK32O2s7AYfo= +github.com/cyphar/filepath-securejoin v0.2.5/go.mod h1:aPGpWjXOXUn2NCNjFvBE6aRxGGx79pTxQpKOJNYHHl4= github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c= github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= @@ -125,8 +125,8 @@ github.com/efficientgo/core v1.0.0-rc.0 h1:jJoA0N+C4/knWYVZ6GrdHOtDyrg8Y/TR4vFpT github.com/efficientgo/core v1.0.0-rc.0/go.mod h1:kQa0V74HNYMfuJH6jiPiwNdpWXl4xd/K4tzlrcvYDQI= github.com/efficientgo/e2e v0.14.1-0.20240418111536-97db25a0c6c0 h1:C/FNIs+MtAJgQYLJ9FX/ACFYyDRuLYoXTmueErrOJyA= github.com/efficientgo/e2e v0.14.1-0.20240418111536-97db25a0c6c0/go.mod h1:plsKU0YHE9uX+7utvr7SiDtVBSHJyEfHRO4UnUgDmts= -github.com/elazarl/goproxy v0.0.0-20230808193330-2592e75ae04a h1:mATvB/9r/3gvcejNsXKSkQ6lcIaNec2nyfOdlTBR2lU= -github.com/elazarl/goproxy v0.0.0-20230808193330-2592e75ae04a/go.mod h1:Ro8st/ElPeALwNFlcTpWmkr6IoMFfkjXAvTHpevnDsM= +github.com/elazarl/goproxy v1.2.1 h1:njjgvO6cRG9rIqN2ebkqy6cQz2Njkx7Fsfv/zIZqgug= +github.com/elazarl/goproxy v1.2.1/go.mod h1:YfEbZtqP4AetfO6d40vWchF3znWX7C7Vd6ZMfdL8z64= github.com/emirpasic/gods v1.18.1 h1:FXtiHYKDGKCW2KzwZKx0iC0PQmdlorYgdFG9jPXJ1Bc= github.com/emirpasic/gods v1.18.1/go.mod h1:8tpGGwCnJ5H4r6BWwaV6OrWmMoPhUl5jm/FMNAnJvWQ= github.com/envoyproxy/go-control-plane v0.9.1-0.20191026205805-5f8ba28d4473/go.mod h1:YTl/9mNaCwkRvm6d1a2C3ymFceY/DCBVvsKhRF0iEA4= @@ -137,16 +137,16 @@ github.com/fatih/color v1.7.0 h1:DkWD4oS2D8LGGgTQ6IvwJJXSL5Vp2ffcQg58nFV38Ys= github.com/fatih/color v1.7.0/go.mod h1:Zm6kSWBoL9eyXnKyktHP6abPY2pDugNf5KwzbycvMj4= github.com/frankban/quicktest v1.14.6 h1:7Xjx+VpznH+oBnejlPUj8oUpdxnVs4f8XU8WnHkI4W8= github.com/frankban/quicktest v1.14.6/go.mod h1:4ptaffx2x8+WTWXmUCuVU6aPUX1/Mz7zb5vbUoiM6w0= -github.com/gliderlabs/ssh v0.3.7 h1:iV3Bqi942d9huXnzEF2Mt+CY9gLu8DNM4Obd+8bODRE= -github.com/gliderlabs/ssh v0.3.7/go.mod h1:zpHEXBstFnQYtGnB8k8kQLol82umzn/2/snG7alWVD8= +github.com/gliderlabs/ssh v0.3.8 h1:a4YXD1V7xMF9g5nTkdfnja3Sxy1PVDCj1Zg4Wb8vY6c= +github.com/gliderlabs/ssh v0.3.8/go.mod h1:xYoytBv1sV0aL3CavoDuJIQNURXkkfPA/wxQ1pL1fAU= github.com/go-git/gcfg v1.5.1-0.20230307220236-3a3c6141e376 h1:+zs/tPmkDkHx3U66DAb0lQFJrpS6731Oaa12ikc+DiI= github.com/go-git/gcfg v1.5.1-0.20230307220236-3a3c6141e376/go.mod h1:an3vInlBmSxCcxctByoQdvwPiA7DTK7jaaFDBTtu0ic= -github.com/go-git/go-billy/v5 v5.5.0 h1:yEY4yhzCDuMGSv83oGxiBotRzhwhNr8VZyphhiu+mTU= -github.com/go-git/go-billy/v5 v5.5.0/go.mod h1:hmexnoNsr2SJU1Ju67OaNz5ASJY3+sHgFRpCtpDCKow= +github.com/go-git/go-billy/v5 v5.6.0 h1:w2hPNtoehvJIxR00Vb4xX94qHQi/ApZfX+nBE2Cjio8= +github.com/go-git/go-billy/v5 v5.6.0/go.mod h1:sFDq7xD3fn3E0GOwUSZqHo9lrkmx8xJhA0ZrfvjBRGM= github.com/go-git/go-git-fixtures/v4 v4.3.2-0.20231010084843-55a94097c399 h1:eMje31YglSBqCdIqdhKBW8lokaMrL3uTkpGYlE2OOT4= github.com/go-git/go-git-fixtures/v4 v4.3.2-0.20231010084843-55a94097c399/go.mod h1:1OCfN199q1Jm3HZlxleg+Dw/mwps2Wbk9frAWm+4FII= -github.com/go-git/go-git/v5 v5.12.0 h1:7Md+ndsjrzZxbddRDZjF14qK+NN56sy6wkqaVrjZtys= -github.com/go-git/go-git/v5 v5.12.0/go.mod h1:FTM9VKtnI2m65hNI/TenDDDnUf2Q9FHnXYjuz9i5OEY= +github.com/go-git/go-git/v5 v5.13.0 h1:vLn5wlGIh/X78El6r3Jr+30W16Blk0CTcxTYcYPWi5E= +github.com/go-git/go-git/v5 v5.13.0/go.mod h1:Wjo7/JyVKtQgUNdXYXIepzWfJQkUEIGvkvVkiXRR/zw= github.com/go-gl/glfw v0.0.0-20190409004039-e6da0acd62b1/go.mod h1:vR7hzQXu2zJy9AVAgeJqvqgH9Q5CA+iKCZ2gyEVpxRU= github.com/go-gl/glfw/v3.3/glfw v0.0.0-20191125211704-12ad95a8df72/go.mod h1:tQ2UAYgL5IevRw8kRxooKSPJfGvJ9fJQFa0TUsXzTg8= github.com/go-logfmt/logfmt v0.6.0 h1:wGYYu3uicYdqXVgoYbvnkrPVXkuLM1p1ifugDMEdRi4= @@ -320,8 +320,8 @@ github.com/nwaples/rardecode/v2 v2.0.0-beta.2 h1:e3mzJFJs4k83GXBEiTaQ5HgSc/kOK8q github.com/nwaples/rardecode/v2 v2.0.0-beta.2/go.mod h1:yntwv/HfMc/Hbvtq9I19D1n58te3h6KsqCf3GxyfBGY= github.com/oklog/run v1.0.0 h1:Ru7dDtJNOyC66gQ5dQmaCa0qIsAUFY3sFpK1Xk8igrw= github.com/oklog/run v1.0.0/go.mod h1:dlhp/R75TPv97u0XWUtDeV/lRKWPKSdTuV0TZvrmrQA= -github.com/onsi/gomega v1.27.10 h1:naR28SdDFlqrG6kScpT8VWpu1xWY5nJRCF3XaYyBjhI= -github.com/onsi/gomega v1.27.10/go.mod h1:RsS8tutOdbdgzbPtzzATp12yT7kM5I5aElG3evPbQ0M= +github.com/onsi/gomega v1.34.1 h1:EUMJIKUjM8sKjYbtxQI9A4z2o+rruxnzNvpknOXie6k= +github.com/onsi/gomega v1.34.1/go.mod h1:kU1QgUvBDLXBJq618Xvm2LUX6rSAfRaFRTcdOeDLwwY= github.com/pelletier/go-toml/v2 v2.1.0 h1:FnwAJ4oYMvbT/34k9zzHuZNrhlz48GB3/s6at6/MHO4= github.com/pelletier/go-toml/v2 v2.1.0/go.mod h1:tJU2Z3ZkXwnxa4DPO899bsyIoywizdUvyaeZurnPPDc= github.com/pierrec/lz4/v4 v4.1.15 h1:MO0/ucJhngq7299dKLwIMtgTfbkoSPF6AoMYDd8Q4q0= @@ -361,8 +361,8 @@ github.com/sergi/go-diff v1.3.2-0.20230802210424-5b0b94c5c0d3/go.mod h1:A0bzQcvG github.com/shopspring/decimal v1.2.0 h1:abSATXmQEYyShuxI4/vyW3tV1MrKAJzCZ/0zLUXYbsQ= github.com/shopspring/decimal v1.2.0/go.mod h1:DKyhrW/HYNuLGql+MJL6WCR6knT2jwCFRcu2hWCYk4o= github.com/sirupsen/logrus v1.7.0/go.mod h1:yWOB1SBYBC5VeMP7gHvWumXLIWorT60ONWic61uBYv0= -github.com/skeema/knownhosts v1.2.2 h1:Iug2P4fLmDw9f41PB6thxUkNUkJzB5i+1/exaj40L3A= -github.com/skeema/knownhosts v1.2.2/go.mod h1:xYbVRSPxqBZFrdmDyMmsOs+uX1UZC3nTN3ThzgDxUwo= +github.com/skeema/knownhosts v1.3.0 h1:AM+y0rI04VksttfwjkSTNQorvGqmwATnvnAHpSgc0LY= +github.com/skeema/knownhosts v1.3.0/go.mod h1:sPINvnADmT/qYH1kfv+ePMmOBTH6Tbl7b5LvTDjFK7M= github.com/smarty/assertions v1.15.0 h1:cR//PqUBUiQRakZWqBiFFQ9wb8emQGDb0HeGdqGByCY= github.com/smarty/assertions v1.15.0/go.mod h1:yABtdzeQs6l1brC900WlRNwj6ZR55d7B+E8C6HtKdec= github.com/smartystreets/goconvey v1.8.1 h1:qGjIddxOk4grTu9JPOU31tVfq3cNdBlNa5sSznIX1xY= @@ -419,10 +419,8 @@ golang.org/x/crypto v0.0.0-20191011191535-87dc89f01550/go.mod h1:yigFU9vqHzYiE8U golang.org/x/crypto v0.0.0-20210921155107-089bfa567519/go.mod h1:GvvjBRRGRdwPK5ydBHafDWAxML/pGHZbMvKqRZ5+Abc= golang.org/x/crypto v0.0.0-20220622213112-05595931fe9d/go.mod h1:IxCIyHEi3zRg3s0A5j5BB6A9Jmi73HwBIUl50j+osU4= golang.org/x/crypto v0.3.0/go.mod h1:hebNnKkNXi2UzZN1eVRvBB7co0a+JxK6XbPiWVs/3J4= -golang.org/x/crypto v0.3.1-0.20221117191849-2c476679df9a/go.mod h1:hebNnKkNXi2UzZN1eVRvBB7co0a+JxK6XbPiWVs/3J4= -golang.org/x/crypto v0.7.0/go.mod h1:pYwdfH91IfpZVANVyUOhSIPZaFoJGxTFbZhFTx+dXZU= -golang.org/x/crypto v0.32.0 h1:euUpcYgM8WcP71gNpTqQCn6rC2t6ULUPiOzfWaXVVfc= -golang.org/x/crypto v0.32.0/go.mod h1:ZnnJkOaASj8g0AjIduWNlq2NRxL0PlBrbKVyZ6V/Ugc= +golang.org/x/crypto v0.36.0 h1:AnAEvhDddvBdpY+uR+MyHmuZzzNqXSe/GvuDeob5L34= +golang.org/x/crypto v0.36.0/go.mod h1:Y4J0ReaxCR1IMaabaSMugxJES1EpwhBHhv2bDHklZvc= golang.org/x/exp v0.0.0-20190121172915-509febef88a4/go.mod h1:CJ0aWSM057203Lf6IL+f9T1iT9GByDxfZKAQTCR3kQA= golang.org/x/exp v0.0.0-20190306152737-a1d7652674e8/go.mod h1:CJ0aWSM057203Lf6IL+f9T1iT9GByDxfZKAQTCR3kQA= golang.org/x/exp v0.0.0-20190510132918-efd6b22b2522/go.mod h1:ZjyILWgesfNpC6sMxTJOJm9Kp84zZh5NQWvqDGG3Qr8= @@ -431,8 +429,8 @@ golang.org/x/exp v0.0.0-20191030013958-a1ab85dbe136/go.mod h1:JXzH8nQsPlswgeRAPE golang.org/x/exp v0.0.0-20191129062945-2f5052295587/go.mod h1:2RIsYlXP63K8oxa1u096TMicItID8zy7Y6sNkU49FU4= golang.org/x/exp v0.0.0-20191227195350-da58074b4299/go.mod h1:2RIsYlXP63K8oxa1u096TMicItID8zy7Y6sNkU49FU4= golang.org/x/exp v0.0.0-20200207192155-f17229e696bd/go.mod h1:J/WKrq2StrnmMY6+EHIKF9dgMWnmCNThgcyBT1FY9mM= -golang.org/x/exp v0.0.0-20231206192017-f3f8817b8deb h1:c0vyKkb6yr3KR7jEfJaOSv4lG7xPkbN6r52aJz1d8a8= -golang.org/x/exp v0.0.0-20231206192017-f3f8817b8deb/go.mod h1:iRJReGqOEeBhDZGkGbynYwcHlctCvnjTYIamk7uXpHI= +golang.org/x/exp v0.0.0-20240719175910-8a7402abbf56 h1:2dVuKD2vS7b0QIHQbpyTISPd0LeHDbnYEryqj5Q1ug8= +golang.org/x/exp v0.0.0-20240719175910-8a7402abbf56/go.mod h1:M4RDyNAINzryxdtnbRXRL/OHtkFuWGRjvuhBJpk2IlY= golang.org/x/image v0.0.0-20190227222117-0694c2d4d067/go.mod h1:kZ7UVZpmo3dzQBMxlp+ypCbDeSB+sBbTgSJuh5dn5js= golang.org/x/image v0.0.0-20190802002840-cff245a6509b/go.mod h1:FeLwcggjj3mMvU+oOTbSwawSJRM1uh48EjtB4UJZlP0= golang.org/x/lint v0.0.0-20181026193005-c67002cb31c3/go.mod h1:UVdnD1Gm6xHRNCYTkRU2/jEulfH38KcIWyp/GAMgvoE= @@ -451,9 +449,8 @@ golang.org/x/mod v0.1.0/go.mod h1:0QHyrYULN0/3qlju5TqG8bIK38QM8yzMo5ekMj3DlcY= golang.org/x/mod v0.1.1-0.20191105210325-c90efee705ee/go.mod h1:QqPTAvyqsEbceGzBzNggFXnrqF1CaUcvgkdR5Ot7KZg= golang.org/x/mod v0.2.0/go.mod h1:s0Qsj1ACt9ePp/hMypM3fl4fZqREWJwdYDEqhRiZZUA= golang.org/x/mod v0.6.0-dev.0.20220419223038-86c51ed26bb4/go.mod h1:jJ57K6gSWd91VN4djpZkiMVwK6gcyfeH4XE8wZrZaV4= -golang.org/x/mod v0.8.0/go.mod h1:iBbtSCu2XBx23ZKBPSOrRkjjQPZFPuis4dIYUhu/chs= -golang.org/x/mod v0.18.0 h1:5+9lSbEzPSdWkH32vYPBwEpX8KwDbM52Ud9xBUvNlb0= -golang.org/x/mod v0.18.0/go.mod h1:hTbmBsO62+eylJbnUtE2MGJUyE7QWk4xUqPFrRgJ+7c= +golang.org/x/mod v0.19.0 h1:fEdghXQSo20giMthA7cd28ZC+jts4amQ3YMXiP5oMQ8= +golang.org/x/mod v0.19.0/go.mod h1:hTbmBsO62+eylJbnUtE2MGJUyE7QWk4xUqPFrRgJ+7c= golang.org/x/net v0.0.0-20180724234803-3673e40ba225/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= golang.org/x/net v0.0.0-20180826012351-8a410e7b638d/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= golang.org/x/net v0.0.0-20190108225652-1e06a53dbb7e/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= @@ -472,10 +469,8 @@ golang.org/x/net v0.0.0-20210226172049-e18ecbb05110/go.mod h1:m0MpNAwzfU5UDzcl9v golang.org/x/net v0.0.0-20211112202133-69e39bad7dc2/go.mod h1:9nx3DQGgdP8bBQD5qxJ1jj9UTztislL4KSBs9R2vV5Y= golang.org/x/net v0.0.0-20220722155237-a158d28d115b/go.mod h1:XRhObCWvk6IyKnWLug+ECip1KBveYUHfp+8e9klMJ9c= golang.org/x/net v0.2.0/go.mod h1:KqCZLdyyvdV855qA2rE3GC2aiw5xGR5TEjj8smXukLY= -golang.org/x/net v0.6.0/go.mod h1:2Tu9+aMcznHK/AK1HMvgo6xiTLG5rD5rZLDS+rp2Bjs= -golang.org/x/net v0.8.0/go.mod h1:QVkue5JL9kW//ek3r6jTKnTFis1tRmNAW2P1shuFdJc= -golang.org/x/net v0.34.0 h1:Mb7Mrk043xzHgnRM88suvJFwzVrRfHEHJEl5/71CKw0= -golang.org/x/net v0.34.0/go.mod h1:di0qlW3YNM5oh6GqDGQr92MyTozJPmybPK4Ev/Gm31k= +golang.org/x/net v0.38.0 h1:vRMAPTMaeGqVhG5QyLJHqNDwecKTomGeqbnfZyKlBI8= +golang.org/x/net v0.38.0/go.mod h1:ivrbrMbzFq5J41QOQh0siUuly180yBYtLp+CKbEaFx8= golang.org/x/oauth2 v0.0.0-20180821212333-d2e6202438be/go.mod h1:N/0e6XlmueqKjAGxoOufVs8QHGRruUQn6yWY3a++T0U= golang.org/x/oauth2 v0.0.0-20190226205417-e64efc72b421/go.mod h1:gOpvHmFTYa4IltrdGE7lF6nIHvwfUNPOp7c8zoXwtLw= golang.org/x/oauth2 v0.0.0-20190604053449-0f29369cfe45/go.mod h1:gOpvHmFTYa4IltrdGE7lF6nIHvwfUNPOp7c8zoXwtLw= @@ -490,9 +485,8 @@ golang.org/x/sync v0.0.0-20190227155943-e225da77a7e6/go.mod h1:RxMgew5VJxzue5/jJ golang.org/x/sync v0.0.0-20190423024810-112230192c58/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= golang.org/x/sync v0.0.0-20190911185100-cd5d95a43a6e/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= golang.org/x/sync v0.0.0-20220722155255-886fb9371eb4/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= -golang.org/x/sync v0.1.0/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= -golang.org/x/sync v0.10.0 h1:3NQrjDixjgGwUOCaF8w2+VYHv0Ve/vGYSbdkTa98gmQ= -golang.org/x/sync v0.10.0/go.mod h1:Czt+wKu1gCyEFDUtn0jG5QVvpJ6rzVqr5aXyt9drQfk= +golang.org/x/sync v0.12.0 h1:MHc5BpPuC30uJk597Ri8TV3CNZcTLu6B6z4lJy+g6Jw= +golang.org/x/sync v0.12.0/go.mod h1:1dzgHSNfp02xaA81J2MS99Qcpr2w7fw1gpm99rleRqA= golang.org/x/sys v0.0.0-20180830151530-49385e6e1522/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= golang.org/x/sys v0.0.0-20190215142949-d0b11bdaac8a/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= golang.org/x/sys v0.0.0-20190222072716-a9d3bda3a223/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= @@ -519,18 +513,14 @@ golang.org/x/sys v0.0.0-20220715151400-c0bba94af5f8/go.mod h1:oPkhp1MJrh7nUepCBc golang.org/x/sys v0.0.0-20220722155257-8c9f86f7a55f/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.0.0-20220811171246-fbc7d0a398ab/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.2.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= -golang.org/x/sys v0.3.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= -golang.org/x/sys v0.5.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.6.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= -golang.org/x/sys v0.29.0 h1:TPYlXGxvx1MGTn2GiZDhnjPA9wZzZeGKHHmKhHYvgaU= -golang.org/x/sys v0.29.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA= +golang.org/x/sys v0.31.0 h1:ioabZlmFYtWhL+TRYpcnNlLwhyxaM9kWTDEmfnprqik= +golang.org/x/sys v0.31.0/go.mod h1:BJP2sWEmIv4KK5OTEluFJCKSidICx8ciO85XgH3Ak8k= golang.org/x/term v0.0.0-20201126162022-7de9c90e9dd1/go.mod h1:bj7SfCRtBDWHUb9snDiAeCFNEtKQo2Wmx5Cou7ajbmo= golang.org/x/term v0.0.0-20210927222741-03fcf44c2211/go.mod h1:jbD1KX2456YbFQfuXm/mYQcufACuNUgVhRMnK/tPxf8= golang.org/x/term v0.2.0/go.mod h1:TVmDHMZPmdnySmBfhjOoOdhjzdE1h4u1VwSiw2l1Nuc= -golang.org/x/term v0.5.0/go.mod h1:jMB1sMXY+tzblOD4FWmEbocvup2/aLOaQEp7JmGp78k= -golang.org/x/term v0.6.0/go.mod h1:m6U89DPEgQRMq3DNkDClhWw02AUbt2daBVO4cn4Hv9U= -golang.org/x/term v0.28.0 h1:/Ts8HFuMR2E6IP/jlo7QVLZHggjKQbhu/7H0LJFr3Gg= -golang.org/x/term v0.28.0/go.mod h1:Sw/lC2IAUZ92udQNf3WodGtn4k/XoLyZoh8v/8uiwek= +golang.org/x/term v0.30.0 h1:PQ39fJZ+mfadBm0y5WlL4vlM7Sx1Hgf13sMIY2+QS9Y= +golang.org/x/term v0.30.0/go.mod h1:NYYFdzHoI5wRh/h5tDMdMqCqPJZEuNqVR5xJLd/n67g= golang.org/x/text v0.0.0-20170915032832-14c0d48ead0c/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ= golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ= golang.org/x/text v0.3.1-0.20180807135948-17ff2d5776d2/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ= @@ -539,10 +529,8 @@ golang.org/x/text v0.3.3/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ= golang.org/x/text v0.3.6/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ= golang.org/x/text v0.3.7/go.mod h1:u+2+/6zg+i71rQMx5EYifcz6MCKuco9NR6JIITiCfzQ= golang.org/x/text v0.4.0/go.mod h1:mrYo+phRRbMaCq/xk9113O4dZlRixOauAjOtrjsXDZ8= -golang.org/x/text v0.7.0/go.mod h1:mrYo+phRRbMaCq/xk9113O4dZlRixOauAjOtrjsXDZ8= -golang.org/x/text v0.8.0/go.mod h1:e1OnstbJyHTd6l/uOt8jFFHp6TRDWZR/bV3emEE/zU8= -golang.org/x/text v0.21.0 h1:zyQAAkrwaneQ066sspRyJaG9VNi/YJ1NfzcGB3hZ/qo= -golang.org/x/text v0.21.0/go.mod h1:4IBbMaMmOPCJ8SecivzSH54+73PCFmPWxNTLm+vZkEQ= +golang.org/x/text v0.23.0 h1:D71I7dUrlY+VX0gQShAThNGHFxZ13dGLBHQLVl1mJlY= +golang.org/x/text v0.23.0/go.mod h1:/BLNzu4aZCJ1+kcD0DNRotWKage4q2rGVAg4o22unh4= golang.org/x/time v0.0.0-20181108054448-85acf8d2951c/go.mod h1:tRJNPiyCQ0inRvYxbN9jk5I+vvW/OXSQhTDSoE431IQ= golang.org/x/time v0.0.0-20190308202827-9d24e82272b4/go.mod h1:tRJNPiyCQ0inRvYxbN9jk5I+vvW/OXSQhTDSoE431IQ= golang.org/x/tools v0.0.0-20180917221912-90fa682c2a6e/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ= @@ -570,9 +558,8 @@ golang.org/x/tools v0.0.0-20200130002326-2f3ba24bd6e7/go.mod h1:TB2adYChydJhpapK golang.org/x/tools v0.0.0-20200207183749-b753a1ba74fa/go.mod h1:TB2adYChydJhpapKDTa4BR/hXlZSLoq2Wpct/0txZ28= golang.org/x/tools v0.0.0-20200212150539-ea181f53ac56/go.mod h1:TB2adYChydJhpapKDTa4BR/hXlZSLoq2Wpct/0txZ28= golang.org/x/tools v0.1.12/go.mod h1:hNGJHUnrk76NpqgfD5Aqm5Crs+Hm0VOH/i9J2+nxYbc= -golang.org/x/tools v0.6.0/go.mod h1:Xwgl3UAJ/d3gWutnCtw505GrjyAbvKui8lOU390QaIU= -golang.org/x/tools v0.22.0 h1:gqSGLZqv+AI9lIQzniJ0nZDRG5GBPsSi+DRNHWNz6yA= -golang.org/x/tools v0.22.0/go.mod h1:aCwcsjqvq7Yqt6TNyX7QMU2enbQ/Gt0bo6krSeEri+c= +golang.org/x/tools v0.23.0 h1:SGsXPZ+2l4JsgaCKkx+FQ9YZ5XEtA1GZYuoDjenLjvg= +golang.org/x/tools v0.23.0/go.mod h1:pnu6ufv6vQkll6szChhK3C3L/ruaIv5eBeztNG8wtsI= golang.org/x/xerrors v0.0.0-20190717185122-a985d3407aa7/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= golang.org/x/xerrors v0.0.0-20191011141410-1b5146add898/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= golang.org/x/xerrors v0.0.0-20191204190536-9bdfabe68543/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= diff --git a/internal/db/db.go b/internal/db/db.go index f8b817e..eba0f64 100644 --- a/internal/db/db.go +++ b/internal/db/db.go @@ -31,7 +31,7 @@ import ( // CurrentVersion is the current version of the database. // The database is reset if its version doesn't match this. -const CurrentVersion = 3 +const CurrentVersion = 4 // Package is a ALR package's database representation type Package struct { @@ -40,7 +40,9 @@ type Package struct { Version string `sh:"version,required" db:"version"` Release int `sh:"release,required" db:"release"` Epoch uint `sh:"epoch" db:"epoch"` + Summary JSON[map[string]string] `db:"summary"` Description JSON[map[string]string] `db:"description"` + Group JSON[map[string]string] `db:"group_name"` Homepage JSON[map[string]string] `db:"homepage"` Maintainer JSON[map[string]string] `db:"maintainer"` Architectures JSON[[]string] `sh:"architectures" db:"architectures"` @@ -106,7 +108,9 @@ func (d *Database) initDB(ctx context.Context) error { version TEXT NOT NULL, release INT NOT NULL, epoch INT, + summary TEXT CHECK(summary = 'null' OR (JSON_VALID(summary) AND JSON_TYPE(summary) = 'object')), description TEXT CHECK(description = 'null' OR (JSON_VALID(description) AND JSON_TYPE(description) = 'object')), + group_name TEXT CHECK(group_name = 'null' OR (JSON_VALID(group_name) AND JSON_TYPE(group_name) = 'object')), homepage TEXT CHECK(homepage = 'null' OR (JSON_VALID(homepage) AND JSON_TYPE(homepage) = 'object')), maintainer TEXT CHECK(maintainer = 'null' OR (JSON_VALID(maintainer) AND JSON_TYPE(maintainer) = 'object')), architectures TEXT CHECK(architectures = 'null' OR (JSON_VALID(architectures) AND JSON_TYPE(architectures) = 'array')), @@ -204,7 +208,9 @@ func (d *Database) InsertPackage(ctx context.Context, pkg Package) error { version, release, epoch, + summary, description, + group_name, homepage, maintainer, architectures, @@ -222,7 +228,9 @@ func (d *Database) InsertPackage(ctx context.Context, pkg Package) error { :version, :release, :epoch, + :summary, :description, + :group_name, :homepage, :maintainer, :architectures, diff --git a/internal/overrides/overrides.go b/internal/overrides/overrides.go index c5710b0..5490c76 100644 --- a/internal/overrides/overrides.go +++ b/internal/overrides/overrides.go @@ -157,6 +157,8 @@ type ResolvedPackage struct { Version string `sh:"version"` Release int `sh:"release"` Epoch uint `sh:"epoch"` + Group string `db:"group_name"` + Summary string `db:"summary"` Description string `db:"description"` Homepage string `db:"homepage"` Maintainer string `db:"maintainer"` diff --git a/internal/shutils/handlers/fakeroot.go b/internal/shutils/handlers/fakeroot.go index 90a45dc..bc0090b 100644 --- a/internal/shutils/handlers/fakeroot.go +++ b/internal/shutils/handlers/fakeroot.go @@ -25,11 +25,11 @@ import ( "os" "os/exec" "runtime" - "slices" "strings" "syscall" "time" + "gitea.plemya-x.ru/Plemya-x/fakeroot" "mvdan.cc/sh/v3/expand" "mvdan.cc/sh/v3/interp" ) @@ -54,7 +54,7 @@ func FakerootExecHandler(killTimeout time.Duration) interp.ExecHandlerFunc { Stderr: hc.Stderr, } - err = Apply(cmd) + err = fakeroot.Apply(cmd) if err != nil { return err } @@ -108,52 +108,6 @@ func FakerootExecHandler(killTimeout time.Duration) interp.ExecHandlerFunc { } } -func rootMap(m syscall.SysProcIDMap) bool { - return m.ContainerID == 0 -} - -func Apply(cmd *exec.Cmd) error { - uid := os.Getuid() - gid := os.Getgid() - - // If the user is already root, there's no need for fakeroot - if uid == 0 { - return nil - } - - // Ensure SysProcAttr isn't nil - if cmd.SysProcAttr == nil { - cmd.SysProcAttr = &syscall.SysProcAttr{} - } - - // Create a new user namespace - cmd.SysProcAttr.Cloneflags |= syscall.CLONE_NEWUSER - - // If the command already contains a mapping for the root user, return an error - if slices.ContainsFunc(cmd.SysProcAttr.UidMappings, rootMap) { - return nil - } - - // If the command already contains a mapping for the root group, return an error - if slices.ContainsFunc(cmd.SysProcAttr.GidMappings, rootMap) { - return nil - } - - cmd.SysProcAttr.UidMappings = append(cmd.SysProcAttr.UidMappings, syscall.SysProcIDMap{ - ContainerID: 0, - HostID: uid, - Size: 1, - }) - - cmd.SysProcAttr.GidMappings = append(cmd.SysProcAttr.GidMappings, syscall.SysProcIDMap{ - ContainerID: 0, - HostID: gid, - Size: 1, - }) - - return nil -} - // execEnv was extracted from github.com/mvdan/sh/interp/vars.go func execEnv(env expand.Environ) []string { list := make([]string, 0, 64) diff --git a/internal/translations/default.pot b/internal/translations/default.pot index 6c7e98b..e9ea863 100644 --- a/internal/translations/default.pot +++ b/internal/translations/default.pot @@ -274,11 +274,11 @@ msgstr "" msgid "OPTIONS" msgstr "" -#: internal/db/db.go:133 +#: internal/db/db.go:137 msgid "Database version mismatch; resetting" msgstr "" -#: internal/db/db.go:140 +#: internal/db/db.go:144 msgid "" "Database version does not exist. Run alr fix if something isn't working." msgstr "" @@ -397,15 +397,15 @@ msgstr "" msgid "Building package metadata" msgstr "" -#: pkg/build/script_executor.go:356 +#: pkg/build/script_executor.go:368 msgid "Executing prepare()" msgstr "" -#: pkg/build/script_executor.go:365 +#: pkg/build/script_executor.go:377 msgid "Executing build()" msgstr "" -#: pkg/build/script_executor.go:394 pkg/build/script_executor.go:414 +#: pkg/build/script_executor.go:406 pkg/build/script_executor.go:426 msgid "Executing %s()" msgstr "" @@ -471,39 +471,39 @@ msgstr "" msgid "Pull all repositories that have changed" msgstr "" -#: search.go:36 +#: search.go:40 msgid "Search packages" msgstr "" -#: search.go:42 +#: search.go:51 msgid "Search by name" msgstr "" -#: search.go:47 +#: search.go:56 msgid "Search by description" msgstr "" -#: search.go:52 +#: search.go:61 msgid "Search by repository" msgstr "" -#: search.go:57 +#: search.go:66 msgid "Search by provides" msgstr "" -#: search.go:62 +#: search.go:71 msgid "Format output using a Go template" msgstr "" -#: search.go:96 +#: search.go:130 msgid "Error while executing search" msgstr "" -#: search.go:104 +#: search.go:138 msgid "Error parsing format template" msgstr "" -#: search.go:112 +#: search.go:153 msgid "Error executing template" msgstr "" diff --git a/internal/translations/po/ru/default.po b/internal/translations/po/ru/default.po index 8318d00..452cc8e 100644 --- a/internal/translations/po/ru/default.po +++ b/internal/translations/po/ru/default.po @@ -12,8 +12,8 @@ msgstr "" "MIME-Version: 1.0\n" "Content-Type: text/plain; charset=UTF-8\n" "Content-Transfer-Encoding: 8bit\n" -"Plural-Forms: nplurals=3; plural=(n%10==1 && n%100!=11 ? 0 : n%10>=2 && " -"n%10<=4 && (n%100<10 || n%100>=20) ? 1 : 2);\n" +"Plural-Forms: nplurals=3; plural=(n%10==1 && n%100!=11 ? 0 : n%10>=2 && n" +"%10<=4 && (n%100<10 || n%100>=20) ? 1 : 2);\n" "X-Generator: Gtranslator 48.0\n" #: build.go:42 @@ -281,11 +281,11 @@ msgstr "КАТЕГОРИЯ" msgid "OPTIONS" msgstr "ПАРАМЕТРЫ" -#: internal/db/db.go:133 +#: internal/db/db.go:137 msgid "Database version mismatch; resetting" msgstr "Несоответствие версий базы данных; сброс настроек" -#: internal/db/db.go:140 +#: internal/db/db.go:144 msgid "" "Database version does not exist. Run alr fix if something isn't working." msgstr "" @@ -409,15 +409,15 @@ msgstr "" msgid "Building package metadata" msgstr "Сборка метаданных пакета" -#: pkg/build/script_executor.go:356 +#: pkg/build/script_executor.go:368 msgid "Executing prepare()" msgstr "Выполнение prepare()" -#: pkg/build/script_executor.go:365 +#: pkg/build/script_executor.go:377 msgid "Executing build()" msgstr "Выполнение build()" -#: pkg/build/script_executor.go:394 pkg/build/script_executor.go:414 +#: pkg/build/script_executor.go:406 pkg/build/script_executor.go:426 msgid "Executing %s()" msgstr "Выполнение %s()" @@ -485,39 +485,39 @@ msgstr "Ошибка при удалении пакетов из базы дан msgid "Pull all repositories that have changed" msgstr "Скачать все изменённые репозитории" -#: search.go:36 +#: search.go:40 msgid "Search packages" msgstr "Поиск пакетов" -#: search.go:42 +#: search.go:51 msgid "Search by name" msgstr "Искать по имени" -#: search.go:47 +#: search.go:56 msgid "Search by description" msgstr "Искать по описанию" -#: search.go:52 +#: search.go:61 msgid "Search by repository" msgstr "Искать по репозиторию" -#: search.go:57 +#: search.go:66 msgid "Search by provides" msgstr "Иcкать по provides" -#: search.go:62 +#: search.go:71 msgid "Format output using a Go template" msgstr "Формат выходных данных с использованием шаблона Go" -#: search.go:96 +#: search.go:130 msgid "Error while executing search" msgstr "Ошибка при выполнении поиска" -#: search.go:104 +#: search.go:138 msgid "Error parsing format template" msgstr "Ошибка при разборе шаблона" -#: search.go:112 +#: search.go:153 msgid "Error executing template" msgstr "Ошибка при выполнении шаблона" diff --git a/internal/types/build.go b/internal/types/build.go index aadb8e6..5fc2eff 100644 --- a/internal/types/build.go +++ b/internal/types/build.go @@ -20,10 +20,6 @@ package types type BuildOpts struct { - // Script string - // Repository string - // Packages []string - // Manager manager.Manager Clean bool Interactive bool } @@ -32,7 +28,9 @@ type BuildVarsPre struct { Version string `sh:"version,required"` Release int `sh:"release,required"` Epoch uint `sh:"epoch"` + Summary string `sh:"summary"` Description string `sh:"desc"` + Group string `sh:"group"` Homepage string `sh:"homepage"` Maintainer string `sh:"maintainer"` Architectures []string `sh:"architectures"` diff --git a/pkg/build/script_executor.go b/pkg/build/script_executor.go index cb4b1e5..bc24e2f 100644 --- a/pkg/build/script_executor.go +++ b/pkg/build/script_executor.go @@ -304,6 +304,7 @@ func buildPkgMetadata( Provides: append(vars.Provides, vars.Name), Depends: deps, } + pkgInfo.Section = vars.Group pkgFormat := input.PkgFormat() info := input.OSRelease() @@ -315,6 +316,17 @@ func buildPkgMetadata( }) } + if pkgFormat == "rpm" { + pkgInfo.RPM.Group = vars.Group + + if vars.Summary != "" { + pkgInfo.RPM.Summary = vars.Summary + } else { + lines := strings.SplitN(vars.Description, "\n", 2) + pkgInfo.RPM.Summary = lines[0] + } + } + if vars.Epoch != 0 { pkgInfo.Epoch = strconv.FormatUint(uint64(vars.Epoch), 10) } diff --git a/pkg/repos/utils.go b/pkg/repos/utils.go index 58b1ed3..5fbdf16 100644 --- a/pkg/repos/utils.go +++ b/pkg/repos/utils.go @@ -79,26 +79,22 @@ type PackageInfo struct { } func (inf *PackageInfo) ToPackage(repoName string) *db.Package { - return &db.Package{ - Version: inf.Version, - Release: inf.Release, - Epoch: inf.Epoch, - Architectures: inf.Architectures, - Licenses: inf.Licenses, - Provides: inf.Provides, - Conflicts: inf.Conflicts, - Replaces: inf.Replaces, - Description: db.NewJSON(map[string]string{}), - Homepage: db.NewJSON(map[string]string{}), - Maintainer: db.NewJSON(map[string]string{}), - Depends: db.NewJSON(map[string][]string{}), - BuildDepends: db.NewJSON(map[string][]string{}), - Repository: repoName, - } + pkg := EmptyPackage(repoName) + pkg.Version = inf.Version + pkg.Release = inf.Release + pkg.Epoch = inf.Epoch + pkg.Architectures = inf.Architectures + pkg.Licenses = inf.Licenses + pkg.Provides = inf.Provides + pkg.Conflicts = inf.Conflicts + pkg.Replaces = inf.Replaces + return pkg } func EmptyPackage(repoName string) *db.Package { return &db.Package{ + Group: db.NewJSON(map[string]string{}), + Summary: db.NewJSON(map[string]string{}), Description: db.NewJSON(map[string]string{}), Homepage: db.NewJSON(map[string]string{}), Maintainer: db.NewJSON(map[string]string{}), @@ -114,6 +110,8 @@ var overridable = map[string]string{ "desc": "Description", "homepage": "Homepage", "maintainer": "Maintainer", + "group": "Group", + "summary": "Summary", } func resolveOverrides(runner *interp.Runner, pkg *db.Package) { diff --git a/scripts/update-deps-cve.sh b/scripts/update-deps-cve.sh new file mode 100644 index 0000000..8c0e59e --- /dev/null +++ b/scripts/update-deps-cve.sh @@ -0,0 +1,58 @@ +#!/bin/bash +# ALR - Any Linux Repository +# Copyright (C) 2025 Евгений Храмов +# +# 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 . + + +VULNS_FILE="vulns.json" +COMMIT_MSG_FILE="commit_msg.txt" + +echo "Scanning for vulnerabilities with Trivy..." +trivy fs --scanners vuln --format json . > "$VULNS_FILE" + +echo "security: update vulnerable packages" > "$COMMIT_MSG_FILE" +echo "" >> "$COMMIT_MSG_FILE" +echo "Vulnerabilities detected by Trivy scan:" >> "$COMMIT_MSG_FILE" + +echo "Processing vulnerabilities..." +jq -r ' + .Results[].Vulnerabilities[] | + select(.PkgName and .FixedVersion) | + "\(.PkgName)|\(.FixedVersion)|\(.VulnerabilityID)" +' "$VULNS_FILE" | sort | uniq | while IFS="|" read -r pkg version cve; do + echo "- ${pkg} (${cve})" >> "$COMMIT_MSG_FILE" + echo "Updating ${pkg} to v${version} (${cve})..." + go get "${pkg}@v${version}" || echo "Failed to update ${pkg}" +done + +echo "Running go mod tidy..." +go mod tidy + +echo "Verifying fixes..." +trivy fs --scanners vuln . + +echo "" +echo "Suggested commit message:" +echo "------------------------" +cat "$COMMIT_MSG_FILE" +echo "------------------------" + +rm "$VULNS_FILE" + +git add go.mod go.sum + +echo "" +echo "To commit these changes, run:" +echo "git commit -a -F $(pwd)/$COMMIT_MSG_FILE" \ No newline at end of file diff --git a/search.go b/search.go index 4dad507..25bfb82 100644 --- a/search.go +++ b/search.go @@ -21,12 +21,16 @@ import ( "os" "text/template" + "github.com/jeandeaual/go-locale" "github.com/leonelquinteros/gotext" "github.com/urfave/cli/v2" "gitea.plemya-x.ru/Plemya-x/ALR/internal/cliutils" appbuilder "gitea.plemya-x.ru/Plemya-x/ALR/internal/cliutils/app_builder" + "gitea.plemya-x.ru/Plemya-x/ALR/internal/db" + "gitea.plemya-x.ru/Plemya-x/ALR/internal/overrides" "gitea.plemya-x.ru/Plemya-x/ALR/internal/utils" + "gitea.plemya-x.ru/Plemya-x/ALR/pkg/distro" "gitea.plemya-x.ru/Plemya-x/ALR/pkg/search" ) @@ -36,6 +40,11 @@ func SearchCmd() *cli.Command { Usage: gotext.Get("Search packages"), Aliases: []string{"s"}, Flags: []cli.Flag{ + &cli.BoolFlag{ + Name: "all", + Aliases: []string{"a"}, + Usage: gotext.Get("Show all information, not just for the current distro"), + }, &cli.StringFlag{ Name: "name", Aliases: []string{"n"}, @@ -69,6 +78,31 @@ func SearchCmd() *cli.Command { ctx := c.Context + var names []string + all := c.Bool("all") + + systemLang, err := locale.GetLanguage() + if err != nil { + return cliutils.FormatCliExit(gotext.Get("Can't detect system language"), err) + } + if systemLang == "" { + systemLang = "en" + } + if !all { + info, err := distro.ParseOSRelease(ctx) + if err != nil { + return cliutils.FormatCliExit(gotext.Get("Error parsing os-release file"), err) + } + names, err = overrides.Resolve( + info, + overrides.DefaultOpts. + WithLanguages([]string{systemLang}), + ) + if err != nil { + return cliutils.FormatCliExit(gotext.Get("Error resolving overrides"), err) + } + } + deps, err := appbuilder. New(ctx). WithConfig(). @@ -79,9 +113,9 @@ func SearchCmd() *cli.Command { } defer deps.Defer() - db := deps.DB + database := deps.DB - s := search.New(db) + s := search.New(database) packages, err := s.Search( ctx, @@ -106,14 +140,26 @@ func SearchCmd() *cli.Command { } for _, dbPkg := range packages { + var pkg any + if !all { + pkg = overrides.ResolvePackage(&dbPkg, names) + } else { + pkg = &dbPkg + } + if tmpl != nil { - err = tmpl.Execute(os.Stdout, dbPkg) + err = tmpl.Execute(os.Stdout, pkg) if err != nil { return cliutils.FormatCliExit(gotext.Get("Error executing template"), err) } fmt.Println() } else { - fmt.Println(dbPkg.Name) + switch v := pkg.(type) { + case *overrides.ResolvedPackage: + fmt.Println(v.Name) + case *db.Package: + fmt.Println(v.Name) + } } }