Skip to content

Commit

Permalink
compression
Browse files Browse the repository at this point in the history
  • Loading branch information
alvindimas05 committed Aug 15, 2024
1 parent 87600ef commit e2056de
Show file tree
Hide file tree
Showing 5 changed files with 79 additions and 10 deletions.
23 changes: 17 additions & 6 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -20,18 +20,29 @@ jobs:
- uses: actions/checkout@v4
- uses: actions/setup-node@v4
with:
node-version: '20.11.0'
- uses: oven-sh/setup-bun@v2
- run: bun i
- run: bun run build
node-version: '18.19.0'
- name: Set up Homebrew
uses: Homebrew/actions/setup-homebrew@master
- name: Install Bun
uses: oven-sh/setup-bun@v2
- name: Install Brew dependencies
uses: brew install p7zip coreutils
- name: Build and Install
run: |
bun i
bun run build
- name: Compress executable
run: |
cp build/amdhelper .
tar c ./amdhelper | ./gz99 amdhelper.gz
- name: Publish release
if: ${{ github.event_name == 'workflow_dispatch' }}
uses: ncipollo/release-action@v1
with:
artifacts: ./build/amdhelper
artifacts: ./amdhelper.gz
tag: ${{ inputs.tag }}
name: AMDHelper ${{ inputs.tag }}
allowUpdates: true
artifactErrorsFailBuild: false
prerelease: true
token: ${{ secrets.GITHUB_TOKEN }}
token: ${{ secrets.GITHUB_TOKEN }}
4 changes: 3 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -166,4 +166,6 @@ dist
# Finder (MacOS) folder config
.DS_Store

build
build
amdhelper.gz
amdhelper.gz.new
4 changes: 3 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -28,4 +28,6 @@ to support Hackintosh on AMD iGPU.
- [tomnic](https://macos86.it/profile/69-tomnic/) for [guide](https://macos86.it/topic/5489-tutorial-for-patching-binaries-for-amd-hackintosh-compatibility/)
to patch apps that uses Intel MKL libraries.
- [NyaomiDEV](https://github.com/NyaomiDEV) for developing [AMDFriend](https://github.com/NyaomiDEV/AMDFriend)
to automatically patch apps that uses Intel MKL libraries.
to automatically patch apps that uses Intel MKL libraries.
- [gmatht](https://github.com/gmatht) for script code [gz99](https://github.com/gmatht/joshell/blob/master/scripts/gz99)
script for better compression.
53 changes: 53 additions & 0 deletions gz99
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
#!/bin/bash
set -e

command -v advdef > /dev/null || echo advdef is not installed. Install for a better compression ratio
command -v 7z > /dev/null || echo 7z is not installed. Install for a better compression ratio

if [ -z "$1" ]
then
echo "USAGE: $0 OUTPUT.gz"
echo "Compresses stdin to OUTPUT.gz"
exit 1
fi


OUT=$1

myhash(){
sha256sum $@ | sed s/\ .*//
}

time gzip -9 > $OUT.new
mv $OUT.new $OUT
ORIG_HASH=`gunzip < $OUT|myhash`

accept_new(){
if [ ".`gunzip < $OUT.new|myhash`" = ".$ORIG_HASH" ]
then
oldsize=$(stat -f%z "$OUT")
newsize=$(stat -f%z "$OUT.new")
if [ $oldsize -gt $newsize ]
then
echo "$oldsize->$newsize: Saved $((oldsize-newsize)) bytes."
mv -f $OUT.new $OUT
else
echo "$oldsize->$newsize: No savings, new file discarded."
fi
else
echo $OUT.new corrupt. Deleting.
rm $OUT.new
fi
}
echo Finished GZIP compression, you now have a complete gz file
echo You can stop here, but we will try to make the file smaller for you.
rm $OUT.new || true
#time 7z a $OUT.new -mx=9 -tgzip $OUT
gunzip < $OUT | time 7z a $OUT.new -mx=9 -tgzip -si
#time 7z a dummy -mx=9 -tgzip -so -si $OUT.new $OUT

accept_new
#cp $OUT $OUT.new
#echo Trying advdef compression
#time advdef -4 -z $OUT.new # instead link?
#accept_new
5 changes: 3 additions & 2 deletions install.sh
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
echo "Installing AMDHelper..."
curl -sSL https://github.com/alvindimas05/AMDHelper/releases/latest/download/amdhelper -o amdhelper
curl -sSL https://github.com/alvindimas05/AMDHelper/releases/latest/download/amdhelper.gz -o amdhelper.gz
tar -xvzf amdhelper.gz
chmod +x amdhelper
sudo mv amdhelper /usr/local/bin
echo "AMDHelper installed! Run the command below to start."
echo "sudo amdhelper"
echo "sudo amdhelper"

0 comments on commit e2056de

Please sign in to comment.