static int do_show_primary(const symboldb_options &opt, database &db, const char *base) { repomd rp; rp.acquire(opt.download(), db, base); repomd::primary_xml primary(rp, opt.download_always_cache(), db); fd_sink out(STDOUT_FILENO); copy_source_to_sink(primary, out); return 0; }
static int do_download(const symboldb_options &opt, database &db, const char *url) { fd_sink out(1); copy_source_to_sink(*download(opt.download(), db, url), out); return 0; }
void expire(const symboldb_options &opt, database &db) { if (opt.output != symboldb_options::quiet) { fprintf(stderr, "info: expiring URL cache\n"); } db.expire_url_cache(); if (opt.output != symboldb_options::quiet) { fprintf(stderr, "info: expiring unreferenced packages\n"); } db.expire_packages(); if (opt.output != symboldb_options::quiet) { fprintf(stderr, "info: expiring file contents\n"); } db.expire_file_contents(); if (opt.output != symboldb_options::quiet) { fprintf(stderr, "info: expiring java classes\n"); } db.expire_java_classes(); if (opt.output != symboldb_options::quiet) { fprintf(stderr, "info: expiring unused RPMs\n"); } { typedef std::vector<std::vector<unsigned char> > digvec; std::tr1::shared_ptr<file_cache> fcache(opt.rpm_cache()); digvec fcdigests; fcache->digests(fcdigests); std::sort(fcdigests.begin(), fcdigests.end()); digvec dbdigests; db.referenced_package_digests(dbdigests); digvec result; std::set_difference(fcdigests.begin(), fcdigests.end(), dbdigests.begin(), dbdigests.end(), std::back_inserter(result)); fd_handle dir; dir.open_directory(opt.rpm_cache_path().c_str()); for (digvec::iterator p = result.begin(), end = result.end(); p != end; ++p) { dir.unlinkat(base16_encode(p->begin(), p->end()).c_str(), 0); } } }
static int do_show_repomd(const symboldb_options &opt, database &db, const char *base) { repomd rp; rp.acquire(opt.download(), db, base); printf("revision: %s\n", rp.revision.c_str()); for (std::vector<repomd::entry>::iterator p = rp.entries.begin(), end = rp.entries.end(); p != end; ++p) { std::string entry_url(url_combine_yum(rp.base_url.c_str(), p->href.c_str())); printf("entry: %s %s\n", p->type.c_str(), entry_url.c_str()); } return 0; }
static int do_show_stale_cached_rpms(const symboldb_options &opt, database &db) { typedef std::vector<std::vector<unsigned char> > digvec; std::tr1::shared_ptr<file_cache> fcache(opt.rpm_cache()); digvec fcdigests; fcache->digests(fcdigests); std::sort(fcdigests.begin(), fcdigests.end()); digvec dbdigests; db.referenced_package_digests(dbdigests); digvec result; std::set_difference(fcdigests.begin(), fcdigests.end(), dbdigests.begin(), dbdigests.end(), std::back_inserter(result)); for (digvec::iterator p = result.begin(), end = result.end(); p != end; ++p) { printf("%s\n", base16_encode(p->begin(), p->end()).c_str()); } return 0; }
bool get_file(const symboldb_options &opt, database &db, const std::vector<unsigned char> &digest, sink &target) { database::files_with_digest fwd(db, digest); std::shared_ptr<file_cache> fcache(opt.rpm_cache()); checksum csum; csum.length = checksum::no_length; std::string rpm_path; rpm_file_entry rfe; while (fwd.next()) { csum.value = fwd.rpm_digest(); switch (csum.value.size()) { case 32: csum.type = hash_algorithm::sha256; break; case 20: csum.type = hash_algorithm::sha1; break; default: continue; } if (fcache->lookup_path(csum, rpm_path)) { rpm_parser rp(rpm_path.c_str()); while (rp.read_file(rfe)) { typedef std::vector<rpm_file_info>::const_iterator iterator; const iterator end = rfe.infos.end(); for (iterator p = rfe.infos.begin(); p != end; ++p) { if (p->name == fwd.file_name()) { target.write(rfe.contents); return true; } } } } } return false; }