Exemple #1
0
func (x *cmdBuild) Execute(args []string) (err error) {
	if len(args) == 0 {
		args = []string{"."}
	}

	snapPackage, err := snappy.BuildSquashfsSnap(args[0], x.Output)
	if err != nil {
		return err
	}

	_, err = exec.LookPath(clickReview)
	if err != nil {
		fmt.Fprintf(os.Stderr, "Warning: could not review package (%s not available)\n", clickReview)
	} else {
		cmd := exec.Command(clickReview, snapPackage)
		cmd.Stdout = os.Stdout
		cmd.Stderr = os.Stderr
		// we ignore the error for now
		_ = cmd.Run()
	}

	// TRANSLATORS: the %s is a pkgname
	fmt.Printf(i18n.G("Generated '%s' snap\n"), snapPackage)
	return nil
}
Exemple #2
0
// FIXME: extract into snappy/testutils
func (s *storeTestSuite) makeTestSnap(c *C, snapYamlContent string) string {
	tmpdir := c.MkDir()
	os.MkdirAll(filepath.Join(tmpdir, "meta"), 0755)

	snapYaml := filepath.Join(tmpdir, "meta", "snap.yaml")
	err := ioutil.WriteFile(snapYaml, []byte(snapYamlContent), 0644)
	c.Assert(err, IsNil)

	targetDir := s.store.blobDir
	snapFn, err := snappy.BuildSquashfsSnap(tmpdir, targetDir)
	c.Assert(err, IsNil)
	return snapFn
}
Exemple #3
0
func makeTestSnap(c *C, snapYamlContent string) (snapFilePath string) {
	tmpdir := c.MkDir()
	os.MkdirAll(filepath.Join(tmpdir, "meta"), 0755)
	snapYamlFn := filepath.Join(tmpdir, "meta", "snap.yaml")
	ioutil.WriteFile(snapYamlFn, []byte(snapYamlContent), 0644)
	err := osutil.ChDir(tmpdir, func() error {
		var err error
		snapFilePath, err = snappy.BuildSquashfsSnap(tmpdir, "")
		c.Assert(err, IsNil)
		return err
	})
	c.Assert(err, IsNil)
	return filepath.Join(tmpdir, snapFilePath)

}
Exemple #4
0
// FIXME: extract into snappy/testutils
func (s *storeTestSuite) makeTestSnap(c *C, packageYamlContent string) string {
	tmpdir := c.MkDir()
	os.MkdirAll(filepath.Join(tmpdir, "meta"), 0755)

	packageYaml := filepath.Join(tmpdir, "meta", "package.yaml")
	ioutil.WriteFile(packageYaml, []byte(packageYamlContent), 0644)
	readmeMd := filepath.Join(tmpdir, "meta", "readme.md")

	content := "Random\nExample"
	err := ioutil.WriteFile(readmeMd, []byte(content), 0644)
	c.Assert(err, IsNil)

	targetDir := s.store.blobDir
	snapFn, err := snappy.BuildSquashfsSnap(tmpdir, targetDir)
	c.Assert(err, IsNil)
	return snapFn
}