Skip to content

Commit

Permalink
Merge pull request #2631 from mitya57/metainfo
Browse files Browse the repository at this point in the history
Add AppStream metainfo file
  • Loading branch information
elfmz authored Feb 22, 2025
2 parents 1b85dd8 + d42482c commit cd70be2
Show file tree
Hide file tree
Showing 5 changed files with 125 additions and 1 deletion.
4 changes: 4 additions & 0 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -176,6 +176,7 @@ jobs:
libssl-dev libsmbclient-dev libnfs-dev libneon27-dev libssh-dev
libarchive-dev
python3-dev python3-cffi
python3-markdown appstream
- name: Create Build Environment
# Create a separate build directory as working directory for all subsequent commands
Expand All @@ -195,6 +196,9 @@ jobs:
# Execute the build. You can specify a specific target with "--target <NAME>"
run: |
cmake --build _build --config $BUILD_TYPE -j$(nproc --all)
- name: Validate AppStream metainfo file
run: appstreamcli validate --strict _build/far2l/DE/io.github.elfmz.far2l.metainfo.xml

macos14-arm64-clang15:
if: ${{ !(github.event_name == 'push' && github.ref == 'refs/heads/master' && github.repository != 'elfmz/far2l') }}
Expand Down
2 changes: 1 addition & 1 deletion changelog.md
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ Only significant user-side changes are listed here (for all changes see history
* _New:_ RGB in far2l Palette
* Several bugfixes

## 2.6.1 beta + hotfix (2024-04-14)
## 2.6.1 beta (2024-04-14)
## 2.6.0 beta (2024-02-19)
## 2.5.3 beta (2023-11-05)
## 2.5.3 beta (2023-11-05)
Expand Down
30 changes: 30 additions & 0 deletions far2l/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -300,4 +300,34 @@ else()
DESTINATION "share/applications"
COMPONENT desktop
PERMISSIONS OWNER_EXECUTE OWNER_WRITE OWNER_READ GROUP_EXECUTE GROUP_READ WORLD_READ WORLD_EXECUTE)

find_package(Python3 COMPONENTS Interpreter)

if(Python3_Interpreter_FOUND)
execute_process(COMMAND "${Python3_EXECUTABLE}" -c "import markdown"
RESULT_VARIABLE PYTHON_MARKDOWN_STATUS
OUTPUT_QUIET
ERROR_QUIET)

if(PYTHON_MARKDOWN_STATUS EQUAL 0)
add_custom_command(TARGET far2l POST_BUILD
COMMAND ${Python3_EXECUTABLE} "${CMAKE_CURRENT_SOURCE_DIR}/DE/generate_metainfo.py"
"${CMAKE_SOURCE_DIR}/changelog.md"
"${CMAKE_CURRENT_SOURCE_DIR}/DE/io.github.elfmz.far2l.metainfo.xml.in"
"${CMAKE_CURRENT_BINARY_DIR}/DE/io.github.elfmz.far2l.metainfo.xml"
DEPENDS "${CMAKE_CURRENT_SOURCE_DIR}/DE/generate_metainfo.py"
"${CMAKE_SOURCE_DIR}/changelog.md"
"${CMAKE_CURRENT_SOURCE_DIR}/DE/io.github.elfmz.far2l.metainfo.xml.in"
COMMENT "Generating DE/io.github.elfmz.far2l.metainfo.xml"
VERBATIM)
install(FILES "${CMAKE_CURRENT_BINARY_DIR}/DE/io.github.elfmz.far2l.metainfo.xml"
DESTINATION "share/metainfo"
COMPONENT desktop)
else()
message(WARNING "Python-Markdown not found. Skipping AppStream metainfo generation.")
endif()
else()
message(WARNING "Python3 interpreter not found. Skipping AppStream metainfo generation.")
endif()

endif()
38 changes: 38 additions & 0 deletions far2l/DE/generate_metainfo.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
#!/usr/bin/env python3

import markdown
import re
import sys
import xml.etree.ElementTree as ET

[changelog_file, xml_template_file, xml_output_file] = sys.argv[1:]

with open(changelog_file) as fp:
md_text = fp.read()

html_content = markdown.markdown(md_text)
html_root = ET.fromstring(f"<root>{html_content}</root>")
release_re = re.compile(r"(?P<version>[\d.]+) (?P<type>[a-z]+) \((?P<date>\d{4}-\d{2}-\d{2})\)")

tree = ET.parse(xml_template_file)
releases = tree.getroot().find("releases")
release_elem = None

for elem in html_root:
if elem.tag == "h2":
if elem.text[0].isdecimal():
match = release_re.match(elem.text)
release = match.groupdict()
if release["type"] == "beta":
release["type"] = "development"
release_elem = ET.SubElement(releases, "release", release)
elif elem.tag == "ul" and release_elem is not None:
for child_elem in elem.iter():
# https://www.freedesktop.org/software/appstream/docs/chap-Metadata.html#tag-description
if child_elem.tag == "strong":
child_elem.tag = "em"
desc_elem = ET.SubElement(release_elem, "description")
desc_elem.append(elem)

ET.indent(tree)
tree.write(xml_output_file, encoding="utf-8", xml_declaration=True)
52 changes: 52 additions & 0 deletions far2l/DE/io.github.elfmz.far2l.metainfo.xml.in
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
<?xml version="1.0" encoding="UTF-8"?>
<component type="desktop-application">
<id>io.github.elfmz.far2l</id>

<name>far2l</name>
<summary>Linux port of FAR v2</summary>
<categories>
<category>Utility</category>
<category>FileManager</category>
<category>System</category>
<category>FileTools</category>
</categories>
<url type="homepage">https://github.com/elfmz/far2l</url>
<developer id="io.github.elfmz">
<name>elfmz</name>
</developer>
<content_rating type="oars-1.1"/>

<metadata_license>CC0-1.0</metadata_license>
<project_license>GPL-2.0 and BSD-3-Clause</project_license>

<description>
<p>
This is a clone of FAR manager for Windows, similar, but more powerful than Norton Commander/Midnight Commander.
</p>
<p>
Plug-ins that are currently working:
</p>
<ul>
<li>align</li>
<li>autowrap</li>
<li>calc</li>
<li>colorer</li>
<li>compare</li>
<li>drawline</li>
<li>editcase</li>
<li>editorcomp</li>
<li>filecase</li>
<li>incsrch</li>
<li>inside</li>
<li>multiarc</li>
<li>NetRocks (SFTP/SCP/FTP/FTPS/SMB/NFS/WebDAV)</li>
<li>python</li>
<li>SimpleIndent</li>
<li>tmppanel</li>
</ul>
</description>

<launchable type="desktop-id">far2l.desktop</launchable>

<releases/>
</component>

0 comments on commit cd70be2

Please sign in to comment.