Skip to content

Commit cd70be2

Browse files
authored
Merge pull request elfmz#2631 from mitya57/metainfo
Add AppStream metainfo file
2 parents 1b85dd8 + d42482c commit cd70be2

File tree

5 files changed

+125
-1
lines changed

5 files changed

+125
-1
lines changed

.github/workflows/build.yml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -176,6 +176,7 @@ jobs:
176176
libssl-dev libsmbclient-dev libnfs-dev libneon27-dev libssh-dev
177177
libarchive-dev
178178
python3-dev python3-cffi
179+
python3-markdown appstream
179180
180181
- name: Create Build Environment
181182
# Create a separate build directory as working directory for all subsequent commands
@@ -195,6 +196,9 @@ jobs:
195196
# Execute the build. You can specify a specific target with "--target <NAME>"
196197
run: |
197198
cmake --build _build --config $BUILD_TYPE -j$(nproc --all)
199+
200+
- name: Validate AppStream metainfo file
201+
run: appstreamcli validate --strict _build/far2l/DE/io.github.elfmz.far2l.metainfo.xml
198202

199203
macos14-arm64-clang15:
200204
if: ${{ !(github.event_name == 'push' && github.ref == 'refs/heads/master' && github.repository != 'elfmz/far2l') }}

changelog.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,7 @@ Only significant user-side changes are listed here (for all changes see history
5959
* _New:_ RGB in far2l Palette
6060
* Several bugfixes
6161

62-
## 2.6.1 beta + hotfix (2024-04-14)
62+
## 2.6.1 beta (2024-04-14)
6363
## 2.6.0 beta (2024-02-19)
6464
## 2.5.3 beta (2023-11-05)
6565
## 2.5.3 beta (2023-11-05)

far2l/CMakeLists.txt

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -300,4 +300,34 @@ else()
300300
DESTINATION "share/applications"
301301
COMPONENT desktop
302302
PERMISSIONS OWNER_EXECUTE OWNER_WRITE OWNER_READ GROUP_EXECUTE GROUP_READ WORLD_READ WORLD_EXECUTE)
303+
304+
find_package(Python3 COMPONENTS Interpreter)
305+
306+
if(Python3_Interpreter_FOUND)
307+
execute_process(COMMAND "${Python3_EXECUTABLE}" -c "import markdown"
308+
RESULT_VARIABLE PYTHON_MARKDOWN_STATUS
309+
OUTPUT_QUIET
310+
ERROR_QUIET)
311+
312+
if(PYTHON_MARKDOWN_STATUS EQUAL 0)
313+
add_custom_command(TARGET far2l POST_BUILD
314+
COMMAND ${Python3_EXECUTABLE} "${CMAKE_CURRENT_SOURCE_DIR}/DE/generate_metainfo.py"
315+
"${CMAKE_SOURCE_DIR}/changelog.md"
316+
"${CMAKE_CURRENT_SOURCE_DIR}/DE/io.github.elfmz.far2l.metainfo.xml.in"
317+
"${CMAKE_CURRENT_BINARY_DIR}/DE/io.github.elfmz.far2l.metainfo.xml"
318+
DEPENDS "${CMAKE_CURRENT_SOURCE_DIR}/DE/generate_metainfo.py"
319+
"${CMAKE_SOURCE_DIR}/changelog.md"
320+
"${CMAKE_CURRENT_SOURCE_DIR}/DE/io.github.elfmz.far2l.metainfo.xml.in"
321+
COMMENT "Generating DE/io.github.elfmz.far2l.metainfo.xml"
322+
VERBATIM)
323+
install(FILES "${CMAKE_CURRENT_BINARY_DIR}/DE/io.github.elfmz.far2l.metainfo.xml"
324+
DESTINATION "share/metainfo"
325+
COMPONENT desktop)
326+
else()
327+
message(WARNING "Python-Markdown not found. Skipping AppStream metainfo generation.")
328+
endif()
329+
else()
330+
message(WARNING "Python3 interpreter not found. Skipping AppStream metainfo generation.")
331+
endif()
332+
303333
endif()

far2l/DE/generate_metainfo.py

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
#!/usr/bin/env python3
2+
3+
import markdown
4+
import re
5+
import sys
6+
import xml.etree.ElementTree as ET
7+
8+
[changelog_file, xml_template_file, xml_output_file] = sys.argv[1:]
9+
10+
with open(changelog_file) as fp:
11+
md_text = fp.read()
12+
13+
html_content = markdown.markdown(md_text)
14+
html_root = ET.fromstring(f"<root>{html_content}</root>")
15+
release_re = re.compile(r"(?P<version>[\d.]+) (?P<type>[a-z]+) \((?P<date>\d{4}-\d{2}-\d{2})\)")
16+
17+
tree = ET.parse(xml_template_file)
18+
releases = tree.getroot().find("releases")
19+
release_elem = None
20+
21+
for elem in html_root:
22+
if elem.tag == "h2":
23+
if elem.text[0].isdecimal():
24+
match = release_re.match(elem.text)
25+
release = match.groupdict()
26+
if release["type"] == "beta":
27+
release["type"] = "development"
28+
release_elem = ET.SubElement(releases, "release", release)
29+
elif elem.tag == "ul" and release_elem is not None:
30+
for child_elem in elem.iter():
31+
# https://www.freedesktop.org/software/appstream/docs/chap-Metadata.html#tag-description
32+
if child_elem.tag == "strong":
33+
child_elem.tag = "em"
34+
desc_elem = ET.SubElement(release_elem, "description")
35+
desc_elem.append(elem)
36+
37+
ET.indent(tree)
38+
tree.write(xml_output_file, encoding="utf-8", xml_declaration=True)
Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,52 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<component type="desktop-application">
3+
<id>io.github.elfmz.far2l</id>
4+
5+
<name>far2l</name>
6+
<summary>Linux port of FAR v2</summary>
7+
<categories>
8+
<category>Utility</category>
9+
<category>FileManager</category>
10+
<category>System</category>
11+
<category>FileTools</category>
12+
</categories>
13+
<url type="homepage">https://github.com/elfmz/far2l</url>
14+
<developer id="io.github.elfmz">
15+
<name>elfmz</name>
16+
</developer>
17+
<content_rating type="oars-1.1"/>
18+
19+
<metadata_license>CC0-1.0</metadata_license>
20+
<project_license>GPL-2.0 and BSD-3-Clause</project_license>
21+
22+
<description>
23+
<p>
24+
This is a clone of FAR manager for Windows, similar, but more powerful than Norton Commander/Midnight Commander.
25+
</p>
26+
<p>
27+
Plug-ins that are currently working:
28+
</p>
29+
<ul>
30+
<li>align</li>
31+
<li>autowrap</li>
32+
<li>calc</li>
33+
<li>colorer</li>
34+
<li>compare</li>
35+
<li>drawline</li>
36+
<li>editcase</li>
37+
<li>editorcomp</li>
38+
<li>filecase</li>
39+
<li>incsrch</li>
40+
<li>inside</li>
41+
<li>multiarc</li>
42+
<li>NetRocks (SFTP/SCP/FTP/FTPS/SMB/NFS/WebDAV)</li>
43+
<li>python</li>
44+
<li>SimpleIndent</li>
45+
<li>tmppanel</li>
46+
</ul>
47+
</description>
48+
49+
<launchable type="desktop-id">far2l.desktop</launchable>
50+
51+
<releases/>
52+
</component>

0 commit comments

Comments
 (0)