ivan-hc / AM

AppImage package manager to install, update (for real) and manage ALL of them (system-wide or locally) thanks to its ever-growing AUR-inspired database listing 2000+ portable apps and programs for GNU/Linux. The first, real centralized repository to manage your AppImages with the ease of APT and the power of PacMan.
https://portable-linux-apps.github.io
GNU General Public License v3.0
483 stars 34 forks source link

[Portable Package Request] Flashpoint Archive #1008

Open contrarybaton60 opened 1 day ago

contrarybaton60 commented 1 day ago

To help us make adding applications quicker and easier, please try to follow the following two syntaxes.

mutable version

immutable version

Important!

The two syntaxes mentioned above are enough for programs that can only be used from the command line.

However, for graphical programs and programs that require integration into the menu, and therefore a launcher, also add the following two pieces of information:


List of portable applications to add

Flashpoint Archive (immutable and mutable builds)

ivan-hc commented 1 day ago

Hi, sorry if I answered so late, I was busy on some other repos.

Well, it seems to be an "installer" more than a portable app... to made it work, we need to extract it and run a script that does as follows (from the "start-flashpoint.sh" script):

#!/bin/bash

# Check if the script is running as root or is already running, and exit if true.
if [[ $EUID -eq 0 ]]; then
  echo "Running as root. Stop."
  exit 1
fi
for PID in $(pidof -x start-flashpoint.sh); do
  if [[ $PID -ne $$ ]]; then
    if [[ $(pidof -x flashpoint-launcher) ]]; then
      echo "Already running. Stop.
If launcher isn't visible, run:
    $ killall flashpoint-launcher"
      exit 1
    else
      kill -n9 $PID
    fi
  fi
done

# If GTK3 isn't installed, set GTK_USE_PORTAL to prevent the launcher from crashing when calling the file chooser.
if [[ ! $(ldconfig -p | grep libgtk-3.so) ]]; then
  export GTK_USE_PORTAL=1
fi

# Set some environment variables needed for platforms to run properly.
export DIR="$(dirname "$(readlink -f "${BASH_SOURCE[0]}")")"
export FP_STARTUP_PATH="Z:${DIR//\//\\}\\FPSoftware"
export FP_BROWSER_PLUGINS="$FP_STARTUP_PATH\\BrowserPlugins" WINEPREFIX="$DIR/FPSoftware/Wine" PATH="$DIR/Libraries/bin:$PATH" LD_LIBRARY_PATH="$DIR/Libraries/lib"

cd "$DIR"

# Copy the Wine backup to the prefix location and setup a minimal prefix.
if [[ ! -d "$WINEPREFIX" ]]; then
  cp -nr FPSoftware/.winebak "$WINEPREFIX" 2>/dev/null
  WINEDLLOVERRIDES="control.exe,explorer.exe,mscoree,plugplay.exe,services.exe,winedevice.exe,winemenubuilder.exe=d" wine reg add "HKLM\\Software\\Wine\\MSHTML\\2.47.4" /v "GeckoPath" /d "C:\\windows\\syswow64\\gecko\\2.47.4\\wine_gecko\\" /reg:32 /f >/dev/null &
fi

# Watch the Ruffle binary in the background for 15 seconds, and give it execute permissions if modified.
function watch_ruffle {
  RUFMOD=$(stat -c%Y Data/Ruffle/standalone/latest/ruffle)
  sleep 15
  if [[ $(stat -c%Y Data/Ruffle/standalone/latest/ruffle) -ne $RUFMOD ]]; then
    chmod +x Data/Ruffle/standalone/latest/ruffle
  fi
}
watch_ruffle 2>/dev/null &

cd Launcher

# Disable the launcher's sandbox for Steam compatibility, and run through Wayland if able (otherwise use X11).
./flashpoint-launcher --no-sandbox --ozone-platform-hint=auto

cd ..

# Copy Flash saves to the backup prefix.
mkdir -p "FPSoftware/.winebak/drive_c/users/$USER/AppData/Roaming/Macromedia/Flash Player"
cp -rf "$WINEPREFIX/drive_c/users/$USER/AppData/Roaming/Macromedia/Flash Player/#SharedObjects" "FPSoftware/.winebak/drive_c/users/$USER/AppData/Roaming/Macromedia/Flash Player" 2>/dev/null

# Kill PHP & the game server. This is ran in case the launcher fails to do so.
pkill -9 -f 'php -S 127.0.0.1:22600 router.php'
pkill -9 -f 'php -S 127.0.0.1:22600 router_mad4fp.php'
killall -qs9 Server/FlashpointGameServer

they say that it should work as an electron app... if so, why they don't provide a portable build?

All in all it seems pretty harmless, but I wouldn't play with the variables so easily if I were them.

I need to know if it's safe to install an app like this.

contrarybaton60 commented 21 hours ago

they say that it should work as an electron app... if so, why they don't provide a portable build?

likely because of the amount of time needed to compile, specially for the immutable build.

also I was able to just launch the launcher from /Launcher/flashpoint-launcher without needing start-flashpoint.sh but I don't know it would be a good idea or not.

contrarybaton60 commented 20 hours ago

btw there's also some lutris scripts for it

https://lutris.net/games/bluemaximas-flashpoint/

Twig6943 commented 18 hours ago

@contrarybaton60 thanks for creating this issue (I was thinking of making an issue for flashpoint too)

ivan-hc commented 17 hours ago

The point is, to split them in mutable/immutable versions, it means that system dependences are needed.

I can test only one of them, the one that we are sure it will not try to handle the system package manager on the one that in general already have all dependences with it.

It's a portability thing: I need to be able to move a directory between different systems, and it has to work. The same way Firefox, Thunderbird, Blender, Tor Browser... or any Electron app.

