save point
This commit is contained in:
parent
7c274a8b7a
commit
59198cb6b4
2 changed files with 21 additions and 46 deletions
21
LICENSE
Normal file
21
LICENSE
Normal file
|
@ -0,0 +1,21 @@
|
|||
MIT License
|
||||
|
||||
Copyright (c) 2025 Paul Malcher
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
of this software and associated documentation files (the "Software"), to deal
|
||||
in the Software without restriction, including without limitation the rights
|
||||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
copies of the Software, and to permit persons to whom the Software is
|
||||
furnished to do so, subject to the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be included in all
|
||||
copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
SOFTWARE.
|
|
@ -1,46 +0,0 @@
|
|||
#!/bin/bash
|
||||
|
||||
# Function to check and pull the latest version of a package from GitHub
|
||||
check_and_update_package() {
|
||||
local repo_owner="$1"
|
||||
local repo_name="$2"
|
||||
local local_path="$3"
|
||||
|
||||
echo "Checking for updates for $repo_name..."
|
||||
|
||||
# Get the latest release info from GitHub API
|
||||
latest_release=$(curl -s "https://api.github.com/repos/$repo_owner/$repo_name/releases/latest")
|
||||
latest_version=$(echo "$latest_release" | grep -oP '(?<="tag_name": ")([^"]+)')
|
||||
|
||||
if [ -z "$latest_version" ]; then
|
||||
echo "Failed to fetch latest version for $repo_name."
|
||||
return 1
|
||||
fi
|
||||
|
||||
# Check if the package is already installed at the local path
|
||||
if [ -d "$local_path" ]; then
|
||||
# Check if the installed version matches the latest
|
||||
current_version=$(cd "$local_path" && git describe --tags 2>/dev/null || echo 'unknown')
|
||||
if [ "$current_version" == "$latest_version" ]; then
|
||||
echo "$repo_name is already up to date (version: $current_version)."
|
||||
return 0
|
||||
else
|
||||
echo "Updating $repo_name from version $current_version to $latest_version..."
|
||||
cd "$local_path" && git pull origin "$latest_version"
|
||||
fi
|
||||
else
|
||||
echo "Installing $repo_name version $latest_version..."
|
||||
git clone "https://github.com/$repo_owner/$repo_name.git" "$local_path"
|
||||
cd "$local_path" && git checkout "$latest_version"
|
||||
fi
|
||||
|
||||
if [ $? -eq 0 ]; then
|
||||
echo "$repo_name has been updated to version $latest_version."
|
||||
else
|
||||
echo "Failed to update $repo_name."
|
||||
return 1
|
||||
fi
|
||||
}
|
||||
|
||||
# Example usage:
|
||||
# check_and_update_package 'owner' 'repository' '/path/to/install'
|
Loading…
Add table
Add a link
Reference in a new issue