chia-blockchain/build_scripts/build_license_directory.sh
Patrick Maslana 3a2dc484b5
Generate a license directory that contains licenses missing from the installers (#15146)
* Add scripts to build a tree of licenses that are missing from the installers

* Add a line that was accidentally removed

* add steps in the build_license_directory script to install pip-licenses and license-checker

* Pip install pip-license

* Added commands to check the working dir in the build_license_direcotory.sh

* Fix the path for the npm commands

* Copy the library dir over

* Add a line to cd back to the previous dir in the build_licenses_directory.sh file

* Fix path to go back to "build_scripts"

* Fixing a typo with a path in the build_license_directory.sh file

* Troubleshoot path

* Change word from library to licenses

* Add a command to list contents of "dist/$CLI_DEB_BASE/opt/chia/" for troubleshooting

* Copy the license file to the "GUI" directory

* Fix the last for loop

* Move the step to change directory back to build scripts in the build_license_directory.sh file

* Add some more steps to troubleshoot the path and license-checker usage

* Fix a typo

* Add an "npm install ." before running the license-checker

* Fix a typo

* Change back to the build_scripts dir before the first loop in build_license_directory.sh file

* Revert "Change back to the build_scripts dir before the first loop in build_license_directory.sh file"

This reverts commit a3e88a2583.

* Fix the path for moving the license file

* Change the first loop for printing licenses from npm license-checker

* Add steps to copy the license file over to the builds and comment out the "npm install ." step out of the build_license_firectory script

* Add npm ci to the build_license_directory file

* Adding a dir for troubleshooting

* Fix errors in the scripts

* Fix a path to the licenses file

* Remove a dir from the windows installer script

* Remove a copy command

* Remove a few more copy commands

* Adding a ps1 script for usage in the windows installer build script

* Replace the powershell script

* Made a couple changes to the ps1 script for building the license directory

* Remove the ps1 script for building the license dir

* Add a new script for the windows installer to build the license dir

* Fix issues with the code for windows

* Remove the -1 from NF

* Changing the script for windows to test

* Remove filename=$(basename "$i")

* Remove some ls command lines

* Add "cp -r dist/daemon ../chia-blockchain-gui/packages/gui" to the RPM installer script

* Remove "|| 'exit" or "cd' || return" from when CD'ing in the license creation scripts

* Remove extra set of ||
2023-06-21 16:51:05 -05:00

56 lines
1.4 KiB
Bash

#!/bin/bash
# PULL IN LICENSES USING NPM - LICENSE CHECKER
npm install -g license-checker
cd ../chia-blockchain-gui || exit 1
npm ci
sum=$(license-checker --summary)
printf "%s\n" "$sum"
license_list=$(license-checker --json | jq -r '.[].licenseFile' | grep -v null)
# Split the license list by newline character into an array
IFS=$'\n' read -rd '' -a licenses_array <<< "$license_list"
#print the contents of the array
printf '%s\n' "${licenses_array[@]}"
for i in "${licenses_array[@]}"; do
dirname="licenses/$(dirname "$i" | awk -F'/' '{print $NF}')"
mkdir -p "$dirname"
echo "$dirname"
cp "$i" "$dirname"
done
mv licenses/ ../build_scripts/dist/daemon
cd ../build_scripts || exit 1
# PULL IN THE LICENSES FROM PIP-LICENSE
pip install pip-licenses || pip3 install pip-licenses
# capture the output of the command in a variable
output=$(pip-licenses -l -f json | jq -r '.[].LicenseFile' | grep -v UNKNOWN)
# initialize an empty array
license_path_array=()
# read the output line by line into the array
while IFS= read -r line; do
license_path_array+=("$line")
done <<< "$output"
# create a dir for each license and copy the license file over
for i in "${license_path_array[@]}"; do
dirname="dist/daemon/licenses/$(dirname "$i" | awk -F'/' '{print $NF}')"
echo "$dirname"
mkdir -p "$dirname"
cp "$i" "$dirname"
echo "$i"
done
ls -lah dist/daemon