diff --git a/.tools/README.md b/.tools/README.md index 70e1906..28caf13 100644 --- a/.tools/README.md +++ b/.tools/README.md @@ -52,6 +52,9 @@ dev-util/mise: | Key | Description | | --- | --- | | `url` | The URL where the git repository lives. HTTPS is recommended. | +| `tags` | Denote if we should consider tags or commits as the version | +| `disable_semver` | Disables parsing/sorting versions based on semver | +| `consider_pre_releases` | Denotes if we should consider semver pre-releases or not | ### **apt** `options` @@ -59,14 +62,18 @@ dev-util/mise: | --- | --- | | `repository` | Sources list entry for the APT repository | | `package` | The package name as it appears in the repository | +| `strip_release` | Strips semver release information from the calculated version | ### `steps` | Key | Description | | --- | --- | | `command` | A command to be ran. | -| `original_ebuild` | Path to write an ebuild | +| `checkout` | Checkout the Git repository at the detected version | | `ebuild` | Path to read modified ebuild from | +| `generate_go_deps` | Generate a `deps.tar.xz` for the current Go project | +| `original_ebuild` | Path to write an ebuild | +| `upload_artifact` | Upload a built artifact to a predictable path for usage in `SRC_URI` | ## License diff --git a/.tools/internal/steps/embed/generate-go-deps.sh b/.tools/internal/steps/embed/generate-go-deps.sh new file mode 100644 index 0000000..bbfb313 --- /dev/null +++ b/.tools/internal/steps/embed/generate-go-deps.sh @@ -0,0 +1,38 @@ +#!/usr/bin/env bash +# Copyright (C) 2024 Jared Allard +# +# This program is free software: you can redistribute it and/or modify +# it under the terms of the GNU Affero 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 Affero General Public License for more details. +# +# You should have received a copy of the GNU Affero General Public License +# along with this program. If not, see . +set -euo pipefail + +MODE="${1:-"slim"}" + +GO_VERSION=$(grep "^go" go.mod | awk '{ print $2 }' | awk -F '.' '{ print $1"."$2}') +mise use -g golang@"${GO_VERSION}" + +# Create the dependency tar. +echo "Creating dependency tarball" +if [[ "$MODE" == "full" ]]; then + tarDir="go-mod" + GOMODCACHE="${PWD}"/go-mod go mod download -modcacherw +else + go mod vendor + tarDir="vendor" +fi + +echo "Creating tarball (compressing with xz, this may take a while...)" +XZ_OPT=-e9T0 tar cJf deps.tar.xz "$tarDir" +ls -alh deps.tar.xz + +echo "Changing Go version to ${GO_VERSION}" +sed -i 's|dev-lang\/go-.*|dev-lang\/go-'"${GO_VERSION}"'"|' new.ebuild diff --git a/.tools/internal/steps/generate_go_deps.go b/.tools/internal/steps/generate_go_deps.go new file mode 100644 index 0000000..404f56b --- /dev/null +++ b/.tools/internal/steps/generate_go_deps.go @@ -0,0 +1,63 @@ +// Copyright (C) 2024 Jared Allard +// +// This program is free software: you can redistribute it and/or modify +// it under the terms of the GNU Affero 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 Affero General Public License for more details. +// +// You should have received a copy of the GNU Affero General Public License +// along with this program. If not, see . + +package steps + +import ( + "context" + _ "embed" + "fmt" + + "github.com/jaredallard/overlay/.tools/internal/steps/stepshelpers" +) + +//go:embed embed/generate-go-deps.sh +var generateGoDepsScript []byte + +// GenerateGoDepsStep generates a go dependency archive in the container +// at deps.tar.xz. +type GenerateGoDepsStep struct { + mode string // "slim" or "full", defaults to "slim" +} + +// NewGenerateGoDepsStep creates a new GenerateGoDepsStep from the +// provided input. +func NewGenerateGoDepsStep(input any) (StepRunner, error) { + mode, ok := input.(string) + if !ok && input != nil { + return nil, fmt.Errorf("expected string, got %T", input) + } + + if mode == "" { + mode = "slim" + } + + return &GenerateGoDepsStep{mode}, nil +} + +// Run runs the provided command inside of the step runner. +func (e GenerateGoDepsStep) Run(ctx context.Context, env Environment) (*StepOutput, error) { + if err := stepshelpers.CopyFileBytesToContainer(ctx, env.containerID, generateGoDepsScript, "/tmp/command.sh"); err != nil { + return nil, fmt.Errorf("failed to create shell script in container: %w", err) + } + + if err := stepshelpers.RunCommandInContainer(ctx, env.containerID, + "bash", "/tmp/command.sh", e.mode, + ); err != nil { + return nil, fmt.Errorf("failed to generate manifest: %w", err) + } + + return &StepOutput{}, nil +} diff --git a/.tools/internal/steps/steps.go b/.tools/internal/steps/steps.go index a51c9e6..5d4123c 100644 --- a/.tools/internal/steps/steps.go +++ b/.tools/internal/steps/steps.go @@ -62,11 +62,12 @@ func (s *Steps) UnmarshalYAML(node *yaml.Node) error { // knownSteps map of key values to their respective steps. knownSteps := map[string]func(any) (StepRunner, error){ - "command": NewCommandStep, - "checkout": NewCheckoutStep, - "ebuild": NewEbuildStep, - "original_ebuild": NewOriginalEbuildStep, - "upload_artifact": NewUploadArtifactStep, + "command": NewCommandStep, + "checkout": NewCheckoutStep, + "ebuild": NewEbuildStep, + "generate_go_deps": NewGenerateGoDepsStep, + "original_ebuild": NewOriginalEbuildStep, + "upload_artifact": NewUploadArtifactStep, } for _, rawStep := range raw { diff --git a/Dockerfile b/Dockerfile index ad2d0d7..05603ab 100644 --- a/Dockerfile +++ b/Dockerfile @@ -13,4 +13,4 @@ RUN export MAKEOPTS="-j$(nproc)" && \ # Install mise for things that might need it. RUN curl https://mise.run | sh ENV PATH="/root/.local/bin:/root/.local/share/mise/shims:${PATH}" -RUN set -e; whoami; echo $HOME; mise --version \ No newline at end of file +RUN set -e; whoami; echo "$HOME"; mise --version \ No newline at end of file diff --git a/net-vpn/tailscale/Manifest b/net-vpn/tailscale/Manifest index 6fb726d..94b03a6 100644 --- a/net-vpn/tailscale/Manifest +++ b/net-vpn/tailscale/Manifest @@ -1,5 +1,3 @@ -DIST tailscale-1.66.4-deps.tar.xz 395282764 BLAKE2B ce730c19a71ac4ea6528d5c71c8ef7271da9b2c668ea878e717d7d6e2e11d1fc371c50ab8bab68a6a841e8596f9f8a5a3eec1f94f17e7f21d1d6f2c475cca9e4 SHA512 8670dd91268f1254834a0c6ddd945015da7c21f5f2228366fafb667861f7670ac2523119e004e39d65eacce2dfef4518fb35cd93451eddbf5b062da619eca2a3 -DIST tailscale-1.66.4.tar.gz 2636998 BLAKE2B 617cd97d7536faac53d46167fdf48acd430bc453cef6f5157df1c8f6bd98973c8b17c0687a7d931501979b70da3b1268fde77a3f9653b1143eb363d09b5e719f SHA512 6c114508964f86984cdbcd2f3e81c4939f4c5a0ed20363b4463642fc8ca235d5b220e46e5b55c655e435f20be24295391b0070db3a78d45210ac9c27f5e7bbab DIST tailscale-1.68.0-deps.tar.xz 475022544 BLAKE2B 9bc68ff79c11457387c0f665eca9a74c0e7945f8d7a23a053cbafb91ccf2ae94bd13a1b9c9b26bcfafd52b250aecf6571b65c089d0a87c5e9af2dfa7d8327026 SHA512 c6814f4aaeb80aa3982b7fa893090026587a1d48beccdce2589cec55c1611f5e0c9394e52aaf70995621808cb0cbefd275e3b6050d24a9354c52b5bb8345a46d DIST tailscale-1.68.0.tar.gz 2721807 BLAKE2B ffb6b4cc36473195587a8fc7a3142e1e7c73a5ccd50dc1fe8b26f3d0b69feb476e339a9bb66b2836823090c48a12b79e5bdbf54af96e4603464d70837ae0e7d0 SHA512 b63ee338e2a75d5be3b3c9c7446db178c66f326aea074bb1cdd18d7f1aa5fa720b0cafd5ff07a3665bb403d05d22c8f4cf0fa9638a5a87b08b6b617bd5795ee8 DIST tailscale-1.68.1-deps.tar.xz 475973944 BLAKE2B 9cb7cf0e8d608eaec21dda674c37b3f52a9b31a41b9676fbfced24d3dbe51cbdec8af9accdb1a83d104a5f3e73e43903567168aa19467517d6445f27e0bd3b63 SHA512 849c81b39b563c88a69e2e74d7d7e57aa3c2f1b1bd50cb5801765c0c4a211116692224a0a925c7c89a905fbe5c90a28657259170e44c7166b55f543db2a6f243 diff --git a/net-vpn/tailscale/tailscale-1.66.4.ebuild b/net-vpn/tailscale/tailscale-1.66.4.ebuild deleted file mode 100644 index 6570e54..0000000 --- a/net-vpn/tailscale/tailscale-1.66.4.ebuild +++ /dev/null @@ -1,60 +0,0 @@ -# Copyright 2020-2024 Gentoo Authors -# Distributed under the terms of the GNU General Public License v2 - -EAPI=8 -inherit go-module systemd tmpfiles - -# These settings are obtained by running ./build_dist.sh shellvars in -# the upstream repo. -VERSION_MINOR="66" -VERSION_SHORT="1.66.4" -VERSION_LONG="1.66.4-te64efe4f7" -VERSION_GIT_HASH="e64efe4f777cb5b4d9efd603ad1360a509006cd1" - -DESCRIPTION="Tailscale vpn client" -HOMEPAGE="https://tailscale.com" -SRC_URI="https://github.com/tailscale/tailscale/archive/v${PV}.tar.gz -> ${P}.tar.gz" -SRC_URI+=" https://gentoo.rgst.io/updater_artifacts/${CATEGORY}/${PN}/${PV}/deps.tar.xz -> ${P}-deps.tar.xz" - -LICENSE="MIT" -SLOT="0" -KEYWORDS="~amd64 ~arm arm64 ~riscv ~x86" - -RDEPEND="net-firewall/iptables" -BDEPEND=">=dev-lang/go-1.22" - -RESTRICT="test" - -# This translates the build command from upstream's build_dist.sh to an -# ebuild equivalent. -build_dist() { - ego build -tags xversion -ldflags " - -X tailscale.com/version.Long=${VERSION_LONG} - -X tailscale.com/version.Short=${VERSION_SHORT} - -X tailscale.com/version.GitCommit=${VERSION_GIT_HASH}" "$@" -} - -src_compile() { - build_dist ./cmd/tailscale - build_dist ./cmd/tailscaled -} - -src_install() { - dosbin tailscaled - dobin tailscale - - systemd_dounit cmd/tailscaled/tailscaled.service - insinto /etc/default - newins cmd/tailscaled/tailscaled.defaults tailscaled - keepdir /var/lib/${PN} - fperms 0750 /var/lib/${PN} - - newtmpfiles "${FILESDIR}/${PN}.tmpfiles" ${PN}.conf - - newinitd "${FILESDIR}/${PN}d.initd" ${PN} - newconfd "${FILESDIR}/${PN}d.confd" ${PN} -} - -pkg_postinst() { - tmpfiles_process ${PN}.conf -} diff --git a/packages.yml b/packages.yml index ae65f8d..06ed2e5 100644 --- a/packages.yml +++ b/packages.yml @@ -41,16 +41,10 @@ net-vpn/tailscale: steps: - checkout: https://github.com/tailscale/tailscale - original_ebuild: new.ebuild + - generate_go_deps - 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 - XZ_OPT=-e9T0 tar cJf deps.tar.xz go-mod - # Get the shell variables and rewrite the ebuild to contain # them. eval "$(./build_dist.sh shellvars)" @@ -58,8 +52,6 @@ net-vpn/tailscale: sed -i 's/VERSION_SHORT=".*"/VERSION_SHORT="'"${VERSION_SHORT}"'"/' new.ebuild sed -i 's/VERSION_LONG=".*"/VERSION_LONG="'"${VERSION_LONG}"'"/' new.ebuild sed -i 's/VERSION_GIT_HASH=".*"/VERSION_GIT_HASH="'"${VERSION_GIT_HASH}"'"/' new.ebuild - - sed -i 's|dev-lang\/go-.*|dev-lang\/go-'"${GO_VERSION}"'"|' new.ebuild - upload_artifact: deps.tar.xz - ebuild: new.ebuild app-admin/chezmoi: @@ -72,22 +64,14 @@ app-admin/chezmoi: steps: - checkout: https://github.com/twpayne/chezmoi - original_ebuild: new.ebuild + - generate_go_deps - 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 - XZ_OPT=-e9T0 tar cJf deps.tar.xz go-mod - # Get the shell variables and rewrite the ebuild to contain # them. VERSION_GIT_HASH=$(go run assets/scripts/generate-commit.go) sed -i 's/VERSION_GIT_HASH=".*"/VERSION_GIT_HASH="'"${VERSION_GIT_HASH}"'"/' new.ebuild - - sed -i 's|dev-lang\/go-.*|dev-lang\/go-'"${GO_VERSION}"'"|' new.ebuild - upload_artifact: deps.tar.xz - ebuild: new.ebuild @@ -101,17 +85,7 @@ dev-util/glab: steps: - checkout: https://gitlab.com/gitlab-org/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 - XZ_OPT=-e9T0 tar cJf deps.tar.xz go-mod - - sed -i 's|dev-lang\/go-.*|dev-lang\/go-'"${GO_VERSION}"'"|' new.ebuild + - generate_go_deps - upload_artifact: deps.tar.xz - ebuild: new.ebuild @@ -125,16 +99,6 @@ dev-util/doppler: 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 - XZ_OPT=-e9T0 tar cJf deps.tar.xz go-mod - - sed -i 's|dev-lang\/go-.*|dev-lang\/go-'"${GO_VERSION}"'"|' new.ebuild + - generate_go_deps - upload_artifact: deps.tar.xz - ebuild: new.ebuild diff --git a/www-client/chromium/.update.sh b/www-client/chromium/.update.sh index 6b756b2..636641e 100755 --- a/www-client/chromium/.update.sh +++ b/www-client/chromium/.update.sh @@ -1,6 +1,7 @@ #!/usr/bin/env bash # Updates the chromium package to use the versions inside from the # gentoo repository while persisting the patches we need. +set -euo pipefail DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"