The list of requirements is too strange, from my point of view.

ivan-hc commented 17 hours ago
#!/bin/sh

# AM INSTALL SCRIPT VERSION 3.5
set -u
APP=flashpoint
SITE="https://flashpointarchive.org"

# CREATE DIRECTORIES AND ADD REMOVER
[ -n "$APP" ] && mkdir -p "/opt/$APP/tmp" "/opt/$APP/icons" && cd "/opt/$APP/tmp" || exit 1
printf "#!/bin/sh\nset -e\nrm -f /usr/local/bin/$APP\nrm -R -f /opt/$APP" > ../remove
printf '\n%s' "rm -f /usr/local/share/applications/$APP-AM.desktop" >> ../remove
chmod a+x ../remove || exit 1

# DOWNLOAD AND PREPARE THE APP, $version is also used for updates
version=$(curl -Ls https://flashpointarchive.org/datahub/Linux_Support | tr '><" ' '\n' | grep -i "^http.*m.7z$")
wget "$version" || exit 1
[ -e ./*7z ] && 7z x ./*7z && rm -f ./*7z
[ -e ./*tar.* ] && tar fx ./*tar.* && rm -f ./*tar.*
[ -e ./*zip ] && unzip -qq ./*zip 1>/dev/null && rm -f ./*zip
cd ..
if [ -d ./tmp/* 2>/dev/null ]; then mv ./tmp/*/* ./; else mv ./tmp/* ./"$APP" 2>/dev/null || mv ./tmp/* ./; fi
rm -R -f ./tmp || exit 1
echo "$version" > ./version
chmod a+x ./start-flashpoint.sh || exit 1

# LINK TO PATH
ln -s "/opt/$APP/start-flashpoint.sh" "/usr/local/bin/$APP"

# SCRIPT TO UPDATE THE PROGRAM
cat >> ./AM-updater << 'EOF'
#!/bin/sh
set -u
APP=flashpoint
SITE="https://flashpointarchive.org"
version0=$(cat "/opt/$APP/version")
version=$(curl -Ls https://flashpointarchive.org/datahub/Linux_Support | tr '><" ' '\n' | grep -i "^http.*m.7z$")
[ -n "$version" ] || { echo "Error getting link"; exit 1; }
if [ "$version" != "$version0" ]; then
    mkdir "/opt/$APP/tmp" && cd "/opt/$APP/tmp" || exit 1
    notify-send "A new version of $APP is available, please wait"
    wget "$version" || exit 1
    [ -e ./*7z ] && 7z x ./*7z && rm -f ./*7z
    [ -e ./*tar.* ] && tar fx ./*tar.* && rm -f ./*tar.*
    [ -e ./*zip ] && unzip -qq ./*zip 1>/dev/null && rm -f ./*zip
    cd ..
    if [ -d ./tmp/* 2>/dev/null ]; then mv --backup=t ./tmp/*/* ./; else mv --backup=t ./tmp/* ./"$APP" 2>/dev/null || mv --backup=t ./tmp/* ./; fi
    chmod a+x ./start-flashpoint.sh || exit 1
    echo "$version" > ./version
    rm -R -f ./tmp ./*~
    notify-send "$APP is updated!"
else
    echo "Update not needed!"
fi
EOF
chmod a+x ./AM-updater || exit 1

# ICON
mkdir -p icons
wget https://raw.githubusercontent.com/FlashpointProject/launcher/refs/heads/master/icons/icon.png -O ./icons/"$APP" 2> /dev/null

# LAUNCHER
echo "[Desktop Entry]
Name=FlashPoint
Exec=$APP
Icon=/opt/$APP/icons/$APP
Type=Application
Terminal=false
Categories=Game;" > /usr/local/share/applications/"$APP"-AM.desktop
ivan-hc commented 17 hours ago

the script in the previous comment is what I wrote using the -t option of AM and based on what I know now about the "mutable" version of Flashpoint. This is the video (I had to speedup the FPS due to the rule of 10MB of video uploading in github)

https://github.com/user-attachments/assets/08ff300d-a34d-4b6a-8e82-9f2d636d7b8c

To test if it works, you should copi the script above into a script and save it with the name you want (maybe "flashpoint.sh"), made it executable and run the command am -i /path/to/flashpoint.sh or if you use AppMan appman -i /path/to/flashpoint.sh

I test the scripts like this.

In this sript I had to manually change the reference to the binary to made executable and to made a symlink in PATH (from $APP to start-flashpoint.sh).

@Sush-ruta is one of the more active uploaders in this project, so also have experience on how these scripts are built. @Samueru-sama is the author of the template, available at https://github.com/ivan-hc/AM/blob/main/templates/AM-SAMPLE-Archive and used in -t to create scripts related to portable archives.

All you need now is to run the script and report the results. The app will be installed among the other apps you have installed via AM/AppMan, to remove it use the command am -R flashpoint or appman -R flashpoint

ivan-hc commented 17 hours ago

I have tested it personally, via AppMan... I have a strange extraction process for 7z that I've never seen:

https://github.com/user-attachments/assets/333727f5-38be-4f29-a61d-76ff45534ef5

Everything is installed well: icon, launcher and symlink in $PATH (~/.local/bin) named "flashpoint", to "start-flashpoint.sh"

Anyway, I don't know this app, and I'm afraid of running it. I leave you this job. Let me know.

ivan-hc commented 16 hours ago

I don't normally create dedicated branches for loading individual apps, but I'll make an exception this time. It all depends on your experience with the app installed this way.

ivan-hc commented 7 hours ago

up

Sush-ruta commented 2 hours ago

Sorry for the late reply @ivan-hc ; the script works fine. One suggestion: Add Comments= in the desktop file