Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ require (
github.com/crillab/gophersat v1.4.0
github.com/dsnet/compress v0.0.1
github.com/google/uuid v1.6.0
github.com/klauspost/compress v1.18.3
github.com/ulikunitz/xz v0.5.15
golang.org/x/crypto v0.47.0
golang.org/x/term v0.39.0
Expand All @@ -19,7 +20,6 @@ require (
require (
github.com/coregx/ahocorasick v0.1.0 // indirect
github.com/dustin/go-humanize v1.0.1 // indirect
github.com/klauspost/compress v1.18.3 // indirect
github.com/mattn/go-isatty v0.0.20 // indirect
github.com/ncruces/go-strftime v1.0.0 // indirect
github.com/remyoudompheng/bigfft v0.0.0-20230129092748-24d4a6f8daec // indirect
Expand All @@ -32,3 +32,5 @@ require (
modernc.org/mathutil v1.7.1 // indirect
modernc.org/memory v1.11.0 // indirect
)

replace mvdan.cc/sh/v3 => ../reference/mvdan-sh
2 changes: 0 additions & 2 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -113,5 +113,3 @@ modernc.org/strutil v1.2.1 h1:UneZBkQA+DX2Rp35KcM69cSsNES9ly8mQWD71HKlOA0=
modernc.org/strutil v1.2.1/go.mod h1:EHkiggD70koQxjVdSBM3JKM7k6L0FbGE5eymy9i3B9A=
modernc.org/token v1.1.0 h1:Xl7Ap9dKaEs5kLoOQeQmPWevfnk/DM5qcLcYlA8ys6Y=
modernc.org/token v1.1.0/go.mod h1:UGzOrNV1mAFSEB63lOFHIpNRUVMvYTc6yu1SMY/XTDM=
mvdan.cc/sh/v3 v3.12.0 h1:ejKUR7ONP5bb+UGHGEG/k9V5+pRVIyD+LsZz7o8KHrI=
mvdan.cc/sh/v3 v3.12.0/go.mod h1:Se6Cj17eYSn+sNooLZiEUnNNmNxg0imoYlTu4CyaGyg=
13 changes: 11 additions & 2 deletions internal/ebuild/executor.go
Original file line number Diff line number Diff line change
Expand Up @@ -619,8 +619,17 @@ func (e *Executor) ParseEbuild() error {
return fmt.Errorf("checking ebuild file: %w", err)
}

// Parse the ebuild script
parsed, err := ParseEbuildScript(e.EbuildPath)
// Parse the ebuild script with known variables for conditional evaluation.
// This ensures inherit calls inside "if [[ ${PV} == 9999 ]]" blocks
// are skipped when PV doesn't match (e.g., git-r3 for non-live ebuilds).
ebuildVars := map[string]string{
"PV": e.Env.PV,
"PVR": e.Env.PVR,
"PN": e.Env.PN,
"P": e.Env.P,
"PF": e.Env.PF,
}
parsed, err := ParseEbuildScript(e.EbuildPath, ebuildVars)
if err != nil {
return fmt.Errorf("parsing ebuild: %w", err)
}
Expand Down
20 changes: 10 additions & 10 deletions internal/ebuild/phase_dispatch_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ src_configure() {
}

// Parse ebuild to detect functions
script, err := ParseEbuildScript(ebuildPath)
script, err := ParseEbuildScript(ebuildPath, nil)
if err != nil {
t.Fatalf("failed to parse ebuild: %v", err)
}
Expand Down Expand Up @@ -98,7 +98,7 @@ SLOT="0"
}

// Parse ebuild
script, err := ParseEbuildScript(ebuildPath)
script, err := ParseEbuildScript(ebuildPath, nil)
if err != nil {
t.Fatalf("failed to parse ebuild: %v", err)
}
Expand Down Expand Up @@ -131,7 +131,7 @@ SLOT="0"
}

// Parse ebuild
script, err := ParseEbuildScript(ebuildPath)
script, err := ParseEbuildScript(ebuildPath, nil)
if err != nil {
t.Fatalf("failed to parse ebuild: %v", err)
}
Expand Down Expand Up @@ -237,7 +237,7 @@ src_configure() {
}

// Parse ebuild
script, parseErr := ParseEbuildScript(ebuildPath)
script, parseErr := ParseEbuildScript(ebuildPath, nil)
if parseErr != nil {
t.Fatalf("failed to parse ebuild: %v", parseErr)
}
Expand Down Expand Up @@ -295,7 +295,7 @@ src_prepare() {
}

// Parse ebuild
script, parseErr := ParseEbuildScript(ebuildPath)
script, parseErr := ParseEbuildScript(ebuildPath, nil)
if parseErr != nil {
t.Fatalf("failed to parse ebuild: %v", parseErr)
}
Expand Down Expand Up @@ -370,7 +370,7 @@ pkg_prerm() { :; }
pkg_postrm() { :; }
`

script, err := ParseEbuildScriptFromString(content)
script, err := ParseEbuildScriptFromString(content, nil)
if err != nil {
t.Fatalf("ParseEbuildScriptFromString failed: %v", err)
}
Expand Down Expand Up @@ -407,7 +407,7 @@ src_compile() { emake; }
pkg_postinst() { einfo "Done"; }
`

script, err := ParseEbuildScriptFromString(content)
script, err := ParseEbuildScriptFromString(content, nil)
if err != nil {
t.Fatalf("ParseEbuildScriptFromString failed: %v", err)
}
Expand Down Expand Up @@ -501,7 +501,7 @@ src_configure() {
EbuildPath: ebuildPath,
}

script, parseErr := ParseEbuildScript(ebuildPath)
script, parseErr := ParseEbuildScript(ebuildPath, nil)
if parseErr != nil {
t.Fatalf("failed to parse ebuild: %v", parseErr)
}
Expand Down Expand Up @@ -549,7 +549,7 @@ src_install() {

b.ResetTimer()
for i := 0; i < b.N; i++ {
_, _ = ParseEbuildScriptFromString(content)
_, _ = ParseEbuildScriptFromString(content, nil)
}
}

Expand All @@ -561,7 +561,7 @@ src_configure() { econf; }
src_compile() { emake; }
src_install() { emake install; }
`
script, err := ParseEbuildScriptFromString(content)
script, err := ParseEbuildScriptFromString(content, nil)
if err != nil {
b.Fatalf("ParseEbuildScriptFromString failed: %v", err)
}
Expand Down
Loading
Loading