Giter VIP home page Giter VIP logo

vrms-rpm's Introduction

vrms-rpm

A clone of vrms ("virtual Richard M. Stallman") for RPM-based GNU/Linux distributions.

This program analyses the list of currently installed RPM packages and reports found non-free packages to stdout.

Why a clone instead of a fork?

Because my only experience with Perl (which the original vrms is written in) has been one semester of Operating Systems class, and that was a long time ago.

Also, seeing how much the resulting program differs from the original, it's quite possible that making a fork instead of starting fresh would only complicate matters. After all, removing code is hard.

How does it work?

vrms-rpm works by processing the list of installed packages (as reported by rpm) and analysing their licence strings. The program breaks down compound expressions using AND / OR operators and parentheses, and then checks individual licences against a list of acceptable licences.

To make a simple example, the licence string (AGPL-3.0-or-later OR SSPL) AND CC-BY-3.0 will be broken down in the following way:

AGPL-3.0-or-later      SSPL      CC-BY-3.0
     [Free]         [Non-free]     [Free]
        |               |            |
        \----- OR ------/            |
             [Free]                  |
                |                    |
                \-------- AND -------/
                         [Free]

Installing from a repository

Packaging status
Fedora users can install vrms-rpm from the official distro repository. RHEL/CentOS users can get the package from the Fedora EPEL repositories.

$ dnf install vrms-rpm

Building it on your own: dependencies

  • bash, as there are some shell scripts used during the build process

  • sed - used in the aforementioned shell scripts

  • make, for simplifying the build & install process

  • gcc, although clang should work too

  • gettext (libintl), for handling multiple languages

  • librpm (optional), for accessing RPM's functions for comparing package versions

  • cmocka (optional), for running the test suite

Picking the licence list

As mentioned earlier, vrms-rpm works by checking package licences against a list of known good licences. Since distributions can have differing opinions on what constitutes as free software, and what the licence tags should be written as (e.g. "GPLv2" vs "GPL-2.0"), vrms-rpm comes packaged with several different licence lists.

These are:

  • fedora - a list created in accordance to the Fedora Allowed License list.

  • spdx-fsf-and-osi - a list created in accordance to the SPDX licence list. Includes only licences marked as both "FSF free/libre" and "OSI approved".

  • spdx-fsf-or-osi - a list created in accordance to the SPDX licence list. Includes licences marked as either "FSF free/libre" or "OSI approved".

  • spdx-only-fsf - a list created in accordance to the SPDX licence list. Includes only licences marked as "FSF free/libre".

  • spdx-only-osi - a list created in accordance to the SPDX licence list. Includes only licences marked as "OSI approved".

  • suse - a list created in accordance to openSUSE packaging guidelines.

  • tweaked - a list that combines all of the above and also includes many non-standard licence tags spotted in the wild. This list has the smallest chance of generating false-positives (free packages being marked as non-free)

When building the program, one of those lists has to be selected as default. This can be done by providing the DEFAULT_LICENCE_LIST variable to make.

Picking the grammar rules

Licensing can be a complicated subject, with many pieces of software utilising various multiple-licensing schemes. These can be written down in various ways - using combining words such as "and" / "or", but also listing individual licences separated by commas or semicolons. This results in a myriad of possible ways to describe the licensing situation.

In recent years, the SPDX standard - offering a formalized way of building licence expressions - has gained a lot of traction, with more and more distributions adopting SPDX as the preferred way of specifying package licences.

To reflect this, vrms-rpm comes with multiple licence-string parsers. Currently, the supported options are:

  • spdx-strict - a parser implementing the SPDX license expressions specification.

  • spdx-lenient - a variant of the SPDX parser, which relaxes some rules regarding case-sensitivity and whitespace.

  • loose - an ad-hoc, informal parser that tries its best to make sense of licence strings that do not follow any formal grammar. This is the original parser used in vrms-rpm v2.2 and older.

When building the program, one of the parsers has to be selected as default. This can be done by providing the DEFAULT_GRAMMAR variable to make.

Building

