From b587caf2e863902eb04a6540462db5852fd1a0b5 Mon Sep 17 00:00:00 2001 From: Ophestra Date: Mon, 13 Apr 2026 15:06:53 +0900 Subject: [PATCH] internal/rosa: assume file source is xz-compressed XZ happens to be the only widely-used format that is awful to deal with, everything else is natively supported. Signed-off-by: Ophestra --- internal/pkg/tar.go | 3 +-- internal/rosa/gnu.go | 1 - internal/rosa/rosa.go | 28 +++++++++++----------------- internal/rosa/strace.go | 2 -- 4 files changed, 12 insertions(+), 22 deletions(-) diff --git a/internal/pkg/tar.go b/internal/pkg/tar.go index 32b4b362..1c558d52 100644 --- a/internal/pkg/tar.go +++ b/internal/pkg/tar.go @@ -43,8 +43,7 @@ var _ fmt.Stringer = new(tarArtifactNamed) func (a *tarArtifactNamed) String() string { return a.name + "-unpack" } // NewTar returns a new [Artifact] backed by the supplied [Artifact] and -// compression method. The source [Artifact] must be compatible with -// [TContext.Open]. +// compression method. The source [Artifact] must be a [FileArtifact]. func NewTar(a Artifact, compression uint32) Artifact { ta := tarArtifact{a, compression} if s, ok := a.(fmt.Stringer); ok { diff --git a/internal/rosa/gnu.go b/internal/rosa/gnu.go index 5272ad31..61f64122 100644 --- a/internal/rosa/gnu.go +++ b/internal/rosa/gnu.go @@ -639,7 +639,6 @@ func (t Toolchain) newFindutils() (pkg.Artifact, string) { nil, "https://ftpmirror.gnu.org/gnu/findutils/findutils-"+version+".tar.xz", mustDecode(checksum), ), &PackageAttr{ - SourceKind: SourceKindTarXZ, ScriptEarly: ` echo '#!/bin/sh' > gnulib-tests/test-c32ispunct.sh echo 'int main(){return 0;}' > tests/xargs/test-sigusr.c diff --git a/internal/rosa/rosa.go b/internal/rosa/rosa.go index 930a1896..556ed44b 100644 --- a/internal/rosa/rosa.go +++ b/internal/rosa/rosa.go @@ -443,11 +443,6 @@ type Helper interface { script(name string) string } -const ( - // SourceKindTarXZ denotes a source tarball to be decompressed using [XZ]. - SourceKindTarXZ = 1 + iota -) - // PackageAttr holds build-system-agnostic attributes. type PackageAttr struct { // Mount the source tree writable. @@ -464,8 +459,6 @@ type PackageAttr struct { // Passed to [Toolchain.NewPatchedSource]. Patches []KV - // Kind of source artifact. - SourceKind int // Dependencies not provided by stage0. NonStage0 []pkg.Artifact @@ -537,11 +530,6 @@ func (t Toolchain) NewPackage( panic("source must be non-nil") } wantsChmod, wantsWrite := helper.wantsChmod(), helper.wantsWrite() - if attr.SourceKind > 0 && - (attr.Writable || attr.Chmod || wantsChmod || wantsWrite || len(attr.Patches) > 0) { - panic("source processing requested on a non-unpacked kind") - } - dc := len(attr.NonStage0) if !t.isStage0() { dc += 1<<3 + len(extra) @@ -560,17 +548,23 @@ func (t Toolchain) NewPackage( paPut(pv) } - var scriptEarly string + var ( + scriptEarly string + sourceSuffix string + ) + + if _, ok := source.(pkg.FileArtifact); ok { + if attr.Writable || attr.Chmod || + wantsChmod || wantsWrite || + len(attr.Patches) > 0 { + panic("source processing requested on a xz-compressed tarball") + } - var sourceSuffix string - switch attr.SourceKind { - case SourceKindTarXZ: sourceSuffix = ".tar.xz" scriptEarly += ` tar -C /usr/src/ -xf '/usr/src/` + name + `.tar.xz' mv '/usr/src/` + name + `-` + version + `' '/usr/src/` + name + `' ` - break } dir := helper.wantsDir() diff --git a/internal/rosa/strace.go b/internal/rosa/strace.go index 3bc4428e..9aa0ca4a 100644 --- a/internal/rosa/strace.go +++ b/internal/rosa/strace.go @@ -11,8 +11,6 @@ func (t Toolchain) newStrace() (pkg.Artifact, string) { nil, "https://strace.io/files/"+version+"/strace-"+version+".tar.xz", mustDecode(checksum), ), &PackageAttr{ - SourceKind: SourceKindTarXZ, - // patch not possible with nonzero SourceKind ScriptEarly: ` sed -i 's/off64_t/off_t/g' \