AppImage / appimagetool

A low-level tool to generate an AppImage from an existing AppDir
96 stars 16 forks source link

Add support for metainfo.xml #55

Open Rosalie241 opened 5 months ago

Rosalie241 commented 5 months ago

This adds support for metainfo.xml, appdata.xml is still supported though.

see https://www.freedesktop.org/software/appstream/docs/chap-Metadata.html#spec-component-location

probonopd commented 5 months ago

Thanks @Rosalie241. Not sure we want this ambiguity in AppImages, though. After all, if we allow 2 different file paths in AppImages, then all tools that verify AppImages or integrate them into the system would have to check 2 different file paths as well.

Rosalie241 commented 5 months ago

Thanks @Rosalie241. Not sure we want this ambiguity in AppImages, though. After all, if we allow 2 different file paths in AppImages, then all tools that verify AppImages or integrate them into the system would have to check 2 different file paths as well.

Tools which want to support normal desktop applications that provide a metainfo/appdata.xml file will also have to check 2 paths though, so I'm not sure if it's a big problem, but I've updated my application (RMG) to use the new metainfo.xml file according to the freedesktop appstream documentation, and now the appimagetool cannot find the appstream data, which isn't ideal either.

probonopd commented 5 months ago

Maybe we should just put in a symlink? That would be backwards compatible.

Rosalie241 commented 5 months ago

That could be an option but I'm not sure how to do that with the APIs available.

probonopd commented 5 months ago

Something roughly along these lines?

package main

import (
    "fmt"
    "log"
    "os"
)

func main() {
    metainfoPath := "usr/share/metainfo/metainfo.xml"
    appdataPath := "usr/share/metainfo/appdata.xml"

    // Check if metainfo.xml exists
    if _, err := os.Stat(metainfoPath); os.IsNotExist(err) {
        fmt.Println(metainfoPath, "does not exist, creating symlink to", appdataPath)

        // Create symlink from appdata.xml to metainfo.xml
        if err := os.Symlink(appdataPath, metainfoPath); err != nil {
            log.Fatalf("Failed to create symlink from %s to %s: %v", appdataPath, metainfoPath, err)
        } else {
            fmt.Println("Symlink created from", appdataPath, "to", metainfoPath)
        }
    } else {
        fmt.Println(metainfoPath, "exists")
    }

    // Check if appdata.xml exists
    if _, err := os.Stat(appdataPath); os.IsNotExist(err) {
        fmt.Println(appdataPath, "does not exist, creating symlink to", metainfoPath)

        // Create symlink from metainfo.xml to appdata.xml
        if err := os.Symlink(metainfoPath, appdataPath); err != nil {
            log.Fatalf("Failed to create symlink from %s to %s: %v", metainfoPath, appdataPath, err)
        } else {
            fmt.Println("Symlink created from", metainfoPath, "to", appdataPath)
        }
    } else {
        fmt.Println(appdataPath, "exists")
    }
}