10

If apt search fails me, the next step is usually look for a PPA, but ppasearch seems like abandonware, so what can I use to search for PPAs (via the commandline)?

Jonathan
  • 3,904

1 Answers1

3

Don't really understand why you'd want to search for PPAs from the command line because most people already have a browser window perpetually open. Here are a few options:

  • If you use a browser that supports adding keywords to bookmarks, you can bookmark https://launchpad.net/ubuntu/+ppas?name_filter=%s with keyword ppa. Then type ppa [package-name] into the URL bar to search.

  • If ppasearch does what you need, keep using it for as long as it continues to work. You can try contributing to development to add features or fix bugs. If developers are non-responsive, you can create a personal fork.

  • You can create your own script, similar to the following:

    #!/usr/bin/env bash
    
    function _show_help_ {
       echo "Usage:" `basename ${0}` "[options] [package-name]"
       echo "Open web browser to search Launchpad for [package-name]."
       echo
       echo "  -l, --list      List PPAs with link and description"
       echo "  -h, --help      Display this help and exit."
    }
    
    function msed {
       perl -0777 -pe "$@"
    }
    
    if [ $# -lt 1 ]; then
       _show_help_
       exit 1
    fi
    
    case "$1" in
       '-h'|'--help')
          _show_help_
          ;;
       '-l'|'--list')
          shift
          curl -s "https://launchpad.net/ubuntu/+ppas?name_filter=$@" \
              | pandoc -f html -t markdown \
              | msed 's@[\s\S]*<div id="ppa_list">@@' \
              | msed 's@\]\(@\]\(https://launchpad.net/@'
              | grep -E '^\s+\[' \
              | msed 's@^\s+@@' \
              | msed 's@\s+[0-9]+\s+[0-9]+\s+@\n@g'
          ;;
       *)
          xdg-open "https://launchpad.net/ubuntu/+ppas?name_filter=$@"
          ;;
    esac
    

    This script opens a link to a Launchpad search for the given package in the default browser. With the appropriate flag -l, it outputs a list of PPA names with their URLs and descriptions.

    You can add additional features as you encounter the need for them.

David Foerster
  • 36,264
  • 56
  • 94
  • 147
xiota
  • 4,849
  • 1
    The whole point is that OP wants to have a tool similar to apt-cache search package_name. Problem with that is apt-cache relies on searching to package metadata of the repositories that have already been added to the system. That said, you're not far off - that link can be used to list PPAs, so making a request and parsing the response should be fairly straightforward, but probably whole lot of PITA in the parsing part – Sergiy Kolodyazhnyy May 30 '18 at 08:05
  • 1
    You can't assume people have a browser open. They may be on a headless system such as a server, or a raspberry pi. Arguably MOST linux systems are headless, since linux is primarily used by servers not desktops – Jonathan May 31 '18 at 18:36
  • The devices you use to access headless servers don't have browsers either? Is it headless servers all the way down? – xiota May 31 '18 at 18:40
  • 1
    You can't assume I have eyes, I may even be headless too – Jonathan May 31 '18 at 18:42