[Frugalware-darcs] setup-current: install: handle category order

VMiklos vmiklos at frugalware.org
Thu Mar 16 18:01:17 CET 2006


[install: handle category order
VMiklos <vmiklos at frugalware.org>**20051118163250] {
hunk ./src/plugins/install.c 43
-int installpkgs(GList *cats)
+GList *genfwcats(int cdnum)
hunk ./src/plugins/install.c 45
-	int i, ret;
+	GList *list=NULL;
+
+	if(cdnum==1)
+	{
+		list = g_list_append(list, "base");
+		list = g_list_append(list, "apps");
+		list = g_list_append(list, "lib");
+		list = g_list_append(list, "multimedia");
+		list = g_list_append(list, "network");
+		list = g_list_append(list, "devel");
+	}
+	else if(cdnum==2)
+	{
+		list = g_list_append(list, "x11");
+		list = g_list_append(list, "xlib");
+		list = g_list_append(list, "xapps");
+		list = g_list_append(list, "xfce4");
+		list = g_list_append(list, "gnome");
+		list = g_list_append(list, "kde");
+	}
+	return(list);
+}
+
+int installpkgs_forreal(GList *cats)
+{
+	int i;
hunk ./src/plugins/install.c 73
-	// TODO: handle cd changing and category order
+	// TODO: handle cd changing
hunk ./src/plugins/install.c 81
-			/* is this required?
-			msg(g_strdup_printf(_("Installing packages selected "
-				"from the %s section"), section)); */
-			if (system(g_strdup_printf("echo pacman -S -r ./ --noconfirm %s && sleep 3", ptr))
+			if (system(g_strdup_printf("echo %s: pacman -S -r ./ --noconfirm %s && sleep 3", section, ptr))
hunk ./src/plugins/install.c 100
+int cat_isin(GList *list, char *cat)
+{
+	int i;
+	for (i=0; i<g_list_length(list); i++)
+	{
+		if(!strcmp((char*)g_list_nth_data((GList*)g_list_nth_data(list, i), 0), cat))
+			return(i);
+	}
+}
+
+GList *mergecats(GList *allowed, GList *all)
+{
+	GList *final = NULL;
+	char *section;
+	int i, pos;
+
+	for (i=0; i<g_list_length(allowed); i++)
+	{
+		section = g_list_nth_data(allowed, i);
+		pos = cat_isin(all, section);
+		final = g_list_append(final, (GList*)g_list_nth_data(all, pos));
+	}
+	return(final);
+}
+
+int installpkgs(GList *cats, int extra)
+{
+	if(!extra)
+	{
+		installpkgs_forreal(mergecats(genfwcats(1), cats));
+		installpkgs_forreal(mergecats(genfwcats(2), cats));
+	}
+	else
+		installpkgs_forreal(cats);
+	return(0);
+}
+
hunk ./src/plugins/install.c 139
-	installpkgs((GList*)data_get(*config, "packages"));
-	installpkgs((GList*)data_get(*config, "expackages"));
+	installpkgs((GList*)data_get(*config, "packages"), 0);
+	installpkgs((GList*)data_get(*config, "expackages"), 1);
}


More information about the Frugalware-darcs mailing list