예제 #1
0
파일: postconf.c 프로젝트: Elentir/fwife
void checkdms(GtkListStore *store)
{
	PM_DB *db;
	GtkTreeIter iter;

	if(pacman_initialize(TARGETDIR)==-1)
		return;
	if(!(db = pacman_db_register("local")))
	{
		pacman_release();
		return;
	}

	gtk_list_store_append (store, &iter);
	gtk_list_store_set (store, &iter, 0, "XDM", 1, _("   X Window Display Manager"), -1);
	if(pacman_db_readpkg(db, "kdebase"))
	{
		gtk_list_store_append (store, &iter);
		gtk_list_store_set (store, &iter, 0, "KDM", 1, _("  KDE Display Manager"), -1);
	}
	if(pacman_db_readpkg(db, "gdm"))
	{
		gtk_list_store_append (store, &iter);
		gtk_list_store_set (store, &iter, 0, "GDM", 1, _("  Gnome Display Manager"), -1);
	}
	if(pacman_db_readpkg(db, "slim"))
	{
		gtk_list_store_append (store, &iter);
		gtk_list_store_set (store, &iter, 0, "Slim", 1, _("  Simple Login Manager"), -1);
	}
	pacman_db_unregister(db);
	pacman_release();
	return;
}
예제 #2
0
파일: gfpm-db.c 프로젝트: frugalware/gfpm
int
gfpm_db_init (void)
{
	if (NULL == (local_db=pacman_db_register(FW_LOCAL)))
		return 1;

	return 0;
}
예제 #3
0
파일: gfpm-db.c 프로젝트: frugalware/gfpm
void
gfpm_db_reset_localdb (void)
{
	if (local_db)
	{
		pacman_db_unregister (local_db);
		local_db = pacman_db_register (FW_LOCAL);
	}

	return;
}
예제 #4
0
파일: gfpm-db.c 프로젝트: frugalware/gfpm
void
gfpm_db_register (const char *dbname)
{
	if (sync_db != NULL)
	{
		pacman_db_unregister (sync_db);
		sync_db = NULL;
		g_free (repo);
	}
	if (strcmp(dbname,"local"))
		sync_db = pacman_db_register ((char*)dbname);
	asprintf (&repo, dbname);

	return;
}
예제 #5
0
파일: install.c 프로젝트: frugalware/fwife
int install_pkgs(GList *pkgs)
{
	int i = 0, questret;
	PM_LIST *pdata = NULL, *pkgsl;
	char *ptr, *file;

	/* nothing to install */
	if(pkgs == NULL)
		return 0;

	if(pacman_initialize(TARGETDIR) == -1) {
		LOG("Failed to initialize pacman library (%s)\n", pacman_strerror(pm_errno));
		return -1;
	}

	if (pacman_parse_config("/etc/pacman-g2.conf", NULL, "") == -1) {
			LOG("Failed to parse pacman-g2 configuration file (%s)", pacman_strerror(pm_errno));
			pacman_release();
			return(-1);
	}

	//* Set pacman options *//
#ifndef NDEBUG
	pacman_set_option(PM_OPT_LOGMASK, -1);
#else
	pacman_set_option(PM_OPT_LOGMASK, PM_LOG_ERROR | PM_LOG_WARNING);
#endif
	pacman_set_option(PM_OPT_LOGCB, (long)cb_log);
	pacman_set_option (PM_OPT_DLCB, (long)progress_update);
	pacman_set_option (PM_OPT_DLOFFSET, (long)&offset);
	pacman_set_option (PM_OPT_DLRATE, (long)&rate);
	pacman_set_option (PM_OPT_DLFNM, (long)reponame);
	pacman_set_option (PM_OPT_DLHOWMANY, (long)&howmany);
	pacman_set_option (PM_OPT_DLREMAIN, (long)&remains);
	pacman_set_option (PM_OPT_DLT0, (long)&t0);
	pacman_set_option (PM_OPT_DLT0, (long)&t);
	pacman_set_option (PM_OPT_DLXFERED1, (long)&xferred1);

	PM_DB *db_local = pacman_db_register("local");
	if(db_local == NULL) {
		LOG("Could not register 'local' database (%s)\n", pacman_strerror(pm_errno));
		pacman_release();
		return -1;
	}

retry:	if(pacman_trans_init(PM_TRANS_TYPE_SYNC, PM_TRANS_FLAG_FORCE|PM_TRANS_FLAG_NODEPS, progress_event, progress_conv, progress_install) == -1) {
		if (pm_errno == PM_ERR_HANDLE_LOCK) {
			file = g_strdup_printf("%s/tmp/pacman-g2.lck", TARGETDIR);
			g_remove (file);
			free(file);
			goto retry;
		}
		LOG("Failed to initialize transaction %s\n", pacman_strerror (pm_errno));
		pacman_release();
		return -1;
	}

	for (i = 0; i<g_list_length(pkgs); i++) {
		ptr = strdup((char*)g_list_nth_data(pkgs, i));
		if(pacman_trans_addtarget(strdup(drop_version(ptr))) == -1)
			LOG("Error adding packet %s", pacman_strerror (pm_errno));
		free(ptr);
	}

	//* prepare transaction *//
	if(pacman_trans_prepare(&pdata) == -1) {
		LOG("Failed to prepare transaction (%s)", pacman_strerror (pm_errno));
		pacman_list_free(pdata);
		pacman_trans_release();
		pacman_release();
		return -1;
	}

	pkgsl = pacman_trans_getinfo (PM_TRANS_PACKAGES);
	if (pkgsl == NULL) {
		LOG("Error getting transaction info %s\n", pacman_strerror (pm_errno));
		pacman_trans_release();
		pacman_release();
		return -1;
	}

	/* commit transaction */
	if (pacman_trans_commit(&pdata) == -1) {
		switch(pm_errno) {
			case PM_ERR_DISK_FULL:
				fwife_error(_("Disk full, cannot install more packages"));
				break;
			case PM_ERR_PKG_CORRUPTED:
				questret = fwife_question(_("Some packages seems corrupted, do you want to download them again?"));
				if(questret == GTK_RESPONSE_YES) {
					pacman_list_free(pdata);
					pacman_trans_release();
					goto retry;
				}
				break;
			case PM_ERR_RETRIEVE:
				fwife_error(_("Failed to retrieve packages"));
				break;
			default:
				break;
		}

		LOG("Failed to commit transaction (%s)\n", pacman_strerror (pm_errno));
		pacman_list_free(pdata);
		pacman_trans_release();
		pacman_release();
		return -1;
	}

	/* release the transaction */
	pacman_trans_release();
	pacman_release();

	return 0;
}