To build, use make with the build target. The PREFIX variable can be used for controlling program data paths (e.g. where to look for the good licence list). The default is /usr/local.

By default, vrms-rpm links against librpm and librpmio, to make use of RPM's version comparison functions. To disable this feature, you can set the WITH_LIBRPM variable to 0. In this case, vrms-rpm will use a fallback, simplified algorithm when comparing package versions.

$ make build [PREFIX=/usr/local] [DEFAULT_GRAMMAR=loose] [DEFAULT_LICENCE_LIST=tweaked] [WITH_LIBRPM=1]

Testing

To test the program, use make with the test target. This will build the test suite and immediately execute it. If you want to just build the test suite, use the build/test-suite target.

# Shorthand for: make build/test-suite && ./build/test-suite
$ make test

The test suite uses cmocka, so make sure you have it installed. If you build against librpm, you may notice that some tests are skipped; these check vrms-rpms's fallback behaviour, so it makes no sense to run them when that's disabled.

Installing

To install, perform your usual make install. You can use the DESTDIR variable if you need to install the files somewhere else than PREFIX dictates (e.g. for packaging).

$ [sudo] make install [PREFIX=/usr/local] [DESTDIR=]

Remember that to install stuff inside /usr you will need root capabilities.

Getting rid of it

Should you decide to remove the program, the Makefile has got you covered.

$ [sudo] make remove [PREFIX=/usr/local] [DESTDIR=]

Once again, remember that messing inside /usr requires extra privileges.

Licensing

This program is made available under the terms of the GNU General Public License, version 3, as published by the Free Software Foundation.

This program uses photos courtesy of other people; see IMAGE-CREDITS.txt for details.

Contributing

Whether you'd like to report an issue with the program or submit a patch, you can do so on GitHub or via e-mail.

When sending patches, please keep in mind the following:

  1. When modifying program options, remember to update the --help section and the man page(s).

  2. Use British spelling, when appropriate.

  3. By contributing, you agree for your work to be included under the terms of the program licence.

Donating

If you'd like to support the development of this program financially, you can use the following methods:

Much appreciated!

vrms-rpm's People

Contributors

aaptel avatar alesssia avatar apo-mak avatar bureken avatar dextero avatar dkarakay avatar epse avatar harkce avatar jan200101 avatar joseborges avatar klan avatar martinsustek avatar mfoerd avatar msdeibel avatar natastro avatar nemobis avatar platipo avatar quique avatar sdmoko avatar sergiygolov avatar stacey-impossible avatar suve avatar tassos avatar yanicka avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

vrms-rpm's Issues

Update Italian translation for version 2.0

Version 1.2 of vrms-rpm had an Italian translation. Given the major overhaul of the program for version 2.0, this translation can no longer be used. It'd be awesome if we could update the translation (or create an entirely new one) for the new version.

Files containing the old translation:

  • lang/outdated/it.po
  • man/outdated/it.man

New text (in English) to be translated:

  • lang/en.po
  • man/en.man

src/lang.c: 2 * bad parameter to va_start ?

src/lang.c:59]: (warning) 'msgstr' given to va_start() is not last named argument of the function. Did you intend to pass 'msgid'?

Source code is

int lang_print(FILE *const file, const enum MessageID msgid, ...) {
char *msgstr = lang_getmsg(msgid);
if(msgstr == NULL) return -1;

    va_list args;
    va_start(args, msgstr);

Also:

src/lang.c:71]: (warning) 'msgstr' given to va_start() is not last named argument of the function. Did you intend to pass 'number'?

Duplicate.

Missing Danish translation for --describe

The Danish translation file (lang/da.po) is missing the msg_help_option_describe entry, which describes the --describe option. The man page (man/da.man) also doesn't mention the option's existence.

Missing French translation for --describe

The French translation file (lang/fr.po) is missing the msg_help_option_describe entry, which describes the --describe option. The man page (man/fr.man) also doesn't mention the option's existence.

Update Greek translation for version 2.0

