Skip to content
This repository has been archived by the owner on Apr 24, 2024. It is now read-only.

Commit

Permalink
Revert "style: formatting"
Browse files Browse the repository at this point in the history
This reverts commit a382d8e.
  • Loading branch information
IMXEren committed Mar 5, 2024
1 parent a382d8e commit 8a8318b
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 30 deletions.
4 changes: 2 additions & 2 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

48 changes: 20 additions & 28 deletions build_package.sh
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#!/usr/bin/bash

if [ -n "$TERMUX_VERSION" ]; then
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
Expand All @@ -14,25 +14,17 @@ cargo --version
current_dir="$(pwd)"
tmpdir="$(mktemp -d)"

cd $tmpdir || exit
cd $tmpdir

git clone https://github.com/IMXEren/competition-groups

if [ -n "$TERM" ]; then
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
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"
Expand All @@ -57,29 +49,27 @@ else
fi'

yes | pkg install -y pkg-config openssl binutils
cd competition-groups || exit
cd competition-groups
cargo build --release
bin_path="${tmpdir}/competition-groups/target/release/competition-groups"
package="compgroups"
zip_name="cgroups.zip"

cp -f "$bin_path" "${tmpdir}"/cgroups/${package}.bin

if [ $? -eq 0 ]; then
if [ -n "$TERMUX_VERSION" ]; then
termux-elf-cleaner "${tmpdir}"/cgroups/${package}.bin &>/dev/null
if [ -n $TERMUX_VERSION ]; then
termux-elf-cleaner ${tmpdir}/cgroups/${package}.bin &>/dev/null
fi
cd $current_dir || exit
cd $current_dir
rm -rf build/${zip_name} build/${package} build/${package}.bin build/lib-${package} &>/dev/null
mkdir -p build
cd build || exit
cp "${tmpdir}"/cgroups/${package}.bin .
cd build
cp ${tmpdir}/cgroups/${package}.bin .
if [ $? -ne 0 ]; then
rm -rf "$tmpdir" &>/dev/null
rm -rf $tmpdir &>/dev/null
echo "Error occured, exiting..."
exit 1
exit 1
fi
echo "$package_script" >${package}
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
Expand All @@ -88,21 +78,23 @@ if [ $? -eq 0 ]; then
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
rm -rf $tmpdir &>/dev/null
echo "Error occured, exiting..."
exit 1
fi

rm -rf "$tmpdir" &>/dev/null
rm -rf $tmpdir &>/dev/null


if [ -n "$TERMUX_VERSION" ]; then
if [ -n $TERMUX_VERSION ]; then
pkg clean
fi

mkdir -p ~/cgroups

7z x -aoa ${zip_name} -o"$HOME"/cgroups &>/dev/null
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"

0 comments on commit 8a8318b

Please sign in to comment.