research how to go faster in mobile development #151

Open
opened 2024-12-29 20:58:49 +00:00 by despiegk · 1 comment
Owner

1. poc flutter installer for termux (android)

  • can we make a flutter app which checks termux is installed, if not ask to install
  • then once installed can we automate e.g. the deployment of the script below
  • can we manage the dir's which termux uses, in other words can we install more than 1 session
  • can we from flutter execute commands in the termux

1.b. use adb

  • see how we can use adb to do same as above
  • install the termux
  • get the bash script in termux
  • basically developers can with nothing as adb drive everything we need

2. compatibility of our compile in termux

  • installing in termux e.g. rust or vlang works very well
  • if we compile an example small app static, can we copy it out and use directly from the flutter app on the host os
    • in other words if we would bundle the binary e.g. vlang bin, can we talk to it over e.g. openrpc over sockets or command line with json in/out or ... , basically we are testing here if for development we can do in termux and then bundle with the flutter app so we can go faster?

3. fork termux

  • how easy is it to fork a termux, so we e.g run it underneith another app and don't show the inside
  • we could use this to run our stuff like in a sandbox, still compatible with linux
  • and packag it as apk ourselves
  • if easy can we make procedure how to do it on an ubuntu 24.04 inside our grid

4. vab

  • can we test https://github.com/vlang/vab/tree/master
  • can we directly compile vlang for android
  • see how to do this on cloud linux machine in tfgrid, document all properly
  • some v-scripts would be ideal

5. vlang & ios

  • how can we get vlang compiled or rust compiled progs to work in ios? if at all?
  • is less important because our secure phones will be android

6. grid as build env for mobile development

  • a script to deploy a VM on tfgrid
  • deploy full build env which can compile rust, vlang & flutter all for mobile (reproducible ideal would be vsh - vlang script)
  • then compile example apps and bundle them inside flutter and create apk
  • install codeserver (vscode, see what is best version), so its easy for people to collab on it
  • we basically compile for android on a cloud machine

IMPLEMENTATION INFO

driver of the script

this starts a webserver which then allows the install of the script below in termux (script was called termuxinstall.sh)

we install in termux through curl -s http://$ip_addr:8080/termuxinstall.sh > /install.sh && bash /install.sh

the webserver:

#!/bin/bash

# Get IP address
ip_addr=$(ifconfig | grep -Eo 'inet (addr:)?([0-9]*\.){3}[0-9]*' | grep -Eo '([0-9]*\.){3}[0-9]*' | grep -v '127.0.0.1' | head -n 1)

if [ -z "$ip_addr" ]; then
    echo "Could not determine IP address"
    exit 1
fi

echo "Starting HTTP server..."
echo "Your IP address is: $ip_addr"
echo "Server will be available at: http://$ip_addr:8080/termuxinstall.sh"
echo ""
echo "To download and run the script, use:"
echo "curl -s http://$ip_addr:8080/termuxinstall.sh > /install.sh && bash /install.sh"

# Change to the tools directory and start the server
cd "$(dirname "$0")" && pnpm dlx http-server . -p 8080

example script to install in termux

the termuxinstall.sh:

#!/bin/bash
set -ex

# Ensure script is executed in Termux
if [ -z "$TERMUX_VERSION" ]; then
  echo "This script must be run in Termux. Exiting."
  exit 1
fi

# Function to handle errors
handle_error() {
  echo "Error: $1"
  exit 1
}

# Update and upgrade packages using Termux package management
echo "Updating package list and upgrading installed packages..."
pkg update -y || handle_error "Failed to update package list"
pkg upgrade -y || handle_error "Failed to upgrade packages"

# Install essential utilities
echo "Installing utilities: mc, htop, wget, curl..."
pkg install -y mc htop wget curl termux-gui-bash || handle_error "Failed to install utilities"

# Install OpenSSH SSH server
echo "Installing OpenSSH SSH server..."
pkg install -y openssh || handle_error "Failed to install OpenSSH"

# Define SSH port
SSH_PORT=8022  # Termux default port

# Check and handle existing dropbear
if command -v dropbear >/dev/null 2>&1; then
    echo "Found existing dropbear installation, removing..."
    if pgrep dropbear >/dev/null; then
        pkill dropbear || handle_error "Failed to stop dropbear"
    fi
    pkg uninstall -y dropbear || handle_error "Failed to uninstall dropbear"