Version 1.2 of vrms-rpm had a Greek translation. Given the major overhaul of the program for version 2.0, this translation can no longer be used. It'd be awesome if we could update the translation (or create an entirely new one) for the new version.

Files containing the old translation:

  • lang/outdated/el.po
  • man/outdated/el.man

New text (in English) to be translated:

  • lang/en.po
  • man/en.man

Update Spanish translation for version 2.0

Version 1.2 of vrms-rpm had a Spanish translation. Given the major overhaul of the program for version 2.0, this translation can no longer be used. It'd be awesome if we could update the translation (or create an entirely new one) for the new version.

Files containing the old translation:

  • lang/outdated/es.po
  • man/outdated/es.man

New text (in English) to be translated:

  • lang/en.po
  • man/en.man

Licences missing from `good-licenses.txt`

Hi, on my system, the package texlive-rsfs shows as non-free, because its license is spelt rsfs, but your whitelist only has Rsfs (as spelt on the fedora wiki). In my own implementation I use grep -w -i, which works fine.

I also noticed texlive-lm, which is licensed GFSL. GFSL is basically LaTeX' LPPL, which Fedora considers 'free', but removes clause 6.a.

Respect the NO_COLOR environment variable

The NO_COLOR environment variable is an informal standard which states:

All command-line software which outputs text with ANSI color added should check for the presence of a NO_COLOR environment variable that, when present (regardless of its value), prevents the addition of ANSI color.

How it should work:

  1. If the --colour command-line option is explicitly specified, its value is used.
  2. If the --colour option is not specified (or specified as AUTO), then:
    a. Check if the NO_COLOR envvar is present. If it is, disable coloured output (NO).
    b. Check if stdout is attached to a terminal (isatty()). If it is, enable coloured output (YES).
    c. Otherwise, disable coloured output (NO).

The code, as it stands currently, performs steps 1, 2b and 2c, so this is a matter of adding the extra logic described in step 2a.

Add support for comma-separation to "loose" classifier

An unfortunate, but somewhat common pattern seen in licence strings is the use of a comma to list multiple licences, like so:

Licence-A, Licence-B, Licence-C

It would be good to add some support for this form to the loose classifier.

Things to consider:

  • Just because a string contains a comma, it doesn't mean the comma must be a separator. For example, Fedora used the Redistributable, no modification permitted string for a long time to describe firmware blobs.
  • It is not possible to determine if A, B is supposed to mean A or B or A and B. Since the former interpretation increases the risk of false-negatives (non-free software being listed as free), the latter interpretation should be used.
  • When presenting the licensing breakdown to the user (via the --explain option), the program should try to remain as close as possible to the input string and use a comma to separate the individual licences.

Add a --describe option

Package names rarely make it immediately apparent what a particular program or library does. It could be helpful to add a --describe option to the program, which, akin to how --explain lists licences, would list package descriptions.

For a minimal version, --describe and --explain could be exclusive. Ideally, both can be specified and used at the same time.

vrms-rpm counts packages once for each version installed

Thank you for this very informative and educational vrms!

I suppose this is correct, literally speaking, but the percentage feels a bit less fair when every kernel package is counted three times. :) Feel free to close as invalid if this is intended.

$ LANG=en_GB vrms-rpm
2176 free packages (98.1% of total)
44 non-free packages (1.9% of total)
 - atmel-firmware
 - fedora-logos
 - gobject-introspection
 - google-chrome-stable
 - ipw2100-firmware
 - ipw2200-firmware
 - iwl100-firmware
 - iwl1000-firmware
 - iwl105-firmware
 - iwl135-firmware
 - iwl2000-firmware
 - iwl2030-firmware
 - iwl3160-firmware
 - iwl3945-firmware
 - iwl4965-firmware
 - iwl5000-firmware
 - iwl5150-firmware
 - iwl6000-firmware
 - iwl6000g2a-firmware
 - iwl6000g2b-firmware
 - iwl6050-firmware
 - iwl7260-firmware
 - kernel
 - kernel
 - kernel
 - kernel-core
 - kernel-core
 - kernel-core
 - kernel-devel
 - kernel-devel
 - kernel-devel
 - kernel-modules
 - kernel-modules
 - kernel-modules
 - kernel-modules-extra
 - kernel-modules-extra
 - kernel-modules-extra
 - libertas-usb8388-firmware
 - librados2
 - librbd1
 - linux-firmware
 - linux-firmware-whence
 - lttng-ust
 - microcode_ctl
