From a7b3ccf1982319688c978c15f4f012c340520cc9 Mon Sep 17 00:00:00 2001 From: Adriaan de Groot Date: Sat, 2 Jul 2022 16:00:42 +0200 Subject: [PATCH] [oemid] Use consistent ${} substitution SEE #1438 --- CHANGES-3.3 | 2 ++ src/modules/oemid/OEMViewStep.cpp | 11 ++++------- src/modules/oemid/oemid.conf | 6 +++--- 3 files changed, 9 insertions(+), 10 deletions(-) diff --git a/CHANGES-3.3 b/CHANGES-3.3 index d5c9a5e7f..f2059f700 100644 --- a/CHANGES-3.3 +++ b/CHANGES-3.3 @@ -56,6 +56,8 @@ Pre-release versions: Please update configurations. - *mount* now does most of the mounting; options that were in *fstab* have moved here. See #1993 + - *oemid* now uses consistent variable replacement (e.g. KMacroExpander) + and does not support `@@DATE@@` anymore (use `${DATE}`). - *partition* requires KPMCore 21.12 (e.g. KPMCore 4.2 API, or later). - *partition* can now skip installing the bootloader in more scenarios. #1632 (Thanks Anubhav) diff --git a/src/modules/oemid/OEMViewStep.cpp b/src/modules/oemid/OEMViewStep.cpp index 0c1bdd1d8..0663efdbd 100644 --- a/src/modules/oemid/OEMViewStep.cpp +++ b/src/modules/oemid/OEMViewStep.cpp @@ -14,6 +14,7 @@ #include "IDJob.h" #include "utils/Retranslator.h" +#include "utils/StringExpander.h" #include "utils/Variant.h" #include @@ -82,14 +83,10 @@ OEMViewStep::isAtEnd() const static QString substitute( QString s ) { - QString t_date = QStringLiteral( "@@DATE@@" ); - if ( s.contains( t_date ) ) - { - auto date = QDate::currentDate(); - s = s.replace( t_date, date.toString( Qt::ISODate ) ); - } + Calamares::String::DictionaryExpander d; + d.insert( QStringLiteral( "DATE" ), QDate::currentDate().toString( Qt::ISODate ) ); - return s; + return d.expand( s ); } void diff --git a/src/modules/oemid/oemid.conf b/src/modules/oemid/oemid.conf index 921fb3b30..4fb14d931 100644 --- a/src/modules/oemid/oemid.conf +++ b/src/modules/oemid/oemid.conf @@ -5,12 +5,12 @@ --- # The batch-identifier is written to /var/log/installer/oem-id. # This value is put into the text box as the **suggested** -# OEM ID. If @@DATE@@ is included in the identifier, then +# OEM ID. If ${DATE} is included in the identifier, then # that is replaced by the current date in yyyy-MM-dd (ISO) format. # -# it is ok for the identifier to be empty. +# It is ok for the identifier to be empty. # # The identifier is written to the file as UTF-8 (this will be no # different from ASCII, for most inputs) and followed by a newline. # If the identifier is empty, only a newline is written. -batch-identifier: neon-@@DATE@@ +batch-identifier: neon-${DATE}