func pack(tmpDir, controlDir, dataDir, packagePath string) { dataTarPath := filepath.Join(tmpDir, "data.tar.gz") utils.CreateFakerootTarball(dataDir, dataTarPath, nil) controlTarPath := filepath.Join(tmpDir, "control.tar.gz") utils.CreateTarball(controlDir, controlTarPath, nil) arw, _ := utils.NewArWriter(packagePath) arw.AddMagic() arw.AddData("debian-binary", []byte("2.0\n")) arw.AddData("_click-binary", []byte(utils.SpecVersion+"\n")) arw.AddFile("control.tar.gz", controlTarPath) arw.AddFile("data.tar.gz", dataTarPath) arw.Close() }
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 }