Пример #1
0
func GenerateFullUpdate(version string, prod bool) error {
	var variant string
	if prod {
		variant = "production"
	} else {
		variant = "developer"
	}

	var (
		dir           = sdk.BuildImageDir(version)
		update_prefix = filepath.Join(dir, "coreos_"+variant+"_update")
		update_bin    = update_prefix + ".bin"
		update_gz     = update_prefix + ".gz"
		update_xml    = update_prefix + ".xml"
	)

	if err := checkUpdate(dir, update_xml); err == nil {
		plog.Infof("Using update manifest: %s", update_xml)
		return nil
	}

	plog.Noticef("Generating update payload: %s", update_gz)
	if err := run("delta_generator",
		"-new_image", update_bin,
		"-out_file", update_gz,
		"-private_key", privateKey); err != nil {
		return err
	}

	plog.Infof("Writing update manifest: %s", update_xml)
	update := omaha.Update{Id: sdk.GetDefaultAppId()}
	pkg, err := update.AddPackageFromPath(update_gz)

	// update engine needs the payload hash here in the action element
	postinstall := update.AddAction("postinstall")
	postinstall.Sha256 = pkg.Sha256

	update.Version, err = sdk.GetVersionFromDir(dir)
	if err != nil {
		return err
	}

	return xmlMarshalFile(update_xml, &update)
}
Пример #2
0
func (u *updateServer) CheckUpdate(req *omaha.Request, app *omaha.AppRequest) (*omaha.Update, error) {
	m := omaha.Manifest{}

	pkgpath := filepath.Join(u.updatePath, u.payload)
	pkg, err := m.AddPackageFromPath(pkgpath)
	if err != nil {
		plog.Errorf("Loading package %q failed: %v", pkgpath, err)
		return nil, omaha.UpdateInternalError
	}

	act := m.AddAction("postinstall")
	act.Sha256 = pkg.Sha256

	update := &omaha.Update{
		Id: sdk.GetDefaultAppId(),
		URL: omaha.URL{
			CodeBase: u.updatePath + "/",
		},
		Manifest: m,
	}

	return update, nil
}