Bug 378529

Summary: KPackage does not ignore warnings during appdata generation
Product: [Frameworks and Libraries] frameworks-kpackage Reporter: Fabian Vogt <fabian>
Component: defaultAssignee: Marco Martin <notmart>
Status: RESOLVED FIXED    
Severity: major    
Priority: NOR    
Version: 5.32.0   
Target Milestone: ---   
Platform: openSUSE   
OS: Linux   
Latest Commit: Version Fixed In:

Description Fabian Vogt 2017-04-07 08:35:51 UTC
Due to $SUBJECT building various parts of Plasma 5.8 which use the removed Plasma/PopupApplet service type do not build correctly. The bug is in KF5PackageMacros.cmake, around line 53:


        execute_process(COMMAND ${kpackagetool_cmd} --appstream-metainfo ${CMAKE_CURRENT_SOURCE_DIR}/${dir} OUTPUT_FILE ${APPDATAFILE} ERROR_VARIABLE appstreamerror RESULT_VARIABLE result)
        if(appstreamerror)
            if (NOT result EQUAL 0)
                message(WARNING "couldn't generate metainfo for ${component}: ${appstreamerror}")
            endif ()
        else()
            install(FILES ${APPDATAFILE} DESTINATION ${KDE_INSTALL_METAINFODIR})
        endif()

In the failing case appstreamerror is not empty, as it emits warnings, but the file is still generated successfully, result is 0.
This means that:

* No error or warning is printed

* The file is generated but not installed

This needs to be fixed like this, IMO:

        execute_process(COMMAND ${kpackagetool_cmd} --appstream-metainfo ${CMAKE_CURRENT_SOURCE_DIR}/${dir} OUTPUT_FILE ${APPDATAFILE} ERROR_VARIABLE appstreamerror RESULT_VARIABLE result)
        if (NOT result EQUAL 0)
            message(WARNING "couldn't generate metainfo for ${component}: ${appstreamerror}")
        else()
            if(appstreamerror)
                message(WARNING "warnings during generation of metainfo for ${component}: ${appstreamerror}")

            install(FILES ${APPDATAFILE} DESTINATION ${KDE_INSTALL_METAINFODIR})
        endif()
Comment 1 Fabian Vogt 2017-04-07 09:20:24 UTC
Git commit a0da2bd735d01155667ce21e87d553bcb69e3a6a by Fabian Vogt.
Committed on 07/04/2017 at 09:20.
Pushed by fvogt into branch 'master'.

Ignore warnings during appdata generation

Summary:
The Plasma/PopupApplet service type for example got deprecated and removed,
but is still used by various parts of Plasma 5.8.
This causes kpackagetool to emit warnings, but it still succeeds. However,
this case is handled incorrectly as any stderr output is assumed to be critical
and the file is not installed. As result is 0, no warning message is printed.

This commit fixes this by ignoring the stderr output and using result to indicate
success. Warning messages are printed if applicable.

Major issue is that kpackagetool5 does not exit with an error if it encounters
an error, so this installs a broken appdata file in some circumstances.

Test Plan:
Built Plasma 5.8 with this patch. Works fine now.
As warnings are now printed, it uncovered some little issues as well.

Reviewers: mart, apol

Reviewed By: mart

Subscribers: #frameworks

Tags: #frameworks

Differential Revision: https://phabricator.kde.org/D5328

M  +6    -4    KF5PackageMacros.cmake

https://commits.kde.org/kpackage/a0da2bd735d01155667ce21e87d553bcb69e3a6a