Skip to content
Fabio Mucciante edited this page Feb 23, 2023 · 2 revisions

Welcome to the zypper-onlinesearch wiki!

Zypper-Onlinesearch is a Zypper plugin that aims to bring the software search through portals like software.opensuse.org directly at the terminal, without losing a web interface's ease of use and interactivity.

As always with my projects, it started as a personal script to test the power of the Ruby programming language, and slowly has been structured as an application able to solve an actual use case keeping it very simple to use.

The permitted operations are:

  • Search for a term as it would be in the edit box on the web page;
  • list the application pages, when available, related to the research and be able to open them;
  • display the relevant info on the application page;
  • show the URLs for each repository that provides the application packages.

Besides that:

  • Multiple search engines can be queried for a single search (Packman and software.opensuse.org are the only known);
  • the research can be limited to a specific search engine;
  • the ability to filter the repositories on the application page, for the current distribution (default);
  • the ability to extend the repositories list on the application page to all the supported distro;

Search for a term

The first operation we do while looking for an application is searching for a term and waiting for the result list, to know whether that term is associated with a real application or a package with a similar name is present.

This operation is performed through the --search switch (-s):

$ onlinesearch -s qmmp

The online web pages of the supported engines will be queried and the results are shown in a table:

====================================================================================================
Parameters: Engine: packman | Query: qmmp | Cache: On (2023-02-23 16:37)
====================================================================================================
    # |       Page       | Description 
----------------------------------------------------------------------------------------------------
    1 | qmmp             | Qt-based Multimedia Player
----------------------------------------------------------------------------------------------------
    2 | qmmp-plugin-pack | Extra plugins for Qmmp
----------------------------------------------------------------------------------------------------

====================================================================================================
Parameters: Engine: opensuse | Query: qmmp | Cache: On (2023-02-23 16:37)
====================================================================================================
    # |              Page              | Description 
----------------------------------------------------------------------------------------------------
    1 | qmmp                            | Qt-based Multimedia Player
----------------------------------------------------------------------------------------------------
    2 | libqmmp1                        | Qmmp library
----------------------------------------------------------------------------------------------------
    3 | libqmmp-devel                   | Development files for libqmmp
----------------------------------------------------------------------------------------------------

To limit the results to only one engine:

$ onlinesearch -s qmmp --engine opensuse

The query returns a table for each available engine, composed of a header and a variable number of rows that point to their respective and detailed pages.

The header remembers us what we are seeing in the following rows:

  1. The engine codename;
  2. the query string;
  3. the cache data: whether it is on/off and the datetime the info has been put in the cache.

The last parameter simply reminds us to refresh the data (--refresh switch) when they are too old.

The rows contain three columns:

  1. A progressive number;
  2. a page identified with a codepage;
  3. a brief description of the content of the referred page.

At this point, let's say, we found the application we were looking for, what we need is to know, whether or not this application has a package for our current distro, so let's read the page.

Look at that page

Differently from what happens online, where each session is bound to the previous by cookies and links, on a terminal, using a not-interactive command line application, we simply execute it and get a result.

How to reuse the previous data in the next session is a matter of opportunity.

Here for example we have for each result a row number that is bound to the query string, but more simply we also got a unique page name that points us to the next step.

So to read each page we use the --page switch (-p):

$ onlinesearch -p qmmp

And the result is another couple of tables:

====================================================================================================
Parameters:  Engine: packman | OS: openSUSE Leap 15.4 | Architecture: 64 Bit | Cache: On (2023-02-07 16:57)
====================================================================================================
Name:        qmmp
Summary:     
Description: 
Qt-based Multimedia Player
----------------------------------------------------------------------------------------------------
    # | Version |  Repo   |        Distro       
----------------------------------------------------------------------------------------------------
    1 |   2.1.2 | Packman | openSUSE Leap 15.4
----------------------------------------------------------------------------------------------------

====================================================================================================
Parameters:  Engine: opensuse | OS: openSUSE Leap 15.4 | Architecture: 64 Bit | Cache: On (2023-02-07 16:57)
====================================================================================================
Name:        qmmp
Summary:     Qt-based Multimedia Player
Description: This program is an audio-player, written with help of Qt library.
----------------------------------------------------------------------------------------------------
    # | Version |         Repo          |        Distro       
