FOSSLight Prechecker
FOSSLight Prechecker is a tool that can be used to comply with the copyright/license writing rules in the source code using reuse-tool.
Github Repository : https://github.com/fosslight/fosslight_prechecker
License : GPL-3.0-only
Contents
๐ Prerequisite
FOSSLight Prechecker needs a Python 3.6+.
๐ How to install
It can be installed using pip3.
It is recommended to install it in the python 3.6 + virtualenv environment.
$ pip3 install fosslight_prechecker
๐ How to run
FOSSLight Prechecker has 3 modes as following:
-
lint
โ Check whether the source code's copyright and license writing rules are complied with. -
convert
โ Convert oss-pkg-info.yaml to FOSSLight-Report.xlsx and vice versa.- It converts oss-pkg-info.yaml to SRC Sheet of FOSSLight Report or
- BIN (Android) and BOM Sheet of FOSSLight Report to oss-pkg-info.yaml.
-
add
โ Add copyright and license to source code which is missing copyright and license
fosslight_prechecker [Mode] [option1] <arg1> [option2] <arg2>...
How to run by mode & Parameters
- Required parameter : Mode
- Optional parameter : Options
Mode
lint Check REUSE compliance
convert Convert oss_pkg_info.yaml <-> FOSSLight-Report
add Add missing license and copyright
Options:
-h Print help message
-p <path> Path to check
-f <format> Output file format (yaml, xml, html)
-o <file_name> Output file name
-n Don't exclude venv*, node_modules, and .*/ from the analysis
Options for only 'add' mode
-l <license> License name(SPDX format) to add
-c <copyright> Copyright to add(ex, 2015-2021 LG Electronics Inc.)
(Only for Windows) Run using executable file
1. Download fosslight_prechecker_windows.exe from FOSSLight Prechecker - Release.
2. Move the executable file to the path where oss-pkg-info.yaml file or FOSSLight-OSS-Report.xlsx file is located.
3. Double-click the executable file to run it.
๐ Result
๐ lint mode
1) Analyze for specific folder
(venv)$ fosslight_prechecker lint -p /home/tests -o result.yaml
- Result
Checking copyright/license writing rules: Compliant: Not OK Files without copyright: - add/test_no_copyright.py Files without license: - add/test_no_license.py Files without license and copyright: N/A Summary: Detected Licenses: - '-' - GPL-3.0-only - MIT Files without copyright / total: 1 / 14 Files without license / total: 1 / 14 Open Source Package File: - convert/oss-pkg-info.yaml - add/oss-pkg-info.yaml Tool Info: Analyze path: tests OS: Linux 4.15.0-144-generic Python version: 3 fosslight_prechecker version: fosslight_prechecker v2.2.0
2) Analyze for specific files
(venv)$ fosslight_prechecker lint -p "src/file1.py,src/file2.py"
- Result
# src/file1.py * License: * Copyright: # src/file2.py * License: GPL-3.0-only * Copyright: Copyright (c) 2022 LG Electronics Inc. Checking copyright/license writing rules: Compliant: Not OK Files without copyright: N/A Files without license: N/A Files without license and copyright: - src/fosslight_prechecker/_precheck.py Summary: Detected Licenses: N/A Files without copyright / total: 1 / 2 Files without license / total: 1 / 2 Open Source Package File: [] Tool Info: Analyze path: /home/jaekwonbang/tests OS: Linux 4.15.0-144-generic Python version: 3 fosslight_prechecker version: fosslight_prechecker v2.2.0
Demo Video (lint)

