Download this file
| 1 | package host |
| 2 | |
| 3 | import ( |
| 4 | "fmt" |
| 5 | "os" |
| 6 | "path/filepath" |
| 7 | |
| 8 | "github.com/carlosframework/platform/internal/moves" |
| 9 | ) |
| 10 | |
| 11 | // A bound constrains replacement only while a certified copy meeting it is |
| 12 | // available. The executor itself remains runnable so it can repair the box. |
| 13 | func rootFloorAvailable(opt string, bound *moves.Floor, seeds bool, candidate string) bool { |
| 14 | if bound == nil { |
| 15 | return false |
| 16 | } |
| 17 | for _, path := range []string{systemBinaryPath(opt), systemPrevPath(opt), filepath.Join(systemRootDir(opt), "staging", "carlos"), candidate} { |
| 18 | if path == "" { |
| 19 | continue |
| 20 | } |
| 21 | b, err := readRootFloorBinary(opt, path) |
| 22 | if seeds { |
| 23 | b = b.forSeeds() |
| 24 | } |
| 25 | if err == nil && b.supports(bound) { |
| 26 | return true |
| 27 | } |
| 28 | } |
| 29 | return false |
| 30 | } |
| 31 | func (a *systemApplier) activationFloor(floor *moves.Floor, seeds bool) *moves.Floor { |
| 32 | if _, required, err := a.rootMoves.read(); err != nil || !required || floor == nil { |
| 33 | return floor |
| 34 | } |
| 35 | if rootFloorAvailable(a.optDir, floor, seeds, "") { |
| 36 | return floor |
| 37 | } |
| 38 | if !a.floorAlerted { |
| 39 | rootFloorAlert() |
| 40 | a.floorAlerted = true |
| 41 | } |
| 42 | return nil |
| 43 | } |
| 44 | |
| 45 | func rootFloorAlert() { fmt.Fprintln(os.Stderr, "<1>"+errRootFloorHistory.Error()) } |
| 46 | |