I want to get a list of trending packages but only for actual software excluding dependencies. For that I have to get the list of packages first excluding dependencies

I’m using an arch-based system. And this is what I’ve thought about.

get_packages

#!/usr/bin/env bash

wget https://pkgstats.archlinux.de/api/packages all_packages.txt
# Read the package list
while read package; do
  # Check if the package is a dependency
  if ! pacman -Qi $package | grep -q "Depends On"; then
    # Save actual packages that aren't dependencies
    echo $package
  fi
done < all_packages.txt

I can use it like get_packages > packages.txt

Is there a better way?

I don’t know if pacman knows all about the packages already or it has to make a request to check for each one. And if it does already know about them then I shouldn’t need to download the packages.

Ask specific questions about how to do something with linux

General linux discussion on lemmy.ml

Create Post From:
lemmy.ml

Community icon by Alpár-Etele Méder,
licensed under CC BY 3.0

  • 0 users online
  • 1 user / day
  • 1 user / week
  • 4 users / month
  • 21 users / 6 months
  • 22 subscribers
  • 18 Posts
  • 42 Comments
  • Modlog