Initial Commit
This commit is contained in:
@@ -0,0 +1 @@
|
||||
ARCH=any
|
||||
@@ -0,0 +1,6 @@
|
||||
name: tide-java-utils
|
||||
description: Tide Linux utility for switching between java versions
|
||||
version: 1.0
|
||||
license: MIT
|
||||
architecture: any
|
||||
type: source
|
||||
@@ -0,0 +1,21 @@
|
||||
MIT License
|
||||
|
||||
Copyright (c) 2025 EnumDev
|
||||
|
||||
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.
|
||||
@@ -0,0 +1,2 @@
|
||||
# Append default java version to PATH
|
||||
append_path /usr/lib/java/default/bin
|
||||
@@ -0,0 +1,66 @@
|
||||
#!/bin/bash
|
||||
|
||||
function help() {
|
||||
echo "Tide Linux Java Utilities"
|
||||
echo
|
||||
echo "Available commands:"
|
||||
echo "- tide-java set-default <version> | Sets the default java version"
|
||||
echo "- tide-java get-default <version> | Gets the default java version"
|
||||
echo "- tide-java list | Lists available java versions"
|
||||
}
|
||||
|
||||
function get_installed_java_versions() {
|
||||
for dir in $(find /usr/lib/java/ -mindepth 1 -maxdepth 1 -not -name 'default'); do
|
||||
echo $(basename "$dir")
|
||||
done
|
||||
}
|
||||
|
||||
function get_default_java_version() {
|
||||
# Return 1 if directory isn't found
|
||||
[ -d /usr/lib/java/default/bin ] || return 1
|
||||
|
||||
local LINK_PATH=$(readlink /usr/lib/java/default)
|
||||
echo $(basename "$LINK_PATH")
|
||||
}
|
||||
|
||||
function set_default_java_version() {
|
||||
# Return 1 if empty argument is given
|
||||
[ -z "$1" ] && return 1
|
||||
|
||||
while read line; do
|
||||
if [[ "$1" == "$line" ]]; then
|
||||
ln -sf "$line" -T /usr/lib/java/default || return 1
|
||||
return 0
|
||||
fi
|
||||
done < <(get_installed_java_versions)
|
||||
return 1
|
||||
}
|
||||
|
||||
case "$1" in
|
||||
"set-default")
|
||||
if [ $UID -ne 0 ]; then
|
||||
echo "Root permissions are required to set default java version"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
if set_default_java_version "$2"; then
|
||||
echo "Default java version successfully set to $2"
|
||||
else
|
||||
echo "Could not set default java version to $2"
|
||||
exit 1
|
||||
fi
|
||||
;;
|
||||
"get-default")
|
||||
echo -n "Current default java version: "
|
||||
get_default_java_version || echo "None"
|
||||
;;
|
||||
"list")
|
||||
echo "Available java versions:"
|
||||
while read line; do
|
||||
echo "- $line"
|
||||
done < <(get_installed_java_versions)
|
||||
;;
|
||||
*)
|
||||
help
|
||||
;;
|
||||
esac
|
||||
@@ -0,0 +1,12 @@
|
||||
# This is the source.sh script. It is executed by BPM in a temporary directory when compiling a source package
|
||||
# BPM Expects the source code to be extracted into the automatically created 'source' directory which can be accessed using $BPM_SOURCE
|
||||
# BPM Expects the output files to be present in the automatically created 'output' directory which can be accessed using $BPM_OUTPUT
|
||||
|
||||
# The package function is executed in the source directory
|
||||
# This function is used to move the compiled files into the output directory
|
||||
package() {
|
||||
install -Dm755 "$BPM_WORKDIR"/tide-java-utils "$BPM_OUTPUT"/usr/bin/tide-java-utils
|
||||
install -Dm644 "$BPM_WORKDIR"/java.profile "$BPM_OUTPUT"/etc/profile.d/java.sh
|
||||
|
||||
install -Dm644 "$BPM_WORKDIR"/LICENSE "$BPM_OUTPUT"/usr/share/licenses/tide-java/LICENSE
|
||||
}
|
||||
Reference in New Issue
Block a user