$ rpm -qa | grep kernel-core
kernel-core-5.9.16-200.fc33.x86_64
kernel-core-5.10.6-200.fc33.x86_64
kernel-core-5.10.7-200.fc33.x86_64

Update Portuguese translation for version 2.0

Version 1.2 of vrms-rpm had a Portuguese translation. Given the major overhaul of the program for version 2.0, this translation can no longer be used. It'd be awesome if we could update the translation (or create an entirely new one) for the new version.

Files containing the old translation:

  • lang/outdated/pt.po
  • man/outdated/pt.man

New text (in English) to be translated:

  • lang/en.po
  • man/en.man

Update French translation for version 2.0

Version 1.2 of vrms-rpm had a French translation. Given the major overhaul of the program for version 2.0, this translation can no longer be used. It'd be awesome if we could update the translation (or create an entirely new one) for the new version.

Files containing the old translation:

  • lang/outdated/fr.po
  • man/outdated/fr.man

New text (in English) to be translated:

  • lang/en.po
  • man/en.man

Update German translation for version 2.0

Version 1.2 of vrms-rpm had a German translation. Given the major overhaul of the program for version 2.0, this translation can no longer be used. It'd be awesome if we could update the translation (or create an entirely new one) for the new version.

Files containing the old translation:

  • lang/outdated/de.po
  • man/outdated/de.man

New text (in English) to be translated:

  • lang/en.po
  • man/en.man

Update Turkish translation for version 2.0

Version 1.2 of vrms-rpm had a Turkish translation. Given the major overhaul of the program for version 2.0, this translation can no longer be used. It'd be awesome if we could update the translation (or create an entirely new one) for the new version.

Files containing the old translation:

  • lang/outdated/tr.po
  • man/outdated/tr.man

New text (in English) to be translated:

  • lang/en.po
  • man/en.man

Missing Italian translation for --describe

The Italian translation file (lang/it.po) is missing the msg_help_option_describe entry, which describes the --describe option. The man page (man/it.man) also doesn't mention the option's existence.

Update Dutch translation for version 2.0

Version 1.2 of vrms-rpm had a Dutch translation. Given the major overhaul of the program for version 2.0, this translation can no longer be used. It'd be awesome if we could update the translation (or create an entirely new one) for the new version.

Files containing the old translation:

  • lang/outdated/nl.po
  • man/outdated/nl.man

New text (in English) to be translated:

  • lang/en.po
  • man/en.man

Validate licensing exceptions in "spdx" classifier

Currently, the SPDX classifier will detect if a licence string contains the WITH operator and then evaluate the licence identifier, without paying any attention if the licensing exception is a valid SPDX identifier. While an unknown exception should not cause a licence to be suddenly become non-free, it could be useful to have a way to inform the user that the exception identifier was not recognized.

`vrms-rpm` lacks the ability to report full names of fake packages with GPG keys

Hello. In v. 2.2 fake packages with GPG keys are taken in account in the query. That's also what the rpm utility does when rpm -qa is invoked. In a system where such packages can be found, their presence can be attested with vrms-rpm --list all | grep ' gpg-pubkey$'. A preferable default behaviour would be to not take them in account. As noticeable, vrms-rpm lacks the ability to report full names of such packages.

$ vrms-rpm --list all | grep ' gpg-pubkey$'
 - gpg-pubkey
 - gpg-pubkey
$ rpm -qa | grep '^gpg-pubkey-*-*'
gpg-pubkey-5323552a-6112bcdc
gpg-pubkey-ba3c3a2c-5eb88cc6

Numbers of installed packages reported by `vrms-rpm --list all` and `vrms-rpm --list none` as total sum, differ from each other

