// newKernelFilenamePattern returns the filename pattern to modify files
// in the partition declared in the boot config file.
//
// After the update, the config file is already changed to point to the new partition.
// If we are on a and update, the config file would point to b
// and this function would return "b/%s%s*"
// If we are not in an update process (ie. we are unsetting the failover conditions)
// we want to change the files in the other partition
func newKernelFilenamePattern(c *check.C, bootSystem string) string {
	part, err := partition.CurrentPartition()
	c.Assert(err, check.IsNil,
		check.Commentf("Error getting the current partition: %s", err))
	part = partition.OtherPartition(part)
	return filepath.Join(part, "%s%s*")
}
// newKernelFilenamePattern returns the filename pattern to modify files
// in the partition declared in the boot config file.
//
// After the update, the config file is already changed to point to the new partition.
// If we are on a and update, the config file would point to b
// and this function would return "b/%s%s*"
// If we are not in an update process (ie. we are unsetting the failover conditions)
// we want to change the files in the other partition
func newKernelFilenamePattern(c *check.C, bootSystem string, afterUpdate bool) string {
	var part string
	var err error
	if afterUpdate {
		part, err = partition.NextBootPartition()
		c.Assert(err, check.IsNil,
			check.Commentf("Error getting the next boot partition: %s", err))
	} else {
		part, err = partition.CurrentPartition()
		c.Assert(err, check.IsNil,
			check.Commentf("Error getting the current partition: %s", err))
		part = partition.OtherPartition(part)
	}
	return filepath.Join(part, "%s%s*")
}
Exemple #3
0
func (s *updateSuite) assertBootDirContents(c *check.C) {
	system, err := partition.BootSystem()
	c.Assert(err, check.IsNil, check.Commentf("Error getting the boot system: %s", err))
	current, err := partition.CurrentPartition()
	c.Assert(err, check.IsNil, check.Commentf("Error getting the current partition: %s", err))
	files, err := ioutil.ReadDir(
		path.Join(partition.BootDir(system), partition.OtherPartition(current)))
	c.Assert(err, check.IsNil, check.Commentf("Error reading the other partition boot dir: %s", err))

	expectedFileNames := []string{"hardware.yaml", "initrd.img", "vmlinuz"}
	if system == "uboot" {
		expectedFileNames = append([]string{"dtbs"}, expectedFileNames...)
	}

	fileNames := []string{}
	for _, f := range files {
		fileNames = append(fileNames, f.Name())
	}
	c.Assert(fileNames, check.DeepEquals, expectedFileNames,
		check.Commentf("Wrong files in the other partition boot dir"))
}