This repository has been archived by the owner on Apr 24, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
3 changed files
with
168 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,69 @@ | ||
name: Build Executable | ||
|
||
on: | ||
workflow_dispatch: | ||
|
||
concurrency: | ||
group: build-comp-groups | ||
|
||
jobs: | ||
build_exec: | ||
needs: get_commit_hash | ||
runs-on: ubuntu-latest | ||
permissions: | ||
contents: write | ||
strategy: | ||
matrix: | ||
platform: [arm, aarch64, i686, x86_64] | ||
|
||
steps: | ||
- name: Install Docker | ||
run: | | ||
sudo apt-get update | ||
sudo apt-get install -y ca-certificates curl gnupg | ||
sudo install -m 0755 -d /etc/apt/keyrings | ||
curl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo gpg --dearmor -o /etc/apt/keyrings/docker.gpg | ||
sudo chmod a+r /etc/apt/keyrings/docker.gpg | ||
echo "deb [arch=\"$(dpkg --print-architecture)\" signed-by=/etc/apt/keyrings/docker.gpg] https://download.docker.com/linux/ubuntu $(. /etc/os-release && echo \"$VERSION_CODENAME\") stable" | sudo tee /etc/apt/sources.list.d/docker.list > /dev/null | ||
sudo apt-get update | ||
sudo apt-get install docker-ce docker-ce-cli containerd.io docker-buildx-plugin docker-compose-plugin | ||
- name: Set Build Architecture | ||
run: | | ||
if [ "${{ matrix.platform }}" = "aarch64" ]; then | ||
echo "arch_name=arm64" >> $GITHUB_ENV | ||
elif [ "${{ matrix.platform }}" = "i686" ]; then | ||
echo "arch_name=x86" >> $GITHUB_ENV | ||
else | ||
echo "arch_name=${{ matrix.platform }}" >> $GITHUB_ENV | ||
fi | ||
- name: Build Competition Groups | ||
run: | | ||
mkdir -p build | ||
# Support for ARM and AARCH64 | ||
if [[ "${{ matrix.platform }}" == "arm" || "${{ matrix.platform }}" == "aarch64" ]]; then | ||
docker pull aptman/qus | ||
docker run --rm --privileged aptman/qus -s -- -p arm aarch64 | ||
fi | ||
docker pull termux/termux-docker:${{ matrix.platform }} | ||
docker run --privileged --name cgroups-${{ matrix.platform }} termux/termux-docker:${{ matrix.platform }} bash -c "yes | pkg upgrade -y && pkg install -y git && git clone https://github.com/IMXEren/competition-groups --depth 1 repo && cd repo && bash build_package.sh" | ||
docker cp cgroups-${{ matrix.platform }}:/data/data/com.termux/files/home/repo/build/cgroups.zip build/cgroups-${{ env.arch_name }}.zip | ||
- name: Upload Artifact | ||
uses: actions/upload-artifact@v3 | ||
with: | ||
name: cgroups-${{ env.arch_name }} | ||
path: build/cgroups-${{ env.arch_name }}.zip | ||
|
||
- name: Upload Release | ||
uses: svenstaro/upload-release-action@v2 | ||
with: | ||
repo_token: ${{ secrets.GITHUB_TOKEN }} | ||
file: build/cgroups-${{ env.arch_name }}.zip | ||
asset_name: cgroups-${{ env.arch_name }}.zip | ||
tag: "Assets" | ||
release_name: "Assets for Project" | ||
overwrite: true |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,98 @@ | ||
#!/usr/bin/bash | ||
|
||
if [ -n $TERMUX_VERSION ]; then | ||
apt update | ||
yes | pkg install -y git rust termux-elf-cleaner p7zip 2>/dev/null | grep -E '(Need to get |Get:|Unpacking |Setting up )' | ||
else | ||
echo "The script should run on Termux" | ||
exit 1 | ||
fi | ||
|
||
rustc --version | ||
cargo --version | ||
|
||
current_dir="$(pwd)" | ||
tmpdir="$(mktemp -d)" | ||
|
||
cd $tmpdir | ||
|
||
git clone https://github.com/IMXEren/competition-groups | ||
|
||
if [ -n $TERM ]; then | ||
clear | ||
fi | ||
|
||
# fix Termux permissions | ||
if [ -n $TERMUX_VERSION ]; then | ||
value="true"; key="allow-external-apps"; file="/data/data/com.termux/files/home/.termux/termux.properties"; mkdir -p "$(dirname "$file")"; chmod 700 "$(dirname "$file")"; if ! grep -E '^'"$key"'=.*' $file &>/dev/null; then [[ -s "$file" && ! -z "$(tail -c 1 "$file")" ]] && newline=$'\n' || newline=""; echo "$newline$key=$value" >> "$file"; else sed -i'' -E 's/^'"$key"'=.*/'"$key=$value"'/' $file; fi | ||
fi | ||
|
||
echo -e "\nFinal step, building compgroups binary. Takes about 10s~1min" | ||
|
||
package_script='#!/system/bin/sh | ||
dir="$(cd "$(dirname "$0")"; pwd)" | ||
bin_name="$(basename "$0")" | ||
chmod 744 "$0" &>/dev/null | ||
chmod 744 "$dir/${bin_name}.bin" &>/dev/null | ||
export LD_LIBRARY_PATH="$dir/lib-${bin_name}:$LD_LIBRARY_PATH" | ||
if [ $(getprop ro.build.version.sdk) -gt 28 ]; then | ||
if getprop ro.product.cpu.abilist | grep -q "64" | ||
then | ||
exec /system/bin/linker64 "$dir/${bin_name}.bin" "$@" | ||
else | ||
exec /system/bin/linker "$dir/${bin_name}.bin" "$@" | ||
fi | ||
else | ||
exec "$dir/${bin_name}.bin" "$@" | ||
fi' | ||
|
||
cargo build --release | ||
bin_path="${tmpdir}/competition-groups/target/release/competition-groups" | ||
package="compgroups" | ||
zip_name="cgroups.zip" | ||
|
||
if [ $? -eq 0 ]; then | ||
if [ -n $TERMUX_VERSION ]; then | ||
termux-elf-cleaner ${tmpdir}/cgroups/${package}.bin &>/dev/null | ||
fi | ||
cd $current_dir | ||
rm -rf build/${zip_name} build/${package} build/${package}.bin build/lib-${package} &>/dev/null | ||
mkdir -p build | ||
cd build | ||
cp ${tmpdir}/cgroups/${package}.bin . | ||
if [ $? -ne 0 ]; then | ||
rm -rf $tmpdir &>/dev/null | ||
echo "Error occured, exiting..." | ||
exit 1 | ||
fi | ||
echo "$package_script" > ${package} | ||
for libpath in $(ldd ${package}.bin | grep -F "/data/data/com.termux/" | sed "s/.* //g"); do | ||
cp -L "$libpath" lib-${package} &>/dev/null | ||
done | ||
echo -e "\n Zipping package..." | ||
chmod 744 ${package} ${package}.bin &>/dev/null | ||
7z a -tzip -mx=9 -bd -bso0 ${zip_name} ${package} ${package}.bin lib-${package} | ||
rm -rf ${package} ${package}.bin lib-${package} &>/dev/null | ||
else | ||
rm -rf $tmpdir &>/dev/null | ||
echo "Error occured, exiting..." | ||
exit 1 | ||
fi | ||
|
||
rm -rf $tmpdir &>/dev/null | ||
|
||
|
||
if [ -n $TERMUX_VERSION ]; then | ||
pkg clean | ||
fi | ||
|
||
mkdir -p ~/cgroups | ||
|
||
7z x -aoa ${zip_name} -o$HOME/cgroups &>/dev/null | ||
|
||
chmod 744 ~/cgroups/compgroups | ||
|
||
echo -e "All done! You can type this -\n \n\" cd ~/cgroups; ./compgroups \"\n\nType without quotes to run executable\n" | ||
|