fi

# Setup SSH directory and authorized_keys
SSHDIR="$HOME/.ssh"
mkdir -p "$SSHDIR"
chmod 700 "$SSHDIR"

# Add authorized key
echo "Adding authorized SSH key..."
AUTHKEYS="$SSHDIR/authorized_keys"
echo "ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAIIahWiRRm9cWAKktH9dndn3R45grKqzPC3mKX8IjGgH6 kristof@incubaid.com" > "$AUTHKEYS"
chmod 600 "$AUTHKEYS"

# Set password non-interactively (Termux specific)
echo "Setting default password..."
export PASSWORD="planet007"
(echo "${PASSWORD}"; echo "${PASSWORD}") | passwd || handle_error "Failed to set password"

# Start SSH server
echo "Starting SSH server on port $SSH_PORT..."
sshd -p $SSH_PORT || handle_error "Failed to start SSH server"

termux-setup-storage


pkg install libgc rust

# Display the current IP address
echo "Fetching IP address..."
IP_ADDR=$(ifconfig 2>/dev/null | grep -Eo 'inet (addr:)?([0-9]*\.){3}[0-9]*' | grep -Eo '([0-9]*\.){3}[0-9]*' | grep -v '127.0.0.1' | head -n 1)
if [ -z "$IP_ADDR" ]; then
    echo "Could not determine IP address automatically"
    echo "Please check your IP address manually using 'ip addr'"
else
    echo "Your IP address is: $IP_ADDR"
    echo ""
    echo "SSH connection details:"
    echo "  - Host: $IP_ADDR"
    echo "  - Port: $SSH_PORT"
    echo "  - Password: planet007"
    echo "  - Key authentication is enabled"
    echo ""
    echo "Example SSH commands:"
    echo "  With password: ssh user@$IP_ADDR -p $SSH_PORT"
    echo "  With key: ssh -i /path/to/private/key user@$IP_ADDR -p $SSH_PORT"
fi

echo "Setup completed successfully!"

