|
1 |
| -message(STATUS "Creating AppImage") |
2 |
| -# TODO: https://github.com/AppImageCommunity/AppImageUpdate |
| 1 | +# TODO: # go-appimage, updateinformation w/ GitHub Releases, signing |
| 2 | + |
| 3 | +message(STATUS "QGC: Creating AppImage") |
3 | 4 |
|
4 | 5 | set(APPDIR_PATH "${CMAKE_BINARY_DIR}/AppDir")
|
5 |
| -set(APPIMAGETOOL_PATH "${CMAKE_BINARY_DIR}/appimagetool-x86_64.AppImage") |
6 |
| -set(LD_PATH "${CMAKE_BINARY_DIR}/linuxdeploy-${CMAKE_SYSTEM_PROCESSOR}.AppImage") |
7 |
| -# set(LD_APPIMAGEPLUGIN_PATH "${CMAKE_BINARY_DIR}/linuxdeploy-plugin-appimage-${CMAKE_SYSTEM_PROCESSOR}.AppImage") |
8 |
| -# set(LD_QTPLUGIN_PATH "${CMAKE_BINARY_DIR}/linuxdeploy-plugin-qt-${CMAKE_SYSTEM_PROCESSOR}.AppImage") |
9 |
| -# set(LD_GSTPLUGIN_PATH "${CMAKE_BINARY_DIR}/linuxdeploy-plugin-gstreamer.sh") |
10 |
| - |
11 |
| -if(NOT EXISTS "${APPIMAGETOOL_PATH}") |
12 |
| - file(DOWNLOAD https://github.com/AppImage/appimagetool/releases/download/continuous/appimagetool-${CMAKE_SYSTEM_PROCESSOR}.AppImage "${APPIMAGETOOL_PATH}") |
13 |
| - # file(DOWNLOAD https://github.com/probonopd/go-appimage/releases/download/832/appimagetool-823-${CMAKE_SYSTEM_PROCESSOR}.AppImage "${APPIMAGETOOL_PATH}") # TODO: Use Continuous Release |
14 |
| - execute_process(COMMAND chmod a+x "${APPIMAGETOOL_PATH}") |
15 |
| -endif() |
16 |
| -if(NOT EXISTS "${LD_PATH}") |
17 |
| - file(DOWNLOAD https://github.com/linuxdeploy/linuxdeploy/releases/download/continuous/linuxdeploy-${CMAKE_SYSTEM_PROCESSOR}.AppImage "${LD_PATH}") |
18 |
| - execute_process(COMMAND chmod a+x "${LD_PATH}") |
| 6 | +set(APPIMAGE_PATH "${CMAKE_BINARY_DIR}/${CMAKE_PROJECT_NAME}-${CMAKE_SYSTEM_PROCESSOR}.AppImage") |
| 7 | + |
| 8 | +#===========================================================================# |
| 9 | +# Download Tools |
| 10 | + |
| 11 | +function(download_tool VAR URL) |
| 12 | + cmake_path(GET URL FILENAME _name) |
| 13 | + set(_dest "${CMAKE_BINARY_DIR}/tools/${_name}") |
| 14 | + if(NOT EXISTS "${_dest}") |
| 15 | + file(MAKE_DIRECTORY "${CMAKE_BINARY_DIR}/tools") |
| 16 | + message(STATUS "QGC: Downloading ${_name} to ${_dest}") |
| 17 | + file(DOWNLOAD "${URL}" "${_dest}" STATUS _status) |
| 18 | + list(GET _status 0 _result) |
| 19 | + if(NOT _result EQUAL 0) |
| 20 | + message(FATAL_ERROR "Failed to download ${URL} to ${_dest}: ${_status}") |
| 21 | + endif() |
| 22 | + file(CHMOD "${_dest}" FILE_PERMISSIONS OWNER_READ OWNER_WRITE OWNER_EXECUTE GROUP_READ GROUP_EXECUTE WORLD_READ WORLD_EXECUTE) |
| 23 | + endif() |
| 24 | + set(${VAR}_PATH "${_dest}" PARENT_SCOPE) |
| 25 | +endfunction() |
| 26 | + |
| 27 | +download_tool(LINUXDEPLOY https://github.com/linuxdeploy/linuxdeploy/releases/download/continuous/linuxdeploy-${CMAKE_SYSTEM_PROCESSOR}.AppImage) |
| 28 | +download_tool(APPIMAGETOOL https://github.com/AppImage/appimagetool/releases/download/continuous/appimagetool-${CMAKE_SYSTEM_PROCESSOR}.AppImage) |
| 29 | +if(CMAKE_SYSTEM_PROCESSOR MATCHES "x86_64") |
| 30 | + download_tool(APPIMAGELINT https://github.com/TheAssassin/appimagelint/releases/download/continuous/appimagelint-${CMAKE_SYSTEM_PROCESSOR}.AppImage) |
19 | 31 | endif()
|
20 |
| -# if(NOT EXISTS "${LD_APPIMAGEPLUGIN_PATH}") |
21 |
| -# file(DOWNLOAD https://github.com/linuxdeploy/linuxdeploy-plugin-appimage/releases/download/continuous/linuxdeploy-plugin-appimage-${CMAKE_SYSTEM_PROCESSOR}.AppImage "${LD_APPIMAGEPLUGIN_PATH}") |
22 |
| -# execute_process(COMMAND chmod a+x "${LD_APPIMAGEPLUGIN_PATH}") |
23 |
| -# endif() |
24 |
| -# if(NOT EXISTS "${LD_QTPLUGIN_PATH}") |
25 |
| -# file(DOWNLOAD https://github.com/linuxdeploy/linuxdeploy-plugin-qt/releases/download/continuous/linuxdeploy-plugin-qt-${CMAKE_SYSTEM_PROCESSOR}.AppImage "${LD_QTPLUGIN_PATH}") |
26 |
| -# execute_process(COMMAND chmod a+x "${LD_QTPLUGIN_PATH}") |
27 |
| -# endif() |
28 |
| -# if(NOT EXISTS "${LD_GSTPLUGIN_PATH}") |
29 |
| -# file(DOWNLOAD https://raw.githubusercontent.com/linuxdeploy/linuxdeploy-plugin-gstreamer/master/linuxdeploy-plugin-gstreamer.sh "${LD_GSTPLUGIN_PATH}") |
30 |
| -# execute_process(COMMAND chmod a+x "${LD_GSTPLUGIN_PATH}") |
31 |
| -# endif() |
32 |
| - |
33 |
| -execute_process(COMMAND ${LD_PATH} |
34 |
| - --appdir ${APPDIR_PATH} |
35 |
| - --executable ${APPDIR_PATH}/usr/bin/QGroundControl |
36 |
| - --desktop-file ${APPDIR_PATH}/usr/share/applications/org.mavlink.qgroundcontrol.desktop |
37 |
| - --custom-apprun ${CMAKE_BINARY_DIR}/AppRun) |
38 |
| - # --plugin qt --plugin gstreamer |
39 |
| - # --exclude-library "libgst*" |
| 32 | + |
| 33 | +#===========================================================================# |
| 34 | +# Bundle the runtime |
| 35 | + |
| 36 | +execute_process( |
| 37 | + COMMAND "${LINUXDEPLOY_PATH}" |
| 38 | + --appdir "${APPDIR_PATH}" |
| 39 | + --executable "${APPDIR_PATH}/usr/bin/${CMAKE_PROJECT_NAME}" |
| 40 | + --desktop-file "${APPDIR_PATH}/usr/share/applications/${QGC_PACKAGE_NAME}.desktop" |
| 41 | + --custom-apprun "${CMAKE_BINARY_DIR}/AppRun" |
| 42 | + --icon-file "${APPDIR_PATH}/usr/share/icons/hicolor/256x256/apps/${CMAKE_PROJECT_NAME}.png" |
| 43 | + COMMAND_ECHO STDOUT |
| 44 | + COMMAND_ERROR_IS_FATAL ANY |
| 45 | +) |
| 46 | + |
| 47 | +#===========================================================================# |
| 48 | +# Build the final AppImage |
40 | 49 |
|
41 | 50 | set(ENV{ARCH} ${CMAKE_SYSTEM_PROCESSOR})
|
42 |
| -# set(ENV{VERSION} 5.0) |
43 |
| -execute_process(COMMAND ${APPIMAGETOOL_PATH} ${APPDIR_PATH}) |
| 51 | +set(ENV{VERSION} ${CMAKE_PROJECT_VERSION}) |
| 52 | +execute_process( |
| 53 | + COMMAND "${APPIMAGETOOL_PATH}" "${APPDIR_PATH}" "${APPIMAGE_PATH}" |
| 54 | + COMMAND_ECHO STDOUT |
| 55 | + COMMAND_ERROR_IS_FATAL ANY |
| 56 | +) |
| 57 | + |
| 58 | +#===========================================================================# |
| 59 | +# Lint |
| 60 | + |
| 61 | +if(EXISTS "${APPIMAGELINT_PATH}") |
| 62 | + execute_process( |
| 63 | + COMMAND "${APPIMAGELINT_PATH}" "${APPIMAGE_PATH}" |
| 64 | + RESULT_VARIABLE LINT_RESULT |
| 65 | + COMMAND_ECHO STDOUT |
| 66 | + ) |
| 67 | + if(NOT LINT_RESULT EQUAL 0) |
| 68 | + message(WARNING "QGC: appimagelint reported problems; see log above") |
| 69 | + endif() |
| 70 | +endif() |
0 commit comments