ivan-hc / AM

AppImage package manager to install, update and manage ALL of them, system-wide or locally, thanks to its ever-growing AUR-inspired database listing 2500+ 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
501 stars 40 forks source link

AppImage type detection wrong #818

Closed probonopd closed 3 months ago

probonopd commented 3 months ago

As per the AppImageSpec, currently there are only two image formats: Types 1 and 2.

So why is this talking about a type 3 then? And why is it grepping for the string AppImages require FUSE to run? You should read the AppImageSpec more, instead of just making assumptions that may or may not happen to be true sometimes.

https://github.com/ivan-hc/AM/blob/6f29f8ee059a55eaa66544f928d0817205ec4e0e/modules/files.am#L68-L82

To get the image type, you might use something like this (untested):

#!/bin/sh

get_appimage_type() {
  local file_path=$1
  local content_type=$(file --mime-type -b "$file_path")

  # Check the magic bytes to determine the AppImage type
  if [ -f "$file_path" ]; then
    magic=$(dd bs=1 skip=8 count=4 if="$file_path" 2>/dev/null)
    case $magic in
      $'\x41\x49\x01') echo 1; return;;
      $'\x41\x49\x02') echo 2; return;;
    esac
  fi

  # If we couldn't determine the type, return 0 as default
  echo 0
}

Related:

ivan-hc commented 3 months ago

@probonopd I want to update you about the status of "AM" right now:

I hope that the work done in the last week, mostly based on your doubts about our project, is sufficiently exhaustive.

If you have other requests to make or other suggestions, you are welcome.

probonopd commented 3 months ago

Thank you very much, appreciate it @ivan-hc.