diff --git a/Cargo.lock b/Cargo.lock index a99d8fd..0582d47 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -1171,7 +1171,7 @@ dependencies = [ [[package]] name = "thirtyfour" version = "0.32.0-rc.10" -source = "git+https://github.com/stevepryde/thirtyfour?rev=231ab54#231ab546a1153c4b87d0f422e18f2251b95da6be" +source = "git+https://github.com/stevepryde/thirtyfour#231ab546a1153c4b87d0f422e18f2251b95da6be" dependencies = [ "async-trait", "base64", @@ -1196,7 +1196,7 @@ dependencies = [ [[package]] name = "thirtyfour-macros" version = "0.1.1" -source = "git+https://github.com/stevepryde/thirtyfour?rev=231ab54#231ab546a1153c4b87d0f422e18f2251b95da6be" +source = "git+https://github.com/stevepryde/thirtyfour#231ab546a1153c4b87d0f422e18f2251b95da6be" dependencies = [ "proc-macro-error", "proc-macro2", diff --git a/build_package.sh b/build_package.sh index 9b06353..e7b0e85 100644 --- a/build_package.sh +++ b/build_package.sh @@ -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 @@ -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" @@ -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 @@ -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" +