Beispiel #1
0
func listPackages() (list packages.AppletPackages, e error) {

	// List server only.
	if *listServer {
		return packages.ListDistant(logger, cdglobal.AppletsDirName+"/"+cdglobal.AppletsServerTag)
	}

	// Get applets dir.
	externalUserDir, e := packages.DirAppletsExternal(*listUserDir)
	if e != nil {
		return nil, e
	}

	// List local only.
	if *listLocal {
		return packages.ListFromDir(logger, externalUserDir, packages.TypeUser, packages.SourceApplet)
	}

	// List default (merged both).
	packs, e := packages.ListDownloadApplets(logger, externalUserDir)
	if e != nil {
		return nil, e
	}
	return packages.ListDownloadSort(packs), nil
}
Beispiel #2
0
func installOrRemoveApplets(list []string, remove bool) {

	// TODO: use active dock if available.

	externalUserDir, e := packages.DirAppletsExternal(*listUserDir)
	exitIfFail(e, "get config dir") // Ensure we have the config dir.

	var packs packages.AppletPackages
	var action func(appname string, pack *packages.AppletPackage) bool

	if remove {
		action = func(appname string, pack *packages.AppletPackage) bool {
			e := pack.Uninstall(externalUserDir)
			return testErr(e, "uninstall", "Applet removed", appname)
		}
		packs, e = packages.ListFromDir(logger, externalUserDir, packages.TypeUser, packages.SourceApplet)

	} else { // install.
		options := ""
		if *listVerbose {
			options = "v" // Tar command verbose option.
		}
		action = func(appname string, pack *packages.AppletPackage) bool {
			pack.SrvTag = cdglobal.AppletsDirName + "/" + cdglobal.AppletsServerTag
			e := pack.Install(externalUserDir, options)
			return testErr(e, "install", "Applet installed", appname)
		}
		packs, e = packages.ListDistant(logger, cdglobal.AppletsDirName+"/"+cdglobal.AppletsServerTag)
	}
	exitIfFail(e, "get applets list") // Ensure we have the server list.

	failed := false
	for _, appname := range list {
		pack := packs.Get(strings.Title(appname)) // Applets are using a CamelCase format. This will help lazy users
		if pack != nil {
			failed = failed || !action(appname, pack)
		}
	}
	if failed || len(list) == 0 {
		println("use list command to get the list of valid applets names")
	}
}
Beispiel #3
0
// ListThemeXML builds a list of icon theme in system and user dir.
//
func (sc SourceCommon) ListThemeXML(localSystem, localUser, distant string) map[string]Handbooker {
	// list, _ := packages.ListExternalUser(localSystem, "theme")
	// Themes installed in system dir.
	list, _ := packages.ListThemesDir(sc.Log, localSystem, packages.TypeLocal)

	// Themes installed in user dir.
	userDir, e := packages.DirThemeExtra(sc.ConfDir, localUser)
	if e == nil {
		users, _ := packages.ListThemesDir(sc.Log, userDir, packages.TypeUser)
		list = append(list, users...)
	}
	sc.Log.Debug("ListThemeXML found total ", len(list), userDir)

	// Rename theme title with the online list.
	// TODO: maybe need to use hint here.
	dist, _ := packages.ListDistant(sc.Log, distant)
	for k, v := range list {
		more := dist.Get(v.DirName)
		if more != nil && more.Title != "" {
			list[k].Title = more.Title
		}
	}

	// TODO: Distant theme management will have to be moved into the download area.
	// dist, _ := packages.ListDistant(distant)
	// for _, v := range dist {
	// 	log.DEV("", v)
	// }

	out := make(map[string]Handbooker)
	for _, v := range list {
		out[v.GetName()] = v
	}

	return out
}