예제 #1
0
func (a *ReleaseTestSuite) TestReadLsbNotFound(c *C) {
	reset := release.HackLsbReleasePath("not-there")
	defer reset()

	_, err := release.ReadLsb()
	c.Assert(err, ErrorMatches, "cannot read lsb-release:.*")
}
예제 #2
0
func findDownloadPathFromLxdIndex(r io.Reader) (string, error) {
	arch := arch.UbuntuArchitecture()
	lsb, err := release.ReadLsb()
	if err != nil {
		return "", err
	}
	release := lsb.Codename

	needle := fmt.Sprintf("ubuntu;%s;%s;default;", release, arch)
	scanner := bufio.NewScanner(r)
	for scanner.Scan() {
		if strings.HasPrefix(scanner.Text(), needle) {
			l := strings.Split(scanner.Text(), ";")
			if len(l) < 6 {
				return "", fmt.Errorf("can not find download path in %s", scanner.Text())
			}
			return l[5], nil
		}
	}

	if err := scanner.Err(); err != nil {
		return "", fmt.Errorf("error while reading the index-system data: %s", err)
	}

	return "", fmt.Errorf("needle %q not found", needle)
}
예제 #3
0
func (a *ReleaseTestSuite) TestReadLsb(c *C) {
	reset := release.HackLsbReleasePath(makeMockLsbRelease(c))
	defer reset()

	lsb, err := release.ReadLsb()
	c.Assert(err, IsNil)
	c.Assert(lsb.ID, Equals, "Ubuntu")
	c.Assert(lsb.Release, Equals, "18.09")
	c.Assert(lsb.Codename, Equals, "awsome")
}
예제 #4
0
func makeMockLxdIndexSystem() string {
	lsb, _ := release.ReadLsb()
	arch := arch.UbuntuArchitecture()

	s := fmt.Sprintf(`
ubuntu;xenial;otherarch;default;20151126_03:49;/images/ubuntu/xenial/armhf/default/20151126_03:49/
ubuntu;%s;%s;default;20151126_03:49;/images/ubuntu/CODENAME/ARCH/default/20151126_03:49/
`, lsb.Codename, arch)

	return s
}
예제 #5
0
func defaultPolicyVersion() string {
	// note that we can not use release.Get().Series here
	// because that will return "rolling" for the development
	// version but apparmor stores its templates under the
	// version number (e.g. 16.04) instead
	ver, err := release.ReadLsb()
	if err != nil {
		// when this happens we are in trouble
		panic(err)
	}
	return ver.Release
}