[Frugalware-darcs] setup-current: select: new function: pkgdir()

VMiklos vmiklos at frugalware.org
Thu Mar 16 18:07:38 CET 2006


[select: new function: pkgdir()
VMiklos <vmiklos at frugalware.org>**20051114002916] {
hunk ./src/plugins/select.c 26
+#include <dirent.h>
+#include <sys/types.h>
+#include <sys/stat.h>
hunk ./src/plugins/select.c 52
-	chdir(TARGETDIR);
hunk ./src/plugins/select.c 78
-int run(GList **config)
+char* pkgdir(char *pkg, char *repo)
hunk ./src/plugins/select.c 80
-	dialog_msgbox("base", categorysize("base"), 0, 0, 1);
+	DIR *dir;
+	struct dirent *ent;
+	struct stat sbuf;
+	char *targetdir, *dirname, *name, *ptr;
+	int gotit=0;
+
+	targetdir = g_strdup_printf("var/lib/pacman/%s", repo);
hunk ./src/plugins/select.c 88
+	dir = opendir(targetdir);
+	if (!dir)
+	{
+		perror(targetdir);
+		return(NULL);
+	}
+
+	while(!gotit && ((ent = readdir(dir)) != NULL))
+	{
+		if(!strcmp(ent->d_name, ".") || !strcmp(ent->d_name, ".."))
+			continue;
+		name = strdup(ent->d_name);
+		dirname = strdup(ent->d_name);
+		if((ptr = rindex(name, '-')))
+			*ptr = '\0';
+		if((ptr = rindex(name, '-')))
+			*ptr = '\0';
+		if(!strcmp(name, pkg))
+			gotit=1;
+		//FREE(name);
+	}
+	closedir(dir);
+	//FREE(targetdir);
+	if(gotit)
+	{
+		ptr = g_strdup_printf("var/lib/pacman/%s/%s", repo, dirname);
+		//FREE(dirname);
+		return(ptr);
+	}
+	else
+		return(NULL);
+}
+
+int run(GList **config)
+{
+	chdir(TARGETDIR);
+	dialog_msgbox("bash", pkgdir("bash", "frugalware-current"), 0, 0, 1);
}


More information about the Frugalware-darcs mailing list