Exemple #1
0
//Pack all package binary assets into tarballs in an ar archive
func build(dir, manifestPath string) (string, error) {
	tmpDir, err := ioutil.TempDir("", "click")
	if err != nil {
		utils.ExitError(err)
	}
	defer os.RemoveAll(tmpDir)

	os.Chmod(tmpDir, 0755)

	dataDir := filepath.Join(tmpDir, "data")

	utils.Copytree(dir, dataDir, ignorePatternsBuild)

	fullManifestpath := filepath.Join(dataDir, "manifest.json")

	manifest := utils.ReadManifest(fullManifestpath)
	manifest["installed-size"] = utils.GetDirSize(dataDir)

	//Do not ship manifest in the data dir, it gets written in the control dir
	os.Remove(fullManifestpath)

	// Make control dir
	controlDir := filepath.Join(tmpDir, "DEBIAN")
	os.Mkdir(controlDir, 0777)

	//Create control file
	controlPath := filepath.Join(controlDir, "control")
	writeControl(controlPath, manifest)

	//Create manifest file
	realManifestPath := filepath.Join(controlDir, "manifest")
	utils.WriteManifest(realManifestPath, manifest)

	//Create preinst file
	preinstPath := filepath.Join(controlDir, "preinst")
	ioutil.WriteFile(preinstPath, []byte(utils.StaticPreinst), 0664)

	//Create md5sums file
	md5sumsPath := filepath.Join(controlDir, "md5sums")
	writeMD5Sums(md5sumsPath, dataDir)

	packageName := fmt.Sprintf("%s_%s_%s.click", manifest["name"].(string), utils.EpochlessVersion(manifest["version"].(string)), manifest["architecture"].(string))

	//Pack them all in an ar file
	packagePath := filepath.Join(dir, packageName)
	pack(tmpDir, controlDir, dataDir, packagePath)
	return packagePath, nil
}
Exemple #2
0
func buildSource(dir, manifestPath string) (string, error) {
	tmpdir, err := ioutil.TempDir("", "click")
	if err != nil {
		utils.ExitError(err)
	}
	defer os.RemoveAll(tmpdir)

	os.Chmod(tmpdir, 0755)

	rootPath := filepath.Join(tmpdir, "source")

	utils.Copytree(dir, rootPath, ignorePatternsBuildsource)

	realManifestPath := filepath.Join(rootPath, "manifest.json")
	manifest := utils.ReadManifest(realManifestPath)

	packageName := fmt.Sprintf("%s_%s.tar.gz", manifest["name"].(string), utils.EpochlessVersion(manifest["version"].(string)))
	packagePath := filepath.Join(dir, packageName)
	utils.CreateFakerootTarball(rootPath, packagePath, nil)

	return packagePath, nil
}