Hello. In v. 2.2 the numbers of installed packages reported by vrms-rpm --list all and vrms-rpm --list none as total sum, differ from each other.

$ vrms-rpm --list all | wc -l
1999
$ vrms-rpm --list none
1888 free packages (94.6% of total)
109 non-free packages (5.4% of total)

vrms-rpm --list none's output | total sum of installed packages: 1997.

Worth noting: numbers of installed packages reported by rpm -qa and dnf rq --installed in IBM's Red Hat and Fedora OSs may differ from each other due to the fact that the rpm utility takes in account fake packages with GPG keys. Illustrations:

$ rpm -qa | wc -l
1991
$ dnf rq --installed | wc -l
1989
$ diff <(dnf rq --installed --nvr) <(rpm -qa --qf '%{nvr}\n') | grep '^> gpg-pubkey-' | wc -l
2

It appears that all for vrms-rpm --list behaves as rpm -qa does.

$ vrms-rpm --list all | grep ' gpg-pubkey$' | wc -l
2

This ability to count fake packages appears to be useful, thought as demonstrated here, as a dedicated option so it could be queried on demand. Yet here the non-equality of numbers of installed packages reported by vrms-rpm --list all and vrms-rpm --list none as total sum, indicates an issue.

Add support for DESTDIR to Makefile

It should be possible to control which directory make install installs stuff by specifying the DESTDIR variable. For example, doing make install DESTDIR=/home/some-user/.local should result in the program being installed to:

/home/some-user/.local/usr/local/bin
/home/some-user/.local/usr/local/share

The PREFIX variable should still be respected.

Add more translations

Currently we have an English and a Polish translation. (Added since: Danish, Dutch, German, Indonesian, Italian, Portuguese, Spanish, Turkish.) It could be helpful for users to add support for more languages.

