示例#1
0
/** Check for new version of pkg in sync repos
 * (only the first occurrence is considered in sync)
 */
alpm_pkg_t SYMEXPORT *alpm_sync_newversion(alpm_pkg_t *pkg, alpm_list_t *dbs_sync)
{
	alpm_list_t *i;
	alpm_pkg_t *spkg = NULL;

	ASSERT(pkg != NULL, return NULL);
	pkg->handle->pm_errno = 0;

	for(i = dbs_sync; !spkg && i; i = i->next) {
		spkg = _alpm_db_get_pkgfromcache(i->data, alpm_pkg_get_name(pkg));
	}

	if(spkg == NULL) {
		_alpm_log(pkg->handle, ALPM_LOG_DEBUG, "'%s' not found in sync db => no upgrade\n",
				alpm_pkg_get_name(pkg));
		return NULL;
	}

	/* compare versions and see if spkg is an upgrade */
	if(_alpm_pkg_compare_versions(spkg, pkg) > 0) {
		_alpm_log(pkg->handle, ALPM_LOG_DEBUG, "new version of '%s' found (%s => %s)\n",
					alpm_pkg_get_name(pkg), alpm_pkg_get_version(pkg),
					alpm_pkg_get_version(spkg));
		return spkg;
	}
	/* spkg is not an upgrade */
	return NULL;
}
示例#2
0
static gboolean
pk_alpm_pkg_is_local (PkBackendJob *job, alpm_pkg_t *pkg)
{
	PkBackend *backend = pk_backend_job_get_backend (job);
	PkBackendAlpmPrivate *priv = pk_backend_get_user_data (backend);
	alpm_pkg_t *local;

	g_return_val_if_fail (pkg != NULL, FALSE);

	/* find an installed package with the same name */
	local = alpm_db_get_pkg (priv->localdb, alpm_pkg_get_name (pkg));
	if (local == NULL)
		return FALSE;

	/* make sure the installed version is the same */
	if (alpm_pkg_vercmp (alpm_pkg_get_version (local),
			     alpm_pkg_get_version (pkg)) != 0) {
		return FALSE;
	}

	/* make sure the installed arch is the same */
	if (g_strcmp0 (alpm_pkg_get_arch (local),
		       alpm_pkg_get_arch (pkg)) != 0) {
		return FALSE;
	}

	return TRUE;
}
示例#3
0
static pmpkg_t *
alpm_pkg_find_update (pmpkg_t *pkg, const alpm_list_t *dbs)
{
	const gchar *name;
	const alpm_list_t *i;

	g_return_val_if_fail (pkg != NULL, NULL);

	name = alpm_pkg_get_name (pkg);

	for (; dbs != NULL; dbs = dbs->next) {
		pmpkg_t *update = alpm_db_get_pkg (dbs->data, name);

		if (update != NULL) {
			if (alpm_pkg_vercmp (alpm_pkg_get_version (update),
					     alpm_pkg_get_version (pkg)) > 0) {
				return update;
			} else {
				return NULL;
			}
		}

		i = alpm_db_get_pkgcache (dbs->data);
		for (; i != NULL; i = i->next) {
			if (alpm_list_find_str (alpm_pkg_get_replaces (i->data),
						name) != NULL) {
				return i->data;
			}
		}
	}

	return NULL;
}
static void
pk_backend_transaction_upgrade_done (PkBackend *self, alpm_pkg_t *pkg,
				     alpm_pkg_t *old, gint direction)
{
	const gchar *name, *pre, *post;

	g_return_if_fail (self != NULL);
	g_return_if_fail (pkg != NULL);
	g_return_if_fail (old != NULL || direction == 0);
	g_return_if_fail (alpm != NULL);

	name = alpm_pkg_get_name (pkg);
	if (direction != 0) {
		pre = alpm_pkg_get_version (old);
	}
	post = alpm_pkg_get_version (pkg);

	if (direction > 0) {
		alpm_logaction (alpm, PK_LOG_PREFIX, "upgraded %s (%s -> %s)\n",
				name, pre, post);
	} else if (direction < 0) {
		alpm_logaction (alpm, PK_LOG_PREFIX,
				"downgraded %s (%s -> %s)\n", name, pre, post);
	} else {
		alpm_logaction (alpm, PK_LOG_PREFIX, "reinstalled %s (%s)\n",
				name, post);
	}
	pk_backend_pkg (self, pkg, PK_INFO_ENUM_FINISHED);

	if (direction != 0) {
		pk_backend_transaction_process_new_optdepends (self, pkg, old);
	}
	pk_backend_output_end (self);
}
示例#5
0
static gboolean
alpm_pkg_same_pkgver (pmpkg_t *a, pmpkg_t *b)
{
	const gchar *version_a, *version_b, *last_a, *last_b;
	gsize length_a, length_b;

	g_return_val_if_fail (a != NULL, (b == NULL));
	g_return_val_if_fail (b != NULL, FALSE);

	version_a = alpm_pkg_get_version (a);
	version_b = alpm_pkg_get_version (b);

	last_a = strrchr (version_a, '-');
	last_b = strrchr (version_b, '-');

	if (last_a != NULL) {
		length_a = last_a - version_a;
	} else {
		length_a = strlen (version_a);
	}

	if (last_b != NULL) {
		length_b = last_b - version_b;
	} else {
		length_b = strlen (version_b);
	}

	if (length_a != length_b) {
		return FALSE;
	} else {
		return strncmp (version_a, version_b, length_a) == 0;
	}
}
static gint
asb_package_alpm_compare (AsbPackage *pkg1, AsbPackage *pkg2)
{
	AsbPackageAlpm *pkg_alpm1 = ASB_PACKAGE_ALPM (pkg1);
	AsbPackageAlpmPrivate *priv1 = GET_PRIVATE (pkg_alpm1);

	AsbPackageAlpm *pkg_alpm2 = ASB_PACKAGE_ALPM (pkg2);
	AsbPackageAlpmPrivate *priv2 = GET_PRIVATE (pkg_alpm2);

	const gchar *pkg1_version = alpm_pkg_get_version (priv1->package);
	const gchar *pkg2_version = alpm_pkg_get_version (priv2->package);
	
	return alpm_pkg_vercmp (pkg1_version, pkg2_version);
}
示例#7
0
文件: util.c 项目: sandsmark/pacman
/* returns package info as list of strings */
static alpm_list_t *create_verbose_row(pm_target_t *target)
{
	char *str;
	off_t size = 0;
	double human_size;
	const char *label;
	alpm_list_t *ret = NULL;

	/* a row consists of the package name, */
	if(target->install) {
		const alpm_db_t *db = alpm_pkg_get_db(target->install);
		if(db) {
			pm_asprintf(&str, "%s/%s", alpm_db_get_name(db), alpm_pkg_get_name(target->install));
		} else {
			pm_asprintf(&str, "%s", alpm_pkg_get_name(target->install));
		}
	} else {
		pm_asprintf(&str, "%s", alpm_pkg_get_name(target->remove));
	}
	ret = alpm_list_add(ret, str);

	/* old and new versions */
	pm_asprintf(&str, "%s",
			target->remove != NULL ? alpm_pkg_get_version(target->remove) : "");
	ret = alpm_list_add(ret, str);

	pm_asprintf(&str, "%s",
			target->install != NULL ? alpm_pkg_get_version(target->install) : "");
	ret = alpm_list_add(ret, str);

	/* and size */
	size -= target->remove ? alpm_pkg_get_isize(target->remove) : 0;
	size += target->install ? alpm_pkg_get_isize(target->install) : 0;
	human_size = humanize_size(size, 'M', 2, &label);
	pm_asprintf(&str, "%.2f %s", human_size, label);
	ret = alpm_list_add(ret, str);

	size = target->install ? alpm_pkg_download_size(target->install) : 0;
	if(size != 0) {
		human_size = humanize_size(size, 'M', 2, &label);
		pm_asprintf(&str, "%.2f %s", human_size, label);
	} else {
		str = NULL;
	}
	ret = alpm_list_add(ret, str);

	return ret;
}
示例#8
0
文件: query.c 项目: moben/pacman
static int display(alpm_pkg_t *pkg)
{
	int ret = 0;

	if(config->op_q_info) {
		if(config->op_q_isfile) {
			dump_pkg_full(pkg, 0);
		} else {
			dump_pkg_full(pkg, config->op_q_info > 1);
		}
	}
	if(config->op_q_list) {
		dump_pkg_files(pkg, config->quiet);
	}
	if(config->op_q_changelog) {
		dump_pkg_changelog(pkg);
	}
	if(config->op_q_check) {
		ret = check(pkg);
	}
	if(!config->op_q_info && !config->op_q_list
			&& !config->op_q_changelog && !config->op_q_check) {
		if(!config->quiet) {
			printf("%s %s\n", alpm_pkg_get_name(pkg), alpm_pkg_get_version(pkg));
		} else {
			printf("%s\n", alpm_pkg_get_name(pkg));
		}
	}
	return ret;
}
static void
pk_backend_transaction_add_done (PkBackend *self, alpm_pkg_t *pkg)
{
	const gchar *name, *version;
	const alpm_list_t *i, *optdepends;

	g_return_if_fail (self != NULL);
	g_return_if_fail (pkg != NULL);
	g_return_if_fail (alpm != NULL);

	name = alpm_pkg_get_name (pkg);
	version = alpm_pkg_get_version (pkg);

	alpm_logaction (alpm, PK_LOG_PREFIX, "installed %s (%s)\n", name,
			version);
	pk_backend_pkg (self, pkg, PK_INFO_ENUM_FINISHED);

	optdepends = alpm_pkg_get_optdepends (pkg);
	if (optdepends != NULL) {
		pk_backend_output (self, "Optional dependencies:\n");

		for (i = optdepends; i != NULL; i = i->next) {
			gchar *depend = alpm_dep_compute_string (i->data);
			gchar *output = g_strdup_printf ("%s\n", depend);
			free (depend);

			pk_backend_output (self, output);
			g_free (output);
		}
	}
	pk_backend_output_end (self);
}
示例#10
0
void print_installed(alpm_db_t *db_local, alpm_pkg_t *pkg)
{
    const char *pkgname = alpm_pkg_get_name(pkg);
    const char *pkgver = alpm_pkg_get_version(pkg);
    alpm_pkg_t *lpkg = alpm_db_get_pkg(db_local, pkgname);
    if(lpkg) {
        const char *lpkgver = alpm_pkg_get_version(lpkg);
        const colstr_t *colstr = &config->colstr;
        if(strcmp(lpkgver, pkgver) == 0) {
            printf(" %s[%s]%s", colstr->meta, _("installed"), colstr->nocolor);
        } else {
            printf(" %s[%s: %s]%s", colstr->meta, _("installed"),
                   lpkgver, colstr->nocolor);
        }
    }
}
示例#11
0
文件: query.c 项目: Berticus/powaur
/* -Qs, only 1 target for now */
static int query_search(alpm_db_t *localdb, const char *pkgname)
{
    int ret, found;
    const char *repo;
    alpm_list_t *i, *k, *dbcache, *groups;
    alpm_list_t *syncdbs;
    alpm_pkg_t *pkg;

    dbcache = alpm_db_get_pkgcache(localdb);
    syncdbs = alpm_option_get_syncdbs(config->handle);

    for (k = dbcache; k; k = k->next) {
        pkg = k->data;
        groups = NULL;

        if (!strcmp(pkgname, alpm_pkg_get_name(pkg))) {
            repo = which_db(syncdbs, pkgname, &groups);
            color_repo(repo);
            printf("%s%s %s%s", color.bold, pkgname,
                   color.bgreen, alpm_pkg_get_version(pkg));
            color_groups(groups);
            printf("%s %s\n", TAB, alpm_pkg_get_desc(pkg));
            found = 1;
        }
    }

    return found ? 0: -1;
}
示例#12
0
文件: package.c 项目: vadmium/pyalpm
static PyObject* pyalpm_pkg_str(PyObject *rawself) {
  AlpmPackage *self = (AlpmPackage *)rawself;
  return PyUnicode_FromFormat("alpm.Package(\"%s-%s-%s\")",
			      alpm_pkg_get_name(self->c_data),
			      alpm_pkg_get_version(self->c_data),
			      alpm_pkg_get_arch(self->c_data));
}
示例#13
0
文件: query.c 项目: moben/pacman
/* search the local database for a matching package */
static int query_search(alpm_list_t *targets)
{
	alpm_list_t *i, *searchlist;
	int freelist;
	alpm_db_t *db_local = alpm_option_get_localdb(config->handle);

	/* if we have a targets list, search for packages matching it */
	if(targets) {
		searchlist = alpm_db_search(db_local, targets);
		freelist = 1;
	} else {
		searchlist = alpm_db_get_pkgcache(db_local);
		freelist = 0;
	}
	if(searchlist == NULL) {
		return 1;
	}

	for(i = searchlist; i; i = alpm_list_next(i)) {
		alpm_list_t *grp;
		alpm_pkg_t *pkg = alpm_list_getdata(i);

		if(!config->quiet) {
			printf("local/%s %s", alpm_pkg_get_name(pkg), alpm_pkg_get_version(pkg));
		} else {
			printf("%s", alpm_pkg_get_name(pkg));
		}


		if(!config->quiet) {
			if((grp = alpm_pkg_get_groups(pkg)) != NULL) {
				alpm_list_t *k;
				printf(" (");
				for(k = grp; k; k = alpm_list_next(k)) {
					const char *group = alpm_list_getdata(k);
					printf("%s", group);
					if(alpm_list_next(k)) {
						/* only print a spacer if there are more groups */
						printf(" ");
					}
				}
				printf(")");
			}

			/* we need a newline and initial indent first */
			printf("\n    ");
			indentprint(alpm_pkg_get_desc(pkg), 4);
		}
		printf("\n");
	}

	/* we only want to free if the list was a search list */
	if(freelist) {
		alpm_list_free(searchlist);
	}
	return 0;
}
示例#14
0
static char *get_db_path(alpm_pkg_t *pkg, const char *path)
{
	static char dbpath[PATH_MAX];
	ssize_t len = snprintf(dbpath, PATH_MAX, "%slocal/%s-%s/%s",
				alpm_option_get_dbpath(handle),
				alpm_pkg_get_name(pkg), alpm_pkg_get_version(pkg), path);
	if(len < 0 || len >= PATH_MAX) { errno = ERANGE; return NULL; } /* TODO */
	return dbpath;
}
示例#15
0
文件: query.c 项目: moben/pacman
static void print_query_fileowner(const char *filename, alpm_pkg_t *info)
{
	if(!config->quiet) {
		printf(_("%s is owned by %s %s\n"), filename,
				alpm_pkg_get_name(info), alpm_pkg_get_version(info));
	} else {
		printf("%s\n", alpm_pkg_get_name(info));
	}
}
示例#16
0
/**
 * Open a package changelog for reading. Similar to fopen in functionality,
 * except that the returned 'file stream' is from the database.
 * @param pkg the package (from db) to read the changelog
 * @return a 'file stream' to the package changelog
 */
