|
| 1 | +#!/data/data/com.termux/files/usr/bin/sh |
| 2 | + |
| 3 | +# SETUP POINTLESS REPO |
| 4 | + |
| 5 | +# Update and install required packages |
| 6 | +apt-get update |
| 7 | +apt-get --assume-yes upgrade |
| 8 | +apt-get --assume-yes install coreutils gnupg apt-transport-https |
| 9 | + |
| 10 | +# Create sources.list.d directory if it doesn't exist |
| 11 | +mkdir -p $PREFIX/etc/apt/sources.list.d |
| 12 | + |
| 13 | +# Write the appropriate source file based on the repository policy |
| 14 | +if apt-cache policy | grep -q "termux.*24\|termux.org\|bintray.*24\|k51qzi5uqu5dg9vawh923wejqffxiu9bhqlze5f508msk0h7ylpac27fdgaskx"; then |
| 15 | + echo "deb https://its-pointless.github.io/files/24 termux extras" > $PREFIX/etc/apt/sources.list.d/pointless.list |
| 16 | +else |
| 17 | + echo "deb https://its-pointless.github.io/files/21 termux extras" > $PREFIX/etc/apt/sources.list.d/pointless.list |
| 18 | +fi |
| 19 | + |
| 20 | +# Add the signing key from the pointless repository |
| 21 | +if command -v curl > /dev/null; then |
| 22 | + curl -sLo $PREFIX/etc/apt/trusted.gpg.d/pointless.gpg --create-dirs https://its-pointless.github.io/pointless.gpg |
| 23 | +elif command -v wget > /dev/null; then |
| 24 | + wget -qP $PREFIX/etc/apt/trusted.gpg.d https://its-pointless.github.io/pointless.gpg |
| 25 | +fi |
| 26 | + |
| 27 | +# Update apt |
| 28 | +apt update |
| 29 | + |
| 30 | +# Install development tools |
| 31 | +pkg install -y rust libgcc build-essential binutils make |
| 32 | + |
| 33 | +# Build Sonic |
| 34 | +export RUSTFLAGS="-C link-args=-Wl,--allow-multiple-definition" |
| 35 | +export TARGET_ARCH="aarch64-linux-android" |
| 36 | + |
| 37 | +# Parse script arguments |
| 38 | +while [ "$1" != "" ]; do |
| 39 | + argument_key=$(echo $1 | awk -F= '{print $1}') |
| 40 | + argument_value=$(echo $1 | awk -F= '{print $2}') |
| 41 | + case $argument_key in |
| 42 | + -g | --git) |
| 43 | + GIT_REPO="$argument_value" |
| 44 | + ;; |
| 45 | + *) |
| 46 | + echo "Unknown argument received: '$argument_key'" |
| 47 | + exit 1 |
| 48 | + ;; |
| 49 | + esac |
| 50 | + shift |
| 51 | +done |
| 52 | + |
| 53 | +# Ensure Git repository is provided |
| 54 | +if [ -z "$GIT_REPO" ]; then |
| 55 | + echo "No GitHub repository provided. Use '-g' or '--git' to specify it." |
| 56 | + exit 1 |
| 57 | +fi |
| 58 | + |
| 59 | +# Extract project name from Git repository URL |
| 60 | +project_name=$(basename "$GIT_REPO" .git) |
| 61 | +echo "Project: $project_name" |
| 62 | + |
| 63 | +# Clone repository if not already cloned |
| 64 | +if [ ! -d "$project_name" ]; then |
| 65 | + echo "Cloning repository from $GIT_REPO..." |
| 66 | + git clone "$GIT_REPO" |
| 67 | +fi |
| 68 | + |
| 69 | +# Navigate to the project directory |
| 70 | +pushd "$project_name" > /dev/null |
| 71 | + |
| 72 | +# Define the release function |
| 73 | +release_for_architecture() { |
| 74 | + local target_dir="target/$TARGET_ARCH/release" |
| 75 | + local final_tar="v${project_name}.tar.gz" |
| 76 | + |
| 77 | + cargo build --release --target "$TARGET_ARCH" |
| 78 | + mkdir -p release_output |
| 79 | + cp -p "$target_dir/$project_name" release_output/ |
| 80 | + tar --owner=0 --group=0 -czvf "$final_tar" -C release_output . |
| 81 | + local release_result=$? |
| 82 | + |
| 83 | + if [ $release_result -eq 0 ]; then |
| 84 | + echo "Successfully packed: $final_tar" |
| 85 | + else |
| 86 | + echo "Error: Packing failed." |
| 87 | + fi |
| 88 | + |
| 89 | + return $release_result |
| 90 | +} |
| 91 | + |
| 92 | +# Execute the release process |
| 93 | +echo "Building and packaging for $TARGET_ARCH..." |
| 94 | +release_for_architecture |
| 95 | +build_result=$? |
| 96 | + |
| 97 | +# Clean up and exit |
| 98 | +popd > /dev/null |
| 99 | +exit $build_result |
0 commit comments