updater weird semver support, rm app-arch/7-zip, add dev-util/doppler

This commit is contained in:
Jared Allard 2024-06-08 14:57:49 -07:00
parent 44bca346b5
commit c32d6cc772
Signed by: jaredallard
SSH key fingerprint: SHA256:wyRyyv28jBYw8Yp/oABNPUYvbGd6hyZj23XVXEm5G/U
12 changed files with 152 additions and 138 deletions

View file

@ -133,6 +133,10 @@ type GitOptions struct {
// Tags denote if tags should be used as the version source.
Tags bool `yaml:"tags"`
// Semver denotes if versions should be parsed as semver. Defaults to
// false. If true, ConsiderPreReleases is ignored.
DisableSemver bool `yaml:"disable_semver"`
// ConsiderPreReleases denotes if pre-releases should be considered,
// when a tag is used and the version is able to be parsed as a
// semver. Defaults to false.

View file

@ -45,7 +45,8 @@ func getGitVersion(ce *packages.Package) (string, error) {
}
// Find the first tag that is not an annotated tag.
var newVersion string
var newestVersion string
var newestSemverVersion *semver.Version
scanner := bufio.NewScanner(bytes.NewReader(b))
for scanner.Scan() {
line := scanner.Text()
@ -53,7 +54,7 @@ func getGitVersion(ce *packages.Package) (string, error) {
continue
}
spl := strings.Split(line, "\t")
spl := strings.Fields(line)
if len(spl) != 2 {
return "", fmt.Errorf("unexpected output from git ls-remote: %s", line)
}
@ -75,14 +76,29 @@ func getGitVersion(ce *packages.Package) (string, error) {
// Skip the version if we're not considering pre-releases.
continue
}
if newestSemverVersion == nil || sv.GT(*newestSemverVersion) {
newestSemverVersion = &sv
newestVersion = tag
}
}
newVersion = tag
// Not told to use semver, break once we've found a version because
// we rely on git sorting.
if ce.GitOptions.DisableSemver {
newestVersion = tag
break
}
if newVersion == "" {
}
// If we were told to use semver, and we found a semver version, use it.
if !ce.GitOptions.DisableSemver && newestSemverVersion != nil {
newestVersion = newestSemverVersion.String()
}
if newestVersion == "" {
return "", fmt.Errorf("failed to determine currently available versions")
}
return strings.TrimPrefix(newVersion, "v"), nil
return strings.TrimPrefix(newestVersion, "v"), nil
}

View file

