|
|
|
@ -20,7 +20,7 @@ type SnapDetails struct {
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// collectSnapDependencies collects all dependencies for a given snap, marking them as requiredSnaps regardless of whether they need updates.
|
|
|
|
|
func collectSnapDependencies(snapName, channel, snapsDir, assertionsDir string) ([]SnapDetails, error) {
|
|
|
|
|
func collectSnapDependencies(snapName, channel, fallbackChannel, snapsDir, assertionsDir string) ([]SnapDetails, error) {
|
|
|
|
|
var snapDetailsList []SnapDetails
|
|
|
|
|
|
|
|
|
|
if processedSnaps[snapName] {
|
|
|
|
@ -37,14 +37,37 @@ func collectSnapDependencies(snapName, channel, snapsDir, assertionsDir string)
|
|
|
|
|
if oldSnap == nil || oldSnap.SnapID == "" || oldSnap.Revision.N == 0 {
|
|
|
|
|
result, err = fetchOrRefreshSnapInfo(snapName, nil, channel)
|
|
|
|
|
if err != nil {
|
|
|
|
|
return nil, err // Added 0 for int64
|
|
|
|
|
if strings.Contains(err.Error(), "no snap revision available as specified") {
|
|
|
|
|
result, err = fetchOrRefreshSnapInfo(snapName, nil, fallbackChannel)
|
|
|
|
|
if err != nil {
|
|
|
|
|
return nil, err
|
|
|
|
|
}
|
|
|
|
|
} else {
|
|
|
|
|
return nil, err
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
} else {
|
|
|
|
|
result, err = fetchOrRefreshSnapInfo(snapName, oldSnap, channel)
|
|
|
|
|
if err != nil && strings.Contains(err.Error(), "snap has no updates available") {
|
|
|
|
|
if err != nil {
|
|
|
|
|
if strings.Contains(err.Error(), "snap has no updates available") {
|
|
|
|
|
result, err = fetchOrRefreshSnapInfo(snapName, nil, channel)
|
|
|
|
|
if err != nil {
|
|
|
|
|
return nil, err // Added 0 for int64
|
|
|
|
|
return nil, err
|
|
|
|
|
}
|
|
|
|
|
} else if strings.Contains(err.Error(), "no snap revision available as specified") {
|
|
|
|
|
result, err = fetchOrRefreshSnapInfo(snapName, oldSnap, fallbackChannel)
|
|
|
|
|
if err != nil {
|
|
|
|
|
if strings.Contains(err.Error(), "snap has no updates available") {
|
|
|
|
|
result, err = fetchOrRefreshSnapInfo(snapName, nil, fallbackChannel)
|
|
|
|
|
if err != nil {
|
|
|
|
|
return nil, err
|
|
|
|
|
}
|
|
|
|
|
} else {
|
|
|
|
|
return nil, err
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
} else {
|
|
|
|
|
return nil, err
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
@ -86,7 +109,7 @@ func collectSnapDependencies(snapName, channel, snapsDir, assertionsDir string)
|
|
|
|
|
for prereq := range missingPrereqs {
|
|
|
|
|
if !processedSnaps[prereq] {
|
|
|
|
|
verboseLog("Collecting dependencies for prerequisite snap: %s for %s", prereq, snapName)
|
|
|
|
|
prereqDetails, err := collectSnapDependencies(prereq, "stable", snapsDir, assertionsDir)
|
|
|
|
|
prereqDetails, err := collectSnapDependencies(prereq, channel, fallbackChannel, snapsDir, assertionsDir)
|
|
|
|
|
if err != nil {
|
|
|
|
|
// Additional logging for dependency resolution issues
|
|
|
|
|
verboseLog("Failed to collect dependencies for prerequisite %s for snap %s: %v", prereq, snapName, err)
|
|
|
|
@ -99,7 +122,7 @@ func collectSnapDependencies(snapName, channel, snapsDir, assertionsDir string)
|
|
|
|
|
// Also handle base snaps safely
|
|
|
|
|
if info.Base != "" && !processedSnaps[info.Base] {
|
|
|
|
|
verboseLog("Collecting dependencies for base snap: %s for %s", info.Base, snapName)
|
|
|
|
|
baseDetails, err := collectSnapDependencies(info.Base, "stable", snapsDir, assertionsDir)
|
|
|
|
|
baseDetails, err := collectSnapDependencies(info.Base, channel, fallbackChannel, snapsDir, assertionsDir)
|
|
|
|
|
if err != nil {
|
|
|
|
|
verboseLog("Failed to collect dependencies for base snap %s for snap %s: %v", info.Base, snapName, err)
|
|
|
|
|
return nil, fmt.Errorf("failed to collect dependencies for base snap %s for snap %s: %v", info.Base, snapName, err) // Added 0 for int64
|
|
|
|
|