Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feature request: Add option to check single package(s) #10

Open
mahlzahn opened this issue Oct 17, 2023 · 0 comments
Open

Feature request: Add option to check single package(s) #10

mahlzahn opened this issue Oct 17, 2023 · 0 comments

Comments

@mahlzahn
Copy link

Expected behaviour

For a free package packageA, a non-free packageB and a packageC with ambiguous licenses

vrms packageA packageB packageC

should yield

packageB: ['nonFreeLicenseA', …]

and possibly in the stderr

Non-free packages: 1 (33.3% of total)
Packages with ambiguous licenses: 1 (33.3% of total)
Use --list-unknowns to list them (or --help for more info)

If a package of given packages is not found either raise an error or write a message to the stderr with the corresponding package and maybe exit with error code 1.

Origin of package information

I suggest to look for the license information for a given package in the following order:

  1. locally installed packages
  2. global package database (from synced repositories, as with option -g)
  3. [optional] external: official package repository on https://archlinux.org/packages
  4. [optional] external: community-operated package repository on https://aur.archlinux.org

Possible implementation of external lookup

The search in 1. and 2. should be easily implementable. 3. and 4. need some further implementation (either with external package or with some simple HTTP requests, see https://wiki.archlinux.org/title/Official_repositories_web_interface#Exact_name and https://aur.archlinux.org/rpc/swagger)

E.g. for package coreutils

import json
import urllib.request

package = 'coreutils'
with urllib.request.urlopen(f'https://archlinux.org/packages/search/json/?name={package}') as f:
    print(json.JSONDecoder().decode(f.read().decode())['results'][0]['licenses'])

yields

['GFDL-1.3-or-later', 'GPL-3.0-or-later']

and for package vrms-arch

package = 'vrms-arch'
with urllib.request.urlopen(f'https://aur.archlinux.org/rpc/v5/info/{package}') as f:
    print(json.JSONDecoder().decode(f.read().decode())['results'][0]['License'])

yields

['custom:BSD3']

Of course, this needs also proper handling of errors such as missing internet connection, etc.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant