Add gitlab CI stuff for binary mode

This makes gitlab auto build binary mode packages for the stable branch.
This commit is contained in:
TotallyNotElite 2020-05-24 19:50:21 +02:00
parent d69453186e
commit 1d5c30b2df
4 changed files with 92 additions and 0 deletions

26
.gitlab-ci.yml Normal file
View File

@ -0,0 +1,26 @@
# File responsible for building the cathook "binary package"
image: "nullworks/cathook-ci-ubuntu:latest"
variables:
GIT_SUBMODULE_STRATEGY: recursive
stages:
- build
pages:
script:
# Build cathook
- mkdir build_cathook && pushd build_cathook && cmake .. && make && popd
# Create the "package" containing everything needed
- mkdir package && mv ./bin/libcathook.so ./package/libcathook.so && mv ./data ./package/data && mv ./config_data ./package/config_data && mv ./scripts/binarypackage/install ./package/install && mv ./scripts/binarypackage/attach ./package/attach
# Build a static gdb
- mkdir build_gdb && pushd build_gdb && wget http://ftp.gnu.org/gnu/gdb/gdb-9.1.tar.xz -O gdb.tar.xz && tar xf gdb.tar.xz --strip-components 1 && mkdir build && pushd build && ../configure --prefix=<> --enable-static=yes --enable-inprocess-agent=no CFLAGS="-static -Os -s" CXXFLAGS="-Os -s -static" && make && popd && popd
# Create public directory
- mkdir public && tar -czf ./public/package.tar.gz ./package/ && mv ./build_gdb/build/gdb/gdb ./public/gdb
artifacts:
paths:
- public
expire_in: 1 weeks
stage: build
only:
- stable

62
scripts/binarypackage/attach Executable file
View File

@ -0,0 +1,62 @@
#!/usr/bin/env bash
# Error codes:
# 1 Generic
# 2 TF2 not running
set -e
[[ ! -z "$SUDO_USER" ]] && RUNUSER="$SUDO_USER" || RUNUSER="$LOGNAME"
line=$(pgrep -u $RUNUSER hl2_linux || true)
arr=($line)
if [ $# == 1 ]; then
proc=$1
else
if [ ${#arr[@]} == 0 ]; then
echo TF2 isn\'t running!
exit 2
fi
proc=${arr[0]}
fi
echo Running instances: "${arr[@]}"
echo Attaching to "$proc"
#sudo ./detach $inst bin/libcathook.so
#if grep -q "$(realpath bin/libcathook.so)" /proc/"$proc"/maps; then
# echo already loaded
# exit
#fi
# pBypass for crash dumps being sent
# You may also want to consider using -nobreakpad in your launch options.
mkdir -p /tmp/dumps # Make it as root if it doesnt exist
chown root:root /tmp/dumps # Claim it as root
chmod 000 /tmp/dumps # No permissions
FILENAME="/tmp/.gl$(head /dev/urandom | tr -dc 'a-zA-Z0-9' | head -c 6)"
cp "libcathook.so" "$FILENAME"
echo loading "$FILENAME" to "$proc"
gdbbin="gdb"
if ! [ -x "$(command -v gdb)" ]; then
gdbbin="../gdb"
chmod +x "$gdbbin"
fi
$gdbbin -n -q -batch \
-ex "attach $proc" \
-ex "set \$dlopen = (void*(*)(char*, int)) dlopen" \
-ex "call \$dlopen(\"$FILENAME\", 1)" \
-ex "call dlerror()" \
-ex 'print (char *) $2' \
-ex "detach" \
-ex "quit"
rm $FILENAME

3
scripts/binarypackage/install Executable file
View File

@ -0,0 +1,3 @@
#!/bin/bash
\cp -rf ./data/ ../
\cp -nr ./config_data/* ../data

View File

@ -0,0 +1 @@
Just some scripts used by the "binary" version of cathook available in cathook-gui. Ignore this if you are just using cathook.