|
|
9b34cb7 |
From 09a496c65e5f91767336daddd0c9aa13d22160d5 Mon Sep 17 00:00:00 2001
|
|
|
9b34cb7 |
From: Fabio Valentini <decathorpe@gmail.com>
|
|
|
9b34cb7 |
Date: Oct 31 2022 14:26:11 +0000
|
|
|
9b34cb7 |
Subject: rust2rpm: fix crash in sorting of binary targets
|
|
|
9b34cb7 |
|
|
|
9b34cb7 |
|
|
|
9b34cb7 |
The "sort" Jinja2 filter doesn't work because the bins are objects,
|
|
|
9b34cb7 |
not strings. This commit changes the sorting to happen correctly,
|
|
|
9b34cb7 |
before binary targets are passed to the template for rendering.
|
|
|
9b34cb7 |
|
|
|
9b34cb7 |
---
|
|
|
9b34cb7 |
|
|
|
9b34cb7 |
diff --git a/rust2rpm/generator.py b/rust2rpm/generator.py
|
|
|
9b34cb7 |
index e01c1b5..76875f7 100644
|
|
|
9b34cb7 |
--- a/rust2rpm/generator.py
|
|
|
9b34cb7 |
+++ b/rust2rpm/generator.py
|
|
|
9b34cb7 |
@@ -1,3 +1,4 @@
|
|
|
9b34cb7 |
+import operator
|
|
|
9b34cb7 |
import time
|
|
|
9b34cb7 |
|
|
|
9b34cb7 |
import jinja2
|
|
|
9b34cb7 |
@@ -52,6 +53,9 @@ def spec_file_render(
|
|
|
9b34cb7 |
is_bin = len(bins) > 0
|
|
|
9b34cb7 |
is_lib = len(libs) > 0
|
|
|
9b34cb7 |
|
|
|
9b34cb7 |
+ # sort binaries by name for consistent ordering
|
|
|
9b34cb7 |
+ bins.sort(key=operator.attrgetter("name"))
|
|
|
9b34cb7 |
+
|
|
|
9b34cb7 |
kwargs = {
|
|
|
9b34cb7 |
"generator_version": __version__,
|
|
|
9b34cb7 |
"target": args.target,
|
|
|
9b34cb7 |
diff --git a/rust2rpm/templates/main.spec b/rust2rpm/templates/main.spec
|
|
|
9b34cb7 |
index b39df3b..13b9bfd 100644
|
|
|
9b34cb7 |
--- a/rust2rpm/templates/main.spec
|
|
|
9b34cb7 |
+++ b/rust2rpm/templates/main.spec
|
|
|
9b34cb7 |
@@ -124,7 +124,7 @@ Requires: {{ req }}
|
|
|
9b34cb7 |
{% for file in doc_files %}
|
|
|
9b34cb7 |
%doc {{ file }}
|
|
|
9b34cb7 |
{% endfor %}
|
|
|
9b34cb7 |
- {% for bin in bins | sort %}
|
|
|
9b34cb7 |
+ {% for bin in bins %}
|
|
|
9b34cb7 |
%{_bindir}/{{ bin.name }}
|
|
|
9b34cb7 |
{% endfor %}
|
|
|
9b34cb7 |
{% if not only_main %}
|
|
|
9b34cb7 |
|