mirror of
https://git.launchpad.net/~ubuntu-qt-code/+git/calamares-settings-ubuntu
synced 2025-03-12 03:31:09 +00:00
40 lines
1.1 KiB
C++
40 lines
1.1 KiB
C++
#include <iostream>
|
|
#include <string>
|
|
#include <apt-pkg/algorithms.h>
|
|
#include <apt-pkg/cacheiterators.h>
|
|
#include <apt-pkg/init.h>
|
|
#include <apt-pkg/cachefile.h>
|
|
#include <apt-pkg/pkgcache.h>
|
|
#include <apt-pkg/pkgsystem.h>
|
|
#include <apt-pkg/progress.h>
|
|
|
|
int main(int argc, char* argv[]) {
|
|
pkgInitConfig(*_config);
|
|
pkgInitSystem(*_config, _system);
|
|
if (_system == 0) {
|
|
std::cerr << "apt-pkg not initialized\n";
|
|
return 1;
|
|
}
|
|
|
|
// Open the package cache.
|
|
pkgCacheFile *cache = new pkgCacheFile();
|
|
OpProgress progress;
|
|
if (!cache || cache->Open(&progress, false) == false) {
|
|
std::cerr << "Error: could not open APT cache.\n";
|
|
return 1;
|
|
}
|
|
pkgApplyStatus(*cache);
|
|
|
|
std::vector<std::string> package_names(argv + 1, argv + argc);
|
|
if (package_names.empty()) return 0;
|
|
|
|
for (std::string package_name : package_names) {
|
|
pkgCache::PkgIterator it = cache->GetPkgCache()->FindPkg(package_name);
|
|
if (!it.end()) std::cout << package_name << " ";
|
|
}
|
|
|
|
std::cout << "\n";
|
|
cache->Close();
|
|
return 0;
|
|
}
|