static void *_cache_changelog_open(pmpkg_t *pkg)
{
    char clfile[PATH_MAX];
    snprintf(clfile, PATH_MAX, "%s/%s/%s-%s/changelog",
             alpm_option_get_dbpath(pkg->handle),
             alpm_db_get_name(alpm_pkg_get_db(pkg)),
             alpm_pkg_get_name(pkg),
             alpm_pkg_get_version(pkg));
    return fopen(clfile, "r");
}
示例#17
0
static int files_fileowner(alpm_list_t *syncs, alpm_list_t *targets) {
	int ret = 0;
	alpm_list_t *t;

	for(t = targets; t; t = alpm_list_next(t)) {
		char *filename = NULL, *f;
		int found = 0;
		alpm_list_t *s;
		size_t len;

		if((filename = strdup(t->data)) == NULL) {
			goto notfound;
		}

		len = strlen(filename);
		f = filename;
		while(len > 1 && f[0] == '/') {
			f = f + 1;
			len--;
		}

		for(s = syncs; s; s = alpm_list_next(s)) {
			alpm_list_t *p;
			alpm_db_t *repo = s->data;
			alpm_list_t *packages = alpm_db_get_pkgcache(repo);

			for(p = packages; p; p = alpm_list_next(p)) {
				alpm_pkg_t *pkg = p->data;
				alpm_filelist_t *files = alpm_pkg_get_files(pkg);

				if(alpm_filelist_contains(files, f)) {

					if(!config->quiet) {
						printf(_("%s is owned by %s/%s %s\n"), f,
								alpm_db_get_name(repo), alpm_pkg_get_name(pkg),
								alpm_pkg_get_version(pkg));
					} else {
						printf("%s/%s\n", alpm_db_get_name(repo), alpm_pkg_get_name(pkg));
					}

					found = 1;
				}
			}
		}

		free(filename);

notfound:
		if(!found) {
			ret++;
		}
	}

	return 0;
}
示例#18
0
static struct pkginfo * get_pkginfo_from_pmpkg(alpm_pkg_t *pmpkg)
{
    struct pkginfo *ret;

