Skip to content

Commit da0a7b6

Browse files
authored
Merge pull request #146 from CU-Robotics/feature-better-mac-install
Feature better mac install
2 parents 50d2fed + 5c57e41 commit da0a7b6

File tree

3 files changed

+89
-19
lines changed

3 files changed

+89
-19
lines changed

.gitignore

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,4 +45,4 @@ src/git_info.h
4545

4646

4747
# Ignore Rust tool's build directory
48-
/tools/waggle-interceptor/target
48+
/tools/waggle-interceptor/target

tools/install_compiler.sh

Lines changed: 18 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -23,18 +23,30 @@ if [[ "$(uname -s)" == "Linux" ]]; then
2323
wget $AArch64_Linux -O $TAR_NAME
2424
fi
2525
elif [[ "$(uname -s)" == "Darwin" ]]; then
26+
# If wget is not installed, install it using Homebrew
27+
# Suppress output with >/dev/null and 2>&1 sends errors to /dev/null
28+
if ! command -v wget >/dev/null 2>&1; then
29+
echo "wget not found. Installing via Homebrew..."
30+
# If homebrew is installed, use it
31+
if command -v brew >/dev/null 2>&1; then
32+
brew install wget
33+
else
34+
echo "Homebrew is not installed. Please install Homebrew first: https://brew.sh/"
35+
exit 1
36+
fi
37+
fi
2638
if [[ $(uname -m) == "x86_64" ]]; then
27-
wget $x86_64_MacOS -O $TAR_NAME
39+
wget "$x86_64_MacOS" -O "$TAR_NAME"
2840
elif [[ $(uname -m) == "arm64" ]]; then
29-
wget $Arm64_MacOS -O $TAR_NAME
41+
wget "$Arm64_MacOS" -O "$TAR_NAME"
3042
fi
3143
fi
3244

3345
# extract the compiler
3446
echo "Extracting the compiler..."
35-
tar -xf $TAR_NAME -C $OUTPUT
36-
mv $OUTPUT/arm-gnu-toolchain* $OUTPUT/arm-gnu-toolchain
47+
tar -xf "$TAR_NAME" -C "$OUTPUT"
48+
mv "$OUTPUT"/arm-gnu-toolchain* "$OUTPUT"/arm-gnu-toolchain
3749

38-
# remove the downloaded tar files
50+
# remove the downloaded tar file
3951
echo "Cleaning up..."
40-
rm -f $TAR_NAME
52+
rm -f "$TAR_NAME"

tools/install_tytools.sh

Lines changed: 70 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,75 @@
1-
# install dependencies (curl)
2-
sudo apt install curl
1+
#!/usr/bin/env bash
2+
# install-ty.sh
3+
#
4+
# Installs tytools on Linux, or tycmd on macOS.
35

4-
# makes the keyrings directory with correct permission
5-
sudo mkdir -p -m0755 /etc/apt/keyrings
6+
set -euo pipefail
67

7-
# downloads the key for the repo for apt to install from
8-
sudo curl https://download.koromix.dev/debian/koromix-archive-keyring.gpg -o /etc/apt/keyrings/koromix-archive-keyring.gpg
8+
OS="$(uname -s)"
9+
echo "Detected OS: $OS"
910

10-
# adds the repo to the apt list
11-
echo "deb [signed-by=/etc/apt/keyrings/koromix-archive-keyring.gpg] https://download.koromix.dev/debian stable main" | sudo tee /etc/apt/sources.list.d/koromix.dev-stable.list
11+
if [[ "$OS" == "Linux" ]]; then
12+
echo "--> Running Linux tytools installer..."
1213

13-
# updates apt
14-
sudo apt update
14+
# 1. Ensure curl is present
15+
echo "Installing curl..."
16+
sudo apt update
17+
sudo apt install -y curl
1518

16-
# install tytools
17-
sudo apt install -y tytools
19+
# 2. Prepare keyrings directory
20+
echo "Creating /etc/apt/keyrings with proper perm..."
21+
sudo mkdir -p -m0755 /etc/apt/keyrings
22+
23+
# 3. Download Koromix key
24+
echo "Downloading Koromix GPG key..."
25+
sudo curl -fsSL \
26+
https://download.koromix.dev/debian/koromix-archive-keyring.gpg \
27+
-o /etc/apt/keyrings/koromix-archive-keyring.gpg
28+
29+
# 4. Add repo to sources.list.d
30+
echo "Adding Koromix repo..."
31+
echo \
32+
"deb [signed-by=/etc/apt/keyrings/koromix-archive-keyring.gpg] \
33+
https://download.koromix.dev/debian stable main" \
34+
| sudo tee /etc/apt/sources.list.d/koromix.dev-stable.list > /dev/null
35+
36+
# 5. Update & install
37+
echo "Updating APT and installing tytools..."
38+
sudo apt update
39+
sudo apt install -y tytools
40+
41+
echo "[OK] tytools installed!"
42+
43+
elif [[ "$OS" == "Darwin" ]]; then
44+
echo "--> Running macOS installer (tycmd)..."
45+
46+
REPO_URL="https://github.com/CU-Robotics/tycmd.git"
47+
BIN_NAME="tycmd"
48+
DEST_DIR="/usr/local/bin"
49+
TMP_DIR="$(mktemp -d)"
50+
51+
echo "Cloning ${REPO_URL} into ${TMP_DIR}..."
52+
git clone "${REPO_URL}" "${TMP_DIR}"
53+
54+
# Verify file exists (may not be executable yet)
55+
if [[ ! -e "${TMP_DIR}/${BIN_NAME}" ]]; then
56+
echo "Error: '${BIN_NAME}' not found in repo root."
57+
exit 1
58+
fi
59+
60+
echo "Moving '${BIN_NAME}' to ${DEST_DIR} (requires sudo)..."
61+
sudo mv "${TMP_DIR}/${BIN_NAME}" "${DEST_DIR}/"
62+
63+
echo "Setting executable permissions..."
64+
sudo chmod +x "${DEST_DIR}/${BIN_NAME}"
65+
66+
echo "Cleaning up..."
67+
rm -rf "${TMP_DIR}"
68+
69+
echo "[OK] '${BIN_NAME}' installed to ${DEST_DIR}/${BIN_NAME}."
70+
71+
else
72+
echo "[WARN] Unsupported OS: $OS"
73+
echo "Please install manually."
74+
exit 1
75+
fi

0 commit comments

Comments
 (0)