## 1. poc flutter installer for termux (android) - can we make a flutter app which checks termux is installed, if not ask to install - then once installed can we automate e.g. the deployment of the script below - can we manage the dir's which termux uses, in other words can we install more than 1 session - can we from flutter execute commands in the termux ## 1.b. use adb - see how we can use adb to do same as above - install the termux - get the bash script in termux - basically developers can with nothing as adb drive everything we need ## 2. compatibility of our compile in termux - installing in termux e.g. rust or vlang works very well - if we compile an example small app static, can we copy it out and use directly from the flutter app on the host os - in other words if we would bundle the binary e.g. vlang bin, can we talk to it over e.g. openrpc over sockets or command line with json in/out or ... , basically we are testing here if for development we can do in termux and then bundle with the flutter app so we can go faster? ## 3. fork termux - how easy is it to fork a termux, so we e.g run it underneith another app and don't show the inside - we could use this to run our stuff like in a sandbox, still compatible with linux - and packag it as apk ourselves - if easy can we make procedure how to do it on an ubuntu 24.04 inside our grid ## 4. vab - can we test https://github.com/vlang/vab/tree/master - can we directly compile vlang for android - see how to do this on cloud linux machine in tfgrid, document all properly - some v-scripts would be ideal ## 5. vlang & ios - how can we get vlang compiled or rust compiled progs to work in ios? if at all? - is less important because our secure phones will be android ## 6. grid as build env for mobile development - a script to deploy a VM on tfgrid - deploy full build env which can compile rust, vlang & flutter all for mobile (reproducible ideal would be vsh - vlang script) - then compile example apps and bundle them inside flutter and create apk - install codeserver (vscode, see what is best version), so its easy for people to collab on it - we basically compile for android on a cloud machine # IMPLEMENTATION INFO ### driver of the script this starts a webserver which then allows the install of the script below in termux (script was called termuxinstall.sh) we install in termux through ```curl -s http://$ip_addr:8080/termuxinstall.sh > /install.sh && bash /install.sh``` the webserver: ```bash #!/bin/bash # Get IP address ip_addr=$(ifconfig | grep -Eo 'inet (addr:)?([0-9]*\.){3}[0-9]*' | grep -Eo '([0-9]*\.){3}[0-9]*' | grep -v '127.0.0.1' | head -n 1) if [ -z "$ip_addr" ]; then echo "Could not determine IP address" exit 1 fi echo "Starting HTTP server..." echo "Your IP address is: $ip_addr" echo "Server will be available at: http://$ip_addr:8080/termuxinstall.sh" echo "" echo "To download and run the script, use:" echo "curl -s http://$ip_addr:8080/termuxinstall.sh > /install.sh && bash /install.sh" # Change to the tools directory and start the server cd "$(dirname "$0")" && pnpm dlx http-server . -p 8080 ``` ### example script to install in termux the termuxinstall.sh: ```bash #!/bin/bash set -ex # Ensure script is executed in Termux if [ -z "$TERMUX_VERSION" ]; then echo "This script must be run in Termux. Exiting." exit 1 fi # Function to handle errors handle_error() { echo "Error: $1" exit 1 } # Update and upgrade packages using Termux package management echo "Updating package list and upgrading installed packages..." pkg update -y || handle_error "Failed to update package list" pkg upgrade -y || handle_error "Failed to upgrade packages" # Install essential utilities echo "Installing utilities: mc, htop, wget, curl..." pkg install -y mc htop wget curl termux-gui-bash || handle_error "Failed to install utilities" # Install OpenSSH SSH server echo "Installing OpenSSH SSH server..." pkg install -y openssh || handle_error "Failed to install OpenSSH" # Define SSH port SSH_PORT=8022 # Termux default port # Check and handle existing dropbear if command -v dropbear >/dev/null 2>&1; then echo "Found existing dropbear installation, removing..." if pgrep dropbear >/dev/null; then pkill dropbear || handle_error "Failed to stop dropbear" fi pkg uninstall -y dropbear || handle_error "Failed to uninstall dropbear" fi # Setup SSH directory and authorized_keys SSHDIR="$HOME/.ssh" mkdir -p "$SSHDIR" chmod 700 "$SSHDIR" # Add authorized key echo "Adding authorized SSH key..." AUTHKEYS="$SSHDIR/authorized_keys" echo "ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAIIahWiRRm9cWAKktH9dndn3R45grKqzPC3mKX8IjGgH6 kristof@incubaid.com" > "$AUTHKEYS" chmod 600 "$AUTHKEYS" # Set password non-interactively (Termux specific) echo "Setting default password..." export PASSWORD="planet007" (echo "${PASSWORD}"; echo "${PASSWORD}") | passwd || handle_error "Failed to set password" # Start SSH server echo "Starting SSH server on port $SSH_PORT..." sshd -p $SSH_PORT || handle_error "Failed to start SSH server" termux-setup-storage pkg install libgc rust # Display the current IP address echo "Fetching IP address..." IP_ADDR=$(ifconfig 2>/dev/null | grep -Eo 'inet (addr:)?([0-9]*\.){3}[0-9]*' | grep -Eo '([0-9]*\.){3}[0-9]*' | grep -v '127.0.0.1' | head -n 1) if [ -z "$IP_ADDR" ]; then echo "Could not determine IP address automatically" echo "Please check your IP address manually using 'ip addr'" else echo "Your IP address is: $IP_ADDR" echo "" echo "SSH connection details:" echo " - Host: $IP_ADDR" echo " - Port: $SSH_PORT" echo " - Password: planet007" echo " - Key authentication is enabled" echo "" echo "Example SSH commands:" echo " With password: ssh user@$IP_ADDR -p $SSH_PORT" echo " With key: ssh -i /path/to/private/key user@$IP_ADDR -p $SSH_PORT" fi echo "Setup completed successfully!" ```
Author
Owner
https://github.com/termux/termux-app/wiki/RUN_COMMAND-Intent
Sign in to join this conversation.
No Milestone
No project
No Assignees
1 Participants
Notifications
Due Date
The due date is invalid or out of range. Please use the format 'yyyy-mm-dd'.

No due date set.

Dependencies

No dependencies set.

Reference: tfgrid/circle_engineering#151
No description provided.