From 3ae4b7b1f9ab4e8f9172854706baa6040280b917 Mon Sep 17 00:00:00 2001 From: endernon Date: Mon, 13 Jan 2025 22:14:36 +0000 Subject: [PATCH] build script yep --- .gitignore | 3 +++ build.sh | 54 ++++++++++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 57 insertions(+) create mode 100644 .gitignore create mode 100755 build.sh diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..21fd39e --- /dev/null +++ b/.gitignore @@ -0,0 +1,3 @@ +build +build.zip +*.zip diff --git a/build.sh b/build.sh new file mode 100755 index 0000000..732d3b7 --- /dev/null +++ b/build.sh @@ -0,0 +1,54 @@ +#!/bin/bash +# enable globbing properly +shopt -s extglob + +# create the build dir if it doesn't already exist +mkdir -p ./build + +# move all necessary files to the build dir +cp -r {assets,pack.png,pack.mcmeta} ./build + +# change working dir into the build dir +cd build + +# detect arch for downloading OxiPng +frfrarch=$(uname -m) +echo SYSTEM ARCHITECTURE IS $frarch +# get and use oxipng if it is available for your architecture +if [[ $frfrarch == "x86_64" ]]; then + echo "downloading oxipng x64" + wget -O oxipng.tar.gz https://github.com/shssoichiro/oxipng/releases/download/v9.1.3/oxipng-9.1.3-x86_64-unknown-linux-musl.tar.gz +elif [[ $frfrarch == "aarch64" ]]; then + echo "downloading oxipng arm64" + wget -O oxipng.tar.gz https://github.com/shssoichiro/oxipng/releases/download/v9.1.3/oxipng-9.1.3-aarch64-unknown-linux-musl.tar.gz +else + echo unknown architecture, oxipng wont be used +fi + +# banger size reduction on files in build dir yep +if [[ -e oxipng.tar.gz ]]; then + tar -xvzf oxipng.tar.gz + rm oxipng.tar.gz + mv ./oxipng* ./oxipngdir + mv ./oxipngdir/oxipng ./oxipng + chmod +x oxipng + oxipng -o max --strip all --alpha $(find . -name "*.png" -type f) + + # clean up the oxipng before build + rm -rf oxipng + rm -rf oxipngdir +fi + +# remove all the gimp files (those don't do anything in the final build) +find . -name "*.xcf" -type f -delete + +# zip all files in build dir recursively, into build.zip in base folder. use -0 flag to disable compression. +zip -r ../build.zip . -0 + +# change back to root dir +cd .. + +# nuke the build dir +rm -r build + +echo "file built to build.zip"