如何从 AppImage 中提取文件?

Sek*_*mty 21 linux extract appimage

简单的问题,如何从 AppImage 中提取文件?

GUI,CLI,无所谓,只要能完成工作。

如果重要的话,我正在使用 openSUSE Tumbleweed

Kur*_*fle 23

First, look if your AppImage file is using the newest version of its internal format:

/path/to/your.AppImage --appimage-help
Run Code Online (Sandbox Code Playgroud)

If you see the following line in the output:

--appimage-extract              Extract content from embedded filesystem image
Run Code Online (Sandbox Code Playgroud)

you can conclude yourself how to proceed. In this case you have a (newer) type 2 AppImage format in front of you. (The 'path' part of the command may be relative or absolute.)

Second, if the first command didn't work, you can use a helper tool. However, you need sudo/root privileges for this: download appimagetool (which off course is available as an AppImage). Make it executable and run:

/path/to/appimagetool-x86_64.AppImage --list /path/to/your.AppImage
Run Code Online (Sandbox Code Playgroud)

This should give you a list of all files and their (relative) paths embedded in your.AppImage. To extract your.AppImage into a directory named and located at /path/to/somedir , run

mkdir /path/to/somedir
/path/to/appimagetool-x86_64.AppImage /path/to/your.AppImage /path/to/somedir
Run Code Online (Sandbox Code Playgroud)

Third, you can mount AppImages (type 1 as well as type 2) without the helper tool too:

  • Type 1:

    mkdir mountpoint
    sudo mount -o loop my.AppImage mountpoint/
    
    # You can now inspect the contents
    # You can now also copy the contents to a writable location of your hard disk
    
    sudo umount mountpoint/
    # Do not forget the umount step!
    # If you do forget it, your system may exhibit unwanted behavior.
    
    Run Code Online (Sandbox Code Playgroud)
  • Type 2:

    mkdir mountpoint
    my.AppImage --appimage-offset
    123456   # This is just an example output
    
    sudo mount my.AppImage mountpoint/ -o offset=123456
    
    # you can now inspect the contents
    
    sudo umount mountpoint/
    # Do not forget the umount step!
    # If you do forget it, your system may exhibit unwanted behavior.
    
    Run Code Online (Sandbox Code Playgroud)

“偏执狂”提示:如果您不想信任 AppImage,则最好使用第三种方法。因为运行(对于类型 2 AppImages)the.AppImage --appimage-extractthe.AppImage --appimage-mountthe.AppImage --appimage-offset意味着您实际上正在执行 AppImage(尽管不是它的内容)。

更新:

在下面的评论中回答@jayarjo的问题(修改后如何重新打包AppImage?):

  1. 您不仅可以使用appimagetool将现有的 AppImage 提取到 AppDir 中。您还可以使用它来将 AppDir(可能在一些更改之后)重新打包回(修改后的)AppImage。

  2. 赶紧跑

     appimagetool -v /path/to/AppDir
    
    Run Code Online (Sandbox Code Playgroud)

    观察-v新创建的 AppImage 的位置和名称的命令输出(由 详细说明)。就是这样。