:-'Generic Commit'

This commit is contained in:
Your Name 2025-05-28 20:40:20 +12:00
parent 0fc886bbf7
commit dae98a3686
2 changed files with 44 additions and 35 deletions

View File

@ -4,6 +4,15 @@ set -euo pipefail
SCRIPT_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" &> /dev/null && pwd )" SCRIPT_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" &> /dev/null && pwd )"
_die() {
echo -e "Error: $1" >&2
exit 1
}
#---------------------------------------------------------------------------------------------------------- #----------------------------------------------------------------------------------------------------------
# Headers on Host (Native) # Headers on Host (Native)
#---------------------------------------------------------------------------------------------------------- #----------------------------------------------------------------------------------------------------------
@ -141,11 +150,42 @@ function install_openssl_musl() {
# MUSL CROSS COMPILERS # MUSL CROSS COMPILERS
# ---------------------------------------------------------------------------------------------------------- # ----------------------------------------------------------------------------------------------------------
function check_path() {
local BASHRC="${USER_HOME}/.bashrc"
local TOOLCHAIN="$1"
local MUSL_PATH="$INSTALL_DIR/$TOOLCHAIN/bin"
if ! echo "$PATH" | grep -q "$MUSL_PATH"; then
echo "Adding $MUSL_PATH to PATH in $BASHRC"
PATH_LINE="export PATH=\"$MUSL_PATH:\$PATH\""
if ! grep -Fxq "$PATH_LINE" "$BASHRC"; then
echo "" >> "$BASHRC"
echo "# Add musl cross compilers to PATH for dropshell" >> "$BASHRC"
echo "$PATH_LINE" >> "$BASHRC"
echo "Added musl cross compilers to $BASHRC"
echo "You should run 'source ~/.bashrc' to update your PATH"
else
echo "You should run 'source ~/.bashrc' to update your PATH"
fi
fi
}
function install_musl_cross() {
local TOOLCHAIN="$1"
local MUSL_CC_URL="https://musl.cc"
if [ ! -d "$INSTALL_DIR/$TOOLCHAIN" ]; then
echo "Downloading $TOOLCHAIN musl cross toolchain..."
wget -nc -O "$TMPDIR/$TOOLCHAIN.tgz" "$MUSL_CC_URL/$TOOLCHAIN.tgz"
tar -C "$INSTALL_DIR" -xvf "$TMPDIR/$TOOLCHAIN.tgz"
fi
}
function installmusl() { function installmusl() {
echo "Installing musl toolchain" echo "Installing musl toolchain"
# Set install directory # Set install directory
if [ -n "$SUDO_USER" ] && [ "$SUDO_USER" != "root" ]; then if [ -n "${SUDO_USER:-}" ] && [ "$SUDO_USER" != "root" ]; then
USER_HOME=$(eval echo "~${SUDO_USER}") USER_HOME=$(eval echo "~${SUDO_USER}")
else else
USER_HOME="$HOME" USER_HOME="$HOME"
@ -156,38 +196,6 @@ function installmusl() {
TMPDIR=$(mktemp -d) TMPDIR=$(mktemp -d)
trap 'rm -rf "$TMPDIR"' EXIT trap 'rm -rf "$TMPDIR"' EXIT
function install_musl_cross() {
local TOOLCHAIN="$1"
local MUSL_CC_URL="https://musl.cc"
if [ ! -d "$INSTALL_DIR/$TOOLCHAIN" ]; then
echo "Downloading $TOOLCHAIN musl cross toolchain..."
wget -nc -O "$TMPDIR/$TOOLCHAIN.tgz" "$MUSL_CC_URL/$TOOLCHAIN.tgz"
tar -C "$INSTALL_DIR" -xvf "$TMPDIR/$TOOLCHAIN.tgz"
fi
}
function check_path() {
if [ -n "$SUDO_USER" ] && [ "$SUDO_USER" != "root" ]; then
local BASHRC="$USER_HOME/.bashrc"
local TOOLCHAIN="$1"
local MUSL_PATH="$INSTALL_DIR/$TOOLCHAIN/bin"
if ! echo "$PATH" | grep -q "$MUSL_PATH"; then
echo "Adding $MUSL_PATH to PATH in $BASHRC"
PATH_LINE="export PATH=\"$MUSL_PATH:\$PATH\""
if ! grep -Fxq "$PATH_LINE" "$BASHRC"; then
echo "" >> "$BASHRC"
echo "# Add musl cross compilers to PATH for dropshell" >> "$BASHRC"
echo "$PATH_LINE" >> "$BASHRC"
echo "Added musl cross compilers to $BASHRC"
echo "You should run 'source ~/.bashrc' to update your PATH"
else
echo "You should run 'source ~/.bashrc' to update your PATH"
fi
fi
fi
}
TOOLCHAIN_LIST=( TOOLCHAIN_LIST=(
"aarch64-linux-musl-cross" "aarch64-linux-musl-cross"
"x86_64-linux-musl-cross" "x86_64-linux-musl-cross"
@ -203,7 +211,6 @@ function installmusl() {
} }
#---------------------------------------------------------------------------------------------------------- #----------------------------------------------------------------------------------------------------------
# Main # Main
#---------------------------------------------------------------------------------------------------------- #----------------------------------------------------------------------------------------------------------

View File

@ -100,7 +100,9 @@ void DropshellScriptManager::addAutocomplete(const std::string& toolName) {
std::string funcDef; std::string funcDef;
funcDef += blockStart + "\n"; funcDef += blockStart + "\n";
funcDef += funcName + "() {\n"; funcDef += funcName + "() {\n";
funcDef += " COMPREPLY=($(" + toolName + " autocomplete \"${COMP_WORDS[@]:1}\"))\n"; funcDef += " local cur=\"${COMP_WORDS[COMP_CWORD]}\"\n";
funcDef += " mapfile -t completions < <(" + toolName + " autocomplete \"${COMP_WORDS[@]:1:${COMP_CWORD}-1}\")\n";
funcDef += " mapfile -t COMPREPLY < <(compgen -W \"${completions[*]}\" -- \"$cur\")\n";
funcDef += "}\n"; funcDef += "}\n";
funcDef += blockEnd + "\n"; funcDef += blockEnd + "\n";
std::string completeLine = "complete -F " + funcName + " " + toolName + " # dropshell-autocomplete:" + toolName; std::string completeLine = "complete -F " + funcName + " " + toolName + " # dropshell-autocomplete:" + toolName;