Browse Source

Manager: Implement convenience functions in Package

master
Riyyi 3 years ago
parent
commit
2af81120c3
  1. 15
      src/package.cpp

15
src/package.cpp

@ -41,19 +41,20 @@ void Package::list(const std::vector<std::string>& targets)
Util::System $; Util::System $;
if (m_distro == Distro::Arch) { if (m_distro == Distro::Arch) {
auto basePackages = $("pactree -u base") | $("tail -n +2"); auto basePackages = $("pactree -u base").tail(2, true);
auto develPackages = $("pacman -Qqg base-devel"); auto develPackages = $("pacman -Qqg base-devel");
auto filterList = basePackages + develPackages | $("sort -u"); auto filterList = (basePackages + develPackages).sort(true);
auto packageList = $("pacman -Qqe") | $("grep -vx " + filterList.output()) | $("sort"); auto packageList = ($("pacman -Qqe") | $("grep -xv " + filterList.output())).sort();
packages = packageList.output(); packages = packageList.output();
} }
else if (m_distro == Distro::Debian) { else if (m_distro == Distro::Debian) {
auto installedList = $("dpkg-query --show --showformat=${Package}\\t${Priority}\\n"); auto installedList = $("dpkg-query --show --showformat=${Package}\\t${Priority}\\n");
auto filterList = installedList | $("grep -E required|important|standard") | $("cut -f 1"); auto filterList = (installedList | $("grep -E required|important|standard")).cut(1);
installedList = installedList | $("cut -f 1"); installedList = installedList.cut(1);
auto installedManuallyList = $("awk '/Commandline:.* install / && !/APT::/ { print $NF }' /var/log/apt/history.log"); auto installedManuallyList = $("awk '/Commandline:.* install / && !/APT::/ { print $NF }' /var/log/apt/history.log");
installedManuallyList = (installedManuallyList + $("apt-mark showmanual")) | $("sort -u"); installedManuallyList = (installedManuallyList + $("apt-mark showmanual")).sort(true);
auto packageList = installedManuallyList | $("grep -x " + installedList.output()) | $("grep -vx " + filterList.output()); auto packageList = installedManuallyList | $("grep -x " + installedList.output()) | $("grep -xv " + filterList.output());
packages = packageList.output();
} }
if (targets.empty()) { if (targets.empty()) {

Loading…
Cancel
Save