Skip to content

Commit 14abab4

Browse files
committed
use update-alternative slave to allow switching all execuatables in one shot
1 parent 12dde3b commit 14abab4

File tree

2 files changed

+8
-18
lines changed

2 files changed

+8
-18
lines changed

install-java.sh

+7-6
Original file line numberDiff line numberDiff line change
@@ -182,20 +182,21 @@ fi
182182
# Run update-alternatives commands
183183
if (confirm "Run update-alternatives commands?"); then
184184
echo "Running update-alternatives..."
185-
declare -a commands=($(ls -1 ${extracted_dirname}/bin))
185+
cmd="update-alternatives --install /usr/bin/java java $extracted_dirname/bin/java 10000"
186+
declare -a commands=($(ls -1 ${extracted_dirname}/bin | grep -v ^java$))
186187
for command in "${commands[@]}"; do
187188
command_path=$extracted_dirname/bin/$command
188189
if [[ -x $command_path ]]; then
189-
update-alternatives --install "/usr/bin/$command" "$command" "$command_path" 10000
190-
update-alternatives --set "$command" "$command_path"
190+
cmd="$cmd --slave /usr/bin/$command $command $command_path"
191191
fi
192192
done
193-
194193
lib_path=$extracted_dirname/jre/lib/amd64/libnpjp2.so
195194
if [[ -d "/usr/lib/mozilla/plugins/" ]] && [[ -f $lib_path ]]; then
196-
update-alternatives --install "/usr/lib/mozilla/plugins/libjavaplugin.so" "mozilla-javaplugin.so" "$lib_path" 10000
197-
update-alternatives --set "mozilla-javaplugin.so" "$lib_path"
195+
cmd="$cmd --slave /usr/lib/mozilla/plugins/libjavaplugin.so mozilla-javaplugin.so $lib_path"
198196
fi
197+
echo $cmd
198+
exec $cmd
199+
update-alternatives --set java $extracted_dirname/bin/java
199200
fi
200201

201202
# Create system preferences directory

uninstall-java.sh

+1-12
Original file line numberDiff line numberDiff line change
@@ -79,18 +79,7 @@ fi
7979
# Run update-alternatives commands
8080
if (confirm "Run update-alternatives commands?"); then
8181
echo "Running update-alternatives..."
82-
declare -a commands=($(ls -1 ${java_dist_dir}/bin))
83-
for command in "${commands[@]}"; do
84-
command_path="$java_dist_dir/bin/$command"
85-
if [[ -x $command_path ]]; then
86-
update-alternatives --remove "$command" "$command_path"
87-
fi
88-
done
89-
90-
lib_path="$java_dist_dir/jre/lib/amd64/libnpjp2.so"
91-
if [[ -d "/usr/lib/mozilla/plugins/" ]] && [[ -f $lib_path ]]; then
92-
update-alternatives --remove "mozilla-javaplugin.so" "$lib_path"
93-
fi
82+
update-alternatives --remove java ${java_dist_dir}/bin/java
9483
fi
9584

9685
if (confirm "Remove directory '$java_dist_dir'?"); then

0 commit comments

Comments
 (0)