From a385480d8930115c240da64aa2f0f5eab9df2bc3 Mon Sep 17 00:00:00 2001 From: Azalea Gui Date: Tue, 23 Apr 2024 08:31:23 -0400 Subject: [PATCH] [+] Package fastfetch into hyfetch --- tools/build_bash.sh | 21 +++++++++---- tools/build_pkg.sh | 77 ++++++++++++++++++++++++++++++++++++++++----- 2 files changed, 84 insertions(+), 14 deletions(-) mode change 100644 => 100755 tools/build_bash.sh mode change 100644 => 100755 tools/build_pkg.sh diff --git a/tools/build_bash.sh b/tools/build_bash.sh old mode 100644 new mode 100755 index 2f381122..d22e8c0a --- a/tools/build_bash.sh +++ b/tools/build_bash.sh @@ -1,19 +1,28 @@ #!/usr/bin/env bash # This script is used to build a customized Git Bash for windows pacakge that only include bash and no other unnecessary files +set -e + # Get script directory DIR="$( cd -- "$( dirname -- "${BASH_SOURCE[0]}" )" &> /dev/null && pwd )" -cd $DIR/../dist +cd "$DIR/../dist" # Get the git distribution if it doesn't exist -if [ ! -f git.tar.bz2 ]; then +if [ ! -f /tmp/git.tar.bz2 ]; then # NOTE: Git for Windows v2.44 is the last release to support Windows 7 and 8 URL="https://github.com/git-for-windows/git/releases/download/v2.44.0.windows.1/Git-2.44.0-32-bit.tar.bz2" - wget $URL -O git.tar.bz2 + echo "> Downloading git distribution" + wget -q $URL -O /tmp/git.tar.bz2 fi # Unzip the git distribution to git directory # Ignore the unnecessary files -rm -rf git -mkdir git -tar -xvf git.tar.bz2 -C git --exclude-from="$DIR/bash_ignore.txt" \ No newline at end of file +# rm -rf git +if [ ! -d /tmp/git ]; then + mkdir -p /tmp/git + echo "> Unzipping git distribution" + tar -xf /tmp/git.tar.bz2 --exclude-from="$DIR/bash_ignore.txt" -C /tmp/git +fi + +# Copy the git distribution +cp -r /tmp/git ./git diff --git a/tools/build_pkg.sh b/tools/build_pkg.sh old mode 100644 new mode 100755 index e4c25231..cfd2978a --- a/tools/build_pkg.sh +++ b/tools/build_pkg.sh @@ -1,8 +1,11 @@ #!/usr/bin/env bash +FASTFETCH_VERSION="2.10.2" +FASTFETCH_DL="https://github.com/fastfetch-cli/fastfetch/releases/download/$FASTFETCH_VERSION/" + # Get script directory DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" >/dev/null 2>&1 && pwd )" -cd $DIR/.. +cd "$DIR/.." set -e @@ -17,29 +20,87 @@ rm -rf hyfetch/git/ python3 setup.py sdist bdist_wheel # Check -twine check dist/* +twine check dist/*.tar.gz +twine check dist/*.whl # ================= # Build for windows cd dist # Get the file name -file=$(ls | grep .whl) +# file="$(ls | grep .whl)" use glob instead +file=$(echo *-none-any.whl) # Build bash pacakge -$DIR/build_bash.sh +"$DIR/build_bash.sh" # Unzip the wheel -unzip $file -d wheel +echo "> Unzipping $file" +rm -rf wheel +unzip -qq "$file" -d wheel +# TODO: Find a way to exclude the tools folder +rm -rf wheel/tools # Copy the git distribution to the wheel cp -r git/ wheel/hyfetch/ +# Embed fastfetch binary +echo "> Embedding fastfetch binary" +wget -q "$FASTFETCH_DL/fastfetch-windows-i686.zip" -O fastfetch-windows.zip +mkdir -p wheel/hyfetch/fastfetch +bsdtar -zxf fastfetch-windows.zip -C wheel/hyfetch/fastfetch +rm -rf fastfetch-windows.zip + # Change the file name (replace -none-any with -win_amd64) -new_name="$(echo $file | sed 's/-none-any/-win32/')" +new_name=${file/-any/-win32} # Zip the wheel to win_amd64.whl -cd wheel && zip -y -r "../$new_name" * && cd .. +cd wheel && zip -qq -y -r "../$new_name" * && cd .. # Check again -twine check $new_name \ No newline at end of file +twine check "$new_name" + +# ================= +# Build for linux + +# Now we're done with windows, delete the git folder +rm -rf wheel/git + +function build_for_platform() { + ff_platform=$1 + wheel_platform=$2 + + echo "Building for $ff_platform" + + # Download the fastfetch binary + wget -q "$FASTFETCH_DL/fastfetch-$ff_platform.zip" -O "fastfetch-$ff_platform.zip" + + # Delete the old fastfetch folder + rm -rf wheel/hyfetch/fastfetch + + # Unzip the fastfetch binary + # unzip -qq "fastfetch-$ff_platform.zip" -d wheel/hyfetch/fastfetch + mkdir -p wheel/hyfetch/fastfetch + bsdtar -zxf "fastfetch-$ff_platform.zip" -C wheel/hyfetch/fastfetch --strip-components 1 + rm -rf "fastfetch-$ff_platform.zip" + + # Change the file name + new_name=${file/-any/-"$wheel_platform"} + + # Zip the wheel to platform.whl + cd wheel && zip -qq -y -r "../$new_name" * && cd .. + + # Check again + twine check "$new_name" +} + +# See https://packaging.python.org/en/latest/specifications/platform-compatibility-tags/ +build_for_platform "linux-amd64" "manylinux1_x86_64" +build_for_platform "linux-aarch64" "manylinux2014_aarch64" +# There doesn't seem to be tags for freebsd? +# build_for_platform "freebsd-amd64" "freebsd_x86_64" +# build_for_platform "freebsd-aarch64" "freebsd_aarch64" +build_for_platform "musl-amd64" "musllinux_1_1_x86_64" +build_for_platform "musl-aarch64" "musllinux_1_1_aarch64" +build_for_platform "macos-universal" "macosx_11_0_x86_64" +build_for_platform "macos-universal" "macosx_11_0_arm64"