|
| 1 | +#!/bin/bash |
| 2 | +# Claude helped |
| 3 | +# Function to check and update a package |
| 4 | +check_and_update_package() { |
| 5 | + local package_name=$1 |
| 6 | + local repo_url=$2 |
| 7 | + local egg_name=$3 |
| 8 | + |
| 9 | + echo "Checking $package_name..." |
| 10 | + |
| 11 | + # Get the installed version (only the first line) |
| 12 | + installed_version=$(pip show $package_name | grep Version | cut -d' ' -f2 | head -n 1) |
| 13 | + echo "Installed version: $installed_version" |
| 14 | + |
| 15 | + # Extract the commit hash from the version, accounting for the 'g' prefix |
| 16 | + installed_commit=$(echo $installed_version | grep -oE 'g?[a-f0-9]{7,}$' | sed 's/^g//') |
| 17 | + echo "Installed commit: $installed_commit" |
| 18 | + |
| 19 | + # Get the latest commit SHA from the repository |
| 20 | + latest_commit=$(git ls-remote $repo_url HEAD | cut -f1) |
| 21 | + echo "Latest commit: ${latest_commit:0:7}" |
| 22 | + |
| 23 | + if [ -z "$installed_commit" ]; then |
| 24 | + echo "Unable to determine installed commit hash. Will attempt to update." |
| 25 | + needs_update=true |
| 26 | + elif [ "${latest_commit:0:${#installed_commit}}" != "$installed_commit" ]; then |
| 27 | + echo "New version available." |
| 28 | + needs_update=true |
| 29 | + else |
| 30 | + echo "$package_name is up to date." |
| 31 | + needs_update=false |
| 32 | + fi |
| 33 | + |
| 34 | + if [ "$needs_update" = true ]; then |
| 35 | + echo "Updating $package_name..." |
| 36 | + pip install --upgrade "git+$repo_url#egg=$egg_name" |
| 37 | + fi |
| 38 | +} |
| 39 | + |
| 40 | +# Activate the virtual environment |
| 41 | +echo "Activating virtual environment..." |
| 42 | +source ./venv/bin/activate |
| 43 | + |
| 44 | +# Check and update JitStreamer |
| 45 | +check_and_update_package "JitStreamer" "https://github.com/jawshoeadan/JitStreamer.git" "JitStreamer" |
| 46 | + |
| 47 | +# Check and update pymobiledevice3 |
| 48 | +check_and_update_package "pymobiledevice3" "https://github.com/jawshoeadan/pymobiledevice3.git" "pymobiledevice3" |
| 49 | + |
| 50 | +# Update Tailscale |
| 51 | +echo "Updating Tailscale..." |
| 52 | +sudo tailscale update |
| 53 | + |
| 54 | +echo "All updates completed." |
0 commit comments