Skip to content

fix null terminate search #46

fix null terminate search

fix null terminate search #46

Workflow file for this run

name: Buildrunner
on: [push]
jobs:
build:
strategy:
matrix:
platform: [ubuntu-latest, macos-latest]
runs-on: ${{ matrix.platform }}
env:
BUILDROOT: "buildroot_${{ matrix.platform }}"
GIT_DEPENDENCIES: img3tool,img4tool,libgeneral,libinsn,libplist
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Install pre-dependencies
run: |
if [ "$RUNNER_OS" == "Linux" ]; then
sudo apt-get update
sudo apt-get install -y jq
wget https://github.com/apple-oss-distributions/cctools/archive/refs/tags/cctools-973.0.1.tar.gz -O cctools.tar.gz
mkdir tmp
tar -xvzf cctools.tar.gz -C tmp
mv tmp/cctoo* tmp/cctools
sed -i 's_#include_//_g' tmp/cctools/include/mach-o/loader.h
sed -i -e 's=<stdint.h>=\n#include <stdint.h>\ntypedef int integer_t;\ntypedef integer_t cpu_type_t;\ntypedef integer_t cpu_subtype_t;\ntypedef integer_t cpu_threadtype_t;\ntypedef int vm_prot_t;=g' tmp/cctools/include/mach-o/loader.h
sudo cp -r tmp/cctools/include/* /usr/local/include/
rm -rf tmp cctools.tar.gz
elif [ "$RUNNER_OS" == "macOS" ]; then
brew install autoconf automake libtool jq pkg-config
else
echo "$RUNNER_OS not supported"
exit 1
fi
shell: bash
- name: download dependencies
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
get_latest_release() {
url="https://github.com/gitapi/repos/$1/releases/latest"
echo "url: ${url}" >&2
curl --silent --header 'authorization: Bearer ${{ secrets.GITHUB_TOKEN }}' "${url}" | # Get latest release from GitHub api
jq .tag_name | # Get tag
tr -d '"' # Strip quotes
}
mkdir depdir
cd depdir
mkdir $BUILDROOT
IFS=',' read -r -a deparray <<< "$GIT_DEPENDENCIES"; for d in ${deparray[@]}; do
dep=$d
if ! echo ${dep} | grep -q '/'; then
dep=${{ github.repository_owner }}/${dep}
fi
echo "Got dependency: ${dep}"
tag=$(get_latest_release ${dep});
echo "Found tag: $tag"
wget "https://github.com/${dep}/releases/download/$tag/$BUILDROOT.zip"
unzip -u "$BUILDROOT.zip"
rm "$BUILDROOT.zip"
done
echo "moving dependencies to /"
sudo cp -r $BUILDROOT/* /
cd ..
rm -rf depdir
- name: prepre buildroot
run: mkdir -p $BUILDROOT
- name: autogen
run: ./autogen.sh --enable-static --disable-shared
- name: make
run: |
if [ "$RUNNER_OS" == "macOS" ]; then
IFS=',' read -r -a deparray <<< "$MAC_DYNAMIC_LIBS"; for d in ${deparray[@]}; do
echo "moving library $d"
cd $(brew --prefix $d)
find . -name "*.dylib" -exec mv {} {}.bak \;
done
cd $GITHUB_WORKSPACE
make -j || make
IFS=',' read -r -a deparray <<< "$MAC_DYNAMIC_LIBS"; for d in ${deparray[@]}; do
echo "restoring library $d"
cd $(brew --prefix $d)
find . -name "*.dylib.bak" | while read f; do o=$(echo $f | rev | cut -d '.' -f2- | rev); mv $f $o; done
done
cd $GITHUB_WORKSPACE
else
make -j || make
fi
- name: make install
run: make DESTDIR=$GITHUB_WORKSPACE/$BUILDROOT install
- uses: actions/upload-artifact@v4
with:
name: ${{ env.BUILDROOT }}
path: ${{ env.BUILDROOT }}
release:
needs: build
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Download ubuntu artifact
uses: actions/download-artifact@v4
with:
name: buildroot_ubuntu-latest
path: buildroot_ubuntu-latest
- name: Download macos artifact
uses: actions/download-artifact@v4
with:
name: buildroot_macos-latest
path: buildroot_macos-latest
- name: Set env vars and zip
run: |
echo "BUILD_VERSION_NUM=$(echo "$(git rev-list --count HEAD | tr -d '\n')")" >> $GITHUB_ENV
echo "BUILD_VERSION_SHA=$(echo "$(git rev-parse HEAD | tr -d '\n'])")" >> $GITHUB_ENV
echo "BUILD_VERSION_STR=$(echo "$(git rev-list --count HEAD | tr -d '\n')-$(git rev-parse HEAD | tr -d '\n'])")" >> $GITHUB_ENV
echo "COMMIT_MSG=$(echo "$(git log -1 --pretty=%B)")" >> $GITHUB_ENV
zip -r buildroot_macos-latest.zip buildroot_macos-latest
zip -r buildroot_ubuntu-latest.zip buildroot_ubuntu-latest
- name: Create Release
id: create_release
uses: softprops/action-gh-release@v2
if: github.ref == 'refs/heads/master'
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
prerelease: false
draft: false
tag_name: ${{ env.BUILD_VERSION_NUM }}
name: Build ${{ env.BUILD_VERSION_STR }}
body: ${{ env.COMMIT_MSG }}
files: |
buildroot_ubuntu-latest.zip
buildroot_macos-latest.zip