Fix issues found during macOS fakeroot testing

- Increase maxAutoBuildDepth from 3 to 15 for complex dependency chains

- Remove ${ from dangerous patterns (valid shell variable expansion)

- Add support for Debian-native packages without orig.tar.gz

- Add isDebianSourceArchive() to handle native Debian source packages
This commit is contained in:
itexpert228 2026-03-14 20:09:05 +03:00
parent fbe74e8a87
commit bbf2f00578
No known key found for this signature in database
3 changed files with 41 additions and 3 deletions

View file

@ -184,7 +184,7 @@ func looksLikeFilePath(target string) bool {
strings.HasSuffix(target, ".zov") strings.HasSuffix(target, ".zov")
} }
const maxAutoBuildDepth = 3 // Уменьшим для тестов const maxAutoBuildDepth = 15 // Увеличим для сложных цепочек зависимостей
type autoBuildSession struct { type autoBuildSession struct {
workDir string workDir string

View file

@ -665,7 +665,6 @@ func (b *Builder) validateCommand(command string) error {
"init 6", "init 6",
"eval", "eval",
"$(", // command substitution "$(", // command substitution
"${", // parameter expansion
} }
// Check against original // Check against original

View file

@ -201,8 +201,19 @@ func (f *Fetcher) downloadAndExtractFromDebianDSC(dscURL, dscHash, destDir strin
origEntries = append(origEntries, entry) origEntries = append(origEntries, entry)
} }
} }
// If no orig archives found, this might be a Debian-native package
// Fall back to the main source tarball (which doesn't have .orig in name)
if len(origEntries) == 0 { if len(origEntries) == 0 {
return fmt.Errorf("debian dsc does not contain upstream orig archive") for _, entry := range entries {
if isDebianSourceArchive(entry.Name) {
origEntries = append(origEntries, entry)
}
}
}
if len(origEntries) == 0 {
return fmt.Errorf("debian dsc does not contain any recognizable source archive")
} }
base, err := neturl.Parse(dscURL) base, err := neturl.Parse(dscURL)
@ -312,6 +323,34 @@ func isDebianOrigArchive(name string) bool {
return false return false
} }
func isDebianSourceArchive(name string) bool {
// Debian-native packages have .tar.gz or .tar.xz without .orig in the name
// e.g., package_1.0.tar.gz (not package_1.0.orig.tar.gz)
if isDebianOrigArchive(name) {
return false // This is an orig archive, not a native source
}
// Check if it looks like a source tarball (has .tar suffix)
if !strings.Contains(name, ".tar") {
return false
}
// Exclude .dsc and .debian.tar files
if strings.HasSuffix(name, ".dsc") {
return false
}
if strings.Contains(name, ".debian.tar") {
return false
}
if strings.Contains(name, ".diff.") {
return false
}
if strings.Contains(name, ".asc") { // signature files
return false
}
return hasTarSuffix(name)
}
func hasTarSuffix(s string) bool { func hasTarSuffix(s string) bool {
if !strings.HasPrefix(s, ".tar") { if !strings.HasPrefix(s, ".tar") {
return false return false