@ -42,18 +42,35 @@ func NewCheckoutStep(input any) (StepRunner, error) {
return &CheckoutStep{url}, nil
}
type checkoutCmd struct {
cmd []string
// onFailure is a command to run if this command fails. If the
// onFailure command succeeds, the step will continue.
onFailure []string
}
// Run runs the provided command inside of the step runner.
func (c CheckoutStep) Run(ctx context.Context, env Environment) (*StepOutput, error) {
cmds := [][]string{
{"git", "-c", "init.defaultBranch=main", "init", env.workDir},
{"git", "remote", "add", "origin", c.url},
{"git", "-c", "protocol.version=2", "fetch", "origin", "v" + env.in.LatestVersion},
{"git", "reset", "--hard", "FETCH_HEAD"},
cmds := []checkoutCmd{
{cmd: []string{"git", "-c", "init.defaultBranch=main", "init", env.workDir}},
{cmd: []string{"git", "remote", "add", "origin", c.url}},
{
cmd: []string{"git", "-c", "protocol.version=2", "fetch", "origin", "v" + env.in.LatestVersion},
onFailure: []string{"git", "-c", "protocol.version=2", "fetch", "origin", env.in.LatestVersion},
},
{cmd: []string{"git", "reset", "--hard", "FETCH_HEAD"}},
}
for _, cmd := range cmds {
if err := stepshelpers.RunCommandInContainer(ctx, env.containerID, cmd...); err != nil {
return nil, fmt.Errorf("failed to run command %v: %w", cmd, err)
if err := stepshelpers.RunCommandInContainer(ctx, env.containerID, cmd.cmd...); err != nil {
if len(cmd.onFailure) > 0 {
if err := stepshelpers.RunCommandInContainer(ctx, env.containerID, cmd.onFailure...); err != nil {
return nil, fmt.Errorf("failed to run onFailure command %v: %w", cmd.onFailure, err)
}
} else {
return nil, fmt.Errorf("failed to run command %v: %w", cmd.cmd, err)
}
}
}

View file

@ -1,59 +0,0 @@
# Copyright 1999-2023 Gentoo Authors
# Distributed under the terms of the GNU General Public License v2
EAPI=8
inherit toolchain-funcs
DESCRIPTION="A file archiver with a high compression ratio"
HOMEPAGE="https://7-zip.org"
SRC_URI="https://github.com/ip7z/7zip/releases/download/${PV}/7z$(ver_rs 1 '')-src.tar.xz"
RESTRICT="primaryuri"
S="${WORKDIR}"
LICENSE="LGPL-2.1 BSD rar? ( unRAR )"
SLOT="0"
KEYWORDS="amd64 arm64"
IUSE="asm rar static"
RDEPEND=""
DEPEND="${RDEPEND}"
BDEPEND="
asm? ( dev-lang/asmc )
"
DOCS=(
DOC/7zC.txt
DOC/7zFormat.txt
DOC/lzma.txt
DOC/Methods.txt
DOC/readme.txt
DOC/src-history.txt
)
src_prepare() {
sed -e 's: -\(O2\|s\) ::' -i CPP/7zip/7zip_gcc.mak
default
}
src_compile() {
local myemakeargs=(
CFLAGS_BASE2="${CFLAGS}"
CXXFLAGS_BASE2="${CXXFLAGS}"
CFLAGS_WARN_WALL='-Wall -Wextra'
IS_X64=1
USE_ASM=$(usex asm 1 '')
COMPL_STATIC=$(usex static 1 '')
O="${S}"
DISABLE_RAR=$(usex rar '' 1)
)
tc-env_build emake \
-C CPP/7zip/Bundles/Alone2 \
-f makefile.gcc \
"${myemakeargs[@]}"
}
src_install() {
dobin 7zz$(usex static 's' '')
einstalldocs
}

View file

@ -1,59 +0,0 @@
# Copyright 1999-2023 Gentoo Authors
# Distributed under the terms of the GNU General Public License v2
EAPI=8
inherit toolchain-funcs
DESCRIPTION="A file archiver with a high compression ratio"
HOMEPAGE="https://7-zip.org"
SRC_URI="https://github.com/ip7z/7zip/releases/download/${PV}/7z$(ver_rs 1 '')-src.tar.xz"
RESTRICT="primaryuri"
S="${WORKDIR}"
LICENSE="LGPL-2.1 BSD rar? ( unRAR )"
SLOT="0"
KEYWORDS="amd64 arm64"
IUSE="asm rar static"
RDEPEND=""
DEPEND="${RDEPEND}"
BDEPEND="
asm? ( dev-lang/asmc )
"
DOCS=(
DOC/7zC.txt
DOC/7zFormat.txt
DOC/lzma.txt
DOC/Methods.txt
DOC/readme.txt
DOC/src-history.txt
)
src_prepare() {
sed -e 's: -\(O2\|s\) ::' -i CPP/7zip/7zip_gcc.mak
default
}
src_compile() {
local myemakeargs=(
CFLAGS_BASE2="${CFLAGS}"
CXXFLAGS_BASE2="${CXXFLAGS}"
CFLAGS_WARN_WALL='-Wall -Wextra'
IS_X64=1
USE_ASM=$(usex asm 1 '')
COMPL_STATIC=$(usex static 1 '')
O="${S}"
DISABLE_RAR=$(usex rar '' 1)
)
tc-env_build emake \
-C CPP/7zip/Bundles/Alone2 \
-f makefile.gcc \
"${myemakeargs[@]}"
}
src_install() {
dobin 7zz$(usex static 's' '')
einstalldocs
}

View file

@ -1,2 +0,0 @@
DIST 7z2301-src.tar.xz 1378588 BLAKE2B 348484b24b39db70e513fe50d79954ea0e2dd669f83e3601fa796c8f0ca4734132ca20fac8cda9b8ba550bad9146627fc0ae07056abb99028ef6d825b6a533bd SHA512 e39f660c023aa65e55388be225b5591fe2a5c9138693f3c9107e2eb4ce97fafde118d3375e01ada99d29de9633f56221b5b3d640c982178884670cd84c8aa986
DIST 7z2406-src.tar.xz 1487008 BLAKE2B 0f8dd19a031520a9c233725e376bca06c91b9b513bc802a54b92ea046ae3dda69a293561938a1e4467d01333d46427bfee7a055c8b62cab7a9d04cf8262fe4eb SHA512 02c6d7d045ba0dc0e8533f471f3c138f0d6549b59594095cb81a2f0e602627bd6a49df3fd680e21400a908006121ff7ba370086db9bde639f79b821bb4c9707a

View file

@ -0,0 +1,3 @@
DIST deps.tar.xz 33072660 BLAKE2B 73dbed477b5ce0da6d9d3b9019e90534e5250562ff68bcddb17a9829cbbfae59c6e9536f3aa3f04189b90a3804f8d23e3f6ca543160b8fe20050de866852848c SHA512 531427ab0141ed37dc80e3626f86fa33776b3d8ac304cf6f4aa2e091146e8cb7b317a404d6b5bca637574e19cbf08f0a0d6bbb5cabd66b369df3ae81214d58b9
DIST doppler-3.67.1.tar.gz 133096 BLAKE2B 7e8bb2c2774d742da6ea6fc8376524f9165e87d7d2bd01854ee14807c0020f2cd4628621093bddd494e33575f93ca0e8a0a675ea2bf19212100591ac71f52549 SHA512 4ca87340683cb09205444a535f6ef201fe89b39fa234f19ede677bba880f406effcb95dbbc8e353e009528a136793ffcada27c80051a453ee85901f4735ea8f1
DIST doppler-3.68.0.tar.gz 133250 BLAKE2B 8ea286c0f3f575bc1c7386840bc4cdd56fe397849d1b86d806446c2403f25a795ca568ddb0040b838a0ed4d8bdaac6f06d9c77224ee9fef97e19bd52b18f97cd SHA512 4357eb56df565ec5c6ceb76787d9dffcdebd8a97bb956037bebc9b9e982e707ad51847c89ec75516c2ac82f1316e9659c3e240a96977cd7f4e4300098095ea9a

View file

@ -0,0 +1,31 @@
# Copyright 2020-2024 Gentoo Authors
# Distributed under the terms of the GNU General Public License v2
EAPI=8
inherit go-module tmpfiles
DESCRIPTION="The official CLI for interacting with your Doppler secrets and configuration"
HOMEPAGE="https://gitlab.com/gitlab-org/cli"
SRC_URI="https://github.com/DopplerHQ/cli/archive/refs/tags/${PV}.tar.gz -> ${P}.tar.gz"
SRC_URI+=" https://gentoo.rgst.io/updater_artifacts/${CATEGORY}/${PN}/${PV}/deps.tar.xz"
LICENSE="Apache-2.0"
SLOT="0"
KEYWORDS="~amd64 ~arm arm64 ~riscv ~x86"
BDEPEND=">=dev-lang/go-1.21"
RESTRICT="test"
src_unpack() {
default
mv "cli-v${PV}" "${P}"
}
src_compile() {
ego build -o bin/doppler -ldflags "-s -w -X github.com/DopplerHQ/cli/pkg/version.ProgramVersion=${PV}" .
}
src_install() {
dobin "${S}/bin/${PN}"
}

View file

@ -0,0 +1,31 @@
# Copyright 2020-2024 Gentoo Authors
# Distributed under the terms of the GNU General Public License v2
EAPI=8
inherit go-module tmpfiles
DESCRIPTION="The official CLI for interacting with your Doppler secrets and configuration"
HOMEPAGE="https://gitlab.com/gitlab-org/cli"
SRC_URI="https://github.com/DopplerHQ/cli/archive/refs/tags/${PV}.tar.gz -> ${P}.tar.gz"
SRC_URI+=" https://gentoo.rgst.io/updater_artifacts/${CATEGORY}/${PN}/${PV}/deps.tar.xz"
LICENSE="Apache-2.0"
SLOT="0"
KEYWORDS="~amd64 ~arm arm64 ~riscv ~x86"
BDEPEND=">=dev-lang/go-1.21"
RESTRICT="test"
src_unpack() {
default
mv "cli-v${PV}" "${P}"
}
src_compile() {
ego build -o bin/doppler -ldflags "-s -w -X github.com/DopplerHQ/cli/pkg/version.ProgramVersion=${PV}" .
}
src_install() {
dobin "${S}/bin/${PN}"
}

View file

@ -4,7 +4,7 @@
EAPI=8
inherit go-module tmpfiles
DESCRIPTION="Tailscale vpn client"
DESCRIPTION="A GitLab CLI tool bringing GitLab to your command line"
HOMEPAGE="https://gitlab.com/gitlab-org/cli"
SRC_URI="https://gitlab.com/gitlab-org/cli/-/archive/v${PV}/cli-v${PV}.tar.gz -> ${P}.tar.gz"
SRC_URI+=" https://gentoo.rgst.io/updater_artifacts/${CATEGORY}/${PN}/${PV}/deps.tar.xz"

View file

@ -0,0 +1,10 @@
Title: app-arch/7-zip remove in favor of app-arch/7zip::gentoo
Author: Jared Allard <jaredallard@users.noreply.github.com>
Posted: 2024-06-08
Revision: 1
News-Item-Format: 2.0
app-arch/7-zip has been removed in favor of app-arch/7zip::gentoo since
it's now upstream and maintained by the Gentoo project. Please migrate
to app-arch/7zip::gentoo as soon as possible. This is NOT automatically
done.

View file

@ -14,13 +14,10 @@ app-admin/op-cli-bin:
options:
repository: "deb https://downloads.1password.com/linux/debian/amd64 stable main"
package: 1password-cli
app-arch/7-zip:
resolver: git
options:
url: https://github.com/ip7z/7zip
dev-util/mise:
resolver: git
options:
disable_semver: true
url: https://github.com/jdx/mise
# We have to regenerate the ebuild to get new crates and licenses to
@ -120,3 +117,28 @@ dev-util/glab:
sed -i 's|dev-lang\/go-.*|dev-lang\/go-'"${GO_VERSION}"'"|' new.ebuild
- upload_artifact: deps.tar.xz
- ebuild: new.ebuild
dev-util/doppler:
resolver: git
options:
url: https://github.com/DopplerHQ/cli
# We have to generate a Go dependency archive and upload it to a
# stable location, so we do that during this process.
steps:
- checkout: https://github.com/DopplerHQ/cli
- original_ebuild: new.ebuild
- command: |-
set -euxo pipefail
GO_VERSION=$(grep "^go" go.mod | awk '{ print $2 }' | awk -F '.' '{ print $1"."$2}')
mise use -g golang@"${GO_VERSION}"
# Create the dependency tar.
GOMODCACHE="${PWD}"/go-mod go mod download -modcacherw
tar --create --file deps.tar go-mod
xz --threads 0 deps.tar
sed -i 's|dev-lang\/go-.*|dev-lang\/go-'"${GO_VERSION}"'"|' new.ebuild
- upload_artifact: deps.tar.xz
- ebuild: new.ebuild