static void pk_backend_transaction_process_new_optdepends (PkBackend *self, alpm_pkg_t *pkg, alpm_pkg_t *old) { alpm_list_t *optdepends; const alpm_list_t *i; g_return_if_fail (self != NULL); g_return_if_fail (pkg != NULL); g_return_if_fail (old != NULL); optdepends = alpm_list_diff (alpm_pkg_get_optdepends (pkg), alpm_pkg_get_optdepends (old), alpm_depend_compare); if (optdepends == NULL) { return; } pk_backend_output (self, "New 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); } alpm_list_free (optdepends); }
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); }
/** Turn a optdepends list into a text list. * @param optdeps a list with items of type alpm_depend_t */ static void optdeplist_display(alpm_pkg_t *pkg, unsigned short cols) { alpm_list_t *i, *text = NULL; for(i = alpm_pkg_get_optdepends(pkg); i; i = alpm_list_next(i)) { alpm_depend_t *optdep = i->data; char *depstring = alpm_dep_compute_string(optdep); if(alpm_pkg_get_origin(pkg) == ALPM_PKG_FROM_LOCALDB) { if(alpm_db_get_pkg(alpm_get_localdb(config->handle), optdep->name)) { const char *installed = _(" [installed]"); depstring = realloc(depstring, strlen(depstring) + strlen(installed) + 1); strcpy(depstring + strlen(depstring), installed); } } text = alpm_list_add(text, depstring); } list_display_linebreak(_("Optional Deps :"), text, cols); FREELIST(text); }
/** * @brief Send a callback for any optdepend being removed. * * @param handle the context handle * @param lp list of packages to be removed */ static void remove_notify_needed_optdepends(alpm_handle_t *handle, alpm_list_t *lp) { alpm_list_t *i; for(i = _alpm_db_get_pkgcache(handle->db_local); i; i = alpm_list_next(i)) { alpm_pkg_t *pkg = i->data; alpm_list_t *optdeps = alpm_pkg_get_optdepends(pkg); if(optdeps && !alpm_pkg_find(lp, pkg->name)) { alpm_list_t *j; for(j = optdeps; j; j = alpm_list_next(j)) { alpm_depend_t *optdep = j->data; if(alpm_pkg_find(lp, optdep->name)) { EVENT(handle, ALPM_EVENT_OPTDEP_REQUIRED, pkg, optdep); } } } } }
static int check_opt_depends(alpm_pkg_t *p) { int ret = 0; alpm_list_t *i; for(i = alpm_pkg_get_optdepends(p); i; i = alpm_list_next(i)) { char *depstring = alpm_dep_compute_string(i->data); if(!alpm_find_satisfier(pkgcache, depstring)) { eprintf("%s: unsatisfied optional dependency '%s'\n", alpm_pkg_get_name(p), depstring); ret = 1; } free(depstring); } if(!quiet && !ret) { eprintf("%s: all optional dependencies satisfied\n", alpm_pkg_get_name(p)); } return ret; }
/** * @brief Send a callback for any optdepend being removed. * * @param handle the context handle * @param lp list of packages to be removed */ static void remove_notify_needed_optdepends(alpm_handle_t *handle, alpm_list_t *lp) { alpm_list_t *i; for(i = _alpm_db_get_pkgcache(handle->db_local); i; i = alpm_list_next(i)) { alpm_pkg_t *pkg = i->data; alpm_list_t *optdeps = alpm_pkg_get_optdepends(pkg); if(optdeps && !alpm_pkg_find(lp, pkg->name)) { alpm_list_t *j; for(j = optdeps; j; j = alpm_list_next(j)) { alpm_depend_t *optdep = j->data; if(alpm_pkg_find(lp, optdep->name)) { alpm_event_optdep_removal_t event = { .type = ALPM_EVENT_OPTDEP_REMOVAL, .pkg = pkg, .optdep = optdep }; EVENT(handle, &event); } } }
void add_deps(alpm_pkg_t *pkg) { alpm_list_t *i; for(i = alpm_pkg_get_depends(pkg); i; i = alpm_list_next(i)) { char *depstring = alpm_dep_compute_string(i->data); alpm_pkg_t *p = alpm_find_satisfier(pkgcache, depstring); if(p && !alpm_list_find_ptr(packages, p)) { packages = alpm_list_add(packages, p); add_deps(p); } free(depstring); } if(checks & CHECK_OPT_DEPENDS) { for(i = alpm_pkg_get_optdepends(pkg); i; i = alpm_list_next(i)) { char *depstring = alpm_dep_compute_string(i->data); alpm_pkg_t *p = alpm_find_satisfier(pkgcache, depstring); if(p && !alpm_list_find_ptr(packages, p)) { packages = alpm_list_add(packages, p); add_deps(p); } free(depstring); } } }
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; }
ret = strcmp(dep1->desc, dep2->desc); } else if(!dep1->desc && dep2->desc) { ret = -1; } else if(dep1->desc && !dep2->desc) { ret = 1; } } return ret; } void display_new_optdepends(alpm_pkg_t *oldpkg, alpm_pkg_t *newpkg) { alpm_list_t *i, *old, *new, *optdeps, *optstrings = NULL; old = alpm_pkg_get_optdepends(oldpkg); new = alpm_pkg_get_optdepends(newpkg); optdeps = alpm_list_diff(new, old, depend_cmp); /* turn optdepends list into a text list */ for(i = optdeps; i; i = alpm_list_next(i)) { alpm_depend_t *optdep = i->data; optstrings = alpm_list_add(optstrings, alpm_dep_compute_string(optdep)); } if(optstrings) { printf(_("New optional dependencies for %s\n"), alpm_pkg_get_name(newpkg)); unsigned short cols = getcols(fileno(stdout)); list_display_linebreak(" ", optstrings, cols); }
void pacman_pkgdump(pmpkg_t *pkg, enum pkgfrom_t from) { static const char *datefmt = "%a %d %b %Y %I:%M:%S %p %Z"; alpm_list_t *i, *results = NULL; pmdb_t *db; pmdepend_t *dep; pmpkgreason_t reason; int has_script; time_t inst_time; struct tm tm_st; char installdate[60]; char builddate[60]; db = alpm_pkg_get_db(pkg); if (!db) { return; } memset(&tm_st, 0, sizeof(struct tm)); inst_time = alpm_pkg_get_builddate(pkg); localtime_r(&inst_time, &tm_st); strftime(builddate, 60, datefmt, &tm_st); /* Local pkg specific */ if (from == PKG_FROM_LOCAL) { has_script = alpm_pkg_has_scriptlet(pkg); reason = alpm_pkg_get_reason(pkg); memset(&tm_st, 0, sizeof(struct tm)); inst_time = alpm_pkg_get_installdate(pkg); localtime_r(&inst_time, &tm_st); strftime(installdate, 60, datefmt, &tm_st); } if (from == PKG_FROM_SYNC) { printf("%s%s ", color.bold, REPO); const char *repo = alpm_db_get_name(db); if (!strcmp(repo, "core")) { printf("%s", color.bred); } else if (!strcmp(repo, "extra")) { printf("%s", color.bgreen); } else { printf("%s", color.bmag); } printf("%s%s\n", repo, color.nocolor); } printf("%s%s%s %s%s%s\n", color.bold, NAME, color.nocolor, color.bold, alpm_pkg_get_name(pkg), color.nocolor); printf("%s%s %s%s%s\n", color.bold, VERSION, color.bgreen, alpm_pkg_get_version(pkg), color.nocolor); printf("%s%s %s%s%s\n", color.bold, URL, color.bcyan, alpm_pkg_get_url(pkg), color.nocolor); print_list_prefix(alpm_pkg_get_licenses(pkg), LICENSES); print_list_prefix(alpm_pkg_get_groups(pkg), GROUPS); print_list_prefix(alpm_pkg_get_provides(pkg), PROVIDES); print_list_deps(alpm_pkg_get_depends(pkg), DEPS); print_list_break(alpm_pkg_get_optdepends(pkg), OPTDEPS); if (from == PKG_FROM_LOCAL) { results = alpm_pkg_compute_requiredby(pkg); print_list_prefix(results, REQBY); } print_list_prefix(alpm_pkg_get_conflicts(pkg), CONFLICTS); print_list_prefix(alpm_pkg_get_replaces(pkg), REPLACES); if (from == PKG_FROM_SYNC) { humanize_size(alpm_pkg_get_size(pkg), DLSZ); } humanize_size(alpm_pkg_get_isize(pkg), INSTSZ); printf("%s%s%s %s\n", color.bold, PKGER, color.nocolor, alpm_pkg_get_packager(pkg)); printf("%s%s%s %s\n", color.bold, ARCH, color.nocolor, alpm_pkg_get_arch(pkg)); printf("%s%s%s %s\n", color.bold, BDATE, color.nocolor, builddate); if (from == PKG_FROM_LOCAL) { printf("%s%s%s %s\n", color.bold, IDATE, color.nocolor, installdate); printf("%s%s%s ", color.bold, REASON, color.nocolor); switch (reason) { case PM_PKG_REASON_EXPLICIT: printf("Explicitly installed"); break; case PM_PKG_REASON_DEPEND: printf("Installed as a dependency for another package"); break; default: printf("Unknown"); break; } printf("\n"); printf("%s%s%s %s\n", color.bold, SCRIPT, color.nocolor, has_script ? "Yes" : "No"); } if (from == PKG_FROM_SYNC) { printf("%s%s%s %s\n", color.bold, MD5SUM, color.nocolor, alpm_pkg_get_md5sum(pkg)); } printf("%s%s%s %s\n", color.bold, DESC, color.nocolor, alpm_pkg_get_desc(pkg)); FREELIST(results); }