๐ convert mode
1) Convert all oss-pkg-info.yaml or oss-pkg-info.yml in the path recursively.
$ fosslight_prechecker convert -p tests/
2) Convert FOSSLight Report to oss-pkg-info.yaml
$ fosslight_prechecker convert -p src/FOSSLight-Report.xlsx
3) Result file example
oss-pkg-info.yaml
glibc: - version: '2.3' source name or path: - tests/b.c - tests/a.c license: - GPL-3.0 - LGPL-2.1 download location: https://github.com/fsfe/glibc dbus: - version: '1.3' source name or path: - tests/src/* license: - GPL-2.0 download location: https://github.com/fsfe/dbus copyright text: 'Copyright (c) 2020 Test Copyright (c) 2020 Sample' reuse-tool: - version: '' source name or path: - tests/ license: - MIT download location: https://github.com/fsfe/reuse homepage: http://google.com copyright text: Copyright (c) 2020 Test build-tool: - version: '' source name or path: - tests/ license: - Apache-2.0 download location: http://gihub.com/bazel exclude: true
FOSSLight-Report.xlsx
Demo Video (convert)
๐ add mode
1) Add copyright and license to file(s) in the input path
(venv)$ fosslight_prechecker add -p tests/add -c "2019-2021 LG Electronics Inc." -l "GPL-3.0-only"
2) Add copyright and license to input file(s)
(venv)$ fosslight_prechecker add -p "tests/add/test_both_have_1.py,tests/add/test_both_have_2.py,tests/add/test_no_copyright.py,tests/add/test_no_license.py" -c "2019-2021 LG Electronics Inc." -l "GPL-3.0-only"
3) Result โช๏ธ Changes in the file - Added copyright or license at the top of the file
Before | After |
---|---|
# File list that have both license and copyright : 3 / 7
# __init__.py
* License:
* Copyright:
# test_both_have_1.py
* License: GPL-3.0-only
* Copyright: SPDX-FileCopyrightText: Copyright 2019-2021 LG Electronics Inc.
# test_both_have_2.py
* License: MIT
* Copyright: SPDX-FileCopyrightText: Copyright (c) 2011 LG Electronics Inc.
# Missing license File(s)
* test_no_license.py
* Your input license : GPL-3.0-only
Successfully changed header of tests/add_result/test_no_license.py
# Missing Copyright File(s)
* test_no_copyright.py
* Your input Copyright : Copyright 2019-2021 LG Electronics Inc.
Successfully changed header of tests/add_result/test_no_copyright.py
Demo Video (add)

๐ How it works
๐ lint mode
- Find a OSS Package Information file.
Check if at least one of the following files exists (case-free)
- oss-pkg-info.yaml
- oss-pkg-info.yml
- requirement.txt
- requirements.txt
- package.json
- pom.xml
- build.gradle
- Podfile.lock
- Cartfile.resolved
- oss-package.info
- File started with "MODULE_LICENSE_ "
- Run fsfe-reuse lint
2-1. When running on a project basis.- If there is no ./reuse/dep5 file in the Root Path, it is created.
- If it already exists, copy it to bk file and append the default config value to the existing dep file.
- By creating dep5 files, exclude binary or .json, venv /, node_modules/,. */ from reuse.
- Run fsfe-reuse lint (If the OSS Package Information file exists, the list of missing license files is not printed.)
- Recover to existing dep5-related file if it originally existed, delete if it doesn't exist.
2-2. When executing in file unit
- Print the copyright text and license text extraction by file.
- However, if the file does not exist or the file is binary or .json, copyright text and license text are not printed.
- Print the execution result and save it in xml format.
๐ convert mode
- Check if there is an OSS Package Information or FOSSLight Report file.
- file example :ย oss-pkg-info.yaml,ย FOSSLight-Report.xlsx
- Convert oss-pkg-info.yaml file โ FOSSLight Report
2-1. When running on a project basis.- Convert all files in the path (oss-pkg-info.yaml file โ FOSSLight Report)
2-2. When running in file unit
- Convert the input file (oss-pkg-info.yaml โ FOSSLight-Report.xlsx)
- However, if an output file name is specified with -o, a result file is created with that name.
๐ add mode
- Confirm to add copyright and license to missing file
- Add copyright and license to missing file(s) using -c and -l option
- Print file list that both has copyright and license(excluded from Adding)
- Add input copyright and license to missing file(s) using -c and -l option