Merge branch 'master' of https://github.com/calamares/calamares into development
This commit is contained in:
commit
b58bc964c3
3
CHANGES
3
CHANGES
@ -12,6 +12,9 @@ This release contains contributions from (alphabetically by first name):
|
|||||||
|
|
||||||
## Modules ##
|
## Modules ##
|
||||||
|
|
||||||
|
- *branding* now supports os-release variables in the *strings* section,
|
||||||
|
which allows re-using (at runtime) information set in /etc/os-release .
|
||||||
|
This requires KDE Frameworks 5.58. #1150
|
||||||
|
|
||||||
# 3.2.8 (2019-05-10) #
|
# 3.2.8 (2019-05-10) #
|
||||||
|
|
||||||
|
@ -40,8 +40,18 @@ windowSize: 800px,520px
|
|||||||
#
|
#
|
||||||
# bootloaderEntryName is how this installation / distro is named
|
# bootloaderEntryName is how this installation / distro is named
|
||||||
# in the boot loader (e.g. in the GRUB menu).
|
# in the boot loader (e.g. in the GRUB menu).
|
||||||
|
#
|
||||||
|
# These strings support substitution from /etc/os-release
|
||||||
|
# if KDE Frameworks 5.58 are available at build-time. When
|
||||||
|
# enabled, @{var-name} is replaced by the equivalent value
|
||||||
|
# from os-release. All the supported var-names are in all-caps,
|
||||||
|
# and are listed on the FreeDesktop.org site,
|
||||||
|
# https://www.freedesktop.org/software/systemd/man/os-release.html
|
||||||
|
# Note that ANSI_COLOR and CPE_NAME don't make sense here, and
|
||||||
|
# are not supported (the rest are). Remember to quote the string
|
||||||
|
# if it contains substitutions, or you'll get YAML exceptions.
|
||||||
strings:
|
strings:
|
||||||
productName: Generic GNU/Linux
|
productName: "@{NAME}"
|
||||||
shortProductName: Generic
|
shortProductName: Generic
|
||||||
version: 2017.8 LTS
|
version: 2017.8 LTS
|
||||||
shortVersion: 2017.8
|
shortVersion: 2017.8
|
||||||
|
@ -39,21 +39,21 @@ set_target_properties(calamares_bin
|
|||||||
)
|
)
|
||||||
calamares_automoc( calamares_bin )
|
calamares_automoc( calamares_bin )
|
||||||
|
|
||||||
if( WITH_KF5Crash )
|
|
||||||
set( LINK_LIBRARIES
|
|
||||||
KF5::CoreAddons
|
|
||||||
KF5::Crash
|
|
||||||
)
|
|
||||||
endif()
|
|
||||||
|
|
||||||
target_link_libraries( calamares_bin
|
target_link_libraries( calamares_bin
|
||||||
PRIVATE
|
PRIVATE
|
||||||
${CALAMARES_LIBRARIES}
|
${CALAMARES_LIBRARIES}
|
||||||
calamaresui
|
calamaresui
|
||||||
Qt5::Core
|
Qt5::Core
|
||||||
Qt5::Widgets
|
Qt5::Widgets
|
||||||
${LINK_LIBRARIES}
|
|
||||||
)
|
)
|
||||||
|
if( WITH_KF5Crash )
|
||||||
|
target_link_libraries( calamares_bin
|
||||||
|
PRIVATE
|
||||||
|
KF5::CoreAddons
|
||||||
|
KF5::Crash
|
||||||
|
)
|
||||||
|
target_compile_definitions( calamares_bin PRIVATE WITH_KF5Crash )
|
||||||
|
endif()
|
||||||
|
|
||||||
install( TARGETS calamares_bin
|
install( TARGETS calamares_bin
|
||||||
BUNDLE DESTINATION .
|
BUNDLE DESTINATION .
|
||||||
|
@ -26,7 +26,7 @@
|
|||||||
#include "utils/Logger.h"
|
#include "utils/Logger.h"
|
||||||
#include "CalamaresConfig.h"
|
#include "CalamaresConfig.h"
|
||||||
|
|
||||||
#ifdef WITH_KCRASH
|
#ifdef WITH_KF5Crash
|
||||||
#include <KF5/KCrash/KCrash>
|
#include <KF5/KCrash/KCrash>
|
||||||
#include <KF5/KCoreAddons/KAboutData>
|
#include <KF5/KCoreAddons/KAboutData>
|
||||||
#endif
|
#endif
|
||||||
@ -84,7 +84,7 @@ main( int argc, char* argv[] )
|
|||||||
{
|
{
|
||||||
CalamaresApplication a( argc, argv );
|
CalamaresApplication a( argc, argv );
|
||||||
|
|
||||||
#ifdef WITH_KCRASH
|
#ifdef WITH_KF5Crash
|
||||||
KAboutData aboutData( "calamares",
|
KAboutData aboutData( "calamares",
|
||||||
"Calamares",
|
"Calamares",
|
||||||
a.applicationVersion(),
|
a.applicationVersion(),
|
||||||
|
@ -10,12 +10,6 @@
|
|||||||
|
|
||||||
//cmakedefines for CMake variables (e.g. for optdepends) go here
|
//cmakedefines for CMake variables (e.g. for optdepends) go here
|
||||||
#cmakedefine WITH_PYTHON
|
#cmakedefine WITH_PYTHON
|
||||||
|
|
||||||
#cmakedefine WITH_KF5Crash
|
|
||||||
#ifdef WITH_KF5Crash
|
|
||||||
#define WITH_KCRASH
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#cmakedefine WITH_PYTHONQT
|
#cmakedefine WITH_PYTHONQT
|
||||||
|
|
||||||
#endif // CALAMARESCONFIG_H
|
#endif // CALAMARESCONFIG_H
|
||||||
|
@ -32,6 +32,13 @@
|
|||||||
#include <QPixmap>
|
#include <QPixmap>
|
||||||
#include <QVariantMap>
|
#include <QVariantMap>
|
||||||
|
|
||||||
|
#include <functional>
|
||||||
|
|
||||||
|
#ifdef WITH_KOSRelease
|
||||||
|
#include <KMacroExpander>
|
||||||
|
#include <KOSRelease>
|
||||||
|
#endif
|
||||||
|
|
||||||
namespace Calamares
|
namespace Calamares
|
||||||
{
|
{
|
||||||
|
|
||||||
@ -87,6 +94,32 @@ Branding::WindowDimension::suffixes()
|
|||||||
return names;
|
return names;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/** @brief Load the @p map with strings from @p doc
|
||||||
|
*
|
||||||
|
* Each key-value pair from the sub-map in @p doc identified by @p key
|
||||||
|
* is inserted into the @p map, but the value is first transformed by
|
||||||
|
* the @p transform function, which may change strings.
|
||||||
|
*/
|
||||||
|
static void
|
||||||
|
loadStrings( QMap<QString, QString>& map, const YAML::Node& doc, const std::string& key, const std::function< QString(const QString&) >& transform )
|
||||||
|
{
|
||||||
|
if ( !doc[ key ].IsMap() )
|
||||||
|
throw YAML::Exception( YAML::Mark(), std::string("Branding configuration is not a map: ") + key );
|
||||||
|
|
||||||
|
const auto& config = CalamaresUtils::yamlMapToVariant( doc[ key ] ).toMap();
|
||||||
|
|
||||||
|
map.clear();
|
||||||
|
for ( auto it = config.constBegin(); it != config.constEnd(); ++it )
|
||||||
|
map.insert( it.key(), transform( it.value().toString() ) );
|
||||||
|
}
|
||||||
|
|
||||||
|
/** @brief Load the @p map with strings from @p config
|
||||||
|
*
|
||||||
|
* If os-release is supported (with KF5 CoreAddons >= 5.58) then
|
||||||
|
* special substitutions can be done as well. See the branding
|
||||||
|
* documentation for details.
|
||||||
|
*/
|
||||||
|
|
||||||
Branding::Branding( const QString& brandingFilePath,
|
Branding::Branding( const QString& brandingFilePath,
|
||||||
QObject* parent )
|
QObject* parent )
|
||||||
: QObject( parent )
|
: QObject( parent )
|
||||||
@ -118,31 +151,49 @@ Branding::Branding( const QString& brandingFilePath,
|
|||||||
|
|
||||||
initSimpleSettings( doc );
|
initSimpleSettings( doc );
|
||||||
|
|
||||||
if ( !doc[ "strings" ].IsMap() )
|
#ifdef WITH_KOSRelease
|
||||||
bail( "Syntax error in strings map." );
|
KOSRelease relInfo;
|
||||||
|
|
||||||
QVariantMap strings =
|
QHash< QString, QString > relMap{
|
||||||
CalamaresUtils::yamlMapToVariant( doc[ "strings" ] ).toMap();
|
std::initializer_list< std::pair< QString, QString > > {
|
||||||
m_strings.clear();
|
{ QStringLiteral( "NAME" ), relInfo.name() },
|
||||||
for ( auto it = strings.constBegin(); it != strings.constEnd(); ++it )
|
{ QStringLiteral( "VERSION" ), relInfo.version() },
|
||||||
m_strings.insert( it.key(), it.value().toString() );
|
{ QStringLiteral( "ID" ), relInfo.id() },
|
||||||
|
{ QStringLiteral( "ID_LIKE" ), relInfo.idLike().join( ' ' ) },
|
||||||
if ( !doc[ "images" ].IsMap() )
|
{ QStringLiteral( "VERSION_CODENAME" ), relInfo.versionCodename() },
|
||||||
bail( "Syntax error in images map." );
|
{ QStringLiteral( "VERSION_ID" ), relInfo.versionId() },
|
||||||
|
{ QStringLiteral( "PRETTY_NAME" ), relInfo.prettyName() },
|
||||||
QVariantMap images =
|
{ QStringLiteral( "HOME_URL" ), relInfo.homeUrl() },
|
||||||
CalamaresUtils::yamlMapToVariant( doc[ "images" ] ).toMap();
|
{ QStringLiteral( "DOCUMENTATION_URL" ), relInfo.documentationUrl() },
|
||||||
m_images.clear();
|
{ QStringLiteral( "SUPPORT_URL" ), relInfo.supportUrl() },
|
||||||
for ( auto it = images.constBegin(); it != images.constEnd(); ++it )
|
{ QStringLiteral( "BUG_REPORT_URL" ), relInfo.bugReportUrl() },
|
||||||
{
|
{ QStringLiteral( "PRIVACY_POLICY_URL" ), relInfo.privacyPolicyUrl() },
|
||||||
QString pathString = it.value().toString();
|
{ QStringLiteral( "BUILD_ID" ), relInfo.buildId() },
|
||||||
QFileInfo imageFi( componentDir.absoluteFilePath( pathString ) );
|
{ QStringLiteral( "VARIANT" ), relInfo.variant() },
|
||||||
if ( !imageFi.exists() )
|
{ QStringLiteral( "VARIANT_ID" ), relInfo.variantId() },
|
||||||
bail( QString( "Image file %1 does not exist." )
|
{ QStringLiteral( "LOGO" ), relInfo.logo() }
|
||||||
.arg( imageFi.absoluteFilePath() ) );
|
} };
|
||||||
|
loadStrings( m_strings, doc, "strings",
|
||||||
m_images.insert( it.key(), imageFi.absoluteFilePath() );
|
[&]( const QString& s ) -> QString { return KMacroExpander::expandMacros( s, relMap, QLatin1Char( '@' ) ); }
|
||||||
}
|
);
|
||||||
|
#else
|
||||||
|
// No support for substituting in os-release values.
|
||||||
|
loadStrings( m_strings, doc, "strings",
|
||||||
|
[]( const QString& s ) -> QString { return s; }
|
||||||
|
);
|
||||||
|
#endif
|
||||||
|
loadStrings( m_images, doc, "images",
|
||||||
|
[&]( const QString& s ) -> QString
|
||||||
|
{
|
||||||
|
QFileInfo imageFi( componentDir.absoluteFilePath( s ) );
|
||||||
|
if ( !imageFi.exists() )
|
||||||
|
bail( QString( "Image file %1 does not exist." ).arg( imageFi.absoluteFilePath() ) );
|
||||||
|
return imageFi.absoluteFilePath();
|
||||||
|
}
|
||||||
|
);
|
||||||
|
loadStrings( m_style, doc, "style",
|
||||||
|
[]( const QString& s ) -> QString { return s; }
|
||||||
|
);
|
||||||
|
|
||||||
if ( doc[ "slideshow" ].IsSequence() )
|
if ( doc[ "slideshow" ].IsSequence() )
|
||||||
{
|
{
|
||||||
@ -174,20 +225,11 @@ Branding::Branding( const QString& brandingFilePath,
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
bail( "Syntax error in slideshow sequence." );
|
bail( "Syntax error in slideshow sequence." );
|
||||||
|
|
||||||
if ( !doc[ "style" ].IsMap() )
|
|
||||||
bail( "Syntax error in style map." );
|
|
||||||
|
|
||||||
QVariantMap style =
|
|
||||||
CalamaresUtils::yamlMapToVariant( doc[ "style" ] ).toMap();
|
|
||||||
m_style.clear();
|
|
||||||
for ( auto it = style.constBegin(); it != style.constEnd(); ++it )
|
|
||||||
m_style.insert( it.key(), it.value().toString() );
|
|
||||||
|
|
||||||
}
|
}
|
||||||
catch ( YAML::Exception& e )
|
catch ( YAML::Exception& e )
|
||||||
{
|
{
|
||||||
CalamaresUtils::explainYamlException( e, ba, file.fileName() );
|
CalamaresUtils::explainYamlException( e, ba, file.fileName() );
|
||||||
|
bail( e.what() );
|
||||||
}
|
}
|
||||||
|
|
||||||
QDir translationsDir( componentDir.filePath( "lang" ) );
|
QDir translationsDir( componentDir.filePath( "lang" ) );
|
||||||
|
@ -64,8 +64,7 @@ if( WITH_PYTHONQT )
|
|||||||
viewpages/PythonQtGlobalStorageWrapper.cpp
|
viewpages/PythonQtGlobalStorageWrapper.cpp
|
||||||
viewpages/PythonQtUtilsWrapper.cpp
|
viewpages/PythonQtUtilsWrapper.cpp
|
||||||
)
|
)
|
||||||
set( OPTIONAL_PRIVATE_LIBRARIES
|
set( OPTIONAL_PYTHON_LIBRARIES
|
||||||
${OPTIONAL_PRIVATE_LIBRARIES}
|
|
||||||
${PYTHON_LIBRARIES}
|
${PYTHON_LIBRARIES}
|
||||||
${PYTHONQT_LIBRARIES}
|
${PYTHONQT_LIBRARIES}
|
||||||
)
|
)
|
||||||
@ -76,7 +75,7 @@ calamares_add_library( calamaresui
|
|||||||
UI ${calamaresui_UI}
|
UI ${calamaresui_UI}
|
||||||
EXPORT_MACRO UIDLLEXPORT_PRO
|
EXPORT_MACRO UIDLLEXPORT_PRO
|
||||||
LINK_PRIVATE_LIBRARIES
|
LINK_PRIVATE_LIBRARIES
|
||||||
${OPTIONAL_PRIVATE_LIBRARIES}
|
${OPTIONAL_PYTHON_LIBRARIES}
|
||||||
LINK_LIBRARIES
|
LINK_LIBRARIES
|
||||||
Qt5::Svg
|
Qt5::Svg
|
||||||
Qt5::QuickWidgets
|
Qt5::QuickWidgets
|
||||||
@ -84,3 +83,9 @@ calamares_add_library( calamaresui
|
|||||||
EXPORT CalamaresLibraryDepends
|
EXPORT CalamaresLibraryDepends
|
||||||
VERSION ${CALAMARES_VERSION_SHORT}
|
VERSION ${CALAMARES_VERSION_SHORT}
|
||||||
)
|
)
|
||||||
|
|
||||||
|
find_package( KF5CoreAddons 5.58 QUIET ) # If it's really new
|
||||||
|
if ( KF5CoreAddons_FOUND )
|
||||||
|
target_compile_definitions( calamaresui PRIVATE WITH_KOSRelease )
|
||||||
|
target_link_libraries( calamaresui PRIVATE KF5::CoreAddons )
|
||||||
|
endif()
|
||||||
|
@ -21,14 +21,6 @@ set_package_properties(
|
|||||||
)
|
)
|
||||||
|
|
||||||
if ( KF5Plasma_FOUND AND KF5Package_FOUND )
|
if ( KF5Plasma_FOUND AND KF5Package_FOUND )
|
||||||
if ( KF5Config_FOUND )
|
|
||||||
set( option_kf5 Config )
|
|
||||||
set( option_defs WITH_KCONFIG )
|
|
||||||
# set( option_libs KF5::Config ) # Not needed anyway
|
|
||||||
endif()
|
|
||||||
|
|
||||||
find_package( KF5 ${lnf_ver} REQUIRED CoreAddons Plasma Package ${option_kf5} )
|
|
||||||
|
|
||||||
calamares_add_plugin( plasmalnf
|
calamares_add_plugin( plasmalnf
|
||||||
TYPE viewmodule
|
TYPE viewmodule
|
||||||
EXPORT_MACRO PLUGINDLLEXPORT_PRO
|
EXPORT_MACRO PLUGINDLLEXPORT_PRO
|
||||||
@ -45,11 +37,13 @@ if ( KF5Plasma_FOUND AND KF5Package_FOUND )
|
|||||||
page_plasmalnf.ui
|
page_plasmalnf.ui
|
||||||
LINK_PRIVATE_LIBRARIES
|
LINK_PRIVATE_LIBRARIES
|
||||||
calamaresui
|
calamaresui
|
||||||
${option_libs}
|
|
||||||
KF5::Package
|
KF5::Package
|
||||||
KF5::Plasma
|
KF5::Plasma
|
||||||
SHARED_LIB
|
SHARED_LIB
|
||||||
)
|
)
|
||||||
|
if ( KF5Config_FOUND )
|
||||||
|
target_compile_definitions(calamares_viewmodule_plasmalnf PRIVATE WITH_KCONFIG)
|
||||||
|
endif()
|
||||||
else()
|
else()
|
||||||
calamares_skip_module( "plasmalnf (missing requirements)" )
|
calamares_skip_module( "plasmalnf (missing requirements)" )
|
||||||
endif()
|
endif()
|
||||||
|
Loading…
Reference in New Issue
Block a user