@@ -257,43 +257,47 @@ install_dependencies() {
257257 esac
258258}
259259download_and_install_gtk () {
260- # Function: create_launch_script_with_gtk
261- #
262- # Purpose:
263- # This function creates a launch script for the Phoenix Code application that sets the required
264- # GTK library paths in the LD_LIBRARY_PATH environment variable. The launch script ensures that
265- # the Phoenix Code application uses the correct GTK libraries, which are included in the
266- # application's installation directory.
267- #
268- # Parameters:
269- # - binary_path: The path to the directory containing the Phoenix Code binary.
270- # - binary_name: The name of the Phoenix Code binary file.
271- #
272- # Behavior:
273- # 1. The function renames the original Phoenix Code binary to append ".real" to its name.
274- # 2. It then creates a new launch script with the original binary name in the same directory.
275- # 3. The launch script sets the LD_LIBRARY_PATH environment variable to include the path to the
276- # GTK libraries located in the same directory as the binary.
277- # 4. The launch script executes the original Phoenix Code binary (now renamed) with any
278- # arguments passed to the script.
279- # 5. The function sets the appropriate executable permissions on the launch script.
280- #
281- # Usage:
282- # This function should be called after the Phoenix Code binary and its required GTK libraries
283- # have been installed. It ensures that the application uses the correct libraries when launched.
284- #
285- # Example:
286- # create_launch_script_with_gtk "/path/to/phoenix-code" "phoenix-code"
287- #
288- # Notes:
289- # - This function assumes that the GTK libraries are located in a subdirectory named "gtk" within
290- # the same directory as the Phoenix Code binary.
291- # - The function requires the mv, chmod, and cat commands to be available in the environment.
292- # - This piece of code should only be executed if the package manager does not distribute
293- # libgtk or if the version provided by the package manager is not compatible with Phoenix Code.
294-
295- local GTK_URL=" https://github.com/phcode-dev/dependencies/releases/download/v1.0.1/gtk.tar.xz"
296- local WEBKIT2GTK_URL=" https://github.com/phcode-dev/dependencies/releases/download/v1.0.1/webkit2gtk-4.0.tar.xz"
260+ # Function: create_launch_script_with_gtk
261+ #
262+ # Purpose:
263+ # This function creates a launch script for the Phoenix Code application that sets the required
264+ # GTK library paths in the LD_LIBRARY_PATH environment variable. The launch script ensures that
265+ # the Phoenix Code application uses the correct GTK libraries, which are included in the
266+ # application's installation directory.
267+ #
268+ # Parameters:
269+ # - binary_path: The path to the directory containing the Phoenix Code binary.
270+ # - binary_name: The name of the Phoenix Code binary file.
271+ #
272+ # Behavior:
273+ # 1. The function renames the original Phoenix Code binary to append ".real" to its name.
274+ # 2. It then creates a new launch script with the original binary name in the same directory.
275+ # 3. The launch script sets the LD_LIBRARY_PATH environment variable to include the path to the
276+ # GTK libraries located in the same directory as the binary.
277+ # 4. The launch script executes the original Phoenix Code binary (now renamed) with any
278+ # arguments passed to the script.
279+ # 5. The function sets the appropriate executable permissions on the launch script.
280+ #
281+ # Usage:
282+ # This function should be called after the Phoenix Code binary and its required GTK libraries
283+ # have been installed. It ensures that the application uses the correct libraries when launched.
284+ #
285+ # Example:
286+ # create_launch_script_with_gtk "/path/to/phoenix-code" "phoenix-code"
287+ #
288+ # Notes:
289+ # - This function assumes that the GTK libraries are located in a subdirectory named "gtk" within
290+ # the same directory as the Phoenix Code binary.
291+ # - The function requires the mv, chmod, and cat commands to be available in the environment.
292+ # - This piece of code should only be executed if the package manager does not distribute
293+ # libgtk or if the version provided by the package manager is not compatible with Phoenix Code.
294+
295+ local URL_PREFIX=" https://github.com/phcode-dev/dependencies/releases/download/v1.0.2/"
296+ local GTK_FILE=" gtk.tar.xz"
297+ local WEBKIT2GTK_FILE=" webkit2gtk-4.0.tar.xz"
298+
299+ local GTK_URL=" ${URL_PREFIX}${GTK_FILE} "
300+ local WEBKIT2GTK_URL=" ${URL_PREFIX}${WEBKIT2GTK_FILE} "
297301
298302 echo -e " ${YELLOW} Downloading GTK from $GTK_URL ...${RESET} "
299303 local destination=" $TMP_DIR /$BINARY_NAME "
@@ -311,7 +315,7 @@ download_and_install_gtk() {
311315
312316 if [ ! -d " /usr/lib/x86_64-linux-gnu/webkit2gtk-4.0" ]; then
313317 echo -e " ${YELLOW} Downloading WebKit2GTK from $WEBKIT2GTK_URL ...${RESET} "
314- wget $WGET_OPTS " $TMP_DIR /webkit2gtk-4.0.tar.xz" " $WEBKIT2GTK_URL " || {
318+ wget $WGET_OPTS " $TMP_DIR /webkit2gtk-4.0.tar.xz" " $WEBKIT2GTK_URL " || {
315319 echo -e " ${RED} Failed to download WebKit2GTK. Please check your internet connection and try again.${RESET} "
316320 exit 1
317321 }
@@ -320,6 +324,15 @@ download_and_install_gtk() {
320324 echo -e " ${RED} Failed to extract WebKit2GTK. The downloaded file might be corrupt.${RESET} "
321325 exit 1
322326 }
327+
328+ # Inform the user that the next steps require administrative access
329+ echo " The installation of dependencies requires administrative access. You may be prompted to enter your password."
330+
331+ # Check if the script can execute sudo commands without interaction
332+ if ! sudo -n true 2> /dev/null; then
333+ echo " Please enter your password to proceed with the installation of dependencies."
334+ fi
335+
323336 echo " Installing WebKit2GTK..."
324337 sudo cp -r " $TMP_DIR /webkit2gtk-4.0" /usr/lib/x86_64-linux-gnu/ || {
325338 echo -e " ${RED} Failed to install WebKit2GTK. Please check the permissions and try again.${RESET} "
0 commit comments