コード例 #1
0
static gboolean
pk_backend_update_databases (PkBackend *self, gint force, GError **error) {
	alpm_cb_download dlcb;
	alpm_cb_totaldl totaldlcb;
	const alpm_list_t *i;

	g_return_val_if_fail (self != NULL, FALSE);

	if (!pk_backend_transaction_initialize (self, 0, error)) {
		return FALSE;
	}

	alpm_logaction ("synchronizing package lists\n");

	dlcb = alpm_option_get_dlcb ();
	totaldlcb = alpm_option_get_totaldlcb ();

	/* set total size to minus the number of databases */
	i = alpm_option_get_syncdbs ();
	totaldlcb (-alpm_list_count (i));

	for (; i != NULL; i = i->next) {
		gint result;

		if (pk_backend_cancelled (self)) {
			/* pretend to be finished */
			i = NULL;
			break;
		}

		result = alpm_db_update (force, i->data);

		if (result > 0) {
			/* fake the download when already up to date */
			dlcb ("", 1, 1);
		} else if (result < 0) {
			g_set_error (error, ALPM_ERROR, pm_errno, "[%s]: %s",
				     alpm_db_get_name (i->data),
				     alpm_strerrorlast ());
			break;
		}
	}

	totaldlcb (0);

	if (i == NULL) {
		return pk_backend_transaction_end (self, error);
	} else {
		pk_backend_transaction_end (self, NULL);
		return FALSE;
	}
}
コード例 #2
0
ファイル: database.c プロジェクト: Quintus/ruby-alpm
/**
 * call-seq:
 *   update( [ force ] )
 *
 * Synchronise the database with the remote server(s).
 *
 * === Parameters
 * [force (false)]
 *   (undocumented by libalpm)
 */
static VALUE update(int argc, VALUE argv[], VALUE self)
{
  alpm_db_t* p_db = NULL;
  VALUE force;

  Data_Get_Struct(self, alpm_db_t, p_db);
  rb_scan_args(argc, argv, "01", &force);

  if (alpm_db_update(RTEST(force), p_db) < 0) {
    raise_last_alpm_error(get_alpm_from_db(self));
    return Qnil;
  }

  return Qnil;
}
コード例 #3
0
ファイル: ipacman.c プロジェクト: sonald/isoft-os-installer
int ipacman_refresh_databases(void)
{
	alpm_list_t *sync_dbs = NULL;
	alpm_list_t *i;
	unsigned int success = 0;

	sync_dbs = alpm_get_syncdbs(handle);
	if(sync_dbs == NULL) {
		printf("no usable package repositories configured.\n");
		return -1;
	}

	printf("Synchronizing package databases...\n");
	alpm_logaction(handle, PACMAN_CALLER_PREFIX, "synchronizing package lists\n");

	for(i = sync_dbs; i; i = alpm_list_next(i)) {
		alpm_db_t *db = i->data;

		int ret = alpm_db_update(1, db);
		if(ret < 0) {
			printf("failed to update %s (%s)\n",
					alpm_db_get_name(db), alpm_strerror(alpm_errno(handle)));
		} else if(ret == 1) {
			printf(" %s is up to date\n", alpm_db_get_name(db));
			success++;
		} else {
			success++;
		}
	}

	/* We should always succeed if at least one DB was upgraded - we may possibly
	 * fail later with unresolved deps, but that should be rare, and would be
	 * expected
	 */
	if(!success) {
		printf("failed to synchronize any databases\n");
		trans_init_error(handle);
		return success;
	}
	return 0;
}
コード例 #4
0
ファイル: database.c プロジェクト: juster/ruby-alpm
VALUE
db_update ( VALUE self, VALUE force )
{
    INITDBPTR;
    NEGISERR( alpm_db_update( !!force, db ));
}