Each language consists of two parts: the gettext translation file (lang/*.po) and the manpage man/*.man.

Note that any new translations should be done based on the devel branch, NOT master.

Some packages seem to be considered unfree merely for being multi-licensed

The --explain option is very useful but I'm not sure I understand this explanation:

$ LANG=en_GB vrms-rpm --explain | grep -B1 ", MIT"
 - gobject-introspection
   GPLv2+, LGPLv2+, MIT
--
 - lttng-ust
   LGPLv2.1, MIT and GPLv2
$ vrms-rpm --version
vrms-rpm v.2.2 by suve

Why are those MIT etc. licenses listed as red? Is it maybe a parsing failure where the comma separator is not recognised, and the string "LGPLv2.1, MIT" fails to match a license?

Add some black-box testing

It would be useful to add some tests to the program. We could start with some black-box tests, i.e. ones that run on a fully compiled program and just check if it produces the expected output without crashing.

Possible action points:

  • Add a compile-time symbol, or a program option (--stdin?), that allows to pass any input to the program, instead of performing the RPM query
  • Think of some edge cases that might be worth testing

Missing Indonesian translation for --describe

The Indonesian translation file (lang/id.po) is missing the msg_help_option_describe entry, which describes the --describe option. The man page (man/id.man) also doesn't mention the option's existence.

SPDX grammar support

vrms-rpm currently uses an ad-hoc algorithm for parsing the License: tags on packages. With SPDX becoming more widely adopted by various distributions, it would make sense to change the algorithm to comply with the SPDX license expression grammar. The current solution could then either be completely retired (preferably) or left as a fallback option.

Missing German translation for --describe

The German translation file (lang/de.po) is missing the msg_help_option_describe entry, which describes the --describe option. The man page (man/de.man) also doesn't mention the option's existence.

Update Danish translation to version 2.0

Version 1.2 of vrms-rpm had a Danish translation. Given the major overhaul of the program for version 2.0, this translation can no longer be used. It'd be awesome if we could update the translation (or create an entirely new one) for the new version.

Files containing the old translation:

  • lang/outdated/da.po
  • man/outdated/da.man

New text (in English) to be translated:

  • lang/en.po
  • man/en.man

Missing Turkish translation for --describe

The Turkish translation file (lang/tr.po) is missing the msg_help_option_describe entry, which describes the --describe option. The man page (man/tr.man) also doesn't mention the option's existence.

Missing Dutch translation for --describe

The Dutch translation file (lang/nl.po) is missing the msg_help_option_describe entry, which describes the --describe option. The man page (man/nl.man) also doesn't mention the option's existence.

Missing Greek translation for --describe

The Greek translation file (lang/el.po) is missing the msg_help_option_describe entry, which describes the --describe option. The man page (man/el.man) also doesn't mention the option's existence.

Missing Spanish translation for --describe

The Spanish translation file (lang/es.po) is missing the msg_help_option_describe entry, which describes the --describe option. The man page (man/es.man) also doesn't mention the option's existence.

Update translations for v2.3 release

I'd like to make a new release before the end of the year. The following translations could use updating:

  • Danish (da)
    • missing translation for HELP_OPTION_EVRA, ERR_BADOPT_EVRA and ERR_BADOPT_NOARG
    • man page missing description for the --evra option
  • Greek (el)
    • missing translation for HELP_OPTION_EVRA and ERR_BADOPT_EVRA
    • man page missing description for the --evra option
  • Spanish (es)
    • missing translation for HELP_OPTION_EVRA, ERR_BADOPT_EVRA and ERR_BADOPT_NOARG
    • man page missing description for the --evra option
  • French (fr)
    • missing translation for HELP_OPTION_EVRA and ERR_BADOPT_EVRA
    • man page missing description for the --evra option
  • Portuguese (pt)
    • missing translation for HELP_OPTION_EVRA, ERR_BADOPT_EVRA and ERR_BADOPT_NOARG
    • man page missing description for the --colour, --describe, --evra, --image and --licence-list options
  • Turkish (tr)
    • missing translation for HELP_OPTION_EVRA, ERR_BADOPT_EVRA and ERR_BADOPT_NOARG
    • man page missing description for the --evra option
  • Ukrainian (uk)
    • missing translation for HELP_OPTION_EVRA, ERR_BADOPT_EVRA and ERR_BADOPT_NOARG
    • man page missing description for the --evra option

Support lower-case SPDX operators

The SPDX spec had its version 3.0 released in April this year. Among the changes from the previous version (v2.3) is support for lower-case operators - i.e. and, or, with.

It must be noted that this does *not* mean that the operators are now case-insensitive:

License expression operators (AND, and, OR, or, WITH and with) should be matched in a case-sensitive manner, i.e., letters must be all upper case or all lower case.

https://spdx.github.io/spdx-spec/v3.0/annexes/SPDX-license-expressions/#d2-case-sensitivity

Missing Portuguese translation for --describe

The Portuguese translation file (lang/pt.po) is missing the msg_help_option_describe entry, which describes the --describe option. The man page (man/pt.man) also doesn't mention the option's existence.

Update Indonesian translation for version 2.0

Version 1.2 of vrms-rpm had an Indonesian translation. Given the major overhaul of the program for version 2.0, this translation can no longer be used. It'd be awesome if we could update the translation (or create an entirely new one) for the new version.

Files containing the old translation:

  • lang/outdated/id.po
  • man/outdated/id.man

New text (in English) to be translated:

  • lang/en.po
  • man/en.man

Improve WITH support in "loose" classifier

Currently, the loose classifier supports licensing exceptions by way of matching the end of the licence string against a fixed list of suffixes, like so:

  •  with fonts exception
  •  with linking exception
  • -with-fonts-exception
  • -with-linking-exception

This is very inefficient - a licence string will be compared against all suffixes, even if it doesn't contain  with  nor -with-; and made even worse by the fact that every suffix exists in two forms (space-separated and dash-separated).

It would be good to change this to utilise a mechanism similar to the spdx classifier, where we locate the  with  (or -with-) substring and split the expression into licence name and exception name parts.

While at it, support for the , with form could also be added, as I've stumbled across it a few times.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.