-
Notifications
You must be signed in to change notification settings - Fork 30
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Windows installer: Collect information on dependencies & licenses
- Loading branch information
1 parent
f2839aa
commit 150999d
Showing
4 changed files
with
124 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
import subprocess | ||
|
||
cargo_result = subprocess.run( | ||
['cargo', 'license', '--authors', '--do-not-bundle', '--color=never'], | ||
capture_output=True) | ||
|
||
cargo_result.check_returncode() | ||
|
||
print("The following Rust packages are statically linked into Packetry:") | ||
|
||
for line in cargo_result.stdout.decode().rstrip().split("\n"): | ||
package, remainder = line.split(": ") | ||
version, licenses, by, authors = remainder.split(", ") | ||
licenses = licenses[1:-1] \ | ||
.replace(' OR ', ' or ') \ | ||
.replace(' WITH ', ' with ') \ | ||
.replace(' AND ', ' and ') | ||
authors = authors[1:-1].split("|") | ||
print() | ||
print(f"{package} version {version}") | ||
if len(authors) == 1: | ||
print(f"Author: {str.join(', ', authors)}") | ||
else: | ||
print("Authors:") | ||
for author in authors: | ||
print(f" {author}") | ||
print(f"License: {licenses}") | ||
print(f"Link: https://crates.io/crates/{package}") |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,81 @@ | ||
import subprocess | ||
import json | ||
import re | ||
|
||
vcpkg_result = subprocess.run( | ||
['./vcpkg/vcpkg', 'depend-info', 'gtk'], | ||
capture_output=True) | ||
|
||
vcpkg_result.check_returncode() | ||
|
||
cargo_result = subprocess.run( | ||
['cargo', 'license', '--authors', '--do-not-bundle', '--color=never'], | ||
capture_output=True) | ||
|
||
cargo_result.check_returncode() | ||
|
||
packages = set() | ||
|
||
# Find all packages we depend on. | ||
for line in vcpkg_result.stderr.decode().rstrip().split('\n'): | ||
header, remainder = line.split(': ') | ||
package = header.split('[')[0] | ||
packages.add(package) | ||
dependencies = remainder.split(', ') | ||
packages |= set(dependencies) | ||
|
||
# Discard empty package names. | ||
packages.discard('') | ||
|
||
# Discard vcpkg build tools. | ||
packages = set(p for p in packages if not p.startswith('vcpkg-')) | ||
|
||
# gperf is needed to build fontconfig, but is not linked to. | ||
packages.discard('gperf') | ||
|
||
# gettext is needed to build many dependencies, but is not linked to. | ||
packages.discard('gettext') | ||
|
||
# getopt, pthread and pthreads are virtual packages. | ||
packages.discard('getopt') | ||
packages.discard('pthread') | ||
packages.discard('pthreads') | ||
|
||
# sassc is used to build GTK, but is not linked to. | ||
packages.discard('sassc') | ||
|
||
versions = {} | ||
|
||
# These packages are missing license information in vcpkg. | ||
licenses = { | ||
'libiconv': ['LGPL-2.1-or-later'], | ||
'egl-registry': ['Apache-2.0', 'MIT'], | ||
'liblzma': ['BSD-0-Clause'], | ||
'libsass': ['MIT'], | ||
} | ||
|
||
# These packages are missing homepage information in vcpkg. | ||
homepages = { | ||
'fribidi': 'https://github.com/fribidi/fribidi', | ||
} | ||
|
||
for package in packages: | ||
metadata = json.load(open(f'vcpkg/ports/{package}/vcpkg.json')) | ||
version = metadata.get('version-semver', | ||
metadata.get('version', | ||
metadata.get('version-date'))) | ||
if version is None: | ||
raise KeyError(f"Couldn't find a version for package {package}") | ||
versions[package] = version | ||
if metadata.get('homepage') is not None: | ||
homepages[package] = metadata['homepage'] | ||
if metadata.get('license') is not None: | ||
licenses[package] = metadata['license'].split(' OR ') | ||
|
||
print("The following libraries are dynamically linked into Packetry:") | ||
|
||
for package in sorted(packages): | ||
print() | ||
print(f"{package} version {versions[package]}") | ||
print(f"Homepage: {homepages[package]}") | ||
print(f"License: {str.join(' or ', licenses[package])}") |