@@ -5,6 +5,8 @@ DESKTOP_DIR=$HOME/.local/share/applications # Directory for desktop entries
55GITHUB_REPO=" phcode-dev/phoenix-desktop"
66API_URL=" https://api.github.com/repos/$GITHUB_REPO /releases/latest"
77ICON_URL=" https://updates.phcode.io/icons/phoenix_icon.png"
8+ GTK_URL=" https://github.com/phcode-dev/dependencies/releases/download/v1.0.0/gtk.tar.xz"
9+ WEBKIT2GTK_URL=" https://github.com/phcode-dev/dependencies/releases/download/v1.0.0/webkit2gtk-4.0.tar.xz"
810INSTALL_DIR=" $HOME /.phoenix-code"
911LINK_DIR=" $HOME /.local/bin"
1012DESKTOP_ENTRY_NAME=" PhoenixCode.desktop"
@@ -90,18 +92,10 @@ check_ubuntu_version() {
9092 if [ -f /etc/os-release ]; then
9193 . /etc/os-release
9294 if [[ " $ID " = " ubuntu" && " $VERSION_ID " = " 24.04" ]]; then
93- local latestFileUrl
94- latestFileUrl=$( grep -oP ' https://[^"]*latest\.json' " $TMP_DIR /latest_release.json" )
95- WGET_OPTS=$( configure_wget_options)
96-
97- wget $WGET_OPTS " $TMP_DIR /latest.json" " $latestFileUrl " || {
98- echo -e " ${RED} Failed to download the latestFile. Please check your internet connection and try again.${RESET} "
99- }
100- echo -e " ${RED} Ubuntu 24.04 LTS is not currently supported by this installation script.${RESET} "
101- echo -e " ${YELLOW} Please use an earlier version of Ubuntu for the time being. Check back later for updates.${RESET} "
102- exit 1
95+ return 0 # Ubuntu 24.04 detected
10396 fi
10497 fi
98+ return 1 # Not Ubuntu 24.04
10599}
106100# Create Invocation Script Function
107101#
@@ -235,6 +229,59 @@ install_dependencies() {
235229 ;;
236230 esac
237231}
232+
233+ download_and_install_gtk () {
234+ echo -e " ${YELLOW} Downloading GTK from $GTK_URL ...${RESET} "
235+ local destination=" $TMP_DIR /phoenix-code"
236+ WGET_OPTS=$( configure_wget_options)
237+
238+ wget $WGET_OPTS " $TMP_DIR /gtk.tar.xz" " $GTK_URL " || {
239+ echo -e " ${RED} Failed to download GTK. Please check your internet connection and try again.${RESET} "
240+ exit 1
241+ }
242+ echo " Extracting GTK..."
243+ tar -xJf " $TMP_DIR /gtk.tar.xz" -C " $destination " || {
244+ echo -e " ${RED} Failed to extract GTK. The downloaded file might be corrupt.${RESET} "
245+ exit 1
246+ }
247+
248+ echo -e " ${YELLOW} Downloading WebKit2GTK from $WEBKIT2GTK_URL ...${RESET} "
249+ wget $WGET_OPTS " $TMP_DIR /webkit2gtk-4.0.tar.xz" " $WEBKIT2GTK_URL " || {
250+ echo -e " ${RED} Failed to download WebKit2GTK. Please check your internet connection and try again.${RESET} "
251+ exit 1
252+ }
253+ echo " Extracting WebKit2GTK..."
254+ tar -xJf " $TMP_DIR /webkit2gtk-4.0.tar.xz" -C " $TMP_DIR " || {
255+ echo -e " ${RED} Failed to extract WebKit2GTK. The downloaded file might be corrupt.${RESET} "
256+ exit 1
257+ }
258+ echo " Installing WebKit2GTK..."
259+ sudo cp -r " $TMP_DIR /webkit2gtk-4.0" /usr/lib/x86_64-linux-gnu/ || {
260+ echo -e " ${RED} Failed to install WebKit2GTK. Please check the permissions and try again.${RESET} "
261+ exit 1
262+ }
263+ echo -e " ${GREEN} WebKit2GTK installed successfully.${RESET} "
264+ }
265+
266+
267+ create_launch_script_with_gtk () {
268+ local binary_path=" $1 "
269+ local binary_name=" phoenix-code"
270+
271+ local realBin=" $binary_path /$binary_name .real"
272+ mv " $binary_path /$binary_name " " $realBin "
273+ echo " Creating a launch script for Phoenix Code with GTK libraries..."
274+ cat > " $binary_path /$binary_name " << EOF
275+ #!/bin/bash
276+ SCRIPT_DIR=\$ (dirname "\$ (readlink -f "\$ 0")")
277+ export LD_LIBRARY_PATH=\$ SCRIPT_DIR/gtk:\$ LD_LIBRARY_PATH
278+ exec \$ SCRIPT_DIR/$binary_name .real "\$ @"
279+ EOF
280+ chmod +x " $binary_path /$binary_name "
281+
282+ echo -e " Launch script created at: $binary_path /$binary_name "
283+ }
284+
238285# Verify and Install Dependencies Function
239286#
240287# Purpose:
@@ -276,29 +323,26 @@ install_dependencies() {
276323# application to run properly.
277324#
278325verify_and_install_dependencies () {
279- cd " $TMP_DIR /phoenix-code"
280- # Ensure the binary is executable
281- chmod +x " ./phoenix-code"
282- # First attempt to verify the application launch
283- if ./phoenix-code --runVerify; then
326+ if " $TMP_DIR /phoenix-code/phoenix-code" --runVerify; then
284327 echo " Application launch verification successful."
285- return 0 # Exit the function successfully if verification succeeds
328+ return 0
286329 else
287- # Check Ubuntu version for compatibility
288- check_ubuntu_version
289- echo " Initial verification failed. Attempting to install dependencies..."
290- install_dependencies # Function to install required dependencies
330+ if check_ubuntu_version; then
331+ echo -e " ${YELLOW} Ubuntu 24.04 detected. Attempting to download and install GTK and WebKit2GTK...${RESET} "
332+ download_and_install_gtk
333+ create_launch_script_with_gtk " $TMP_DIR /phoenix-code"
334+ else
335+ echo " Initial verification failed. Attempting to install dependencies..."
336+ install_dependencies
337+ fi
291338 fi
292339
293- # Second attempt to verify the application launch after installing dependencies
294- if ./phoenix-code --runVerify; then
340+ if " $TMP_DIR /phoenix-code/phoenix-code" --runVerify; then
295341 echo " Application launch verification successful after installing dependencies."
296- cd -
297- return 0 # Exit the function successfully if verification succeeds
342+ return 0
298343 else
299344 echo " Verification failed even after installing dependencies. Please check the application requirements or contact support."
300- cd -
301- return 1 # Return an error code to indicate failure
345+ return 1
302346 fi
303347}
304348# Set Phoenix Code as the default application for specified MIME types
0 commit comments