diff --git a/build_scripts/build_license_directory.sh b/build_scripts/build_license_directory.sh new file mode 100644 index 0000000000..7650696ad5 --- /dev/null +++ b/build_scripts/build_license_directory.sh @@ -0,0 +1,55 @@ +#!/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 diff --git a/build_scripts/build_linux_deb-2-installer.sh b/build_scripts/build_linux_deb-2-installer.sh index 12da93a0f6..de62de714a 100644 --- a/build_scripts/build_linux_deb-2-installer.sh +++ b/build_scripts/build_linux_deb-2-installer.sh @@ -44,6 +44,12 @@ if [ "$LAST_EXIT_CODE" -ne 0 ]; then exit $LAST_EXIT_CODE fi +# Creates a directory of licenses +echo "Building pip and NPM license directory" +pwd +bash ./build_license_directory.sh + + # Builds CLI only .deb # need j2 for templating the control file pip install j2cli @@ -53,6 +59,7 @@ mkdir -p "dist/$CLI_DEB_BASE/usr/bin" mkdir -p "dist/$CLI_DEB_BASE/DEBIAN" j2 -o "dist/$CLI_DEB_BASE/DEBIAN/control" assets/deb/control.j2 cp -r dist/daemon/* "dist/$CLI_DEB_BASE/opt/chia/" + ln -s ../../opt/chia/chia "dist/$CLI_DEB_BASE/usr/bin/chia" dpkg-deb --build --root-owner-group "dist/$CLI_DEB_BASE" # CLI only .deb done diff --git a/build_scripts/build_linux_rpm-2-installer.sh b/build_scripts/build_linux_rpm-2-installer.sh index f820a79766..77f6a0bee3 100644 --- a/build_scripts/build_linux_rpm-2-installer.sh +++ b/build_scripts/build_linux_rpm-2-installer.sh @@ -42,11 +42,17 @@ if [ "$LAST_EXIT_CODE" -ne 0 ]; then exit $LAST_EXIT_CODE fi +# Creates a directory of licenses +echo "Building pip and NPM license directory" +pwd +bash ./build_license_directory.sh + # Builds CLI only rpm CLI_RPM_BASE="chia-blockchain-cli-$CHIA_INSTALLER_VERSION-1.$REDHAT_PLATFORM" mkdir -p "dist/$CLI_RPM_BASE/opt/chia" mkdir -p "dist/$CLI_RPM_BASE/usr/bin" cp -r dist/daemon/* "dist/$CLI_RPM_BASE/opt/chia/" + ln -s ../../opt/chia/chia "dist/$CLI_RPM_BASE/usr/bin/chia" # This is built into the base build image # shellcheck disable=SC1091 @@ -66,9 +72,7 @@ fpm -s dir -t rpm \ --depends /usr/lib64/libcrypt.so.1 \ . # CLI only rpm done - cp -r dist/daemon ../chia-blockchain-gui/packages/gui - # Change to the gui package cd ../chia-blockchain-gui/packages/gui || exit 1 diff --git a/build_scripts/build_macos-2-installer.sh b/build_scripts/build_macos-2-installer.sh index a827e0f811..a8f30ce50d 100644 --- a/build_scripts/build_macos-2-installer.sh +++ b/build_scripts/build_macos-2-installer.sh @@ -32,8 +32,14 @@ if [ "$LAST_EXIT_CODE" -ne 0 ]; then echo >&2 "pyinstaller failed!" exit $LAST_EXIT_CODE fi -cp -r dist/daemon ../chia-blockchain-gui/packages/gui + +# Creates a directory of licenses +echo "Building pip and NPM license directory" +pwd +bash ./build_license_directory.sh + +cp -r dist/daemon ../chia-blockchain-gui/packages/gui # Change to the gui package cd ../chia-blockchain-gui/packages/gui || exit 1 diff --git a/build_scripts/build_win_license_dir.sh b/build_scripts/build_win_license_dir.sh new file mode 100644 index 0000000000..1c59d4ac42 --- /dev/null +++ b/build_scripts/build_win_license_dir.sh @@ -0,0 +1,54 @@ +#!/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/$(basename "$(dirname "$i")")" + echo "$dirname" + mkdir -p "$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/$(basename "$(dirname "$i")")" + echo "$dirname" + mkdir -p "$dirname" + cp "$i" "$dirname" + echo "$i" +done + +ls -lah dist/daemon diff --git a/build_scripts/build_windows-2-installer.ps1 b/build_scripts/build_windows-2-installer.ps1 index f6a8d9f562..e4d86884f4 100644 --- a/build_scripts/build_windows-2-installer.ps1 +++ b/build_scripts/build_windows-2-installer.ps1 @@ -20,6 +20,11 @@ Write-Output " ---" $SPEC_FILE = (python -c 'import chia; print(chia.PYINSTALLER_SPEC_PATH)') -join "`n" pyinstaller --log-level INFO $SPEC_FILE +Write-Output " ---" +Write-Output "Creating a directory of licenses from pip and npm packages" +Write-Output " ---" +bash ./build_win_license_dir.sh + Write-Output " ---" Write-Output "Copy chia executables to chia-blockchain-gui\" Write-Output " ---"