@@ -1,68 +1,161 @@
#!/usr/bin/env playonlinux-bash
-# Date : (2020-08-18 12:00)
-# Last revision : (2020-08-18 12:00)
-# Wine version used : 5.0.2
-# Distribution used to test : Ubuntu 19.10
-# Author : VolkerFröhlich
-# PlayOnLinux : 4.3.4
-# Script licence : GPL3
-# Program licence : Free
-#!/usr/bin/env playonlinux-bash
[ "$PLAYONLINUX" = "" ] && exit 0
-source "$PLAYONLINUX/lib/sources"
-
+source "/usr/share/playonlinux/lib/sources"
+# ######################################################################
+# created Sa 29. Jan 17:42:49 CET 2022
+# ######################################################################
+# global parameters
TITLE="mp3DirectCut"
-
PREFIX="mp3DirectCut"
AUTHOR="Volker Fröhlich"
EDITOR="Martin Pesch"
-
-EXECUTABLE_FILE="mp3DirectCut.exe"
-MD5="a4043199945edd9023e2274445b6d528"
-
-# Starting the script
+FILE="mp3DC232.exe"
+MD5=""
+# automation parameters
+USE_AUTOMATION="0" # 1: do not ask user
+# ######################################################################
+# FUNCTIONS
+# ======================================================================
+getInstallerLocalDownload()
+# ----------------------------------------------------------------------
+# 1. decide if local or download
+# 1.1 browse for local installer
+# 1.2 download
+# .store download page locally
+# .analyze page for latest installer
+# This may no longer work if download page logic changes.
+# 2. check installer size is not too small
+# ======================================================================
+{
+INSTALLER=""
+DOWNLOAD_FULLPATH="$DOWNLOAD_PATH$FILE"
+POL_Debug_Message "# USER CHOICE: select local or download"
+[ "$USE_AUTOMATION" = 1 ] && \
+ INSTALL_METHOD="DOWNLOAD" || \
+ POL_SetupWindow_InstallMethod "LOCAL,DOWNLOAD"
+if [ "$INSTALL_METHOD" = "LOCAL" ]; then
+ POL_Debug_Message "# local installer"
+ MSG="Please select the setup file to run."
+ POL_SetupWindow_browse "$(eval_gettext '$MSG')" ""
+ INSTALLER="$APP_ANSWER"
+elif [ "$INSTALL_METHOD" = "DOWNLOAD" ]; then
+ POL_Debug_Message "# download installer page"
+ wget -P "$POL_System_TmpDir/" "$DOWNLOAD_PATH"
+ DOWNLOAD_FULLPATH=`cat $POL_System_TmpDir/index.html | grep '.exe' | grep 'href=' | cut -d '"' -f 2`
+ POL_Debug_Message "# download installer"
+ DOWNLOAD_FILE=$(basename "$DOWNLOAD_FULLPATH")
+ DOWNLOAD_LINK=$DOWNLOAD_PATH/$DOWNLOAD_FILE
+ POL_Debug_Message "# DOWNLOAD_LINK=$DOWNLOAD_LINK"
+ POL_Debug_Message "# MD5=$MD5"
+ POL_Download "$DOWNLOAD_LINK" "$MD5"
+ INSTALLER="$POL_System_TmpDir/$DOWNLOAD_FILE"
+fi
+if [[ -z "$INSTALLER" || ! -f "$INSTALLER" ]];then
+ MSG=-e "\x1B[1;31mERROR:\x1b[0m cannot locate installer >$INSTALLER< for $TITLE."
+ POL_Debug_Message "# $MSG"
+ POL_SetupWindow_message "$(eval_gettext '$MSG')" "$TITLE"
+fi
+# ---------------------
+# check installer size
+file_size_kb=`du -k "$INSTALLER" | cut -f1`
+if [ "$file_size_kb" -lt 300 ]; then
+ POL_Debug_Warning "# Warning: Installer $INSTALLER size $file_size_kb kb is too small for a set-up file."
+fi
+return 0
+}
+# ======================================================================
+getVersionInstalled()
+# ----------------------------------------------------------------------
+# store installed version in variable
+# VERSION_INSTALLED
+# ======================================================================
+{
+POL_Debug_Message "# getVersionInstalled"
+VERSION_INSTALLED=""
+POL_Debug_Message "# WINEPREFIX: $WINEPREFIX"
+VERSION_FILE="$WINEPREFIX/drive_c/Program Files/mp3DirectCut/Version.txt"
+POL_Debug_Message "# VERSION_FILE=$VERSION_FILE"
+[ ! -f "$VERSION_FILE" ] && POL_Debug_Message "file not found $VERSION_FILE"
+[ -f "$VERSION_FILE" ] && VERSION_INSTALLED=`head -5 "$VERSION_FILE" | grep "20" | cut -d "," -f 1`
+POL_Debug_Message "# VERSION_INSTALLED: $VERSION_INSTALLED"
+}
+# ======================================================================
+createShortcut()
+# ----------------------------------------------------------------------
+# 1. get installed version
+# 2. remove previous desktop starter
+# 3. remove previous POL shortcut
+# 4. add POL shortcut with version info
+# ======================================================================
+{
+# -------------------
+POL_Debug_Message "# get program version"
+getVersionInstalled
+POL_Debug_Message "# VERSION_INSTALLED: $VERSION_INSTALLED"
+LAUNCHER="$TITLE"
+[ ! -z "$VERSION_INSTALLED" ] && LAUNCHER="$LAUNCHER-v$VERSION_INSTALLED"
+POL_Debug_Message "# LAUNCHER: $LAUNCHER"
+# -------------------
+PATH_SHORTCUT="$POL_USER_ROOT/shortcuts/$LAUNCHER"
+if [ ! -f "$PATH_SHORTCUT" ];then
+ EXECUTABLE_FILE="mp3DirectCut.exe"
+ # -------------------
+ POL_Debug_Message "# remove previous desktop starter"
+ LINUX_DESKTOP=`xdg-user-dir DESKTOP`
+ PATH_SHORTCUT="$LINUX_DESKTOP/$TITLE"
+ [ ! -z "$PATH_SHORTCUT" ] && rm -r "$PATH_SHORTCUT"* 2>/dev/null;
+ rm -r $HOME/.local/share/applications/*$TITLE* 2>/dev/null;
+ # -------------------
+ POL_Debug_Message "# remove previous POL shortcut"
+ PATH_SHORTCUT="$POL_USER_ROOT/shortcuts/$TITLE"
+ [ ! -z "$PATH_SHORTCUT" ] && rm -r "$PATH_SHORTCUT"* 2>/dev/null;
+ # -------------------
+ POL_Debug_Message "# create POL shortcut"
+ POL_Shortcut "$EXECUTABLE_FILE" "$LAUNCHER" "" "" "AudioVideo;Audio;AudioVideoEditing;Music;"
+ POL_Debug_Message "# rename LAUNCHER: playonlinux-$LAUNCHER"
+ DESKTOP_DIR=/home/benutzer1/Desktop
+ [ -f "$DESKTOP_DIR/$LAUNCHER.desktop" ] && mv "$DESKTOP_DIR/$LAUNCHER.desktop" "$DESKTOP_DIR/playonlinux-$LAUNCHER.desktop" && chmod a+x "$DESKTOP_DIR/\playonlinux-$LAUNCHER.desktop"
+ # -------------------
+ PATH_SHORTCUT="$POL_USER_ROOT/shortcuts/$LAUNCHER"
+fi
+[ -f "$PATH_SHORTCUT" ] && MSG="$LAUNCHER installation ok" && POL_Debug_Message "# $MSG"
+return 0
+}
+# ######################################################################
+# MAIN
+POL_GetSetupImages --force "$IMAGE_TOP" "$IMAGE_LEFT" "$TITLE"
POL_SetupWindow_Init
-
-# Starting debugging API
POL_Debug_Init
-
-#POL_SetupWindow_SetID
-# Open dialogue box
+POL_Debug_Message "# show POL Window"
POL_SetupWindow_presentation "$TITLE" "$EDITOR" "$EDITOR_URL" "$AUTHOR" "$PREFIX"
-Set_OS "win7"
-POL_System_TmpCreate "$PREFIX"
-cd "$POL_System_TmpDir" || POL_Debug_Fatal "Unable to change directory"
-
-POL_SetupWindow_InstallMethod "LOCAL,DOWNLOAD"
-
-if [ "$INSTALL_METHOD" = "LOCAL" ]
-then
- POL_SetupWindow_browse "$(eval_gettext 'Please select the setup file to run.')" "$TITLE"
- INSTALLER="$APP_ANSWER"
-elif [ "$INSTALL_METHOD" = "DOWNLOAD" ]; then
- DOWNLOAD_FILE=$(basename $DOWNLOAD_LINK)
- POL_Download "$DOWNLOAD_LINK" "$MD5"
- INSTALLER="$POL_System_TmpDir/$DOWNLOAD_FILE"
-fi
-[ -z "$INSTALLER" ] && exit -1
-
-# Setting prefix path
+# ---------------------
+POL_Debug_Message "# create PREFIX environment"
POL_Wine_SelectPrefix "$PREFIX"
+POL_System_SetArch "x86"
POL_Wine_PrefixCreate
-
+Set_OS "win7"
+POL_System_TmpCreate "$PREFIX"
+PWD_OLD=`pwd`
+cd "$POL_System_TmpDir" || POL_Debug_Fatal "# ERROR: Unable to change directory"
+POL_Debug_Message "# WINEPREFIX: $WINEPREFIX"
+POL_Debug_Message "# PREFIX: $PREFIX"
+POL_Debug_Message "# POL_System_TmpDir: $POL_System_TmpDir"
+# ---------------------
+POL_Debug_Message "# USER CHOICE: Installer local or download"
+getInstallerLocalDownload
+# ======================================================================
+# Run Wine installation
+MSG="Installation in progress."
+POL_SetupWindow_wait "$(eval_gettext '$MSG')" "$TITLE"
POL_Wine_WaitBefore "$TITLE"
-###########
-# The installer consistently crashes wine and,
-# POL_Wine will show an error message.
-# However, the app then runs smoothly, so let's not bother.
export POL_IgnoreWineErrors="True"
POL_Wine "$INSTALLER"
-
-POL_Shortcut "$EXECUTABLE_FILE" "$TITLE" "" "" "AudioVideo;Audio;AudioVideoEditing;Music;"
-
-POL_System_TmpDelete
-
+# ---------------------
+createShortcut
+cd $PWD_OLD
POL_SetupWindow_Close
-exit
\ No newline at end of file
+exit