func getCurrentBootDir(c *check.C) string {
	system, err := partition.BootSystem()
	c.Assert(err, check.IsNil, check.Commentf("Error getting the boot system: %s", err))
	bootDir := partition.BootDir(system)
	current, err := partition.CurrentPartition()
	c.Assert(err, check.IsNil, check.Commentf("Error getting the current partition: %s", err))
	return path.Join(bootDir, current)
}
func (zeroSizeInitrd) unset(c *check.C) {
	boot, err := partition.BootSystem()
	c.Assert(err, check.IsNil, check.Commentf("Error getting the boot system: %s", err))
	dir := partition.BootDir(boot)

	bootFileNamePattern := newKernelFilenamePattern(c, boot)
	commonUnset(c, dir, bootFileNamePattern, initrdFilename)
}
Beispiel #3
0
func (s *updateOSSuite) assertBootDirContents(c *check.C) {
	system, err := partition.BootSystem()
	c.Assert(err, check.IsNil, check.Commentf("Error getting the boot system: %s", err))
	snappyKernel, err := partition.SnappyKernel()
	c.Assert(err, check.IsNil, check.Commentf("Error getting the name of the kernel snap: %s", err))
	snapBootDir := path.Join(partition.BootDir(system), snappyKernel)
	if system == "uboot" {
		s.assertUBootDirContents(c, snapBootDir)
	} else {
		// On amd64 the vmlinuz/initrd comes out of the squashfs via grub loop mounts.
		_, err = os.Stat(snapBootDir)
		c.Assert(os.IsNotExist(err), check.Equals, true,
			check.Commentf("%s exists in the grub system", snapBootDir))
	}
}
Beispiel #4
0
func (s *grubSuite) TestGrubBootDirMustNotContainKernelFiles(c *check.C) {
	bootSystem, err := partition.BootSystem()
	c.Assert(err, check.IsNil, check.Commentf("Error getting boot system: %s", err))

	if bootSystem != "grub" {
		c.Skip("This test checks properties of grub based systems")
	}

	bootDir := partition.BootDir(bootSystem)
	for _, targetFile := range []string{"vmlinuz", "initrd.img"} {
		output, err := cli.ExecCommandErr("find", bootDir, "-name", fmt.Sprintf(`"%s"`, targetFile))

		c.Check(err, check.IsNil)
		c.Check(output, check.Equals, "")
	}
}
Beispiel #5
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"))
}