    ret = (struct pkginfo *)malloc(sizeof(struct pkginfo));
    ret->name = strdup(alpm_pkg_get_name(pmpkg));
    ret->version = strdup(alpm_pkg_get_version(pmpkg));
    ret->filename = NULL;

    return ret;
}
示例#19
0
文件: files.c 项目: AWhetter/pacman
static void print_line_machinereadable(alpm_db_t *db, alpm_pkg_t *pkg, char *filename)
{
	/* Fields are repo, pkgname, pkgver, filename separated with \0 */
	fputs(alpm_db_get_name(db), stdout);
	fputc(0, stdout);
	fputs(alpm_pkg_get_name(pkg), stdout);
	fputc(0, stdout);
	fputs(alpm_pkg_get_version(pkg), stdout);
	fputc(0, stdout);
	fputs(filename, stdout);
	fputs("\n", stdout);
}
示例#20
0
文件: util.c 项目: sandsmark/pacman
void print_packages(const alpm_list_t *packages)
{
	const alpm_list_t *i;
	if(!config->print_format) {
		config->print_format = strdup("%l");
	}
	for(i = packages; i; i = alpm_list_next(i)) {
		alpm_pkg_t *pkg = i->data;
		char *string = strdup(config->print_format);
		char *temp = string;
		/* %n : pkgname */
		if(strstr(temp, "%n")) {
			string = strreplace(temp, "%n", alpm_pkg_get_name(pkg));
			free(temp);
			temp = string;
		}
		/* %v : pkgver */
		if(strstr(temp, "%v")) {
			string = strreplace(temp, "%v", alpm_pkg_get_version(pkg));
			free(temp);
			temp = string;
		}
		/* %l : location */
		if(strstr(temp, "%l")) {
			char *pkgloc = pkg_get_location(pkg);
			string = strreplace(temp, "%l", pkgloc);
			free(pkgloc);
			free(temp);
			temp = string;
		}
		/* %r : repo */
		if(strstr(temp, "%r")) {
			const char *repo = "local";
			alpm_db_t *db = alpm_pkg_get_db(pkg);
			if(db) {
				repo = alpm_db_get_name(db);
			}
			string = strreplace(temp, "%r", repo);
			free(temp);
			temp = string;
		}
		/* %s : size */
		if(strstr(temp, "%s")) {
			char *size;
			pm_asprintf(&size, "%jd", (intmax_t)pkg_get_size(pkg));
			string = strreplace(temp, "%s", size);
			free(size);
			free(temp);
		}
		printf("%s\n", string);
		free(string);
	}
}
示例#21
0
pu_mtree_reader_t *pu_mtree_reader_open_package( alpm_handle_t *h, alpm_pkg_t *p) {
  pu_mtree_reader_t *reader;
  struct archive *mtree;
  char path[PATH_MAX];
  struct archive_entry *entry = NULL;
  char *buf, rbuf[256];
  size_t len;
  FILE *fbuf;
  const char *dbpath = alpm_option_get_dbpath(h);
  const char *pkgname = alpm_pkg_get_name(p);
  const char *pkgver = alpm_pkg_get_version(p);

  if((fbuf = open_memstream(&buf, &len)) == NULL) { return NULL; }

  sprintf(path, "%slocal/%s-%s/mtree", dbpath, pkgname, pkgver);

  if((mtree = archive_read_new()) == NULL) { return NULL; }
  archive_read_support_filter_all(mtree);
  archive_read_support_format_raw(mtree);
  if(archive_read_open_filename(mtree, path, 64) != ARCHIVE_OK) {
    archive_read_free(mtree);
    return NULL;
  }

  if(archive_read_next_header(mtree, &entry) != ARCHIVE_OK) {
    archive_read_free(mtree);
    return NULL;
  }

  while(1) {
      ssize_t size;
      while((size = archive_read_data(mtree, rbuf, 256)) == ARCHIVE_RETRY);
      if(size < 0) { fclose(fbuf); free(buf); return NULL; }
      if(size == 0) { break; }
      fwrite(rbuf, size, 1, fbuf);
  }
  archive_read_free(mtree);
  fclose(fbuf);

  if((fbuf = fmemopen(buf, len, "r")) == NULL) {
    free(buf);
    return NULL;
  } else if((reader = pu_mtree_reader_open_stream(fbuf)) == NULL) {
    free(buf);
    fclose(fbuf);
    return NULL;
  } else {
    reader->_stream_buf = buf;
    reader->_close_stream = 1;
    return reader;
  }
}
示例#22
0
alpm_pkg_t *
pk_backend_find_pkg (PkBackend *self, const gchar *package_id, GError **error)
{
	gchar **package;
	const gchar *repo_id;
	alpm_db_t *db = NULL;
	alpm_pkg_t *pkg;

	g_return_val_if_fail (self != NULL, NULL);
	g_return_val_if_fail (package_id != NULL, NULL);
	g_return_val_if_fail (alpm != NULL, NULL);
	g_return_val_if_fail (localdb != NULL, NULL);

	package = pk_package_id_split (package_id);
	repo_id = package[PK_PACKAGE_ID_DATA];

	/* find the database to search in */
	if (g_strcmp0 (repo_id, "installed") == 0) {
		db = localdb;
	} else {
		const alpm_list_t *i = alpm_get_syncdbs (alpm);
		for (; i != NULL; i = i->next) {
			const gchar *repo = alpm_db_get_name (i->data);

			if (g_strcmp0 (repo, repo_id) == 0) {
				db = i->data;
				break;
			}
		}
	}

	if (db != NULL) {
		pkg = alpm_db_get_pkg (db, package[PK_PACKAGE_ID_NAME]);
	} else {
		pkg = NULL;
	}

	if (pkg != NULL) {
		const gchar *version = alpm_pkg_get_version (pkg);
		if (g_strcmp0 (version, package[PK_PACKAGE_ID_VERSION]) != 0) {
			pkg = NULL;
		}
	}

	if (pkg == NULL) {
		int code = ALPM_ERR_PKG_NOT_FOUND;
		g_set_error (error, ALPM_ERROR, code, "%s: %s", package_id,
			     alpm_strerror (code));
	}
	g_strfreev (package);
	return pkg;
}
示例#23
0
文件: files.c 项目: AWhetter/pacman
static int files_fileowner(alpm_list_t *syncs, alpm_list_t *targets) {
	int ret = 0;
	alpm_list_t *t;

	for(t = targets; t; t = alpm_list_next(t)) {
		char *filename = t->data;
		int found = 0;
		alpm_list_t *s;
		size_t len = strlen(filename);

		while(len > 1 && filename[0] == '/') {
			filename++;
			len--;
		}

		for(s = syncs; s; s = alpm_list_next(s)) {
			alpm_list_t *p;
			alpm_db_t *repo = s->data;
			alpm_list_t *packages = alpm_db_get_pkgcache(repo);

			for(p = packages; p; p = alpm_list_next(p)) {
				alpm_pkg_t *pkg = p->data;
				alpm_filelist_t *files = alpm_pkg_get_files(pkg);

				if(alpm_filelist_contains(files, filename)) {
					if(config->op_f_machinereadable) {
						print_line_machinereadable(repo, pkg, filename);
					} else if(!config->quiet) {
						const colstr_t *colstr = &config->colstr;
						printf(_("%s is owned by %s%s/%s%s %s%s\n"), filename,
								colstr->repo, alpm_db_get_name(repo), colstr->title,
								alpm_pkg_get_name(pkg), colstr->version,
								alpm_pkg_get_version(pkg));
					} else {
						printf("%s/%s\n", alpm_db_get_name(repo), alpm_pkg_get_name(pkg));
					}

					found = 1;
				}
			}
		}

		if(!found) {
			ret++;
		}
	}

	return 0;
}
static void
pk_backend_transaction_remove_done (PkBackend *self, alpm_pkg_t *pkg)
{
	const gchar *name, *version;

	g_return_if_fail (self != NULL);
	g_return_if_fail (pkg != NULL);
	g_return_if_fail (alpm != NULL);

	name = alpm_pkg_get_name (pkg);
	version = alpm_pkg_get_version (pkg);

	alpm_logaction (alpm, PK_LOG_PREFIX, "removed %s (%s)\n", name,
			version);
	pk_backend_pkg (self, pkg, PK_INFO_ENUM_FINISHED);
	pk_backend_output_end (self);
}
示例#25
0
文件: package.c 项目: tadzik/powaur
/* For plain -Q, -Qs, -Ss */
void print_pkg_pretty(alpm_list_t *sdbs, pmpkg_t *pkg, enum dumplvl_t lvl)
{
	alpm_list_t *grp = NULL;
	const char *repo;
	int found_db, grpcnt;

	repo = which_db(sdbs, alpm_pkg_get_name(pkg), &grp);
	color_repo(repo);
	printf("%s%s %s%s%s", color.bold, alpm_pkg_get_name(pkg),
		   color.bgreen, alpm_pkg_get_version(pkg), color.nocolor);

	color_groups(grp);

	if (lvl == DUMP_Q_SEARCH) {
		printf("%s%s\n", TAB, alpm_pkg_get_desc(pkg));
	} else if (lvl == DUMP_S_SEARCH) {
		printf("%s%s", TAB, alpm_pkg_get_desc(pkg));
	}
}
示例#26
0
文件: util.c 项目: sandsmark/pacman
static char *pkg_get_location(alpm_pkg_t *pkg)
{
	alpm_list_t *servers;
	char *string = NULL;
	switch(config->op) {
		case PM_OP_SYNC:
			servers = alpm_db_get_servers(alpm_pkg_get_db(pkg));
			if(servers) {
				pm_asprintf(&string, "%s/%s", servers->data,
						alpm_pkg_get_filename(pkg));
				return string;
			}
		case PM_OP_UPGRADE:
			return strdup(alpm_pkg_get_filename(pkg));
		default:
			pm_asprintf(&string, "%s-%s", alpm_pkg_get_name(pkg), alpm_pkg_get_version(pkg));
			return string;
	}
}
示例#27
0
static void
asb_package_alpm_ensure_version (AsbPackage *pkg, GError **error)
{
	AsbPackageAlpm *pkg_alpm = ASB_PACKAGE_ALPM (pkg);
	AsbPackageAlpmPrivate *priv = GET_PRIVATE (pkg_alpm);

	g_auto(GStrv) split = NULL;

	split = g_strsplit (alpm_pkg_get_version (priv->package), ":-", 3);

	/* epoch:version:release */
	if (g_strv_length (split) == 3) {
		asb_package_set_epoch (pkg, (guint) g_ascii_strtoull (split[0], NULL, 0));
		asb_package_set_version (pkg, split[1]);
		asb_package_set_release (pkg, split[2]);
	} else {/* version:release */
		asb_package_set_version (pkg, split[0]);
		asb_package_set_release (pkg, split[1]);
	}
}
示例#28
0
static alpm_list_t *check_arch(alpm_handle_t *handle, alpm_list_t *pkgs)
{
    alpm_list_t *i;
    alpm_list_t *invalid = NULL;

    const char *arch = alpm_option_get_arch(handle);
    if(!arch) {
        return NULL;
    }
    for(i = pkgs; i; i = i->next) {
        alpm_pkg_t *pkg = i->data;
        const char *pkgarch = alpm_pkg_get_arch(pkg);
        if(pkgarch && strcmp(pkgarch, arch) && strcmp(pkgarch, "any")) {
            char *string;
            const char *pkgname = alpm_pkg_get_name(pkg);
            const char *pkgver = alpm_pkg_get_version(pkg);
            size_t len = strlen(pkgname) + strlen(pkgver) + strlen(pkgarch) + 3;
            MALLOC(string, len, RET_ERR(handle, ALPM_ERR_MEMORY, invalid));
            sprintf(string, "%s-%s-%s", pkgname, pkgver, pkgarch);
            invalid = alpm_list_add(invalid, string);
        }
    }
    return invalid;
}
示例#29
0
gchar *
alpm_pkg_build_id (alpm_pkg_t *pkg)
{
	const gchar *name, *version, *arch, *repo;

	g_return_val_if_fail (pkg != NULL, NULL);

	name = alpm_pkg_get_name (pkg);
	version = alpm_pkg_get_version (pkg);

	arch = alpm_pkg_get_arch (pkg);
	if (arch == NULL) {
		arch = "any";
	}

	/* TODO: check correctness */
	if (alpm_pkg_get_origin (pkg) == ALPM_PKG_FROM_SYNCDB) {
		repo = alpm_db_get_name (alpm_pkg_get_db (pkg));
	} else {
		repo = "installed";
	}

	return pk_package_id_build (name, version, arch, repo);
}
示例#30
0
static int print_pkg(alpm_pkg_t *pkg, const char *format) {
  const char *f, *end;
  char fmt[64], buf[64];
  int len, out = 0;

  end = format + strlen(format);

  for (f = format; f < end; f++) {
    len = 0;
    if (*f == '%') {
      len = strspn(f + 1 + len, printf_flags);
      len += strspn(f + 1 + len, digits);
      snprintf(fmt, len + 3, "%ss", f);
      fmt[len + 1] = 's';
      f += len + 1;
      switch (*f) {
        /* simple attributes */
        case 'f': /* filename */
          out += printf(fmt, alpm_pkg_get_filename(pkg));
          break;
        case 'n': /* package name */
          out += printf(fmt, alpm_pkg_get_name(pkg));
          break;
        case 'v': /* version */
          out += printf(fmt, alpm_pkg_get_version(pkg));
          break;
        case 'd': /* description */
          out += printf(fmt, alpm_pkg_get_desc(pkg));
          break;
        case 'u': /* project url */
          out += printf(fmt, alpm_pkg_get_url(pkg));
          break;
        case 'p': /* packager name */
          out += printf(fmt, alpm_pkg_get_packager(pkg));
          break;
        case 's': /* md5sum */
          out += printf(fmt, alpm_pkg_get_md5sum(pkg));
          break;
        case 'a': /* architecutre */
          out += printf(fmt, alpm_pkg_get_arch(pkg));
          break;
        case 'i': /* has install scriptlet? */
          out += printf(fmt, alpm_pkg_has_scriptlet(pkg) ? "yes" : "no");
          break;
        case 'r': /* repo */
          out += printf(fmt, alpm_db_get_name(alpm_pkg_get_db(pkg)));
          break;
        case 'w': /* install reason */
          out += printf(fmt, alpm_pkg_get_reason(pkg) ? "dependency" : "explicit");
          break;
        case '!': /* result number */
          snprintf(buf, sizeof(buf), "%d", opt_pkgcounter++);
          out += printf(fmt, buf);
          break;
        case 'g': /* base64 gpg sig */
          out += printf(fmt, alpm_pkg_get_base64_sig(pkg));
          break;
        case 'h': /* sha256sum */
          out += printf(fmt, alpm_pkg_get_sha256sum(pkg));
          break;

        /* times */
        case 'b': /* build date */
          out += print_time(alpm_pkg_get_builddate(pkg));
          break;
        case 'l': /* install date */
          out += print_time(alpm_pkg_get_installdate(pkg));
          break;

        /* sizes */
        case 'k': /* download size */
          out += printf(fmt, size_to_string(alpm_pkg_get_size(pkg)));
          break;
        case 'm': /* install size */
          out += printf(fmt, size_to_string(alpm_pkg_get_isize(pkg)));
          break;

        /* lists */
        case 'F': /* files */
          out += print_filelist(alpm_pkg_get_files(pkg));
          break;
        case 'N': /* requiredby */
          out += print_list(alpm_pkg_compute_requiredby(pkg), NULL);
          break;
        case 'L': /* licenses */
          out += print_list(alpm_pkg_get_licenses(pkg), NULL);
          break;
        case 'G': /* groups */
          out += print_list(alpm_pkg_get_groups(pkg), NULL);
          break;
        case 'E': /* depends (shortdeps) */
          out += print_list(alpm_pkg_get_depends(pkg), (extractfn)alpm_dep_get_name);
          break;
        case 'D': /* depends */
          out += print_list(alpm_pkg_get_depends(pkg), (extractfn)alpm_dep_compute_string);
          break;
        case 'O': /* optdepends */
          out += print_list(alpm_pkg_get_optdepends(pkg), (extractfn)format_optdep);
          break;
        case 'o': /* optdepends (shortdeps) */
          out += print_list(alpm_pkg_get_optdepends(pkg), (extractfn)alpm_dep_get_name);
          break;
        case 'C': /* conflicts */
          out += print_list(alpm_pkg_get_conflicts(pkg), (extractfn)alpm_dep_get_name);
          break;
        case 'S': /* provides (shortdeps) */
          out += print_list(alpm_pkg_get_provides(pkg), (extractfn)alpm_dep_get_name);
          break;
        case 'P': /* provides */
          out += print_list(alpm_pkg_get_provides(pkg), (extractfn)alpm_dep_compute_string);
          break;
        case 'R': /* replaces */
          out += print_list(alpm_pkg_get_replaces(pkg), (extractfn)alpm_dep_get_name);
          break;
        case 'B': /* backup */
          out += print_list(alpm_pkg_get_backup(pkg), alpm_backup_get_name);
          break;
        case 'V': /* package validation */
          out += print_allocated_list(get_validation_method(pkg), NULL);
          break;
        case 'M': /* modified */
          out += print_allocated_list(get_modified_files(pkg), NULL);
          break;
        case '%':
          fputc('%', stdout);
          out++;
          break;
        default:
          fputc('?', stdout);
          out++;
          break;
      }
    } else if (*f == '\\') {
      char esc[3] = { f[0], f[1], '\0' };
      out += print_escaped(esc);
      ++f;
    } else {
      fputc(*f, stdout);
      out++;
    }
  }

  /* only print a delimeter if any package data was outputted */
  if (out > 0) {
    print_escaped(opt_delim);
  }

  return !out;
}