----------------------------------------------------------------------------------------------------
    1 |   2.1.2 | home:plater           | openSUSE Leap 15.4
----------------------------------------------------------------------------------------------------
    2 |   1.4.4 | home:ykoba:multimedia | openSUSE Leap 15.4
----------------------------------------------------------------------------------------------------
    3 |   2.1.2 | multimedia:apps       | openSUSE Leap 15.4
----------------------------------------------------------------------------------------------------

Of course, we can limit the results to one of the engines using the aforementioned option:

$ onlinesearch -p qmmp --engine opensuse

What we get this time is a table with a header, an info space, and one or more rows.

The header seems to be similar to the previous one:

  1. The first parameter identifies the engine used to get the results;
  2. the Operative System specification seems a reminder of the system we are using, but in reality it is indicating that the following rows are filtered, for the current distribution;
  3. the current architecture is set up for the next step, but this filter can be disabled as we will see;
  4. the cache field works as we have seen previously.

The info space is quite self-explaining: it includes the package name, a short description, and a long description. The last two aren't always present, but that's.

The rows part shows all the repositories that provide the package.

Of course, in the case of Packman, the repository is always the same, but the openSUSE engine instead, gathers all the repositories in the openSUSE Build Service which may vary for the number of the supported distro, and the available version.

That's why for each row these two parameters are specified beside the repository name and a number.

With the --all-distributions switch we might also ask for displaying all the available repositories for that package, without filtering for only those compatible with our current distribution.

What remains to see now is how to get the list of the links that would help to install the package, without leaving the terminal.

Grab the links

Among the listed repository we can choose our favorite and ask for its links using the --links switch.

To refer to the repositories where to grab the links we used the original page name and the repository number as it is listed in the previous table:

$ onlinesearch -l qmmp,3 --engine opensuse

Warning If the --all-distributions or any other filtering switch has been used to read the page, be sure to append the same options while requesting the links, otherwise, the repository number might not match.

And here below an example of the result:

====================================================================================================
Parameters:  Engine: opensuse | OS: openSUSE Leap 15.4 | Architecture: 64 Bit | Cache: On (2023-02-07 16:57)
====================================================================================================
Name:        qmmp
Summary:     Qt-based Multimedia Player
Description: This program is an audio-player, written with help of Qt library.
----------------------------------------------------------------------------------------------------
    # | Format | Link
----------------------------------------------------------------------------------------------------
    1 |    ymp | https://software.opensuse.org/ymp/multimedia:apps/15.4/qmmp.ymp?base=openSUSE%3ALeap%3A15.4&query=qmmp
----------------------------------------------------------------------------------------------------
    2 |    src | https://download.opensuse.org/repositories/multimedia:/apps/15.4/src/qmmp-2.1.2-lp154.182.3.src.rpm
----------------------------------------------------------------------------------------------------
    3 | x86_64 | https://download.opensuse.org/repositories/multimedia:/apps/15.4/x86_64/qmmp-2.1.2-lp154.182.3.x86_64.rpm
----------------------------------------------------------------------------------------------------

Using the repository number 3 we got the link list from the multimedia:apps repository, among them the ymp format refers to the Yast One Click link, and from a terminal like Konsole, clicking on it open the browser and download the file which recalls the Yast interface that will install the repository and the package.

Just this one might be enough, but having a link that matches the current hardware architecture is even better to confirm the availability of the wanted package for our system.

We can also grab the raw link:

$ onlinesearch -l qmmp,3 --format ymp --urls
https://software.opensuse.org/ymp/multimedia:apps/15.4/qmmp.ymp?base=openSUSE%3ALeap%3A15.4&query=qmmp

And mix it with the OneClickInstallCLI or OneClickInstallUI application to start the installer:

# OneClickInstallCLI `onlinesearch -l qmmp,3 --format ymp --urls`

Other options

This is the list of operations and options not listed above:

Operations

--clean-cache : Remove all the cached files at once.

View options

--table : Show the results as a table (DEFAULT)

--report : Shows the results as a report.

Page and Links options

--no-supported : Hide supported packages.

--no-experimental : Hide experimental packages.

--no-community : Hide community packages.

Resources