Merge branch 'master' into kpmcore-manager
This commit is contained in:
commit
1bb43e06e2
8
CHANGES
8
CHANGES
@ -31,6 +31,14 @@ This release contains contributions from (alphabetically by first name):
|
|||||||
"fancy" release notes as a QML application, rather than a webview
|
"fancy" release notes as a QML application, rather than a webview
|
||||||
or text widget. Note that this does not replace the slideshow-during-
|
or text widget. Note that this does not replace the slideshow-during-
|
||||||
installation module.
|
installation module.
|
||||||
|
- The *users* module now has knobs for setting the hostname and writing
|
||||||
|
the `/etc/hosts` file. The new configuration options are documented
|
||||||
|
in `users.conf`. #1140
|
||||||
|
- Multiple *netinstall* modules can exist side-by-side, and they each
|
||||||
|
control the package installation for their part of the package list.
|
||||||
|
Previously, a netinstall module would overwrite all of the package
|
||||||
|
configuration done by other netinstall modules. Translations can be
|
||||||
|
provided in the configuration file, `netinstall.conf`. #1303
|
||||||
|
|
||||||
|
|
||||||
# 3.2.18 (2020-01-28) #
|
# 3.2.18 (2020-01-28) #
|
||||||
|
@ -549,10 +549,11 @@ install(
|
|||||||
"${PROJECT_BINARY_DIR}/CalamaresConfig.cmake"
|
"${PROJECT_BINARY_DIR}/CalamaresConfig.cmake"
|
||||||
"${PROJECT_BINARY_DIR}/CalamaresConfigVersion.cmake"
|
"${PROJECT_BINARY_DIR}/CalamaresConfigVersion.cmake"
|
||||||
"${PROJECT_BINARY_DIR}/CalamaresUse.cmake"
|
"${PROJECT_BINARY_DIR}/CalamaresUse.cmake"
|
||||||
"CMakeModules/CalamaresAddPlugin.cmake"
|
|
||||||
"CMakeModules/CalamaresAddModuleSubdirectory.cmake"
|
|
||||||
"CMakeModules/CalamaresAddLibrary.cmake"
|
|
||||||
"CMakeModules/CalamaresAddBrandingSubdirectory.cmake"
|
"CMakeModules/CalamaresAddBrandingSubdirectory.cmake"
|
||||||
|
"CMakeModules/CalamaresAddLibrary.cmake"
|
||||||
|
"CMakeModules/CalamaresAddModuleSubdirectory.cmake"
|
||||||
|
"CMakeModules/CalamaresAddPlugin.cmake"
|
||||||
|
"CMakeModules/CalamaresAddTest.cmake"
|
||||||
"CMakeModules/CalamaresAddTranslations.cmake"
|
"CMakeModules/CalamaresAddTranslations.cmake"
|
||||||
"CMakeModules/CalamaresAutomoc.cmake"
|
"CMakeModules/CalamaresAutomoc.cmake"
|
||||||
"CMakeModules/CMakeColors.cmake"
|
"CMakeModules/CMakeColors.cmake"
|
||||||
|
58
CMakeModules/CalamaresAddTest.cmake
Normal file
58
CMakeModules/CalamaresAddTest.cmake
Normal file
@ -0,0 +1,58 @@
|
|||||||
|
# === This file is part of Calamares - <https://github.com/calamares> ===
|
||||||
|
#
|
||||||
|
# Calamares is free software: you can redistribute it and/or modify
|
||||||
|
# it under the terms of the GNU General Public License as published by
|
||||||
|
# the Free Software Foundation, either version 3 of the License, or
|
||||||
|
# (at your option) any later version.
|
||||||
|
#
|
||||||
|
# Calamares is distributed in the hope that it will be useful,
|
||||||
|
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
# GNU General Public License for more details.
|
||||||
|
#
|
||||||
|
# You should have received a copy of the GNU General Public License
|
||||||
|
# along with Calamares. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
#
|
||||||
|
# SPDX-License-Identifier: GPL-3.0+
|
||||||
|
# License-Filename: LICENSE
|
||||||
|
#
|
||||||
|
###
|
||||||
|
#
|
||||||
|
# Support functions for building Calamares tests.
|
||||||
|
# This extends KDE's ECM tests with some custom patterns.
|
||||||
|
#
|
||||||
|
# calamares_add_test(
|
||||||
|
# <NAME>
|
||||||
|
# [GUI]
|
||||||
|
# SOURCES <FILE..>
|
||||||
|
# )
|
||||||
|
|
||||||
|
include( CMakeParseArguments )
|
||||||
|
include( CalamaresAutomoc )
|
||||||
|
|
||||||
|
function( calamares_add_test )
|
||||||
|
# parse arguments (name needs to be saved before passing ARGN into the macro)
|
||||||
|
set( NAME ${ARGV0} )
|
||||||
|
set( options GUI )
|
||||||
|
set( multiValueArgs SOURCES LIBRARIES )
|
||||||
|
cmake_parse_arguments( TEST "${options}" "" "${multiValueArgs}" ${ARGN} )
|
||||||
|
set( TEST_NAME ${NAME} )
|
||||||
|
|
||||||
|
if( ECM_FOUND AND BUILD_TESTING )
|
||||||
|
ecm_add_test(
|
||||||
|
${TEST_SOURCES}
|
||||||
|
TEST_NAME
|
||||||
|
${TEST_NAME}
|
||||||
|
LINK_LIBRARIES
|
||||||
|
calamares
|
||||||
|
${TEST_LIBRARIES}
|
||||||
|
Qt5::Core
|
||||||
|
Qt5::Test
|
||||||
|
)
|
||||||
|
calamares_automoc( ${TEST_NAME} )
|
||||||
|
target_compile_definitions( ${TEST_NAME} PRIVATE -DBUILD_AS_TEST )
|
||||||
|
if( TEST_GUI )
|
||||||
|
target_link_libraries( ${TEST_NAME} calamaresui Qt5::Gui )
|
||||||
|
endif()
|
||||||
|
endif()
|
||||||
|
endfunction()
|
@ -4,6 +4,8 @@
|
|||||||
# YAMLCPP_FOUND, if false, do not try to link to yaml-cpp
|
# YAMLCPP_FOUND, if false, do not try to link to yaml-cpp
|
||||||
# YAMLCPP_LIBRARY, where to find yaml-cpp
|
# YAMLCPP_LIBRARY, where to find yaml-cpp
|
||||||
# YAMLCPP_INCLUDE_DIR, where to find yaml.h
|
# YAMLCPP_INCLUDE_DIR, where to find yaml.h
|
||||||
|
# There is also one IMPORTED library target,
|
||||||
|
# yamlcpp
|
||||||
#
|
#
|
||||||
# By default, the dynamic libraries of yaml-cpp will be found. To find the static ones instead,
|
# By default, the dynamic libraries of yaml-cpp will be found. To find the static ones instead,
|
||||||
# you must set the YAMLCPP_STATIC_LIBRARY variable to TRUE before calling find_package(YamlCpp ...).
|
# you must set the YAMLCPP_STATIC_LIBRARY variable to TRUE before calling find_package(YamlCpp ...).
|
||||||
@ -48,3 +50,12 @@ find_library(YAMLCPP_LIBRARY
|
|||||||
include(FindPackageHandleStandardArgs)
|
include(FindPackageHandleStandardArgs)
|
||||||
FIND_PACKAGE_HANDLE_STANDARD_ARGS(YAMLCPP DEFAULT_MSG YAMLCPP_INCLUDE_DIR YAMLCPP_LIBRARY)
|
FIND_PACKAGE_HANDLE_STANDARD_ARGS(YAMLCPP DEFAULT_MSG YAMLCPP_INCLUDE_DIR YAMLCPP_LIBRARY)
|
||||||
mark_as_advanced(YAMLCPP_INCLUDE_DIR YAMLCPP_LIBRARY)
|
mark_as_advanced(YAMLCPP_INCLUDE_DIR YAMLCPP_LIBRARY)
|
||||||
|
|
||||||
|
# Add an imported target
|
||||||
|
if( YAMLCPP_LIBRARY )
|
||||||
|
add_library( yamlcpp UNKNOWN IMPORTED )
|
||||||
|
set_property( TARGET yamlcpp PROPERTY IMPORTED_LOCATION ${YAMLCPP_LIBRARY} )
|
||||||
|
if ( YAMLCPP_INCLUDE_DIR )
|
||||||
|
set_property( TARGET yamlcpp PROPERTY INTERFACE_INCLUDE_DIRECTORIES ${YAMLCPP_INCLUDE_DIR} )
|
||||||
|
endif()
|
||||||
|
endif()
|
||||||
|
@ -2,6 +2,7 @@ include( CalamaresAddPlugin )
|
|||||||
include( CalamaresAddModuleSubdirectory )
|
include( CalamaresAddModuleSubdirectory )
|
||||||
include( CalamaresAddLibrary )
|
include( CalamaresAddLibrary )
|
||||||
include( CalamaresAddBrandingSubdirectory )
|
include( CalamaresAddBrandingSubdirectory )
|
||||||
|
include( CalamaresAddTest )
|
||||||
|
|
||||||
# library
|
# library
|
||||||
add_subdirectory( libcalamares )
|
add_subdirectory( libcalamares )
|
||||||
|
@ -1,5 +1,3 @@
|
|||||||
add_definitions( -DUIDLLEXPORT_PRO )
|
|
||||||
|
|
||||||
set( calamaresSources
|
set( calamaresSources
|
||||||
main.cpp
|
main.cpp
|
||||||
CalamaresApplication.cpp
|
CalamaresApplication.cpp
|
||||||
|
@ -76,7 +76,6 @@ mark_thirdparty_code( ${kdsagSources} )
|
|||||||
include_directories(
|
include_directories(
|
||||||
${CMAKE_CURRENT_BINARY_DIR}
|
${CMAKE_CURRENT_BINARY_DIR}
|
||||||
${CMAKE_CURRENT_SOURCE_DIR}
|
${CMAKE_CURRENT_SOURCE_DIR}
|
||||||
${YAMLCPP_INCLUDE_DIR}
|
|
||||||
)
|
)
|
||||||
|
|
||||||
### OPTIONAL Python support
|
### OPTIONAL Python support
|
||||||
@ -160,7 +159,7 @@ target_link_libraries( calamares
|
|||||||
LINK_PRIVATE
|
LINK_PRIVATE
|
||||||
${OPTIONAL_PRIVATE_LIBRARIES}
|
${OPTIONAL_PRIVATE_LIBRARIES}
|
||||||
LINK_PUBLIC
|
LINK_PUBLIC
|
||||||
${YAMLCPP_LIBRARY}
|
yamlcpp
|
||||||
Qt5::Core
|
Qt5::Core
|
||||||
KF5::CoreAddons
|
KF5::CoreAddons
|
||||||
${OPTIONAL_PUBLIC_LIBRARIES}
|
${OPTIONAL_PUBLIC_LIBRARIES}
|
||||||
@ -193,85 +192,51 @@ install( FILES ${utilsHeaders} DESTINATION include/libcalam
|
|||||||
### TESTING
|
### TESTING
|
||||||
#
|
#
|
||||||
#
|
#
|
||||||
if ( ECM_FOUND AND BUILD_TESTING )
|
calamares_add_test(
|
||||||
ecm_add_test(
|
|
||||||
utils/Tests.cpp
|
|
||||||
TEST_NAME
|
|
||||||
libcalamarestest
|
libcalamarestest
|
||||||
LINK_LIBRARIES
|
SOURCES
|
||||||
calamares
|
utils/Tests.cpp
|
||||||
Qt5::Core
|
)
|
||||||
Qt5::Test
|
|
||||||
)
|
|
||||||
calamares_automoc( libcalamarestest )
|
|
||||||
|
|
||||||
ecm_add_test(
|
calamares_add_test(
|
||||||
utils/TestPaths.cpp
|
|
||||||
TEST_NAME
|
|
||||||
libcalamarestestpaths
|
libcalamarestestpaths
|
||||||
LINK_LIBRARIES
|
SOURCES
|
||||||
calamares
|
utils/TestPaths.cpp
|
||||||
Qt5::Core
|
)
|
||||||
Qt5::Test
|
|
||||||
)
|
|
||||||
calamares_automoc( libcalamarestestpaths )
|
|
||||||
|
|
||||||
|
calamares_add_test(
|
||||||
ecm_add_test(
|
geoiptest
|
||||||
|
SOURCES
|
||||||
geoip/GeoIPTests.cpp
|
geoip/GeoIPTests.cpp
|
||||||
${geoip_src}
|
${geoip_src}
|
||||||
TEST_NAME
|
)
|
||||||
geoiptest
|
|
||||||
LINK_LIBRARIES
|
|
||||||
calamares
|
|
||||||
Qt5::Test
|
|
||||||
${YAMLCPP_LIBRARY}
|
|
||||||
)
|
|
||||||
calamares_automoc( geoiptest )
|
|
||||||
|
|
||||||
ecm_add_test(
|
calamares_add_test(
|
||||||
partition/Tests.cpp
|
|
||||||
TEST_NAME
|
|
||||||
libcalamarespartitiontest
|
libcalamarespartitiontest
|
||||||
LINK_LIBRARIES
|
SOURCES
|
||||||
calamares
|
partition/Tests.cpp
|
||||||
Qt5::Test
|
)
|
||||||
)
|
|
||||||
calamares_automoc( libcalamarespartitiontest )
|
|
||||||
|
|
||||||
ecm_add_test(
|
calamares_add_test(
|
||||||
locale/Tests.cpp
|
|
||||||
TEST_NAME
|
|
||||||
libcalamareslocaletest
|
libcalamareslocaletest
|
||||||
LINK_LIBRARIES
|
SOURCES
|
||||||
calamares
|
locale/Tests.cpp
|
||||||
Qt5::Test
|
)
|
||||||
)
|
|
||||||
calamares_automoc( libcalamareslocaletest )
|
|
||||||
|
|
||||||
ecm_add_test(
|
calamares_add_test(
|
||||||
network/Tests.cpp
|
|
||||||
TEST_NAME
|
|
||||||
libcalamaresnetworktest
|
libcalamaresnetworktest
|
||||||
LINK_LIBRARIES
|
SOURCES
|
||||||
calamares
|
network/Tests.cpp
|
||||||
Qt5::Test
|
)
|
||||||
)
|
|
||||||
calamares_automoc( libcalamaresnetworktest )
|
|
||||||
|
|
||||||
ecm_add_test(
|
calamares_add_test(
|
||||||
modulesystem/Tests.cpp
|
|
||||||
TEST_NAME
|
|
||||||
libcalamaresmodulesystemtest
|
libcalamaresmodulesystemtest
|
||||||
LINK_LIBRARIES
|
SOURCES
|
||||||
calamares
|
modulesystem/Tests.cpp
|
||||||
Qt5::Test
|
)
|
||||||
)
|
|
||||||
calamares_automoc( libcalamaresmodulesystemtest )
|
|
||||||
endif()
|
|
||||||
|
|
||||||
if( BUILD_TESTING )
|
if( BUILD_TESTING )
|
||||||
add_executable( test_geoip geoip/test_geoip.cpp ${geoip_src} )
|
add_executable( test_geoip geoip/test_geoip.cpp ${geoip_src} )
|
||||||
target_link_libraries( test_geoip calamares Qt5::Network ${YAMLCPP_LIBRARY} )
|
target_link_libraries( test_geoip calamares Qt5::Network yamlcpp )
|
||||||
calamares_automoc( test_geoip )
|
calamares_automoc( test_geoip )
|
||||||
endif()
|
endif()
|
||||||
|
@ -1,6 +1,7 @@
|
|||||||
/* === This file is part of Calamares - <https://github.com/calamares> ===
|
/* === This file is part of Calamares - <https://github.com/calamares> ===
|
||||||
*
|
*
|
||||||
* Copyright 2014, Teo Mrnjavac <teo@kde.org>
|
* Copyright 2014, Teo Mrnjavac <teo@kde.org>
|
||||||
|
* Copyright 2020, Adriaan de Groot <groot@kde.org>
|
||||||
*
|
*
|
||||||
* Calamares is free software: you can redistribute it and/or modify
|
* Calamares is free software: you can redistribute it and/or modify
|
||||||
* it under the terms of the GNU General Public License as published by
|
* it under the terms of the GNU General Public License as published by
|
||||||
@ -21,6 +22,10 @@
|
|||||||
|
|
||||||
#include <QtCore/qglobal.h>
|
#include <QtCore/qglobal.h>
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Mark symbols exported from Calamares non-GUI library with DLLEXPORT.
|
||||||
|
* These are the public API of libcalamares.
|
||||||
|
*/
|
||||||
#ifndef DLLEXPORT
|
#ifndef DLLEXPORT
|
||||||
#if defined( DLLEXPORT_PRO )
|
#if defined( DLLEXPORT_PRO )
|
||||||
#define DLLEXPORT Q_DECL_EXPORT
|
#define DLLEXPORT Q_DECL_EXPORT
|
||||||
@ -29,4 +34,42 @@
|
|||||||
#endif
|
#endif
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Mark symbols exported from Calamares GUI library with DLLEXPORT.
|
||||||
|
* These are the public API of libcalamaresui.
|
||||||
|
*/
|
||||||
|
#ifndef UIDLLEXPORT
|
||||||
|
#if defined( UIDLLEXPORT_PRO )
|
||||||
|
#define UIDLLEXPORT Q_DECL_EXPORT
|
||||||
|
#else
|
||||||
|
#define UIDLLEXPORT Q_DECL_IMPORT
|
||||||
|
#endif
|
||||||
|
#endif
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Mark symbols exported from Calamares C++ plugins with PLUGINDLLEXPORT.
|
||||||
|
* These are the public API of the libraries (generally, the plugin
|
||||||
|
* entry point)
|
||||||
|
*/
|
||||||
|
#ifndef PLUGINDLLEXPORT
|
||||||
|
#if defined( PLUGINDLLEXPORT_PRO )
|
||||||
|
#define PLUGINDLLEXPORT Q_DECL_EXPORT
|
||||||
|
#else
|
||||||
|
#define PLUGINDLLEXPORT Q_DECL_IMPORT
|
||||||
|
#endif
|
||||||
|
#endif
|
||||||
|
|
||||||
|
/*
|
||||||
|
* For functions that should be static in production but also need to
|
||||||
|
* be tested, use STATICTEST as linkage specifier. When built as part
|
||||||
|
* of a test, the function will be given normal linkage.
|
||||||
|
*/
|
||||||
|
#ifndef STATICTEST
|
||||||
|
#if defined( BUILD_AS_TEST )
|
||||||
|
#define STATICTEST
|
||||||
|
#else
|
||||||
|
#define STATICTEST static
|
||||||
|
#endif
|
||||||
|
#endif
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
@ -1,32 +0,0 @@
|
|||||||
/* === This file is part of Calamares - <https://github.com/calamares> ===
|
|
||||||
*
|
|
||||||
* Copyright 2014, Teo Mrnjavac <teo@kde.org>
|
|
||||||
*
|
|
||||||
* Calamares is free software: you can redistribute it and/or modify
|
|
||||||
* it under the terms of the GNU General Public License as published by
|
|
||||||
* the Free Software Foundation, either version 3 of the License, or
|
|
||||||
* (at your option) any later version.
|
|
||||||
*
|
|
||||||
* Calamares is distributed in the hope that it will be useful,
|
|
||||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
||||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
||||||
* GNU General Public License for more details.
|
|
||||||
*
|
|
||||||
* You should have received a copy of the GNU General Public License
|
|
||||||
* along with Calamares. If not, see <http://www.gnu.org/licenses/>.
|
|
||||||
*/
|
|
||||||
|
|
||||||
#ifndef PLUGINDLLMACRO_H
|
|
||||||
#define PLUGINDLLMACRO_H
|
|
||||||
|
|
||||||
#include <QtCore/qglobal.h>
|
|
||||||
|
|
||||||
#ifndef PLUGINDLLEXPORT
|
|
||||||
#if defined( PLUGINDLLEXPORT_PRO )
|
|
||||||
#define PLUGINDLLEXPORT Q_DECL_EXPORT
|
|
||||||
#else
|
|
||||||
#define PLUGINDLLEXPORT Q_DECL_IMPORT
|
|
||||||
#endif
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#endif
|
|
@ -23,6 +23,7 @@
|
|||||||
#include "utils/Logger.h"
|
#include "utils/Logger.h"
|
||||||
#include "utils/Variant.h"
|
#include "utils/Variant.h"
|
||||||
|
|
||||||
|
#include <QCoreApplication>
|
||||||
#include <QRegularExpression>
|
#include <QRegularExpression>
|
||||||
#include <QRegularExpressionMatch>
|
#include <QRegularExpressionMatch>
|
||||||
|
|
||||||
@ -34,7 +35,9 @@ TranslatedString::TranslatedString( const QString& string )
|
|||||||
{
|
{
|
||||||
m_strings[ QString() ] = string;
|
m_strings[ QString() ] = string;
|
||||||
}
|
}
|
||||||
TranslatedString::TranslatedString( const QVariantMap& map, const QString& key )
|
|
||||||
|
TranslatedString::TranslatedString( const QVariantMap& map, const QString& key, const char* context )
|
||||||
|
: m_context( context )
|
||||||
{
|
{
|
||||||
// Get the un-decorated value for the key
|
// Get the un-decorated value for the key
|
||||||
QString value = CalamaresUtils::getString( map, key );
|
QString value = CalamaresUtils::getString( map, key );
|
||||||
@ -99,7 +102,17 @@ TranslatedString::get( const QLocale& locale ) const
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return m_strings[ QString() ];
|
// If we're given a context to work with, also try the same string in
|
||||||
|
// the regular translation framework.
|
||||||
|
const QString& s = m_strings[ QString() ];
|
||||||
|
if ( m_context )
|
||||||
|
{
|
||||||
|
return QCoreApplication::translate( m_context, s.toLatin1().constData() );
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
return s;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -39,8 +39,19 @@ class DLLEXPORT TranslatedString
|
|||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
/** @brief Get all the translations connected to @p key
|
/** @brief Get all the translations connected to @p key
|
||||||
|
*
|
||||||
|
* Gets map[key] as the "untranslated" form, and then all the
|
||||||
|
* keys of the form <key>[lang] are taken as the translation
|
||||||
|
* for <lang> of the untranslated form.
|
||||||
|
*
|
||||||
|
* If @p context is not a nullptr, then that is taken as an
|
||||||
|
* indication to **also** use the regular QObject::tr() translation
|
||||||
|
* mechanism for these strings. It is recommended to pass in
|
||||||
|
* metaObject()->className() as context (from a QObject based class)
|
||||||
|
* to give the TranslatedString the same context as other calls
|
||||||
|
* to tr() within that class.
|
||||||
*/
|
*/
|
||||||
TranslatedString( const QVariantMap& map, const QString& key );
|
TranslatedString( const QVariantMap& map, const QString& key, const char* context = nullptr );
|
||||||
/** @brief Not-actually-translated string.
|
/** @brief Not-actually-translated string.
|
||||||
*/
|
*/
|
||||||
TranslatedString( const QString& string );
|
TranslatedString( const QString& string );
|
||||||
@ -73,6 +84,7 @@ public:
|
|||||||
private:
|
private:
|
||||||
// Maps locale name to human-readable string, "" is English
|
// Maps locale name to human-readable string, "" is English
|
||||||
QMap< QString, QString > m_strings;
|
QMap< QString, QString > m_strings;
|
||||||
|
const char* m_context = nullptr;
|
||||||
};
|
};
|
||||||
} // namespace Locale
|
} // namespace Locale
|
||||||
} // namespace CalamaresUtils
|
} // namespace CalamaresUtils
|
||||||
|
@ -47,6 +47,6 @@ NetworkTests::testPing()
|
|||||||
using namespace CalamaresUtils::Network;
|
using namespace CalamaresUtils::Network;
|
||||||
Logger::setupLogLevel( Logger::LOGVERBOSE );
|
Logger::setupLogLevel( Logger::LOGVERBOSE );
|
||||||
auto& nam = Manager::instance();
|
auto& nam = Manager::instance();
|
||||||
auto r = nam.synchronousPing( QUrl( "https://www.kde.org" ), RequestOptions( RequestOptions::FollowRedirect ) );
|
auto canPing_www_kde_org = nam.synchronousPing( QUrl( "https://www.kde.org" ), RequestOptions( RequestOptions::FollowRedirect ) );
|
||||||
QVERIFY( r );
|
QVERIFY( canPing_www_kde_org );
|
||||||
}
|
}
|
||||||
|
@ -246,19 +246,19 @@ System::targetPath( const QString& path ) const
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
QString
|
CreationResult
|
||||||
System::createTargetFile( const QString& path, const QByteArray& contents ) const
|
System::createTargetFile( const QString& path, const QByteArray& contents ) const
|
||||||
{
|
{
|
||||||
QString completePath = targetPath( path );
|
QString completePath = targetPath( path );
|
||||||
if ( completePath.isEmpty() )
|
if ( completePath.isEmpty() )
|
||||||
{
|
{
|
||||||
return QString();
|
return CreationResult( CreationResult::Code::Invalid );
|
||||||
}
|
}
|
||||||
|
|
||||||
QFile f( completePath );
|
QFile f( completePath );
|
||||||
if ( f.exists() )
|
if ( f.exists() )
|
||||||
{
|
{
|
||||||
return QString();
|
return CreationResult( CreationResult::Code::AlreadyExists );
|
||||||
}
|
}
|
||||||
|
|
||||||
QIODevice::OpenMode m =
|
QIODevice::OpenMode m =
|
||||||
@ -270,18 +270,18 @@ System::createTargetFile( const QString& path, const QByteArray& contents ) cons
|
|||||||
|
|
||||||
if ( !f.open( m ) )
|
if ( !f.open( m ) )
|
||||||
{
|
{
|
||||||
return QString();
|
return CreationResult( CreationResult::Code::Failed );
|
||||||
}
|
}
|
||||||
|
|
||||||
if ( f.write( contents ) != contents.size() )
|
if ( f.write( contents ) != contents.size() )
|
||||||
{
|
{
|
||||||
f.close();
|
f.close();
|
||||||
f.remove();
|
f.remove();
|
||||||
return QString();
|
return CreationResult( CreationResult::Code::Failed );
|
||||||
}
|
}
|
||||||
|
|
||||||
f.close();
|
f.close();
|
||||||
return QFileInfo( f ).canonicalFilePath();
|
return CreationResult( QFileInfo( f ).canonicalFilePath() );
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
|
@ -84,6 +84,41 @@ public:
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
/** @brief The result of a create*() action, for status
|
||||||
|
*
|
||||||
|
* A CreationResult has a status field, can be converted to bool
|
||||||
|
* (true only on success) and can report the full pathname of
|
||||||
|
* the thing created if it was successful.
|
||||||
|
*/
|
||||||
|
class CreationResult : public QPair< int, QString >
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
enum class Code : int
|
||||||
|
{
|
||||||
|
// These are "not failed", but only OK is a success
|
||||||
|
OK = 0,
|
||||||
|
AlreadyExists = 1,
|
||||||
|
// These are "failed"
|
||||||
|
Invalid = -1,
|
||||||
|
Failed = -2
|
||||||
|
};
|
||||||
|
|
||||||
|
CreationResult( Code r )
|
||||||
|
: QPair< int, QString >( static_cast< int >( r ), QString() )
|
||||||
|
{
|
||||||
|
}
|
||||||
|
explicit CreationResult( const QString& path )
|
||||||
|
: QPair< int, QString >( 0, path )
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
Code code() const { return static_cast< Code >( first ); }
|
||||||
|
QString path() const { return second; }
|
||||||
|
|
||||||
|
bool failed() const { return first < 0; }
|
||||||
|
operator bool() const { return first == 0; }
|
||||||
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief The System class is a singleton with utility functions that perform
|
* @brief The System class is a singleton with utility functions that perform
|
||||||
* system-specific operations.
|
* system-specific operations.
|
||||||
@ -237,7 +272,7 @@ public:
|
|||||||
* root of the host system, or empty on failure. (Here, it is
|
* root of the host system, or empty on failure. (Here, it is
|
||||||
* possible to be canonical because the file exists).
|
* possible to be canonical because the file exists).
|
||||||
*/
|
*/
|
||||||
DLLEXPORT QString createTargetFile( const QString& path, const QByteArray& contents ) const;
|
DLLEXPORT CreationResult createTargetFile( const QString& path, const QByteArray& contents ) const;
|
||||||
|
|
||||||
/** @brief Remove a file from the target system.
|
/** @brief Remove a file from the target system.
|
||||||
*
|
*
|
||||||
|
@ -46,6 +46,7 @@ private Q_SLOTS:
|
|||||||
void init();
|
void init();
|
||||||
void cleanupTestCase();
|
void cleanupTestCase();
|
||||||
|
|
||||||
|
void testCreationResult();
|
||||||
void testTargetPath();
|
void testTargetPath();
|
||||||
void testCreateTarget();
|
void testCreateTarget();
|
||||||
void testCreateTargetBasedirs();
|
void testCreateTargetBasedirs();
|
||||||
@ -95,6 +96,42 @@ TestPaths::init()
|
|||||||
m_gs->insert( "rootMountPoint", "/tmp" );
|
m_gs->insert( "rootMountPoint", "/tmp" );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void TestPaths::testCreationResult()
|
||||||
|
{
|
||||||
|
using Code = CalamaresUtils::CreationResult::Code;
|
||||||
|
|
||||||
|
for( auto c : { Code::OK, Code::AlreadyExists, Code::Failed, Code::Invalid } )
|
||||||
|
{
|
||||||
|
auto r = CalamaresUtils::CreationResult( c );
|
||||||
|
QVERIFY( r.path().isEmpty() );
|
||||||
|
QCOMPARE( r.path(), QString() );
|
||||||
|
// Get a warning from Clang if we're not covering everything
|
||||||
|
switch( r.code() )
|
||||||
|
{
|
||||||
|
case Code::OK:
|
||||||
|
QVERIFY( !r.failed() );
|
||||||
|
QVERIFY( r );
|
||||||
|
break;
|
||||||
|
case Code::AlreadyExists:
|
||||||
|
QVERIFY( !r.failed() );
|
||||||
|
QVERIFY( !r );
|
||||||
|
break;
|
||||||
|
case Code::Failed:
|
||||||
|
case Code::Invalid:
|
||||||
|
QVERIFY( r.failed() );
|
||||||
|
QVERIFY( !r );
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
QString path( "/etc/os-release" );
|
||||||
|
auto r = CalamaresUtils::CreationResult( path );
|
||||||
|
QVERIFY( !r.failed() );
|
||||||
|
QVERIFY( r );
|
||||||
|
QCOMPARE( r.code(), Code::OK );
|
||||||
|
QCOMPARE( r.path(), path );
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
void
|
void
|
||||||
TestPaths::testTargetPath()
|
TestPaths::testTargetPath()
|
||||||
@ -117,7 +154,10 @@ TestPaths::testTargetPath()
|
|||||||
void
|
void
|
||||||
TestPaths::testCreateTarget()
|
TestPaths::testCreateTarget()
|
||||||
{
|
{
|
||||||
QCOMPARE( m_system->createTargetFile( testFile, "Hello" ), QString( absFile ) ); // Success
|
auto r = m_system->createTargetFile( testFile, "Hello" );
|
||||||
|
QVERIFY( !r.failed() );
|
||||||
|
QVERIFY( r );
|
||||||
|
QCOMPARE( r.path(), QString( absFile ) ); // Success
|
||||||
|
|
||||||
QFileInfo fi( absFile );
|
QFileInfo fi( absFile );
|
||||||
QVERIFY( fi.exists() );
|
QVERIFY( fi.exists() );
|
||||||
|
@ -22,7 +22,7 @@
|
|||||||
#ifndef BRANDING_H
|
#ifndef BRANDING_H
|
||||||
#define BRANDING_H
|
#define BRANDING_H
|
||||||
|
|
||||||
#include "UiDllMacro.h"
|
#include "DllMacro.h"
|
||||||
|
|
||||||
#include "utils/NamedSuffix.h"
|
#include "utils/NamedSuffix.h"
|
||||||
|
|
||||||
@ -146,9 +146,6 @@ public:
|
|||||||
QString slideshowPath() const { return m_slideshowPath; }
|
QString slideshowPath() const { return m_slideshowPath; }
|
||||||
int slideshowAPI() const { return m_slideshowAPI; }
|
int slideshowAPI() const { return m_slideshowAPI; }
|
||||||
|
|
||||||
QString string( Branding::StringEntry stringEntry ) const;
|
|
||||||
QString styleString( Branding::StyleEntry styleEntry ) const;
|
|
||||||
QString imagePath( Branding::ImageEntry imageEntry ) const;
|
|
||||||
QPixmap image( Branding::ImageEntry imageEntry, const QSize& size ) const;
|
QPixmap image( Branding::ImageEntry imageEntry, const QSize& size ) const;
|
||||||
|
|
||||||
/** @brief Look up an image in the branding directory or as an icon
|
/** @brief Look up an image in the branding directory or as an icon
|
||||||
@ -185,6 +182,11 @@ public:
|
|||||||
*/
|
*/
|
||||||
void setGlobals( GlobalStorage* globalStorage ) const;
|
void setGlobals( GlobalStorage* globalStorage ) const;
|
||||||
|
|
||||||
|
public slots:
|
||||||
|
QString string( StringEntry stringEntry ) const;
|
||||||
|
QString styleString( StyleEntry styleEntry ) const;
|
||||||
|
QString imagePath( ImageEntry imageEntry ) const;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
static Branding* s_instance;
|
static Branding* s_instance;
|
||||||
|
|
||||||
|
@ -1,32 +0,0 @@
|
|||||||
/* === This file is part of Calamares - <https://github.com/calamares> ===
|
|
||||||
*
|
|
||||||
* Copyright 2014, Teo Mrnjavac <teo@kde.org>
|
|
||||||
*
|
|
||||||
* Calamares is free software: you can redistribute it and/or modify
|
|
||||||
* it under the terms of the GNU General Public License as published by
|
|
||||||
* the Free Software Foundation, either version 3 of the License, or
|
|
||||||
* (at your option) any later version.
|
|
||||||
*
|
|
||||||
* Calamares is distributed in the hope that it will be useful,
|
|
||||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
||||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
||||||
* GNU General Public License for more details.
|
|
||||||
*
|
|
||||||
* You should have received a copy of the GNU General Public License
|
|
||||||
* along with Calamares. If not, see <http://www.gnu.org/licenses/>.
|
|
||||||
*/
|
|
||||||
|
|
||||||
#ifndef UIDLLMACRO_H
|
|
||||||
#define UIDLLMACRO_H
|
|
||||||
|
|
||||||
#include <QtCore/qglobal.h>
|
|
||||||
|
|
||||||
#ifndef UIDLLEXPORT
|
|
||||||
#if defined( UIDLLEXPORT_PRO )
|
|
||||||
#define UIDLLEXPORT Q_DECL_EXPORT
|
|
||||||
#else
|
|
||||||
#define UIDLLEXPORT Q_DECL_IMPORT
|
|
||||||
#endif
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#endif
|
|
@ -20,7 +20,7 @@
|
|||||||
#ifndef VIEWMANAGER_H
|
#ifndef VIEWMANAGER_H
|
||||||
#define VIEWMANAGER_H
|
#define VIEWMANAGER_H
|
||||||
|
|
||||||
#include "UiDllMacro.h"
|
#include "DllMacro.h"
|
||||||
#include "viewpages/ViewStep.h"
|
#include "viewpages/ViewStep.h"
|
||||||
|
|
||||||
#include <QList>
|
#include <QList>
|
||||||
|
@ -22,7 +22,7 @@
|
|||||||
#define CALAMARES_CPPJOBMODULE_H
|
#define CALAMARES_CPPJOBMODULE_H
|
||||||
|
|
||||||
#include "Module.h"
|
#include "Module.h"
|
||||||
#include "UiDllMacro.h"
|
#include "DllMacro.h"
|
||||||
|
|
||||||
class QPluginLoader;
|
class QPluginLoader;
|
||||||
|
|
||||||
|
@ -22,7 +22,7 @@
|
|||||||
|
|
||||||
#include "Job.h"
|
#include "Job.h"
|
||||||
#include "Requirement.h"
|
#include "Requirement.h"
|
||||||
#include "UiDllMacro.h"
|
#include "DllMacro.h"
|
||||||
|
|
||||||
#include "modulesystem/Descriptor.h"
|
#include "modulesystem/Descriptor.h"
|
||||||
#include "modulesystem/InstanceKey.h"
|
#include "modulesystem/InstanceKey.h"
|
||||||
|
@ -22,7 +22,7 @@
|
|||||||
|
|
||||||
#include "Module.h"
|
#include "Module.h"
|
||||||
|
|
||||||
#include "UiDllMacro.h"
|
#include "DllMacro.h"
|
||||||
|
|
||||||
#include <chrono>
|
#include <chrono>
|
||||||
|
|
||||||
|
@ -21,7 +21,7 @@
|
|||||||
|
|
||||||
#include "Module.h"
|
#include "Module.h"
|
||||||
|
|
||||||
#include "UiDllMacro.h"
|
#include "DllMacro.h"
|
||||||
|
|
||||||
namespace Calamares
|
namespace Calamares
|
||||||
{
|
{
|
||||||
|
@ -20,7 +20,7 @@
|
|||||||
#define CALAMARES_PYTHONQTVIEWMODULE_H
|
#define CALAMARES_PYTHONQTVIEWMODULE_H
|
||||||
|
|
||||||
#include "Module.h"
|
#include "Module.h"
|
||||||
#include "UiDllMacro.h"
|
#include "DllMacro.h"
|
||||||
|
|
||||||
namespace Calamares
|
namespace Calamares
|
||||||
{
|
{
|
||||||
|
@ -21,7 +21,7 @@
|
|||||||
#define CALAMARES_VIEWMODULE_H
|
#define CALAMARES_VIEWMODULE_H
|
||||||
|
|
||||||
#include "Module.h"
|
#include "Module.h"
|
||||||
#include "UiDllMacro.h"
|
#include "DllMacro.h"
|
||||||
|
|
||||||
class QPluginLoader;
|
class QPluginLoader;
|
||||||
|
|
||||||
|
@ -20,7 +20,7 @@
|
|||||||
#ifndef CALAMARESUTILSGUI_H
|
#ifndef CALAMARESUTILSGUI_H
|
||||||
#define CALAMARESUTILSGUI_H
|
#define CALAMARESUTILSGUI_H
|
||||||
|
|
||||||
#include "UiDllMacro.h"
|
#include "DllMacro.h"
|
||||||
|
|
||||||
#include <QObject>
|
#include <QObject>
|
||||||
#include <QPixmap>
|
#include <QPixmap>
|
||||||
|
@ -28,7 +28,7 @@
|
|||||||
|
|
||||||
#include <QPixmap>
|
#include <QPixmap>
|
||||||
|
|
||||||
#include "UiDllMacro.h"
|
#include "DllMacro.h"
|
||||||
#include "utils/CalamaresUtilsGui.h"
|
#include "utils/CalamaresUtilsGui.h"
|
||||||
|
|
||||||
class UIDLLEXPORT ImageRegistry
|
class UIDLLEXPORT ImageRegistry
|
||||||
|
@ -34,7 +34,7 @@ namespace CalamaresUtils
|
|||||||
*
|
*
|
||||||
* If there is a return value from the QML method, it is logged (but not otherwise used).
|
* If there is a return value from the QML method, it is logged (but not otherwise used).
|
||||||
*/
|
*/
|
||||||
DLLEXPORT void
|
UIDLLEXPORT void
|
||||||
callQMLFunction( QQuickItem* qmlObject, const char* method );
|
callQMLFunction( QQuickItem* qmlObject, const char* method );
|
||||||
|
|
||||||
} // namespace CalamaresUtils
|
} // namespace CalamaresUtils
|
||||||
|
@ -29,12 +29,14 @@
|
|||||||
#include "widgets/WaitingWidget.h"
|
#include "widgets/WaitingWidget.h"
|
||||||
|
|
||||||
#include <QQmlComponent>
|
#include <QQmlComponent>
|
||||||
|
#include <QQmlContext>
|
||||||
#include <QQmlEngine>
|
#include <QQmlEngine>
|
||||||
#include <QQuickItem>
|
#include <QQuickItem>
|
||||||
#include <QQuickWidget>
|
#include <QQuickWidget>
|
||||||
#include <QVBoxLayout>
|
#include <QVBoxLayout>
|
||||||
#include <QWidget>
|
#include <QWidget>
|
||||||
|
|
||||||
|
|
||||||
static const NamedEnumTable< Calamares::QmlViewStep::QmlSearch >&
|
static const NamedEnumTable< Calamares::QmlViewStep::QmlSearch >&
|
||||||
searchNames()
|
searchNames()
|
||||||
{
|
{
|
||||||
@ -82,6 +84,20 @@ changeQMLState( QMLAction action, QQuickItem* item )
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static void
|
||||||
|
registerCalamaresModels()
|
||||||
|
{
|
||||||
|
static bool done = false;
|
||||||
|
if ( !done )
|
||||||
|
{
|
||||||
|
done = true;
|
||||||
|
qmlRegisterSingletonType< Calamares::Branding >(
|
||||||
|
"calamares.ui", 1, 0, "Branding", []( QQmlEngine*, QJSEngine* ) -> QObject* {
|
||||||
|
return Calamares::Branding::instance();
|
||||||
|
} );
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
namespace Calamares
|
namespace Calamares
|
||||||
{
|
{
|
||||||
|
|
||||||
@ -92,6 +108,8 @@ QmlViewStep::QmlViewStep( const QString& name, QObject* parent )
|
|||||||
, m_spinner( new WaitingWidget( tr( "Loading ..." ) ) )
|
, m_spinner( new WaitingWidget( tr( "Loading ..." ) ) )
|
||||||
, m_qmlWidget( new QQuickWidget )
|
, m_qmlWidget( new QQuickWidget )
|
||||||
{
|
{
|
||||||
|
registerCalamaresModels();
|
||||||
|
|
||||||
QVBoxLayout* layout = new QVBoxLayout( m_widget );
|
QVBoxLayout* layout = new QVBoxLayout( m_widget );
|
||||||
layout->addWidget( m_spinner );
|
layout->addWidget( m_spinner );
|
||||||
|
|
||||||
@ -297,6 +315,12 @@ QmlViewStep::setConfigurationMap( const QVariantMap& configurationMap )
|
|||||||
{
|
{
|
||||||
m_qmlFileName = searchQmlFile( m_searchMethod, qmlFile, m_name );
|
m_qmlFileName = searchQmlFile( m_searchMethod, qmlFile, m_name );
|
||||||
|
|
||||||
|
QObject* config = this->getConfig();
|
||||||
|
if ( config )
|
||||||
|
{
|
||||||
|
m_qmlWidget->engine()->rootContext()->setContextProperty( "config", config );
|
||||||
|
}
|
||||||
|
|
||||||
cDebug() << "QmlViewStep" << moduleInstanceKey() << "loading" << m_qmlFileName;
|
cDebug() << "QmlViewStep" << moduleInstanceKey() << "loading" << m_qmlFileName;
|
||||||
m_qmlComponent = new QQmlComponent(
|
m_qmlComponent = new QQmlComponent(
|
||||||
m_qmlWidget->engine(), QUrl( m_qmlFileName ), QQmlComponent::CompilationMode::Asynchronous );
|
m_qmlWidget->engine(), QUrl( m_qmlFileName ), QQmlComponent::CompilationMode::Asynchronous );
|
||||||
@ -316,7 +340,17 @@ void
|
|||||||
QmlViewStep::showFailedQml()
|
QmlViewStep::showFailedQml()
|
||||||
{
|
{
|
||||||
cWarning() << "QmlViewStep" << moduleInstanceKey() << "loading failed.";
|
cWarning() << "QmlViewStep" << moduleInstanceKey() << "loading failed.";
|
||||||
|
if ( m_qmlComponent )
|
||||||
|
{
|
||||||
|
cDebug() << Logger::SubEntry << "QML error:" << m_qmlComponent->errorString();
|
||||||
|
}
|
||||||
m_spinner->setText( prettyName() + ' ' + tr( "Loading failed." ) );
|
m_spinner->setText( prettyName() + ' ' + tr( "Loading failed." ) );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
QObject*
|
||||||
|
QmlViewStep::getConfig()
|
||||||
|
{
|
||||||
|
return nullptr;
|
||||||
|
}
|
||||||
|
|
||||||
} // namespace Calamares
|
} // namespace Calamares
|
||||||
|
@ -73,9 +73,21 @@ public:
|
|||||||
/// @brief QML widgets don't produce jobs by default
|
/// @brief QML widgets don't produce jobs by default
|
||||||
virtual JobList jobs() const override;
|
virtual JobList jobs() const override;
|
||||||
|
|
||||||
/// @brief Configure search paths; subclasses should call this as well
|
/// @brief Configure search paths; subclasses should call this at the **end** of their own implementation
|
||||||
virtual void setConfigurationMap( const QVariantMap& configurationMap ) override;
|
virtual void setConfigurationMap( const QVariantMap& configurationMap ) override;
|
||||||
|
|
||||||
|
protected:
|
||||||
|
/** @brief Gets a pointer to the Config of this view step
|
||||||
|
*
|
||||||
|
* Parts of the configuration of the viewstep can be passed to QML
|
||||||
|
* by placing them in a QObject (as properties). The default
|
||||||
|
* implementation returns nullptr, for no-config.
|
||||||
|
*
|
||||||
|
* Ownership of the config object remains with the ViewStep; it is possible
|
||||||
|
* to return a pointer to a member variable.
|
||||||
|
*/
|
||||||
|
virtual QObject* getConfig();
|
||||||
|
|
||||||
private Q_SLOTS:
|
private Q_SLOTS:
|
||||||
void loadComplete();
|
void loadComplete();
|
||||||
|
|
||||||
|
@ -21,7 +21,7 @@
|
|||||||
#define VIEWSTEP_H
|
#define VIEWSTEP_H
|
||||||
|
|
||||||
#include "Job.h"
|
#include "Job.h"
|
||||||
#include "UiDllMacro.h"
|
#include "DllMacro.h"
|
||||||
|
|
||||||
#include "modulesystem/InstanceKey.h"
|
#include "modulesystem/InstanceKey.h"
|
||||||
#include "modulesystem/Requirement.h"
|
#include "modulesystem/Requirement.h"
|
||||||
|
@ -12,7 +12,7 @@ include_directories(
|
|||||||
|
|
||||||
if( BUILD_TESTING )
|
if( BUILD_TESTING )
|
||||||
add_executable( test_conf test_conf.cpp )
|
add_executable( test_conf test_conf.cpp )
|
||||||
target_link_libraries( test_conf ${YAMLCPP_LIBRARY} Qt5::Core )
|
target_link_libraries( test_conf yamlcpp Qt5::Core )
|
||||||
target_include_directories( test_conf PUBLIC ${YAMLCPP_INCLUDE_DIR} )
|
target_include_directories( test_conf PUBLIC ${YAMLCPP_INCLUDE_DIR} )
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
|
@ -8,18 +8,11 @@ calamares_add_plugin( contextualprocess
|
|||||||
SHARED_LIB
|
SHARED_LIB
|
||||||
)
|
)
|
||||||
|
|
||||||
if( ECM_FOUND AND BUILD_TESTING )
|
calamares_add_test(
|
||||||
ecm_add_test(
|
contextualprocesstest
|
||||||
|
SOURCES
|
||||||
Tests.cpp
|
Tests.cpp
|
||||||
ContextualProcessJob.cpp # Builds it a second time
|
ContextualProcessJob.cpp # Builds it a second time
|
||||||
TEST_NAME
|
LIBRARIES
|
||||||
contextualprocesstest
|
yamlcpp
|
||||||
LINK_LIBRARIES
|
)
|
||||||
${CALAMARES_LIBRARIES}
|
|
||||||
calamaresui
|
|
||||||
${YAMLCPP_LIBRARY}
|
|
||||||
Qt5::Core
|
|
||||||
Qt5::Test
|
|
||||||
)
|
|
||||||
calamares_automoc( contextualprocesstest )
|
|
||||||
endif()
|
|
||||||
|
@ -23,7 +23,7 @@
|
|||||||
#include <QVariantMap>
|
#include <QVariantMap>
|
||||||
|
|
||||||
#include "CppJob.h"
|
#include "CppJob.h"
|
||||||
#include "PluginDllMacro.h"
|
#include "DllMacro.h"
|
||||||
|
|
||||||
#include "utils/PluginFactory.h"
|
#include "utils/PluginFactory.h"
|
||||||
|
|
||||||
|
@ -27,7 +27,7 @@
|
|||||||
|
|
||||||
#include <utils/PluginFactory.h>
|
#include <utils/PluginFactory.h>
|
||||||
|
|
||||||
#include <PluginDllMacro.h>
|
#include <DllMacro.h>
|
||||||
|
|
||||||
class PLUGINDLLEXPORT DracutLuksCfgJob : public Calamares::CppJob
|
class PLUGINDLLEXPORT DracutLuksCfgJob : public Calamares::CppJob
|
||||||
{
|
{
|
||||||
|
@ -27,7 +27,7 @@
|
|||||||
|
|
||||||
#include <utils/PluginFactory.h>
|
#include <utils/PluginFactory.h>
|
||||||
|
|
||||||
#include <PluginDllMacro.h>
|
#include <DllMacro.h>
|
||||||
|
|
||||||
class PLUGINDLLEXPORT DummyCppJob : public Calamares::CppJob
|
class PLUGINDLLEXPORT DummyCppJob : public Calamares::CppJob
|
||||||
{
|
{
|
||||||
|
@ -25,7 +25,7 @@
|
|||||||
#include "utils/PluginFactory.h"
|
#include "utils/PluginFactory.h"
|
||||||
#include "viewpages/ViewStep.h"
|
#include "viewpages/ViewStep.h"
|
||||||
|
|
||||||
#include "PluginDllMacro.h"
|
#include "DllMacro.h"
|
||||||
|
|
||||||
class FinishedPage;
|
class FinishedPage;
|
||||||
|
|
||||||
|
@ -28,21 +28,15 @@ if ( KPMcore_FOUND AND Qt5DBus_FOUND AND KF5CoreAddons_FOUND AND KF5Config_FOUND
|
|||||||
SHARED_LIB
|
SHARED_LIB
|
||||||
)
|
)
|
||||||
|
|
||||||
if( ECM_FOUND AND BUILD_TESTING )
|
calamares_add_test(
|
||||||
ecm_add_test(
|
|
||||||
Tests.cpp
|
|
||||||
TEST_NAME
|
|
||||||
fsresizertest
|
fsresizertest
|
||||||
LINK_LIBRARIES
|
SOURCES
|
||||||
${CALAMARES_LIBRARIES}
|
Tests.cpp
|
||||||
calamares
|
LIBRARIES
|
||||||
calamares_job_fsresizer # From above
|
calamares_job_fsresizer # From above
|
||||||
${YAMLCPP_LIBRARY}
|
yamlcpp
|
||||||
Qt5::Core
|
|
||||||
Qt5::Test
|
|
||||||
)
|
)
|
||||||
set_target_properties( fsresizertest PROPERTIES AUTOMOC TRUE )
|
if( TARGET fsresizertest )
|
||||||
target_include_directories( fsresizertest PRIVATE /usr/local/include )
|
|
||||||
target_compile_definitions( fsresizertest PRIVATE ${_partition_defs} )
|
target_compile_definitions( fsresizertest PRIVATE ${_partition_defs} )
|
||||||
endif()
|
endif()
|
||||||
else()
|
else()
|
||||||
|
@ -28,7 +28,7 @@
|
|||||||
#include "partition/PartitionSize.h"
|
#include "partition/PartitionSize.h"
|
||||||
#include "utils/PluginFactory.h"
|
#include "utils/PluginFactory.h"
|
||||||
|
|
||||||
#include <PluginDllMacro.h>
|
#include <DllMacro.h>
|
||||||
|
|
||||||
class CoreBackend; // From KPMCore
|
class CoreBackend; // From KPMCore
|
||||||
class Device; // From KPMCore
|
class Device; // From KPMCore
|
||||||
|
@ -32,18 +32,11 @@ if ( KF5CoreAddons_FOUND AND KF5CoreAddons_VERSION VERSION_GREATER_EQUAL 5.58 )
|
|||||||
target_compile_definitions( calamares_job_hostinfo PRIVATE WITH_KOSRelease )
|
target_compile_definitions( calamares_job_hostinfo PRIVATE WITH_KOSRelease )
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
if( ECM_FOUND AND BUILD_TESTING )
|
calamares_add_test(
|
||||||
ecm_add_test(
|
|
||||||
Tests.cpp
|
|
||||||
HostInfoJob.cpp # Builds it a second time
|
|
||||||
TEST_NAME
|
|
||||||
hostinfotest
|
hostinfotest
|
||||||
LINK_LIBRARIES
|
SOURCES
|
||||||
${CALAMARES_LIBRARIES}
|
Tests.cpp
|
||||||
calamaresui
|
HostInfoJob.cpp
|
||||||
${YAMLCPP_LIBRARY}
|
LIBRARIES
|
||||||
Qt5::Core
|
yamlcpp
|
||||||
Qt5::Test
|
)
|
||||||
)
|
|
||||||
calamares_automoc( hostinfotest )
|
|
||||||
endif()
|
|
||||||
|
@ -20,7 +20,7 @@
|
|||||||
#define HOSTINFOJOB_H
|
#define HOSTINFOJOB_H
|
||||||
|
|
||||||
#include "CppJob.h"
|
#include "CppJob.h"
|
||||||
#include "PluginDllMacro.h"
|
#include "DllMacro.h"
|
||||||
#include "utils/PluginFactory.h"
|
#include "utils/PluginFactory.h"
|
||||||
|
|
||||||
#include <QObject>
|
#include <QObject>
|
||||||
|
@ -8,18 +8,11 @@ calamares_add_plugin( initcpio
|
|||||||
SHARED_LIB
|
SHARED_LIB
|
||||||
)
|
)
|
||||||
|
|
||||||
if( ECM_FOUND AND BUILD_TESTING )
|
calamares_add_test(
|
||||||
ecm_add_test(
|
|
||||||
Tests.cpp
|
|
||||||
TEST_NAME
|
|
||||||
initcpiotest
|
initcpiotest
|
||||||
LINK_LIBRARIES
|
SOURCES
|
||||||
${CALAMARES_LIBRARIES}
|
Tests.cpp
|
||||||
calamares
|
LIBRARIES
|
||||||
calamares_job_initcpio # From above
|
calamares_job_initcpio # From above
|
||||||
${YAMLCPP_LIBRARY}
|
yamlcpp
|
||||||
Qt5::Core
|
)
|
||||||
Qt5::Test
|
|
||||||
)
|
|
||||||
calamares_automoc( initcpiotest )
|
|
||||||
endif()
|
|
||||||
|
@ -20,7 +20,7 @@
|
|||||||
#define INITCPIOJOB_H
|
#define INITCPIOJOB_H
|
||||||
|
|
||||||
#include "CppJob.h"
|
#include "CppJob.h"
|
||||||
#include "PluginDllMacro.h"
|
#include "DllMacro.h"
|
||||||
#include "utils/PluginFactory.h"
|
#include "utils/PluginFactory.h"
|
||||||
|
|
||||||
#include <QObject>
|
#include <QObject>
|
||||||
|
@ -8,18 +8,11 @@ calamares_add_plugin( initramfs
|
|||||||
SHARED_LIB
|
SHARED_LIB
|
||||||
)
|
)
|
||||||
|
|
||||||
if( ECM_FOUND AND BUILD_TESTING )
|
calamares_add_test(
|
||||||
ecm_add_test(
|
|
||||||
Tests.cpp
|
|
||||||
TEST_NAME
|
|
||||||
initramfstest
|
initramfstest
|
||||||
LINK_LIBRARIES
|
SOURCES
|
||||||
${CALAMARES_LIBRARIES}
|
Tests.cpp
|
||||||
calamares
|
LIBRARIES
|
||||||
calamares_job_initramfs # From above
|
calamares_job_initramfs # From above
|
||||||
${YAMLCPP_LIBRARY}
|
yamlcpp
|
||||||
Qt5::Core
|
)
|
||||||
Qt5::Test
|
|
||||||
)
|
|
||||||
calamares_automoc( initramfstest )
|
|
||||||
endif()
|
|
||||||
|
@ -54,7 +54,7 @@ InitramfsJob::exec()
|
|||||||
// First make sure we generate a safe initramfs with suitable permissions.
|
// First make sure we generate a safe initramfs with suitable permissions.
|
||||||
static const char confFile[] = "/etc/initramfs-tools/conf.d/calamares-safe-initramfs.conf";
|
static const char confFile[] = "/etc/initramfs-tools/conf.d/calamares-safe-initramfs.conf";
|
||||||
static const char contents[] = "UMASK=0077\n";
|
static const char contents[] = "UMASK=0077\n";
|
||||||
if ( CalamaresUtils::System::instance()->createTargetFile( confFile, QByteArray( contents ) ).isEmpty() )
|
if ( CalamaresUtils::System::instance()->createTargetFile( confFile, QByteArray( contents ) ).failed() )
|
||||||
{
|
{
|
||||||
cWarning() << Logger::SubEntry << "Could not configure safe UMASK for initramfs.";
|
cWarning() << Logger::SubEntry << "Could not configure safe UMASK for initramfs.";
|
||||||
// But continue anyway.
|
// But continue anyway.
|
||||||
|
@ -20,7 +20,7 @@
|
|||||||
#define INITRAMFSJOB_H
|
#define INITRAMFSJOB_H
|
||||||
|
|
||||||
#include "CppJob.h"
|
#include "CppJob.h"
|
||||||
#include "PluginDllMacro.h"
|
#include "DllMacro.h"
|
||||||
#include "utils/PluginFactory.h"
|
#include "utils/PluginFactory.h"
|
||||||
|
|
||||||
#include <QObject>
|
#include <QObject>
|
||||||
|
@ -59,7 +59,10 @@ void InitramfsTests::testCreateHostFile()
|
|||||||
{
|
{
|
||||||
|
|
||||||
CalamaresUtils::System s( false ); // don't chroot
|
CalamaresUtils::System s( false ); // don't chroot
|
||||||
QString path = s.createTargetFile( confFile, QByteArray( contents ) );
|
auto r = s.createTargetFile( confFile, QByteArray( contents ) );
|
||||||
|
QVERIFY( !r.failed() );
|
||||||
|
QVERIFY( r );
|
||||||
|
QString path = r.path();
|
||||||
QVERIFY( !path.isEmpty() );
|
QVERIFY( !path.isEmpty() );
|
||||||
QCOMPARE( path, confFile ); // don't chroot, so path create relative to /
|
QCOMPARE( path, confFile ); // don't chroot, so path create relative to /
|
||||||
QVERIFY( QFile::exists( confFile ) );
|
QVERIFY( QFile::exists( confFile ) );
|
||||||
@ -76,7 +79,10 @@ void InitramfsTests::testCreateTargetFile()
|
|||||||
static const char short_confFile[] = "/calamares-safe-umask";
|
static const char short_confFile[] = "/calamares-safe-umask";
|
||||||
|
|
||||||
CalamaresUtils::System s( true );
|
CalamaresUtils::System s( true );
|
||||||
QString path = s.createTargetFile( short_confFile, QByteArray( contents ) );
|
auto r = s.createTargetFile( short_confFile, QByteArray( contents ) );
|
||||||
|
QVERIFY( r.failed() );
|
||||||
|
QVERIFY( !r );
|
||||||
|
QString path = r.path();
|
||||||
QVERIFY( path.isEmpty() ); // because no rootmountpoint is set
|
QVERIFY( path.isEmpty() ); // because no rootmountpoint is set
|
||||||
|
|
||||||
Calamares::JobQueue j;
|
Calamares::JobQueue j;
|
||||||
|
@ -25,7 +25,7 @@
|
|||||||
#include <utils/PluginFactory.h>
|
#include <utils/PluginFactory.h>
|
||||||
#include <viewpages/ViewStep.h>
|
#include <viewpages/ViewStep.h>
|
||||||
|
|
||||||
#include <PluginDllMacro.h>
|
#include <DllMacro.h>
|
||||||
|
|
||||||
class InteractiveTerminalPage;
|
class InteractiveTerminalPage;
|
||||||
|
|
||||||
|
@ -25,7 +25,7 @@
|
|||||||
#include <utils/PluginFactory.h>
|
#include <utils/PluginFactory.h>
|
||||||
#include <viewpages/ViewStep.h>
|
#include <viewpages/ViewStep.h>
|
||||||
|
|
||||||
#include <PluginDllMacro.h>
|
#include <DllMacro.h>
|
||||||
|
|
||||||
class KeyboardPage;
|
class KeyboardPage;
|
||||||
|
|
||||||
|
@ -20,7 +20,7 @@
|
|||||||
#ifndef LICENSEPAGEPLUGIN_H
|
#ifndef LICENSEPAGEPLUGIN_H
|
||||||
#define LICENSEPAGEPLUGIN_H
|
#define LICENSEPAGEPLUGIN_H
|
||||||
|
|
||||||
#include <PluginDllMacro.h>
|
#include <DllMacro.h>
|
||||||
#include <utils/PluginFactory.h>
|
#include <utils/PluginFactory.h>
|
||||||
#include <viewpages/ViewStep.h>
|
#include <viewpages/ViewStep.h>
|
||||||
|
|
||||||
|
@ -27,19 +27,13 @@ calamares_add_plugin( locale
|
|||||||
calamaresui
|
calamaresui
|
||||||
Qt5::Network
|
Qt5::Network
|
||||||
${geoip_libs}
|
${geoip_libs}
|
||||||
${YAMLCPP_LIBRARY}
|
yamlcpp
|
||||||
SHARED_LIB
|
SHARED_LIB
|
||||||
)
|
)
|
||||||
|
|
||||||
if( ECM_FOUND AND BUILD_TESTING )
|
calamares_add_test(
|
||||||
ecm_add_test(
|
localetest
|
||||||
|
SOURCES
|
||||||
Tests.cpp
|
Tests.cpp
|
||||||
LocaleConfiguration.cpp
|
LocaleConfiguration.cpp
|
||||||
TEST_NAME
|
)
|
||||||
localetest
|
|
||||||
LINK_LIBRARIES
|
|
||||||
calamares
|
|
||||||
Qt5::Test
|
|
||||||
)
|
|
||||||
calamares_automoc( localetest )
|
|
||||||
endif()
|
|
||||||
|
@ -25,7 +25,7 @@
|
|||||||
#include "utils/PluginFactory.h"
|
#include "utils/PluginFactory.h"
|
||||||
#include "viewpages/ViewStep.h"
|
#include "viewpages/ViewStep.h"
|
||||||
|
|
||||||
#include "PluginDllMacro.h"
|
#include "DllMacro.h"
|
||||||
|
|
||||||
#include <QFutureWatcher>
|
#include <QFutureWatcher>
|
||||||
#include <QObject>
|
#include <QObject>
|
||||||
|
@ -205,7 +205,7 @@ LuksBootKeyFileJob::exec()
|
|||||||
if ( !setupLuks( d ) )
|
if ( !setupLuks( d ) )
|
||||||
return Calamares::JobResult::error(
|
return Calamares::JobResult::error(
|
||||||
tr( "Encrypted rootfs setup error" ),
|
tr( "Encrypted rootfs setup error" ),
|
||||||
tr( "Could configure LUKS key file on partition %1." ).arg( d.device ) );
|
tr( "Could not configure LUKS key file on partition %1." ).arg( d.device ) );
|
||||||
}
|
}
|
||||||
|
|
||||||
return Calamares::JobResult::ok();
|
return Calamares::JobResult::ok();
|
||||||
|
@ -20,7 +20,7 @@
|
|||||||
#define LUKSBOOTKEYFILEJOB_H
|
#define LUKSBOOTKEYFILEJOB_H
|
||||||
|
|
||||||
#include "CppJob.h"
|
#include "CppJob.h"
|
||||||
#include "PluginDllMacro.h"
|
#include "DllMacro.h"
|
||||||
#include "utils/PluginFactory.h"
|
#include "utils/PluginFactory.h"
|
||||||
|
|
||||||
#include <QObject>
|
#include <QObject>
|
||||||
|
@ -9,17 +9,10 @@ calamares_add_plugin( machineid
|
|||||||
SHARED_LIB
|
SHARED_LIB
|
||||||
)
|
)
|
||||||
|
|
||||||
if ( ECM_FOUND AND BUILD_TESTING )
|
calamares_add_test(
|
||||||
ecm_add_test(
|
machineidtest
|
||||||
|
SOURCES
|
||||||
Tests.cpp
|
Tests.cpp
|
||||||
MachineIdJob.cpp
|
MachineIdJob.cpp
|
||||||
Workers.cpp
|
Workers.cpp
|
||||||
TEST_NAME
|
)
|
||||||
machineidtest
|
|
||||||
LINK_LIBRARIES
|
|
||||||
calamares
|
|
||||||
Qt5::Core
|
|
||||||
Qt5::Test
|
|
||||||
)
|
|
||||||
calamares_automoc( machineidtest )
|
|
||||||
endif()
|
|
||||||
|
@ -26,7 +26,7 @@
|
|||||||
|
|
||||||
#include <utils/PluginFactory.h>
|
#include <utils/PluginFactory.h>
|
||||||
|
|
||||||
#include <PluginDllMacro.h>
|
#include <DllMacro.h>
|
||||||
|
|
||||||
class PLUGINDLLEXPORT MachineIdJob : public Calamares::CppJob
|
class PLUGINDLLEXPORT MachineIdJob : public Calamares::CppJob
|
||||||
{
|
{
|
||||||
|
@ -28,6 +28,9 @@
|
|||||||
#include <QFile>
|
#include <QFile>
|
||||||
#include <QtTest/QtTest>
|
#include <QtTest/QtTest>
|
||||||
|
|
||||||
|
// Internals of Workers.cpp
|
||||||
|
extern int getUrandomPoolSize();
|
||||||
|
|
||||||
class MachineIdTests : public QObject
|
class MachineIdTests : public QObject
|
||||||
{
|
{
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
@ -93,10 +96,10 @@ MachineIdTests::testPoolSize()
|
|||||||
{
|
{
|
||||||
#ifdef Q_OS_FREEBSD
|
#ifdef Q_OS_FREEBSD
|
||||||
// It hardly makes sense, but also the /proc entry is missing
|
// It hardly makes sense, but also the /proc entry is missing
|
||||||
QCOMPARE( MachineId::getUrandomPoolSize(), 512 );
|
QCOMPARE( getUrandomPoolSize(), 512 );
|
||||||
#else
|
#else
|
||||||
// Based on a sample size of 1, Netrunner
|
// Based on a sample size of 1, Netrunner
|
||||||
QCOMPARE( MachineId::getUrandomPoolSize(), 4096 );
|
QCOMPARE( getUrandomPoolSize(), 4096 );
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -122,8 +125,13 @@ MachineIdTests::testJob()
|
|||||||
gs->insert( "rootMountPoint", "/tmp" );
|
gs->insert( "rootMountPoint", "/tmp" );
|
||||||
|
|
||||||
// Prepare part of the target filesystem
|
// Prepare part of the target filesystem
|
||||||
|
{
|
||||||
QVERIFY( system->createTargetDirs("/etc") );
|
QVERIFY( system->createTargetDirs("/etc") );
|
||||||
QVERIFY( !(system->createTargetFile( "/etc/machine-id", "Hello" ).isEmpty() ) );
|
auto r = system->createTargetFile( "/etc/machine-id", "Hello" );
|
||||||
|
QVERIFY( !r.failed() );
|
||||||
|
QVERIFY( r );
|
||||||
|
QVERIFY( !r.path().isEmpty() );
|
||||||
|
}
|
||||||
|
|
||||||
MachineIdJob job( nullptr );
|
MachineIdJob job( nullptr );
|
||||||
QVERIFY( !job.prettyName().isEmpty() );
|
QVERIFY( !job.prettyName().isEmpty() );
|
||||||
|
@ -27,6 +27,34 @@
|
|||||||
|
|
||||||
#include <QFile>
|
#include <QFile>
|
||||||
|
|
||||||
|
/// @brief Returns a recommended size for the entropy pool (in bytes)
|
||||||
|
STATICTEST int
|
||||||
|
getUrandomPoolSize()
|
||||||
|
{
|
||||||
|
QFile f( "/proc/sys/kernel/random/poolsize" );
|
||||||
|
constexpr const int minimumPoolSize = 512;
|
||||||
|
int poolSize = minimumPoolSize;
|
||||||
|
|
||||||
|
if ( f.exists() && f.open( QIODevice::ReadOnly | QIODevice::Text ) )
|
||||||
|
{
|
||||||
|
QByteArray v = f.read( 16 );
|
||||||
|
if ( v.length() > 2 )
|
||||||
|
{
|
||||||
|
if ( v.endsWith( '\n' ) )
|
||||||
|
{
|
||||||
|
v.chop( 1 );
|
||||||
|
}
|
||||||
|
bool ok = false;
|
||||||
|
poolSize = v.toInt( &ok );
|
||||||
|
if ( !ok )
|
||||||
|
{
|
||||||
|
poolSize = minimumPoolSize;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return ( poolSize >= minimumPoolSize ) ? poolSize : minimumPoolSize;
|
||||||
|
}
|
||||||
|
|
||||||
namespace MachineId
|
namespace MachineId
|
||||||
{
|
{
|
||||||
|
|
||||||
@ -59,33 +87,6 @@ copyFile( const QString& rootMountPoint, const QString& fileName )
|
|||||||
return Calamares::JobResult::ok();
|
return Calamares::JobResult::ok();
|
||||||
}
|
}
|
||||||
|
|
||||||
int
|
|
||||||
getUrandomPoolSize()
|
|
||||||
{
|
|
||||||
QFile f( "/proc/sys/kernel/random/poolsize" );
|
|
||||||
constexpr const int minimumPoolSize = 512;
|
|
||||||
int poolSize = minimumPoolSize;
|
|
||||||
|
|
||||||
if ( f.exists() && f.open( QIODevice::ReadOnly | QIODevice::Text ) )
|
|
||||||
{
|
|
||||||
QByteArray v = f.read( 16 );
|
|
||||||
if ( v.length() > 2 )
|
|
||||||
{
|
|
||||||
if ( v.endsWith( '\n' ) )
|
|
||||||
{
|
|
||||||
v.chop( 1 );
|
|
||||||
}
|
|
||||||
bool ok = false;
|
|
||||||
poolSize = v.toInt( &ok );
|
|
||||||
if ( !ok )
|
|
||||||
{
|
|
||||||
poolSize = minimumPoolSize;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return ( poolSize >= minimumPoolSize ) ? poolSize : minimumPoolSize;
|
|
||||||
}
|
|
||||||
|
|
||||||
Calamares::JobResult
|
Calamares::JobResult
|
||||||
createNewEntropy( int poolSize, const QString& rootMountPoint, const QString& fileName )
|
createNewEntropy( int poolSize, const QString& rootMountPoint, const QString& fileName )
|
||||||
{
|
{
|
||||||
|
@ -48,9 +48,6 @@ enum class EntropyGeneration
|
|||||||
CopyFromHost
|
CopyFromHost
|
||||||
};
|
};
|
||||||
|
|
||||||
/// @brief Returns a recommended size for the entropy pool (in bytes)
|
|
||||||
int getUrandomPoolSize();
|
|
||||||
|
|
||||||
/// @brief Creates a new entropy file @p fileName in the target system at @p rootMountPoint
|
/// @brief Creates a new entropy file @p fileName in the target system at @p rootMountPoint
|
||||||
Calamares::JobResult createNewEntropy( int poolSize, const QString& rootMountPoint, const QString& fileName );
|
Calamares::JobResult createNewEntropy( int poolSize, const QString& rootMountPoint, const QString& fileName );
|
||||||
|
|
||||||
|
@ -1,5 +1,3 @@
|
|||||||
include_directories( ${PROJECT_BINARY_DIR}/src/libcalamaresui )
|
|
||||||
|
|
||||||
calamares_add_plugin( netinstall
|
calamares_add_plugin( netinstall
|
||||||
TYPE viewmodule
|
TYPE viewmodule
|
||||||
EXPORT_MACRO PLUGINDLLEXPORT_PRO
|
EXPORT_MACRO PLUGINDLLEXPORT_PRO
|
||||||
@ -15,6 +13,6 @@ calamares_add_plugin( netinstall
|
|||||||
LINK_PRIVATE_LIBRARIES
|
LINK_PRIVATE_LIBRARIES
|
||||||
calamaresui
|
calamaresui
|
||||||
Qt5::Network
|
Qt5::Network
|
||||||
${YAMLCPP_LIBRARY}
|
yamlcpp
|
||||||
SHARED_LIB
|
SHARED_LIB
|
||||||
)
|
)
|
||||||
|
@ -2,7 +2,7 @@
|
|||||||
* Copyright 2016, Luca Giambonini <almack@chakraos.org>
|
* Copyright 2016, Luca Giambonini <almack@chakraos.org>
|
||||||
* Copyright 2016, Lisa Vitolo <shainer@chakraos.org>
|
* Copyright 2016, Lisa Vitolo <shainer@chakraos.org>
|
||||||
* Copyright 2017, Kyle Robbertze <krobbertze@gmail.com>
|
* Copyright 2017, Kyle Robbertze <krobbertze@gmail.com>
|
||||||
* Copyright 2017-2018, Adriaan de Groot <groot@kde.org>
|
* Copyright 2017-2018, 2020, Adriaan de Groot <groot@kde.org>
|
||||||
* Copyright 2017, Gabriel Craciunescu <crazy@frugalware.org>
|
* Copyright 2017, Gabriel Craciunescu <crazy@frugalware.org>
|
||||||
*
|
*
|
||||||
* Calamares is free software: you can redistribute it and/or modify
|
* Calamares is free software: you can redistribute it and/or modify
|
||||||
@ -34,8 +34,6 @@
|
|||||||
#include <QHeaderView>
|
#include <QHeaderView>
|
||||||
#include <QNetworkReply>
|
#include <QNetworkReply>
|
||||||
|
|
||||||
using CalamaresUtils::yamlToVariant;
|
|
||||||
|
|
||||||
NetInstallPage::NetInstallPage( QWidget* parent )
|
NetInstallPage::NetInstallPage( QWidget* parent )
|
||||||
: QWidget( parent )
|
: QWidget( parent )
|
||||||
, ui( new Ui::Page_NetInst )
|
, ui( new Ui::Page_NetInst )
|
||||||
@ -43,6 +41,38 @@ NetInstallPage::NetInstallPage( QWidget* parent )
|
|||||||
, m_groups( nullptr )
|
, m_groups( nullptr )
|
||||||
{
|
{
|
||||||
ui->setupUi( this );
|
ui->setupUi( this );
|
||||||
|
setPageTitle( nullptr );
|
||||||
|
CALAMARES_RETRANSLATE_SLOT( &NetInstallPage::retranslate );
|
||||||
|
}
|
||||||
|
|
||||||
|
NetInstallPage::~NetInstallPage()
|
||||||
|
{
|
||||||
|
delete m_groups;
|
||||||
|
delete m_reply;
|
||||||
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
NetInstallPage::setPageTitle( CalamaresUtils::Locale::TranslatedString* t )
|
||||||
|
{
|
||||||
|
m_title.reset( t );
|
||||||
|
if ( !m_title )
|
||||||
|
{
|
||||||
|
ui->label->hide();
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
ui->label->show();
|
||||||
|
}
|
||||||
|
retranslate();
|
||||||
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
NetInstallPage::retranslate()
|
||||||
|
{
|
||||||
|
if ( ui && m_title )
|
||||||
|
{
|
||||||
|
ui->label->setText( m_title->get() ); // That's get() on the TranslatedString
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
bool
|
bool
|
||||||
@ -58,8 +88,6 @@ NetInstallPage::readGroups( const QByteArray& yamlData )
|
|||||||
}
|
}
|
||||||
Q_ASSERT( groups.IsSequence() );
|
Q_ASSERT( groups.IsSequence() );
|
||||||
m_groups = new PackageModel( groups );
|
m_groups = new PackageModel( groups );
|
||||||
CALAMARES_RETRANSLATE( m_groups->setHeaderData( 0, Qt::Horizontal, tr( "Name" ) );
|
|
||||||
m_groups->setHeaderData( 1, Qt::Horizontal, tr( "Description" ) ); )
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
catch ( YAML::Exception& e )
|
catch ( YAML::Exception& e )
|
||||||
@ -121,6 +149,7 @@ NetInstallPage::dataIsHere()
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
retranslate(); // For changed model
|
||||||
ui->groupswidget->setModel( m_groups );
|
ui->groupswidget->setModel( m_groups );
|
||||||
ui->groupswidget->header()->setSectionResizeMode( 0, QHeaderView::ResizeToContents );
|
ui->groupswidget->header()->setSectionResizeMode( 0, QHeaderView::ResizeToContents );
|
||||||
ui->groupswidget->header()->setSectionResizeMode( 1, QHeaderView::Stretch );
|
ui->groupswidget->header()->setSectionResizeMode( 1, QHeaderView::Stretch );
|
||||||
|
@ -2,7 +2,7 @@
|
|||||||
* Copyright 2016, Luca Giambonini <almack@chakraos.org>
|
* Copyright 2016, Luca Giambonini <almack@chakraos.org>
|
||||||
* Copyright 2016, Lisa Vitolo <shainer@chakraos.org>
|
* Copyright 2016, Lisa Vitolo <shainer@chakraos.org>
|
||||||
* Copyright 2017, Kyle Robbertze <krobbertze@gmail.com>
|
* Copyright 2017, Kyle Robbertze <krobbertze@gmail.com>
|
||||||
* Copyright 2017-2018, Adriaan de Groot <groot@kde.org>
|
* Copyright 2017-2018, 2020, Adriaan de Groot <groot@kde.org>
|
||||||
*
|
*
|
||||||
* Calamares is free software: you can redistribute it and/or modify
|
* Calamares is free software: you can redistribute it and/or modify
|
||||||
* it under the terms of the GNU General Public License as published by
|
* it under the terms of the GNU General Public License as published by
|
||||||
@ -24,9 +24,13 @@
|
|||||||
#include "PackageModel.h"
|
#include "PackageModel.h"
|
||||||
#include "PackageTreeItem.h"
|
#include "PackageTreeItem.h"
|
||||||
|
|
||||||
|
#include "locale/TranslatableConfiguration.h"
|
||||||
|
|
||||||
#include <QString>
|
#include <QString>
|
||||||
#include <QWidget>
|
#include <QWidget>
|
||||||
|
|
||||||
|
#include <memory>
|
||||||
|
|
||||||
class QNetworkReply;
|
class QNetworkReply;
|
||||||
|
|
||||||
namespace Ui
|
namespace Ui
|
||||||
@ -39,6 +43,18 @@ class NetInstallPage : public QWidget
|
|||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
public:
|
public:
|
||||||
NetInstallPage( QWidget* parent = nullptr );
|
NetInstallPage( QWidget* parent = nullptr );
|
||||||
|
virtual ~NetInstallPage();
|
||||||
|
|
||||||
|
/** @brief Sets the page title
|
||||||
|
*
|
||||||
|
* In situations where there is more than one netinstall page,
|
||||||
|
* or you want some explanatory title above the treeview,
|
||||||
|
* set the page title. This page takes ownership of the
|
||||||
|
* TranslatedString object.
|
||||||
|
*
|
||||||
|
* Set to nullptr to remove the title.
|
||||||
|
*/
|
||||||
|
void setPageTitle( CalamaresUtils::Locale::TranslatedString* );
|
||||||
|
|
||||||
void onActivate();
|
void onActivate();
|
||||||
|
|
||||||
@ -63,6 +79,8 @@ public:
|
|||||||
public slots:
|
public slots:
|
||||||
void dataIsHere();
|
void dataIsHere();
|
||||||
|
|
||||||
|
void retranslate();
|
||||||
|
|
||||||
signals:
|
signals:
|
||||||
void checkReady( bool );
|
void checkReady( bool );
|
||||||
|
|
||||||
@ -74,6 +92,8 @@ private:
|
|||||||
|
|
||||||
Ui::Page_NetInst* ui;
|
Ui::Page_NetInst* ui;
|
||||||
|
|
||||||
|
std::unique_ptr< CalamaresUtils::Locale::TranslatedString > m_title; // Above the treeview
|
||||||
|
|
||||||
QNetworkReply* m_reply;
|
QNetworkReply* m_reply;
|
||||||
PackageModel* m_groups;
|
PackageModel* m_groups;
|
||||||
bool m_required;
|
bool m_required;
|
||||||
|
@ -2,7 +2,7 @@
|
|||||||
* Copyright 2016, Luca Giambonini <almack@chakraos.org>
|
* Copyright 2016, Luca Giambonini <almack@chakraos.org>
|
||||||
* Copyright 2016, Lisa Vitolo <shainer@chakraos.org>
|
* Copyright 2016, Lisa Vitolo <shainer@chakraos.org>
|
||||||
* Copyright 2017, Kyle Robbertze <krobbertze@gmail.com>
|
* Copyright 2017, Kyle Robbertze <krobbertze@gmail.com>
|
||||||
* Copyright 2017-2018, Adriaan de Groot <groot@kde.org>
|
* Copyright 2017-2018, 2020, Adriaan de Groot <groot@kde.org>
|
||||||
*
|
*
|
||||||
* Calamares is free software: you can redistribute it and/or modify
|
* Calamares is free software: you can redistribute it and/or modify
|
||||||
* it under the terms of the GNU General Public License as published by
|
* it under the terms of the GNU General Public License as published by
|
||||||
@ -20,45 +20,59 @@
|
|||||||
|
|
||||||
#include "NetInstallViewStep.h"
|
#include "NetInstallViewStep.h"
|
||||||
|
|
||||||
#include "JobQueue.h"
|
|
||||||
#include "GlobalStorage.h"
|
#include "GlobalStorage.h"
|
||||||
|
#include "JobQueue.h"
|
||||||
|
|
||||||
#include "utils/Logger.h"
|
#include "utils/Logger.h"
|
||||||
#include "utils/Variant.h"
|
#include "utils/Variant.h"
|
||||||
|
|
||||||
#include "NetInstallPage.h"
|
#include "NetInstallPage.h"
|
||||||
|
|
||||||
CALAMARES_PLUGIN_FACTORY_DEFINITION( NetInstallViewStepFactory, registerPlugin<NetInstallViewStep>(); )
|
CALAMARES_PLUGIN_FACTORY_DEFINITION( NetInstallViewStepFactory, registerPlugin< NetInstallViewStep >(); )
|
||||||
|
|
||||||
NetInstallViewStep::NetInstallViewStep( QObject* parent )
|
NetInstallViewStep::NetInstallViewStep( QObject* parent )
|
||||||
: Calamares::ViewStep( parent )
|
: Calamares::ViewStep( parent )
|
||||||
, m_widget( new NetInstallPage() )
|
, m_widget( new NetInstallPage() )
|
||||||
, m_nextEnabled( false )
|
, m_nextEnabled( false )
|
||||||
|
, m_sidebarLabel( nullptr )
|
||||||
{
|
{
|
||||||
emit nextStatusChanged( true );
|
emit nextStatusChanged( true );
|
||||||
connect( m_widget, &NetInstallPage::checkReady,
|
connect( m_widget, &NetInstallPage::checkReady, this, &NetInstallViewStep::nextIsReady );
|
||||||
this, &NetInstallViewStep::nextIsReady );
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
NetInstallViewStep::~NetInstallViewStep()
|
NetInstallViewStep::~NetInstallViewStep()
|
||||||
{
|
{
|
||||||
if ( m_widget && m_widget->parent() == nullptr )
|
if ( m_widget && m_widget->parent() == nullptr )
|
||||||
|
{
|
||||||
m_widget->deleteLater();
|
m_widget->deleteLater();
|
||||||
|
}
|
||||||
|
delete m_sidebarLabel;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
QString
|
QString
|
||||||
NetInstallViewStep::prettyName() const
|
NetInstallViewStep::prettyName() const
|
||||||
{
|
{
|
||||||
return tr( "Package selection" );
|
return m_sidebarLabel ? m_sidebarLabel->get() : tr( "Package selection" );
|
||||||
}
|
|
||||||
|
|
||||||
|
#if defined(TABLE_OF_TRANSLATIONS)
|
||||||
QString
|
NOTREACHED
|
||||||
NetInstallViewStep::prettyStatus() const
|
// This is a table of "standard" labels for this module. If you use them
|
||||||
{
|
// in the label: sidebar: section of the config file, the existing
|
||||||
return m_prettyStatus;
|
// translations can be used.
|
||||||
|
tr( "Package selection" );
|
||||||
|
tr( "Office software" );
|
||||||
|
tr( "Office package" );
|
||||||
|
tr( "Browser software" );
|
||||||
|
tr( "Browser package" );
|
||||||
|
tr( "Web browser" );
|
||||||
|
tr( "Kernel" );
|
||||||
|
tr( "Services" );
|
||||||
|
tr( "Login" );
|
||||||
|
tr( "Desktop" );
|
||||||
|
tr( "Applications" );
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -110,61 +124,79 @@ NetInstallViewStep::onActivate()
|
|||||||
m_widget->onActivate();
|
m_widget->onActivate();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void
|
void
|
||||||
NetInstallViewStep::onLeave()
|
NetInstallViewStep::onLeave()
|
||||||
{
|
{
|
||||||
cDebug() << "Leaving netinstall, adding packages to be installed"
|
|
||||||
<< "to global storage";
|
|
||||||
|
|
||||||
PackageModel::PackageItemDataList packages = m_widget->selectedPackages();
|
PackageModel::PackageItemDataList packages = m_widget->selectedPackages();
|
||||||
|
cDebug() << "Netinstall: Processing" << packages.length() << "packages.";
|
||||||
|
|
||||||
|
static const char PACKAGEOP[] = "packageOperations";
|
||||||
|
|
||||||
|
// Check if there's already a PACAKGEOP entry in GS, and if so we'll
|
||||||
|
// extend that one (overwriting the value in GS at the end of this method)
|
||||||
|
Calamares::GlobalStorage* gs = Calamares::JobQueue::instance()->globalStorage();
|
||||||
|
QVariantList packageOperations = gs->contains( PACKAGEOP ) ? gs->value( PACKAGEOP ).toList() : QVariantList();
|
||||||
|
cDebug() << Logger::SubEntry << "Existing package operations length" << packageOperations.length();
|
||||||
|
|
||||||
|
// Clear out existing operations for this module, going backwards:
|
||||||
|
// Sometimes we remove an item, and we don't want the index to
|
||||||
|
// fall off the end of the list.
|
||||||
|
for ( int index = packageOperations.length() - 1; 0 <= index; index-- )
|
||||||
|
{
|
||||||
|
const QVariantMap op = packageOperations.at( index ).toMap();
|
||||||
|
if ( op.contains( "source" ) && op.value( "source" ).toString() == moduleInstanceKey().toString() )
|
||||||
|
{
|
||||||
|
cDebug() << Logger::SubEntry << "Removing existing operations for" << moduleInstanceKey();
|
||||||
|
packageOperations.removeAt( index );
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// This netinstall module may add two sub-steps to the packageOperations,
|
||||||
|
// one for installing and one for try-installing.
|
||||||
QVariantList installPackages;
|
QVariantList installPackages;
|
||||||
QVariantList tryInstallPackages;
|
QVariantList tryInstallPackages;
|
||||||
QVariantList packageOperations;
|
|
||||||
|
|
||||||
cDebug() << "Processing" << packages.length() << "packages from netinstall.";
|
for ( const auto& package : packages )
|
||||||
|
|
||||||
for ( auto package : packages )
|
|
||||||
{
|
{
|
||||||
QVariant details( package.packageName );
|
|
||||||
// If it's a package with a pre- or post-script, replace
|
|
||||||
// with the more complicated datastructure.
|
|
||||||
if ( !package.preScript.isEmpty() || !package.postScript.isEmpty() )
|
|
||||||
{
|
|
||||||
QMap<QString, QVariant> sdetails;
|
|
||||||
sdetails.insert( "pre-script", package.preScript );
|
|
||||||
sdetails.insert( "package", package.packageName );
|
|
||||||
sdetails.insert( "post-script", package.postScript );
|
|
||||||
details = sdetails;
|
|
||||||
}
|
|
||||||
if ( package.isCritical )
|
if ( package.isCritical )
|
||||||
installPackages.append( details );
|
{
|
||||||
|
installPackages.append( package.toOperation() );
|
||||||
|
}
|
||||||
else
|
else
|
||||||
tryInstallPackages.append( details );
|
{
|
||||||
|
tryInstallPackages.append( package.toOperation() );
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if ( !installPackages.empty() )
|
if ( !installPackages.empty() )
|
||||||
{
|
{
|
||||||
QMap<QString, QVariant> op;
|
QVariantMap op;
|
||||||
op.insert( "install", QVariant( installPackages ) );
|
op.insert( "install", QVariant( installPackages ) );
|
||||||
|
op.insert( "source", moduleInstanceKey().toString() );
|
||||||
packageOperations.append( op );
|
packageOperations.append( op );
|
||||||
cDebug() << Logger::SubEntry << installPackages.length() << "critical packages.";
|
cDebug() << Logger::SubEntry << installPackages.length() << "critical packages.";
|
||||||
}
|
}
|
||||||
if ( !tryInstallPackages.empty() )
|
if ( !tryInstallPackages.empty() )
|
||||||
{
|
{
|
||||||
QMap<QString, QVariant> op;
|
QVariantMap op;
|
||||||
op.insert( "try_install", QVariant( tryInstallPackages ) );
|
op.insert( "try_install", QVariant( tryInstallPackages ) );
|
||||||
|
op.insert( "source", moduleInstanceKey().toString() );
|
||||||
packageOperations.append( op );
|
packageOperations.append( op );
|
||||||
cDebug() << Logger::SubEntry << tryInstallPackages.length() << "non-critical packages.";
|
cDebug() << Logger::SubEntry << tryInstallPackages.length() << "non-critical packages.";
|
||||||
}
|
}
|
||||||
|
|
||||||
if ( !packageOperations.isEmpty() )
|
if ( !packageOperations.isEmpty() )
|
||||||
{
|
{
|
||||||
Calamares::GlobalStorage* gs = Calamares::JobQueue::instance()->globalStorage();
|
gs->insert( PACKAGEOP, packageOperations );
|
||||||
gs->insert( "packageOperations", QVariant( packageOperations ) );
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
NetInstallViewStep::nextIsReady( bool b )
|
||||||
|
{
|
||||||
|
m_nextEnabled = b;
|
||||||
|
emit nextStatusChanged( b );
|
||||||
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
NetInstallViewStep::setConfigurationMap( const QVariantMap& configurationMap )
|
NetInstallViewStep::setConfigurationMap( const QVariantMap& configurationMap )
|
||||||
@ -179,11 +211,17 @@ NetInstallViewStep::setConfigurationMap( const QVariantMap& configurationMap )
|
|||||||
Calamares::JobQueue::instance()->globalStorage()->insert( "groupsUrl", groupsUrl );
|
Calamares::JobQueue::instance()->globalStorage()->insert( "groupsUrl", groupsUrl );
|
||||||
m_widget->loadGroupList( groupsUrl );
|
m_widget->loadGroupList( groupsUrl );
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
void
|
bool bogus = false;
|
||||||
NetInstallViewStep::nextIsReady( bool b )
|
auto label = CalamaresUtils::getSubMap( configurationMap, "label", bogus );
|
||||||
{
|
|
||||||
m_nextEnabled = b;
|
if ( label.contains( "sidebar" ) )
|
||||||
emit nextStatusChanged( b );
|
{
|
||||||
|
m_sidebarLabel = new CalamaresUtils::Locale::TranslatedString( label, "sidebar", metaObject()->className() );
|
||||||
|
}
|
||||||
|
if ( label.contains( "title" ) )
|
||||||
|
{
|
||||||
|
m_widget->setPageTitle(
|
||||||
|
new CalamaresUtils::Locale::TranslatedString( label, "title", metaObject()->className() ) );
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -20,10 +20,10 @@
|
|||||||
#ifndef NETINSTALLVIEWSTEP_H
|
#ifndef NETINSTALLVIEWSTEP_H
|
||||||
#define NETINSTALLVIEWSTEP_H
|
#define NETINSTALLVIEWSTEP_H
|
||||||
|
|
||||||
#include <utils/PluginFactory.h>
|
#include "DllMacro.h"
|
||||||
#include <viewpages/ViewStep.h>
|
#include "locale/TranslatableConfiguration.h"
|
||||||
|
#include "utils/PluginFactory.h"
|
||||||
#include <PluginDllMacro.h>
|
#include "viewpages/ViewStep.h"
|
||||||
|
|
||||||
#include <QVariant>
|
#include <QVariant>
|
||||||
|
|
||||||
@ -38,7 +38,6 @@ public:
|
|||||||
virtual ~NetInstallViewStep() override;
|
virtual ~NetInstallViewStep() override;
|
||||||
|
|
||||||
QString prettyName() const override;
|
QString prettyName() const override;
|
||||||
QString prettyStatus() const override;
|
|
||||||
|
|
||||||
QWidget* widget() override;
|
QWidget* widget() override;
|
||||||
|
|
||||||
@ -63,8 +62,7 @@ public slots:
|
|||||||
private:
|
private:
|
||||||
NetInstallPage* m_widget;
|
NetInstallPage* m_widget;
|
||||||
bool m_nextEnabled;
|
bool m_nextEnabled;
|
||||||
QString m_prettyStatus;
|
CalamaresUtils::Locale::TranslatedString* m_sidebarLabel; // As it appears in the sidebar
|
||||||
|
|
||||||
QList< Calamares::job_ptr > m_jobs;
|
QList< Calamares::job_ptr > m_jobs;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -21,9 +21,11 @@
|
|||||||
|
|
||||||
#include "utils/Yaml.h"
|
#include "utils/Yaml.h"
|
||||||
|
|
||||||
PackageModel::PackageModel( const YAML::Node& data, QObject* parent ) :
|
// TODO: see headerData(), remove after 3.2.19
|
||||||
QAbstractItemModel( parent ),
|
#include <QCoreApplication>
|
||||||
m_columnHeadings()
|
|
||||||
|
PackageModel::PackageModel( const YAML::Node& data, QObject* parent )
|
||||||
|
: QAbstractItemModel( parent )
|
||||||
{
|
{
|
||||||
m_rootItem = new PackageTreeItem();
|
m_rootItem = new PackageTreeItem();
|
||||||
setupModelData( data, m_rootItem );
|
setupModelData( data, m_rootItem );
|
||||||
@ -38,33 +40,47 @@ QModelIndex
|
|||||||
PackageModel::index( int row, int column, const QModelIndex& parent ) const
|
PackageModel::index( int row, int column, const QModelIndex& parent ) const
|
||||||
{
|
{
|
||||||
if ( !hasIndex( row, column, parent ) )
|
if ( !hasIndex( row, column, parent ) )
|
||||||
|
{
|
||||||
return QModelIndex();
|
return QModelIndex();
|
||||||
|
}
|
||||||
|
|
||||||
PackageTreeItem* parentItem;
|
PackageTreeItem* parentItem;
|
||||||
|
|
||||||
if ( !parent.isValid() )
|
if ( !parent.isValid() )
|
||||||
|
{
|
||||||
parentItem = m_rootItem;
|
parentItem = m_rootItem;
|
||||||
|
}
|
||||||
else
|
else
|
||||||
parentItem = static_cast<PackageTreeItem*>( parent.internalPointer() );
|
{
|
||||||
|
parentItem = static_cast< PackageTreeItem* >( parent.internalPointer() );
|
||||||
|
}
|
||||||
|
|
||||||
PackageTreeItem* childItem = parentItem->child( row );
|
PackageTreeItem* childItem = parentItem->child( row );
|
||||||
if ( childItem )
|
if ( childItem )
|
||||||
|
{
|
||||||
return createIndex( row, column, childItem );
|
return createIndex( row, column, childItem );
|
||||||
|
}
|
||||||
else
|
else
|
||||||
|
{
|
||||||
return QModelIndex();
|
return QModelIndex();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
QModelIndex
|
QModelIndex
|
||||||
PackageModel::parent( const QModelIndex& index ) const
|
PackageModel::parent( const QModelIndex& index ) const
|
||||||
{
|
{
|
||||||
if ( !index.isValid() )
|
if ( !index.isValid() )
|
||||||
|
{
|
||||||
return QModelIndex();
|
return QModelIndex();
|
||||||
|
}
|
||||||
|
|
||||||
PackageTreeItem* child = static_cast<PackageTreeItem*>( index.internalPointer() );
|
PackageTreeItem* child = static_cast< PackageTreeItem* >( index.internalPointer() );
|
||||||
PackageTreeItem* parent = child->parentItem();
|
PackageTreeItem* parent = child->parentItem();
|
||||||
|
|
||||||
if ( parent == m_rootItem )
|
if ( parent == m_rootItem )
|
||||||
|
{
|
||||||
return QModelIndex();
|
return QModelIndex();
|
||||||
|
}
|
||||||
return createIndex( parent->row(), 0, parent );
|
return createIndex( parent->row(), 0, parent );
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -72,13 +88,19 @@ int
|
|||||||
PackageModel::rowCount( const QModelIndex& parent ) const
|
PackageModel::rowCount( const QModelIndex& parent ) const
|
||||||
{
|
{
|
||||||
if ( parent.column() > 0 )
|
if ( parent.column() > 0 )
|
||||||
|
{
|
||||||
return 0;
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
PackageTreeItem* parentItem;
|
PackageTreeItem* parentItem;
|
||||||
if ( !parent.isValid() )
|
if ( !parent.isValid() )
|
||||||
|
{
|
||||||
parentItem = m_rootItem;
|
parentItem = m_rootItem;
|
||||||
|
}
|
||||||
else
|
else
|
||||||
parentItem = static_cast<PackageTreeItem*>( parent.internalPointer() );
|
{
|
||||||
|
parentItem = static_cast< PackageTreeItem* >( parent.internalPointer() );
|
||||||
|
}
|
||||||
|
|
||||||
return parentItem->childCount();
|
return parentItem->childCount();
|
||||||
}
|
}
|
||||||
@ -86,26 +108,32 @@ PackageModel::rowCount( const QModelIndex& parent ) const
|
|||||||
int
|
int
|
||||||
PackageModel::columnCount( const QModelIndex& parent ) const
|
PackageModel::columnCount( const QModelIndex& parent ) const
|
||||||
{
|
{
|
||||||
if ( parent.isValid() )
|
return 2;
|
||||||
return static_cast<PackageTreeItem*>( parent.internalPointer() )->columnCount();
|
|
||||||
return m_rootItem->columnCount();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
QVariant
|
QVariant
|
||||||
PackageModel::data( const QModelIndex& index, int role ) const
|
PackageModel::data( const QModelIndex& index, int role ) const
|
||||||
{
|
{
|
||||||
if ( !index.isValid() )
|
if ( !index.isValid() )
|
||||||
|
{
|
||||||
return QVariant();
|
return QVariant();
|
||||||
|
}
|
||||||
|
|
||||||
PackageTreeItem* item = static_cast<PackageTreeItem*>( index.internalPointer() );
|
PackageTreeItem* item = static_cast< PackageTreeItem* >( index.internalPointer() );
|
||||||
if ( index.column() == 0 && role == Qt::CheckStateRole )
|
if ( index.column() == 0 && role == Qt::CheckStateRole )
|
||||||
|
{
|
||||||
return item->isSelected();
|
return item->isSelected();
|
||||||
|
}
|
||||||
|
|
||||||
if ( item->isHidden() && role == Qt::DisplayRole ) // Hidden group
|
if ( item->isHidden() && role == Qt::DisplayRole ) // Hidden group
|
||||||
|
{
|
||||||
return QVariant();
|
return QVariant();
|
||||||
|
}
|
||||||
|
|
||||||
if ( role == Qt::DisplayRole )
|
if ( role == Qt::DisplayRole )
|
||||||
|
{
|
||||||
return item->data( index.column() );
|
return item->data( index.column() );
|
||||||
|
}
|
||||||
return QVariant();
|
return QVariant();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -114,28 +142,12 @@ PackageModel::setData( const QModelIndex& index, const QVariant& value, int role
|
|||||||
{
|
{
|
||||||
if ( role == Qt::CheckStateRole && index.isValid() )
|
if ( role == Qt::CheckStateRole && index.isValid() )
|
||||||
{
|
{
|
||||||
PackageTreeItem* item = static_cast<PackageTreeItem*>( index.internalPointer() );
|
PackageTreeItem* item = static_cast< PackageTreeItem* >( index.internalPointer() );
|
||||||
item->setSelected( static_cast<Qt::CheckState>( value.toInt() ) );
|
item->setSelected( static_cast< Qt::CheckState >( value.toInt() ) );
|
||||||
|
|
||||||
emit dataChanged( this->index( 0, 0 ), index.sibling( index.column(), index.row() + 1 ),
|
emit dataChanged( this->index( 0, 0 ),
|
||||||
QVector<int>( Qt::CheckStateRole ) );
|
index.sibling( index.column(), index.row() + 1 ),
|
||||||
}
|
QVector< int >( Qt::CheckStateRole ) );
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
bool
|
|
||||||
PackageModel::setHeaderData( int section, Qt::Orientation orientation,
|
|
||||||
const QVariant& value, int role )
|
|
||||||
{
|
|
||||||
Q_UNUSED( role )
|
|
||||||
|
|
||||||
if ( orientation == Qt::Horizontal )
|
|
||||||
{
|
|
||||||
if ( m_columnHeadings.value( section ) != QVariant() )
|
|
||||||
m_columnHeadings.replace( section, value );
|
|
||||||
else
|
|
||||||
m_columnHeadings.insert( section, value );
|
|
||||||
emit headerDataChanged( orientation, section, section );
|
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
@ -144,9 +156,13 @@ Qt::ItemFlags
|
|||||||
PackageModel::flags( const QModelIndex& index ) const
|
PackageModel::flags( const QModelIndex& index ) const
|
||||||
{
|
{
|
||||||
if ( !index.isValid() )
|
if ( !index.isValid() )
|
||||||
|
{
|
||||||
return Qt::ItemFlags();
|
return Qt::ItemFlags();
|
||||||
|
}
|
||||||
if ( index.column() == 0 )
|
if ( index.column() == 0 )
|
||||||
|
{
|
||||||
return Qt::ItemIsUserCheckable | QAbstractItemModel::flags( index );
|
return Qt::ItemIsUserCheckable | QAbstractItemModel::flags( index );
|
||||||
|
}
|
||||||
return QAbstractItemModel::flags( index );
|
return QAbstractItemModel::flags( index );
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -154,18 +170,27 @@ QVariant
|
|||||||
PackageModel::headerData( int section, Qt::Orientation orientation, int role ) const
|
PackageModel::headerData( int section, Qt::Orientation orientation, int role ) const
|
||||||
{
|
{
|
||||||
if ( orientation == Qt::Horizontal && role == Qt::DisplayRole )
|
if ( orientation == Qt::Horizontal && role == Qt::DisplayRole )
|
||||||
return m_columnHeadings.value( section );
|
{
|
||||||
|
// Unusual translation call uses the existing translation from the NetInstallPage
|
||||||
|
// class (now removed).
|
||||||
|
//
|
||||||
|
// TODO: after 3.2.19, change this to just tr() and push TX
|
||||||
|
return ( section == 0 ) ? QCoreApplication::translate( "NetInstallPage", "Name" )
|
||||||
|
: QCoreApplication::translate( "NetInstallPage", "Description" );
|
||||||
|
}
|
||||||
return QVariant();
|
return QVariant();
|
||||||
}
|
}
|
||||||
|
|
||||||
QList<PackageTreeItem::ItemData>
|
QList< PackageTreeItem::ItemData >
|
||||||
PackageModel::getPackages() const
|
PackageModel::getPackages() const
|
||||||
{
|
{
|
||||||
QList<PackageTreeItem*> items = getItemPackages( m_rootItem );
|
QList< PackageTreeItem* > items = getItemPackages( m_rootItem );
|
||||||
for ( auto package : m_hiddenItems )
|
for ( auto package : m_hiddenItems )
|
||||||
if ( package->hiddenSelected() )
|
if ( package->hiddenSelected() )
|
||||||
|
{
|
||||||
items.append( getItemPackages( package ) );
|
items.append( getItemPackages( package ) );
|
||||||
QList<PackageTreeItem::ItemData> packages;
|
}
|
||||||
|
QList< PackageTreeItem::ItemData > packages;
|
||||||
for ( auto item : items )
|
for ( auto item : items )
|
||||||
{
|
{
|
||||||
PackageTreeItem::ItemData itemData;
|
PackageTreeItem::ItemData itemData;
|
||||||
@ -178,22 +203,27 @@ PackageModel::getPackages() const
|
|||||||
return packages;
|
return packages;
|
||||||
}
|
}
|
||||||
|
|
||||||
QList<PackageTreeItem*>
|
QList< PackageTreeItem* >
|
||||||
PackageModel::getItemPackages( PackageTreeItem* item ) const
|
PackageModel::getItemPackages( PackageTreeItem* item ) const
|
||||||
{
|
{
|
||||||
QList<PackageTreeItem*> selectedPackages;
|
QList< PackageTreeItem* > selectedPackages;
|
||||||
for ( int i = 0; i < item->childCount(); i++ )
|
for ( int i = 0; i < item->childCount(); i++ )
|
||||||
{
|
{
|
||||||
if ( item->child( i )->isSelected() == Qt::Unchecked )
|
if ( item->child( i )->isSelected() == Qt::Unchecked )
|
||||||
|
{
|
||||||
continue;
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
if ( !item->child( i )->childCount() ) // package
|
if ( !item->child( i )->childCount() ) // package
|
||||||
|
{
|
||||||
selectedPackages.append( item->child( i ) );
|
selectedPackages.append( item->child( i ) );
|
||||||
|
}
|
||||||
else
|
else
|
||||||
|
{
|
||||||
selectedPackages.append( getItemPackages( item->child( i ) ) );
|
selectedPackages.append( getItemPackages( item->child( i ) ) );
|
||||||
}
|
}
|
||||||
|
}
|
||||||
return selectedPackages;
|
return selectedPackages;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
@ -203,49 +233,57 @@ PackageModel::setupModelData( const YAML::Node& data, PackageTreeItem* parent )
|
|||||||
{
|
{
|
||||||
const YAML::Node itemDefinition = *it;
|
const YAML::Node itemDefinition = *it;
|
||||||
|
|
||||||
QString name(
|
QString name( tr( CalamaresUtils::yamlToVariant( itemDefinition[ "name" ] ).toByteArray() ) );
|
||||||
tr( CalamaresUtils::yamlToVariant( itemDefinition["name"] ).toByteArray() ) );
|
QString description( tr( CalamaresUtils::yamlToVariant( itemDefinition[ "description" ] ).toByteArray() ) );
|
||||||
QString description(
|
|
||||||
tr( CalamaresUtils::yamlToVariant( itemDefinition["description"] ).toByteArray() ) );
|
|
||||||
|
|
||||||
PackageTreeItem::ItemData itemData;
|
PackageTreeItem::ItemData itemData;
|
||||||
itemData.name = name;
|
itemData.name = name;
|
||||||
itemData.description = description;
|
itemData.description = description;
|
||||||
|
|
||||||
if ( itemDefinition["pre-install"] )
|
if ( itemDefinition[ "pre-install" ] )
|
||||||
itemData.preScript =
|
{
|
||||||
CalamaresUtils::yamlToVariant( itemDefinition["pre-install"] ).toString();
|
itemData.preScript = CalamaresUtils::yamlToVariant( itemDefinition[ "pre-install" ] ).toString();
|
||||||
if ( itemDefinition["post-install"] )
|
}
|
||||||
itemData.postScript =
|
if ( itemDefinition[ "post-install" ] )
|
||||||
CalamaresUtils::yamlToVariant( itemDefinition["post-install"] ).toString();
|
{
|
||||||
|
itemData.postScript = CalamaresUtils::yamlToVariant( itemDefinition[ "post-install" ] ).toString();
|
||||||
|
}
|
||||||
PackageTreeItem* item = new PackageTreeItem( itemData, parent );
|
PackageTreeItem* item = new PackageTreeItem( itemData, parent );
|
||||||
|
|
||||||
if ( itemDefinition["selected"] )
|
if ( itemDefinition[ "selected" ] )
|
||||||
item->setSelected(
|
item->setSelected( CalamaresUtils::yamlToVariant( itemDefinition[ "selected" ] ).toBool() ? Qt::Checked
|
||||||
CalamaresUtils::yamlToVariant( itemDefinition["selected"] ).toBool() ?
|
: Qt::Unchecked );
|
||||||
Qt::Checked : Qt::Unchecked );
|
|
||||||
else
|
else
|
||||||
|
{
|
||||||
item->setSelected( parent->isSelected() ); // Inherit from it's parent
|
item->setSelected( parent->isSelected() ); // Inherit from it's parent
|
||||||
|
}
|
||||||
|
|
||||||
if ( itemDefinition["hidden"] )
|
if ( itemDefinition[ "hidden" ] )
|
||||||
item->setHidden(
|
{
|
||||||
CalamaresUtils::yamlToVariant( itemDefinition["hidden"] ).toBool() );
|
item->setHidden( CalamaresUtils::yamlToVariant( itemDefinition[ "hidden" ] ).toBool() );
|
||||||
|
}
|
||||||
|
|
||||||
if ( itemDefinition["critical"] )
|
if ( itemDefinition[ "critical" ] )
|
||||||
item->setCritical(
|
{
|
||||||
CalamaresUtils::yamlToVariant( itemDefinition["critical"] ).toBool() );
|
item->setCritical( CalamaresUtils::yamlToVariant( itemDefinition[ "critical" ] ).toBool() );
|
||||||
|
}
|
||||||
|
|
||||||
if ( itemDefinition["packages"] )
|
if ( itemDefinition[ "packages" ] )
|
||||||
for ( YAML::const_iterator packageIt = itemDefinition["packages"].begin();
|
for ( YAML::const_iterator packageIt = itemDefinition[ "packages" ].begin();
|
||||||
packageIt != itemDefinition["packages"].end(); ++packageIt )
|
packageIt != itemDefinition[ "packages" ].end();
|
||||||
|
++packageIt )
|
||||||
item->appendChild(
|
item->appendChild(
|
||||||
new PackageTreeItem( CalamaresUtils::yamlToVariant( *packageIt ).toString(), item ) );
|
new PackageTreeItem( CalamaresUtils::yamlToVariant( *packageIt ).toString(), item ) );
|
||||||
|
|
||||||
if ( itemDefinition["subgroups"] )
|
if ( itemDefinition[ "subgroups" ] )
|
||||||
setupModelData( itemDefinition["subgroups"], item );
|
{
|
||||||
|
setupModelData( itemDefinition[ "subgroups" ], item );
|
||||||
|
}
|
||||||
|
|
||||||
if ( item->isHidden() )
|
if ( item->isHidden() )
|
||||||
|
{
|
||||||
m_hiddenItems.append( item );
|
m_hiddenItems.append( item );
|
||||||
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
item->setCheckable( true );
|
item->setCheckable( true );
|
||||||
|
@ -29,7 +29,7 @@
|
|||||||
|
|
||||||
namespace YAML
|
namespace YAML
|
||||||
{
|
{
|
||||||
class Node;
|
class Node;
|
||||||
}
|
}
|
||||||
|
|
||||||
class PackageModel : public QAbstractItemModel
|
class PackageModel : public QAbstractItemModel
|
||||||
@ -43,27 +43,24 @@ public:
|
|||||||
~PackageModel() override;
|
~PackageModel() override;
|
||||||
|
|
||||||
QVariant data( const QModelIndex& index, int role ) const override;
|
QVariant data( const QModelIndex& index, int role ) const override;
|
||||||
bool setData( const QModelIndex& index, const QVariant& value,
|
bool setData( const QModelIndex& index, const QVariant& value, int role = Qt::EditRole ) override;
|
||||||
int role = Qt::EditRole ) override;
|
|
||||||
bool setHeaderData( int section, Qt::Orientation orientation,
|
|
||||||
const QVariant& value, int role = Qt::EditRole ) override;
|
|
||||||
Qt::ItemFlags flags( const QModelIndex& index ) const override;
|
Qt::ItemFlags flags( const QModelIndex& index ) const override;
|
||||||
QVariant headerData( int section, Qt::Orientation orientation,
|
|
||||||
int role = Qt::DisplayRole ) const override;
|
QModelIndex index( int row, int column, const QModelIndex& parent = QModelIndex() ) const override;
|
||||||
QModelIndex index( int row, int column,
|
|
||||||
const QModelIndex& parent = QModelIndex() ) const override;
|
|
||||||
QModelIndex parent( const QModelIndex& index ) const override;
|
QModelIndex parent( const QModelIndex& index ) const override;
|
||||||
|
|
||||||
|
QVariant headerData( int section, Qt::Orientation orientation, int role = Qt::DisplayRole ) const override;
|
||||||
int rowCount( const QModelIndex& parent = QModelIndex() ) const override;
|
int rowCount( const QModelIndex& parent = QModelIndex() ) const override;
|
||||||
int columnCount( const QModelIndex& parent = QModelIndex() ) const override;
|
int columnCount( const QModelIndex& parent = QModelIndex() ) const override;
|
||||||
|
|
||||||
PackageItemDataList getPackages() const;
|
PackageItemDataList getPackages() const;
|
||||||
QList<PackageTreeItem*> getItemPackages( PackageTreeItem* item ) const;
|
QList< PackageTreeItem* > getItemPackages( PackageTreeItem* item ) const;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
void setupModelData( const YAML::Node& data, PackageTreeItem* parent );
|
void setupModelData( const YAML::Node& data, PackageTreeItem* parent );
|
||||||
|
|
||||||
PackageTreeItem* m_rootItem;
|
PackageTreeItem* m_rootItem;
|
||||||
QList<PackageTreeItem*> m_hiddenItems;
|
QList< PackageTreeItem* > m_hiddenItems;
|
||||||
QVariantList m_columnHeadings;
|
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif // PACKAGEMODEL_H
|
#endif // PACKAGEMODEL_H
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
/* === This file is part of Calamares - <https://github.com/calamares> ===
|
/* === This file is part of Calamares - <https://github.com/calamares> ===
|
||||||
*
|
*
|
||||||
* Copyright (c) 2017, Kyle Robbertze <kyle@aims.ac.za>
|
* Copyright (c) 2017, Kyle Robbertze <kyle@aims.ac.za>
|
||||||
* Copyright 2017, Adriaan de Groot <groot@kde.org>
|
* Copyright 2017, 2020, Adriaan de Groot <groot@kde.org>
|
||||||
*
|
*
|
||||||
* Calamares is free software: you can redistribute it and/or modify
|
* Calamares is free software: you can redistribute it and/or modify
|
||||||
* it under the terms of the GNU General Public License as published by
|
* it under the terms of the GNU General Public License as published by
|
||||||
@ -21,28 +21,52 @@
|
|||||||
|
|
||||||
#include "utils/Logger.h"
|
#include "utils/Logger.h"
|
||||||
|
|
||||||
|
QVariant
|
||||||
|
PackageTreeItem::ItemData::toOperation() const
|
||||||
|
{
|
||||||
|
// If it's a package with a pre- or post-script, replace
|
||||||
|
// with the more complicated datastructure.
|
||||||
|
if ( !preScript.isEmpty() || !postScript.isEmpty() )
|
||||||
|
{
|
||||||
|
QMap< QString, QVariant > sdetails;
|
||||||
|
sdetails.insert( "pre-script", preScript );
|
||||||
|
sdetails.insert( "package", packageName );
|
||||||
|
sdetails.insert( "post-script", postScript );
|
||||||
|
return sdetails;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
return packageName;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
PackageTreeItem::PackageTreeItem( const ItemData& data, PackageTreeItem* parent )
|
PackageTreeItem::PackageTreeItem( const ItemData& data, PackageTreeItem* parent )
|
||||||
: m_parentItem( parent )
|
: m_parentItem( parent )
|
||||||
, m_data( data )
|
, m_data( data )
|
||||||
{ }
|
{
|
||||||
|
}
|
||||||
|
|
||||||
PackageTreeItem::PackageTreeItem( const QString packageName, PackageTreeItem* parent ) :
|
PackageTreeItem::PackageTreeItem( const QString packageName, PackageTreeItem* parent )
|
||||||
m_parentItem( parent )
|
: m_parentItem( parent )
|
||||||
{
|
{
|
||||||
m_data.packageName = packageName;
|
m_data.packageName = packageName;
|
||||||
if ( parent != nullptr )
|
if ( parent != nullptr )
|
||||||
|
{
|
||||||
m_data.selected = parent->isSelected();
|
m_data.selected = parent->isSelected();
|
||||||
|
}
|
||||||
else
|
else
|
||||||
|
{
|
||||||
m_data.selected = Qt::Unchecked;
|
m_data.selected = Qt::Unchecked;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
PackageTreeItem::PackageTreeItem( PackageTreeItem* parent ) :
|
PackageTreeItem::PackageTreeItem( PackageTreeItem* parent )
|
||||||
m_parentItem( parent )
|
: m_parentItem( parent )
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
PackageTreeItem::PackageTreeItem::PackageTreeItem() :
|
PackageTreeItem::PackageTreeItem::PackageTreeItem()
|
||||||
PackageTreeItem( QString(), nullptr )
|
: PackageTreeItem( QString(), nullptr )
|
||||||
{
|
{
|
||||||
m_data.selected = Qt::Checked;
|
m_data.selected = Qt::Checked;
|
||||||
m_data.name = QLatin1String( "<root>" );
|
m_data.name = QLatin1String( "<root>" );
|
||||||
@ -75,23 +99,21 @@ int
|
|||||||
PackageTreeItem::row() const
|
PackageTreeItem::row() const
|
||||||
{
|
{
|
||||||
if ( m_parentItem )
|
if ( m_parentItem )
|
||||||
return m_parentItem->m_childItems.indexOf( const_cast<PackageTreeItem*>( this ) );
|
{
|
||||||
|
return m_parentItem->m_childItems.indexOf( const_cast< PackageTreeItem* >( this ) );
|
||||||
|
}
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
int
|
|
||||||
PackageTreeItem::columnCount() const
|
|
||||||
{
|
|
||||||
return m_columns;
|
|
||||||
}
|
|
||||||
|
|
||||||
QVariant
|
QVariant
|
||||||
PackageTreeItem::data( int column ) const
|
PackageTreeItem::data( int column ) const
|
||||||
{
|
{
|
||||||
if ( packageName() != nullptr ) // package
|
if ( packageName() != nullptr ) // package
|
||||||
{
|
{
|
||||||
if ( !column )
|
if ( !column )
|
||||||
|
{
|
||||||
return QVariant( packageName() );
|
return QVariant( packageName() );
|
||||||
|
}
|
||||||
return QVariant();
|
return QVariant();
|
||||||
}
|
}
|
||||||
switch ( column ) // group
|
switch ( column ) // group
|
||||||
@ -164,14 +186,18 @@ bool
|
|||||||
PackageTreeItem::hiddenSelected() const
|
PackageTreeItem::hiddenSelected() const
|
||||||
{
|
{
|
||||||
Q_ASSERT( m_data.isHidden );
|
Q_ASSERT( m_data.isHidden );
|
||||||
if (! m_data.selected )
|
if ( !m_data.selected )
|
||||||
|
{
|
||||||
return false;
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
const PackageTreeItem* currentItem = parentItem();
|
const PackageTreeItem* currentItem = parentItem();
|
||||||
while ( currentItem != nullptr )
|
while ( currentItem != nullptr )
|
||||||
{
|
{
|
||||||
if ( !currentItem->isHidden() )
|
if ( !currentItem->isHidden() )
|
||||||
|
{
|
||||||
return currentItem->isSelected() != Qt::Unchecked;
|
return currentItem->isSelected() != Qt::Unchecked;
|
||||||
|
}
|
||||||
currentItem = currentItem->parentItem();
|
currentItem = currentItem->parentItem();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -203,7 +229,9 @@ PackageTreeItem::setSelected( Qt::CheckState isSelected )
|
|||||||
{
|
{
|
||||||
if ( parentItem() == nullptr )
|
if ( parentItem() == nullptr )
|
||||||
// This is the root, it is always checked so don't change state
|
// This is the root, it is always checked so don't change state
|
||||||
|
{
|
||||||
return;
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
m_data.selected = isSelected;
|
m_data.selected = isSelected;
|
||||||
setChildrenSelected( isSelected );
|
setChildrenSelected( isSelected );
|
||||||
@ -217,7 +245,9 @@ PackageTreeItem::setSelected( Qt::CheckState isSelected )
|
|||||||
}
|
}
|
||||||
if ( currentItem == nullptr )
|
if ( currentItem == nullptr )
|
||||||
// Reached the root .. don't bother
|
// Reached the root .. don't bother
|
||||||
|
{
|
||||||
return;
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
// Figure out checked-state based on the children
|
// Figure out checked-state based on the children
|
||||||
int childrenSelected = 0;
|
int childrenSelected = 0;
|
||||||
@ -225,16 +255,26 @@ PackageTreeItem::setSelected( Qt::CheckState isSelected )
|
|||||||
for ( int i = 0; i < currentItem->childCount(); i++ )
|
for ( int i = 0; i < currentItem->childCount(); i++ )
|
||||||
{
|
{
|
||||||
if ( currentItem->child( i )->isSelected() == Qt::Checked )
|
if ( currentItem->child( i )->isSelected() == Qt::Checked )
|
||||||
|
{
|
||||||
childrenSelected++;
|
childrenSelected++;
|
||||||
|
}
|
||||||
if ( currentItem->child( i )->isSelected() == Qt::PartiallyChecked )
|
if ( currentItem->child( i )->isSelected() == Qt::PartiallyChecked )
|
||||||
|
{
|
||||||
childrenPartiallySelected++;
|
childrenPartiallySelected++;
|
||||||
}
|
}
|
||||||
if ( !childrenSelected && !childrenPartiallySelected)
|
}
|
||||||
|
if ( !childrenSelected && !childrenPartiallySelected )
|
||||||
|
{
|
||||||
currentItem->setSelected( Qt::Unchecked );
|
currentItem->setSelected( Qt::Unchecked );
|
||||||
|
}
|
||||||
else if ( childrenSelected == currentItem->childCount() )
|
else if ( childrenSelected == currentItem->childCount() )
|
||||||
|
{
|
||||||
currentItem->setSelected( Qt::Checked );
|
currentItem->setSelected( Qt::Checked );
|
||||||
|
}
|
||||||
else
|
else
|
||||||
|
{
|
||||||
currentItem->setSelected( Qt::PartiallyChecked );
|
currentItem->setSelected( Qt::PartiallyChecked );
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
/* === This file is part of Calamares - <https://github.com/calamares> ===
|
/* === This file is part of Calamares - <https://github.com/calamares> ===
|
||||||
*
|
*
|
||||||
* Copyright (c) 2017, Kyle Robbertze <kyle@aims.ac.za>
|
* Copyright (c) 2017, Kyle Robbertze <kyle@aims.ac.za>
|
||||||
* Copyright 2017, Adriaan de Groot <groot@kde.org>
|
* Copyright 2017, 2020, Adriaan de Groot <groot@kde.org>
|
||||||
*
|
*
|
||||||
* Calamares is free software: you can redistribute it and/or modify
|
* Calamares is free software: you can redistribute it and/or modify
|
||||||
* it under the terms of the GNU General Public License as published by
|
* it under the terms of the GNU General Public License as published by
|
||||||
@ -21,8 +21,8 @@
|
|||||||
#define PACKAGETREEITEM_H
|
#define PACKAGETREEITEM_H
|
||||||
|
|
||||||
#include <QList>
|
#include <QList>
|
||||||
#include <QVariant>
|
|
||||||
#include <QStandardItem>
|
#include <QStandardItem>
|
||||||
|
#include <QVariant>
|
||||||
|
|
||||||
class PackageTreeItem : public QStandardItem
|
class PackageTreeItem : public QStandardItem
|
||||||
{
|
{
|
||||||
@ -37,6 +37,13 @@ public:
|
|||||||
bool isCritical = false;
|
bool isCritical = false;
|
||||||
bool isHidden = false;
|
bool isHidden = false;
|
||||||
Qt::CheckState selected = Qt::Unchecked;
|
Qt::CheckState selected = Qt::Unchecked;
|
||||||
|
|
||||||
|
/** @brief Turns this item into a variant for PackageOperations use
|
||||||
|
*
|
||||||
|
* For "plain" items, this is just the package name; items with
|
||||||
|
* scripts return a map. See the package module for how it's interpreted.
|
||||||
|
*/
|
||||||
|
QVariant toOperation() const;
|
||||||
};
|
};
|
||||||
explicit PackageTreeItem( const ItemData& data, PackageTreeItem* parent = nullptr );
|
explicit PackageTreeItem( const ItemData& data, PackageTreeItem* parent = nullptr );
|
||||||
explicit PackageTreeItem( const QString packageName, PackageTreeItem* parent = nullptr );
|
explicit PackageTreeItem( const QString packageName, PackageTreeItem* parent = nullptr );
|
||||||
@ -47,7 +54,6 @@ public:
|
|||||||
void appendChild( PackageTreeItem* child );
|
void appendChild( PackageTreeItem* child );
|
||||||
PackageTreeItem* child( int row );
|
PackageTreeItem* child( int row );
|
||||||
int childCount() const;
|
int childCount() const;
|
||||||
int columnCount() const;
|
|
||||||
QVariant data( int column ) const override;
|
QVariant data( int column ) const override;
|
||||||
int row() const;
|
int row() const;
|
||||||
|
|
||||||
@ -78,11 +84,11 @@ public:
|
|||||||
void setSelected( Qt::CheckState isSelected );
|
void setSelected( Qt::CheckState isSelected );
|
||||||
void setChildrenSelected( Qt::CheckState isSelected );
|
void setChildrenSelected( Qt::CheckState isSelected );
|
||||||
int type() const override;
|
int type() const override;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
PackageTreeItem* m_parentItem;
|
PackageTreeItem* m_parentItem;
|
||||||
QList<PackageTreeItem*> m_childItems;
|
QList< PackageTreeItem* > m_childItems;
|
||||||
ItemData m_data;
|
ItemData m_data;
|
||||||
const int m_columns = 2; // Name, description
|
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif // PACKAGETREEITEM_H
|
#endif // PACKAGETREEITEM_H
|
||||||
|
@ -21,3 +21,28 @@
|
|||||||
# This only has an effect if the netinstall data cannot be retrieved,
|
# This only has an effect if the netinstall data cannot be retrieved,
|
||||||
# or is corrupt: having "required" set, means the install cannot proceed.
|
# or is corrupt: having "required" set, means the install cannot proceed.
|
||||||
required: false
|
required: false
|
||||||
|
|
||||||
|
# To support multiple instances of this module,
|
||||||
|
# some strings are configurable and translatable here.
|
||||||
|
# - *sidebar* This is the name of the module in the progress-tree / sidebar
|
||||||
|
# in Calamares.
|
||||||
|
# - *title* This is displayed above the list of packages.
|
||||||
|
# If no *sidebar* values are provided, defaults to "Package selection"
|
||||||
|
# and existing translations. If no *title* values are provided, no string
|
||||||
|
# is displayed.
|
||||||
|
#
|
||||||
|
# The following strings are already known to Calamares and can be
|
||||||
|
# listed here in *untranslated* form (e.g. as value of *sidebar*)
|
||||||
|
# without bothering with the translations: they are picked up from
|
||||||
|
# the regular translation framework:
|
||||||
|
# - "Package selection"
|
||||||
|
# - "Office software"
|
||||||
|
# - "Office package"
|
||||||
|
# - "Browser software"
|
||||||
|
# - "Browser package"
|
||||||
|
# - "Web browser"
|
||||||
|
label:
|
||||||
|
sidebar: "Package selection"
|
||||||
|
# sidebar[nl]: "Pakketkeuze"
|
||||||
|
# title: "Office Package"
|
||||||
|
# title[nl]: "Kantoorsoftware"
|
||||||
|
@ -14,6 +14,13 @@
|
|||||||
<string/>
|
<string/>
|
||||||
</property>
|
</property>
|
||||||
<layout class="QVBoxLayout" name="verticalLayout_2">
|
<layout class="QVBoxLayout" name="verticalLayout_2">
|
||||||
|
<item>
|
||||||
|
<widget class="QLabel" name="label">
|
||||||
|
<property name="alignment">
|
||||||
|
<set>Qt::AlignCenter</set>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
<item>
|
<item>
|
||||||
<widget class="QScrollArea" name="scrollArea">
|
<widget class="QScrollArea" name="scrollArea">
|
||||||
<property name="maximumSize">
|
<property name="maximumSize">
|
||||||
@ -31,7 +38,7 @@
|
|||||||
<x>0</x>
|
<x>0</x>
|
||||||
<y>0</y>
|
<y>0</y>
|
||||||
<width>981</width>
|
<width>981</width>
|
||||||
<height>434</height>
|
<height>407</height>
|
||||||
</rect>
|
</rect>
|
||||||
</property>
|
</property>
|
||||||
<property name="font">
|
<property name="font">
|
||||||
|
@ -37,8 +37,6 @@ NotesQmlViewStep::prettyName() const
|
|||||||
void
|
void
|
||||||
NotesQmlViewStep::setConfigurationMap( const QVariantMap& configurationMap )
|
NotesQmlViewStep::setConfigurationMap( const QVariantMap& configurationMap )
|
||||||
{
|
{
|
||||||
Calamares::QmlViewStep::setConfigurationMap( configurationMap ); // call parent implementation
|
|
||||||
|
|
||||||
bool qmlLabel_ok = false;
|
bool qmlLabel_ok = false;
|
||||||
auto qmlLabel = CalamaresUtils::getSubMap( configurationMap, "qmlLabel", qmlLabel_ok );
|
auto qmlLabel = CalamaresUtils::getSubMap( configurationMap, "qmlLabel", qmlLabel_ok );
|
||||||
|
|
||||||
@ -47,6 +45,7 @@ NotesQmlViewStep::setConfigurationMap( const QVariantMap& configurationMap )
|
|||||||
m_notesName = new CalamaresUtils::Locale::TranslatedString( qmlLabel, "notes" );
|
m_notesName = new CalamaresUtils::Locale::TranslatedString( qmlLabel, "notes" );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Calamares::QmlViewStep::setConfigurationMap( configurationMap ); // call parent implementation last
|
||||||
}
|
}
|
||||||
|
|
||||||
CALAMARES_PLUGIN_FACTORY_DEFINITION( NotesQmlViewStepFactory, registerPlugin< NotesQmlViewStep >(); )
|
CALAMARES_PLUGIN_FACTORY_DEFINITION( NotesQmlViewStepFactory, registerPlugin< NotesQmlViewStep >(); )
|
||||||
|
@ -20,7 +20,7 @@
|
|||||||
#ifndef NOTESQMLVIEWSTEP_H
|
#ifndef NOTESQMLVIEWSTEP_H
|
||||||
#define NOTESQMLVIEWSTEP_H
|
#define NOTESQMLVIEWSTEP_H
|
||||||
|
|
||||||
#include "PluginDllMacro.h"
|
#include "DllMacro.h"
|
||||||
#include "locale/TranslatableConfiguration.h"
|
#include "locale/TranslatableConfiguration.h"
|
||||||
#include "utils/CalamaresUtilsSystem.h"
|
#include "utils/CalamaresUtilsSystem.h"
|
||||||
#include "utils/Variant.h"
|
#include "utils/Variant.h"
|
||||||
|
@ -1,6 +1,7 @@
|
|||||||
/* === This file is part of Calamares - <https://github.com/calamares> ===
|
/* === This file is part of Calamares - <https://github.com/calamares> ===
|
||||||
*
|
*
|
||||||
* Copyright 2020, Anke Boersma <demm@kaosx.us>
|
* Copyright 2020, Anke Boersma <demm@kaosx.us>
|
||||||
|
* Copyright 2020, Adriaan de Groot <groot@kde.org>
|
||||||
*
|
*
|
||||||
* Calamares is free software: you can redistribute it and/or modify
|
* Calamares is free software: you can redistribute it and/or modify
|
||||||
* it under the terms of the GNU General Public License as published by
|
* it under the terms of the GNU General Public License as published by
|
||||||
@ -16,6 +17,14 @@
|
|||||||
* along with Calamares. If not, see <http://www.gnu.org/licenses/>.
|
* along with Calamares. If not, see <http://www.gnu.org/licenses/>.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
/* Some Calamares internals are available to all QML modules.
|
||||||
|
* They live in the calamares.ui namespace (filled programmatically
|
||||||
|
* by Calamares). One of the internals that is exposed is the
|
||||||
|
* Branding object, which can be used to retrieve strings and paths
|
||||||
|
* and colors.
|
||||||
|
*/
|
||||||
|
import calamares.ui 1.0
|
||||||
|
|
||||||
import QtQuick 2.7
|
import QtQuick 2.7
|
||||||
import QtQuick.Controls 2.2
|
import QtQuick.Controls 2.2
|
||||||
import QtQuick.Window 2.2
|
import QtQuick.Window 2.2
|
||||||
@ -32,6 +41,7 @@ Item {
|
|||||||
contentHeight: 800
|
contentHeight: 800
|
||||||
|
|
||||||
ScrollBar.vertical: ScrollBar {
|
ScrollBar.vertical: ScrollBar {
|
||||||
|
id: fscrollbar
|
||||||
width: 10
|
width: 10
|
||||||
policy: ScrollBar.AlwaysOn
|
policy: ScrollBar.AlwaysOn
|
||||||
}
|
}
|
||||||
@ -40,14 +50,14 @@ Item {
|
|||||||
id: intro
|
id: intro
|
||||||
x: 1
|
x: 1
|
||||||
y: 0
|
y: 0
|
||||||
width: 720
|
width: parent.width - fscrollbar.width
|
||||||
font.pointSize: 14
|
font.pointSize: 14
|
||||||
textFormat: Text.RichText
|
textFormat: Text.RichText
|
||||||
antialiasing: true
|
antialiasing: true
|
||||||
activeFocusOnPress: false
|
activeFocusOnPress: false
|
||||||
wrapMode: Text.WordWrap
|
wrapMode: Text.WordWrap
|
||||||
|
|
||||||
text: qsTr("<h3>Generic GNU/Linux 2017.8 LTS <quote>Soapy Sousaphone</quote></h3>
|
text: qsTr("<h3>%1</h3>
|
||||||
<p>This an example QML file, showing options in RichText with Flickable content.</p>
|
<p>This an example QML file, showing options in RichText with Flickable content.</p>
|
||||||
|
|
||||||
<p>QML with RichText can use HTML tags, Flickable content is useful for touchscreens.</p>
|
<p>QML with RichText can use HTML tags, Flickable content is useful for touchscreens.</p>
|
||||||
@ -55,7 +65,8 @@ Item {
|
|||||||
<p><b>This is bold text</b></p>
|
<p><b>This is bold text</b></p>
|
||||||
<p><i>This is italic text</i></p>
|
<p><i>This is italic text</i></p>
|
||||||
<p><u>This is underlined text</u></p>
|
<p><u>This is underlined text</u></p>
|
||||||
<p><strike>This is strikethrough</strike></p>
|
<p><center>This text will be center-aligned.</center></p>
|
||||||
|
<p><s>This is strikethrough</s></p>
|
||||||
|
|
||||||
<p>Code example:
|
<p>Code example:
|
||||||
<code>ls -l /home</code></p>
|
<code>ls -l /home</code></p>
|
||||||
@ -66,7 +77,7 @@ Item {
|
|||||||
<li>AMD CPU systems</li>
|
<li>AMD CPU systems</li>
|
||||||
</ul>
|
</ul>
|
||||||
|
|
||||||
<p>The vertical scrollbar is adjustable, current width set to 10.</p>")
|
<p>The vertical scrollbar is adjustable, current width set to 10.</p>").arg(Branding.string(Branding.VersionedName))
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
@ -1,6 +1,7 @@
|
|||||||
/* === This file is part of Calamares - <https://github.com/calamares> ===
|
/* === This file is part of Calamares - <https://github.com/calamares> ===
|
||||||
*
|
*
|
||||||
* Copyright 2020, Anke Boersma <demm@kaosx.us>
|
* Copyright 2020, Anke Boersma <demm@kaosx.us>
|
||||||
|
* Copyright 2020, Adriaan de Groot <groot@kde.org>
|
||||||
*
|
*
|
||||||
* Calamares is free software: you can redistribute it and/or modify
|
* Calamares is free software: you can redistribute it and/or modify
|
||||||
* it under the terms of the GNU General Public License as published by
|
* it under the terms of the GNU General Public License as published by
|
||||||
@ -16,6 +17,14 @@
|
|||||||
* along with Calamares. If not, see <http://www.gnu.org/licenses/>.
|
* along with Calamares. If not, see <http://www.gnu.org/licenses/>.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
/* Some Calamares internals are available to all QML modules.
|
||||||
|
* They live in the calamares.ui namespace (filled programmatically
|
||||||
|
* by Calamares). One of the internals that is exposed is the
|
||||||
|
* Branding object, which can be used to retrieve strings and paths
|
||||||
|
* and colors.
|
||||||
|
*/
|
||||||
|
import calamares.ui 1.0
|
||||||
|
|
||||||
import QtQuick 2.7
|
import QtQuick 2.7
|
||||||
import QtQuick.Controls 2.2
|
import QtQuick.Controls 2.2
|
||||||
import QtQuick.Window 2.2
|
import QtQuick.Window 2.2
|
||||||
@ -48,27 +57,9 @@ Item {
|
|||||||
activeFocusOnPress: false
|
activeFocusOnPress: false
|
||||||
wrapMode: Text.WordWrap
|
wrapMode: Text.WordWrap
|
||||||
|
|
||||||
text: qsTr("<h3>Generic GNU/Linux 2020.2 LTS <quote>Turgid Tuba</quote></h3>
|
text: qsTr("<h3>%1</h3>
|
||||||
<p>This an example QML file, showing options in RichText with Flickable content.</p>
|
<p>These are example release notes.</p>"
|
||||||
|
).arg(Branding.string(Branding.VersionedName))
|
||||||
<p>QML with RichText can use HTML tags, Flickable content is useful for touchscreens.</p>
|
|
||||||
|
|
||||||
<p><b>This is bold text</b></p>
|
|
||||||
<p><i>This is italic text</i></p>
|
|
||||||
<p><u>This is underlined text</u></p>
|
|
||||||
<p><center>This text will be center-aligned.</center></p>
|
|
||||||
<p><s>This is strikethrough</s></p>
|
|
||||||
|
|
||||||
<p>Code example:
|
|
||||||
<code>ls -l /home</code></p>
|
|
||||||
|
|
||||||
<p><b>Lists:</b></p>
|
|
||||||
<ul>
|
|
||||||
<li>Intel CPU systems</li>
|
|
||||||
<li>AMD CPU systems</li>
|
|
||||||
</ul>
|
|
||||||
|
|
||||||
<p>The vertical scrollbar is adjustable, current width set to 10.</p>")
|
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -22,7 +22,7 @@
|
|||||||
#include <utils/PluginFactory.h>
|
#include <utils/PluginFactory.h>
|
||||||
#include <viewpages/ViewStep.h>
|
#include <viewpages/ViewStep.h>
|
||||||
|
|
||||||
#include <PluginDllMacro.h>
|
#include <DllMacro.h>
|
||||||
|
|
||||||
#include <QVariantMap>
|
#include <QVariantMap>
|
||||||
|
|
||||||
|
@ -53,18 +53,12 @@ calamares_add_plugin( packagechooser
|
|||||||
SHARED_LIB
|
SHARED_LIB
|
||||||
)
|
)
|
||||||
|
|
||||||
if( ECM_FOUND AND BUILD_TESTING )
|
calamares_add_test(
|
||||||
ecm_add_test(
|
|
||||||
Tests.cpp
|
|
||||||
TEST_NAME
|
|
||||||
packagechoosertest
|
packagechoosertest
|
||||||
LINK_LIBRARIES
|
GUI
|
||||||
${CALAMARES_LIBRARIES}
|
SOURCES
|
||||||
|
Tests.cpp
|
||||||
|
LIBRARIES
|
||||||
calamares_viewmodule_packagechooser
|
calamares_viewmodule_packagechooser
|
||||||
Qt5::Core
|
|
||||||
Qt5::Test
|
|
||||||
Qt5::Gui
|
|
||||||
${_extra_libraries}
|
${_extra_libraries}
|
||||||
)
|
)
|
||||||
calamares_automoc( packagechoosertest)
|
|
||||||
endif()
|
|
||||||
|
@ -19,7 +19,7 @@
|
|||||||
#ifndef PACKAGECHOOSERVIEWSTEP_H
|
#ifndef PACKAGECHOOSERVIEWSTEP_H
|
||||||
#define PACKAGECHOOSERVIEWSTEP_H
|
#define PACKAGECHOOSERVIEWSTEP_H
|
||||||
|
|
||||||
#include "PluginDllMacro.h"
|
#include "DllMacro.h"
|
||||||
#include "locale/TranslatableConfiguration.h"
|
#include "locale/TranslatableConfiguration.h"
|
||||||
#include "utils/PluginFactory.h"
|
#include "utils/PluginFactory.h"
|
||||||
#include "viewpages/ViewStep.h"
|
#include "viewpages/ViewStep.h"
|
||||||
|
@ -478,7 +478,10 @@ def run_operations(pkgman, entry):
|
|||||||
else:
|
else:
|
||||||
for package in package_list:
|
for package in package_list:
|
||||||
pkgman.install_package(package, from_local=True)
|
pkgman.install_package(package, from_local=True)
|
||||||
|
elif key == "source":
|
||||||
|
libcalamares.utils.debug("Package-list from {!s}".format(entry[key]))
|
||||||
|
else:
|
||||||
|
libcalamares.utils.warning("Unknown package-operation key {!s}".format(key))
|
||||||
completed_packages += len(package_list)
|
completed_packages += len(package_list)
|
||||||
libcalamares.job.setprogress(completed_packages * 1.0 / total_packages)
|
libcalamares.job.setprogress(completed_packages * 1.0 / total_packages)
|
||||||
libcalamares.utils.debug(pretty_name())
|
libcalamares.utils.debug(pretty_name())
|
||||||
|
@ -55,22 +55,25 @@ update_system: false
|
|||||||
# that is in this configuration file).
|
# that is in this configuration file).
|
||||||
#
|
#
|
||||||
# Allowed package operations are:
|
# Allowed package operations are:
|
||||||
# - install, try_install: will call the package manager to
|
# - *install*, *try_install*: will call the package manager to
|
||||||
# install one or more packages. The install target will
|
# install one or more packages. The install target will
|
||||||
# abort the whole installation if package-installation
|
# abort the whole installation if package-installation
|
||||||
# fails, while try_install carries on. Packages may be
|
# fails, while try_install carries on. Packages may be
|
||||||
# listed as (localized) names, or as (localized) package-data.
|
# listed as (localized) names, or as (localized) package-data.
|
||||||
# See below for the description of the format.
|
# See below for the description of the format.
|
||||||
# - localInstall: this is used to call the package manager
|
# - *localInstall*: this is used to call the package manager
|
||||||
# to install a package from a path-to-a-package. This is
|
# to install a package from a path-to-a-package. This is
|
||||||
# useful if you have a static package archive on the install media.
|
# useful if you have a static package archive on the install media.
|
||||||
# The *pacman* package manager is the only one to specially support
|
# The *pacman* package manager is the only one to specially support
|
||||||
# this operation (all others treat this the same as *install*).
|
# this operation (all others treat this the same as *install*).
|
||||||
# - remove, try_remove: will call the package manager to
|
# - *remove*, *try_remove*: will call the package manager to
|
||||||
# remove one or more packages. The remove target will
|
# remove one or more packages. The remove target will
|
||||||
# abort the whole installation if package-removal fails,
|
# abort the whole installation if package-removal fails,
|
||||||
# while try_remove carries on. Packages may be listed as
|
# while try_remove carries on. Packages may be listed as
|
||||||
# (localized) names.
|
# (localized) names.
|
||||||
|
# One additional key is recognized, to help netinstall out:
|
||||||
|
# - *source*: ignored, does get logged
|
||||||
|
# Any other key is ignored, and logged as a warning.
|
||||||
#
|
#
|
||||||
# There are two formats for naming packages: as a name or as package-data,
|
# There are two formats for naming packages: as a name or as package-data,
|
||||||
# which is an object notation providing package-name, as well as pre- and
|
# which is an object notation providing package-name, as well as pre- and
|
||||||
|
@ -648,7 +648,7 @@ PartitionViewStep::checkRequirements()
|
|||||||
{
|
{
|
||||||
QLatin1String( "partitions" ),
|
QLatin1String( "partitions" ),
|
||||||
[]{ return tr( "has at least one disk device available." ); },
|
[]{ return tr( "has at least one disk device available." ); },
|
||||||
[]{ return tr( "There are no partitons to install on." ); },
|
[]{ return tr( "There are no partitions to install on." ); },
|
||||||
m_core->deviceModel()->rowCount() > 0, // satisfied
|
m_core->deviceModel()->rowCount() > 0, // satisfied
|
||||||
#ifdef DEBUG_PARTITION_UNSAFE
|
#ifdef DEBUG_PARTITION_UNSAFE
|
||||||
false // optional
|
false // optional
|
||||||
|
@ -24,7 +24,7 @@
|
|||||||
#include <utils/PluginFactory.h>
|
#include <utils/PluginFactory.h>
|
||||||
#include <viewpages/ViewStep.h>
|
#include <viewpages/ViewStep.h>
|
||||||
|
|
||||||
#include <PluginDllMacro.h>
|
#include <DllMacro.h>
|
||||||
|
|
||||||
#include "core/PartitionActions.h"
|
#include "core/PartitionActions.h"
|
||||||
|
|
||||||
|
@ -1,9 +1,18 @@
|
|||||||
find_package( Qt5 COMPONENTS Gui REQUIRED )
|
find_package( Qt5 COMPONENTS Gui REQUIRED )
|
||||||
|
|
||||||
# Roundabout way of saying ..
|
|
||||||
set( PartitionModule_SOURCE_DIR .. )
|
set( PartitionModule_SOURCE_DIR .. )
|
||||||
# This is set by parent CMakeLists.txt
|
|
||||||
# set( _partition_defs )
|
set( partitionjobtests_SRCS
|
||||||
|
${PartitionModule_SOURCE_DIR}/core/KPMHelpers.cpp
|
||||||
|
${PartitionModule_SOURCE_DIR}/core/PartitionInfo.cpp
|
||||||
|
${PartitionModule_SOURCE_DIR}/core/PartitionIterator.cpp
|
||||||
|
${PartitionModule_SOURCE_DIR}/jobs/CreatePartitionJob.cpp
|
||||||
|
${PartitionModule_SOURCE_DIR}/jobs/CreatePartitionTableJob.cpp
|
||||||
|
${PartitionModule_SOURCE_DIR}/jobs/DeletePartitionJob.cpp
|
||||||
|
${PartitionModule_SOURCE_DIR}/jobs/PartitionJob.cpp
|
||||||
|
${PartitionModule_SOURCE_DIR}/jobs/ResizePartitionJob.cpp
|
||||||
|
PartitionJobTests.cpp
|
||||||
|
)
|
||||||
|
|
||||||
include_directories(
|
include_directories(
|
||||||
${Qt5Gui_INCLUDE_DIRS}
|
${Qt5Gui_INCLUDE_DIRS}
|
||||||
@ -12,41 +21,25 @@ include_directories(
|
|||||||
${CMAKE_CURRENT_BINARY_DIR}
|
${CMAKE_CURRENT_BINARY_DIR}
|
||||||
)
|
)
|
||||||
|
|
||||||
if( ECM_FOUND AND BUILD_TESTING )
|
calamares_add_test(
|
||||||
ecm_add_test(
|
partitionjobtests
|
||||||
${PartitionModule_SOURCE_DIR}/core/KPMHelpers.cpp
|
SOURCES ${partitionjobtests_SRCS}
|
||||||
${PartitionModule_SOURCE_DIR}/core/PartitionInfo.cpp
|
LIBRARIES
|
||||||
${PartitionModule_SOURCE_DIR}/jobs/CreatePartitionJob.cpp
|
|
||||||
${PartitionModule_SOURCE_DIR}/jobs/CreatePartitionTableJob.cpp
|
|
||||||
${PartitionModule_SOURCE_DIR}/jobs/DeletePartitionJob.cpp
|
|
||||||
${PartitionModule_SOURCE_DIR}/jobs/PartitionJob.cpp
|
|
||||||
${PartitionModule_SOURCE_DIR}/jobs/ResizePartitionJob.cpp
|
|
||||||
PartitionJobTests.cpp
|
|
||||||
|
|
||||||
TEST_NAME partitionjobtests
|
|
||||||
LINK_LIBRARIES
|
|
||||||
${CALAMARES_LIBRARIES}
|
|
||||||
kpmcore
|
kpmcore
|
||||||
Qt5::Core
|
)
|
||||||
Qt5::Test
|
if( TARGET partitionjobtests )
|
||||||
)
|
|
||||||
|
|
||||||
set_target_properties( partitionjobtests PROPERTIES AUTOMOC TRUE )
|
|
||||||
target_compile_definitions( partitionjobtests PRIVATE ${_partition_defs} )
|
target_compile_definitions( partitionjobtests PRIVATE ${_partition_defs} )
|
||||||
|
endif()
|
||||||
|
|
||||||
ecm_add_test(
|
calamares_add_test(
|
||||||
|
clearmountsjobtests
|
||||||
|
SOURCES
|
||||||
${PartitionModule_SOURCE_DIR}/jobs/ClearMountsJob.cpp
|
${PartitionModule_SOURCE_DIR}/jobs/ClearMountsJob.cpp
|
||||||
ClearMountsJobTests.cpp
|
ClearMountsJobTests.cpp
|
||||||
|
LIBRARIES
|
||||||
TEST_NAME clearmountsjobtests
|
|
||||||
LINK_LIBRARIES
|
|
||||||
${CALAMARES_LIBRARIES}
|
|
||||||
kpmcore
|
kpmcore
|
||||||
Qt5::Core
|
)
|
||||||
Qt5::Test
|
if( TARGET clearmountsjobtests )
|
||||||
)
|
|
||||||
|
|
||||||
set_target_properties( clearmountsjobtests PROPERTIES AUTOMOC TRUE )
|
|
||||||
target_compile_definitions( clearmountsjobtests PRIVATE ${_partition_defs} )
|
target_compile_definitions( clearmountsjobtests PRIVATE ${_partition_defs} )
|
||||||
|
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
|
@ -21,7 +21,7 @@
|
|||||||
|
|
||||||
#include <utils/PluginFactory.h>
|
#include <utils/PluginFactory.h>
|
||||||
#include <viewpages/ViewStep.h>
|
#include <viewpages/ViewStep.h>
|
||||||
#include <PluginDllMacro.h>
|
#include <DllMacro.h>
|
||||||
|
|
||||||
#include <QObject>
|
#include <QObject>
|
||||||
#include <QUrl>
|
#include <QUrl>
|
||||||
|
@ -24,7 +24,7 @@
|
|||||||
#include <QVariantMap>
|
#include <QVariantMap>
|
||||||
|
|
||||||
#include "CppJob.h"
|
#include "CppJob.h"
|
||||||
#include "PluginDllMacro.h"
|
#include "DllMacro.h"
|
||||||
|
|
||||||
#include "utils/PluginFactory.h"
|
#include "utils/PluginFactory.h"
|
||||||
|
|
||||||
|
@ -8,17 +8,10 @@ calamares_add_plugin( shellprocess
|
|||||||
SHARED_LIB
|
SHARED_LIB
|
||||||
)
|
)
|
||||||
|
|
||||||
if( ECM_FOUND AND BUILD_TESTING )
|
calamares_add_test(
|
||||||
ecm_add_test(
|
|
||||||
Tests.cpp
|
|
||||||
TEST_NAME
|
|
||||||
shellprocesstest
|
shellprocesstest
|
||||||
LINK_LIBRARIES
|
SOURCES
|
||||||
${CALAMARES_LIBRARIES}
|
Tests.cpp
|
||||||
calamaresui
|
LIBRARIES
|
||||||
${YAMLCPP_LIBRARY}
|
yamlcpp
|
||||||
Qt5::Core
|
)
|
||||||
Qt5::Test
|
|
||||||
)
|
|
||||||
calamares_automoc( shellprocesstest )
|
|
||||||
endif()
|
|
||||||
|
@ -20,7 +20,7 @@
|
|||||||
#define SHELLPROCESSJOB_H
|
#define SHELLPROCESSJOB_H
|
||||||
|
|
||||||
#include "CppJob.h"
|
#include "CppJob.h"
|
||||||
#include "PluginDllMacro.h"
|
#include "DllMacro.h"
|
||||||
|
|
||||||
#include "utils/CommandList.h"
|
#include "utils/CommandList.h"
|
||||||
#include "utils/PluginFactory.h"
|
#include "utils/PluginFactory.h"
|
||||||
|
@ -24,7 +24,7 @@
|
|||||||
#include <utils/PluginFactory.h>
|
#include <utils/PluginFactory.h>
|
||||||
#include <viewpages/ViewStep.h>
|
#include <viewpages/ViewStep.h>
|
||||||
|
|
||||||
#include <PluginDllMacro.h>
|
#include <DllMacro.h>
|
||||||
|
|
||||||
class SummaryPage;
|
class SummaryPage;
|
||||||
|
|
||||||
|
@ -21,7 +21,7 @@
|
|||||||
|
|
||||||
#include "TrackingType.h"
|
#include "TrackingType.h"
|
||||||
|
|
||||||
#include <PluginDllMacro.h>
|
#include <DllMacro.h>
|
||||||
#include <utils/PluginFactory.h>
|
#include <utils/PluginFactory.h>
|
||||||
#include <viewpages/ViewStep.h>
|
#include <viewpages/ViewStep.h>
|
||||||
|
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
find_package( Qt5 COMPONENTS Core REQUIRED )
|
find_package( Qt5 ${QT_VERSION} CONFIG REQUIRED Core DBus Network )
|
||||||
find_package( Crypt REQUIRED )
|
find_package( Crypt REQUIRED )
|
||||||
|
|
||||||
# Add optional libraries here
|
# Add optional libraries here
|
||||||
@ -36,20 +36,24 @@ calamares_add_plugin( users
|
|||||||
calamaresui
|
calamaresui
|
||||||
${CRYPT_LIBRARIES}
|
${CRYPT_LIBRARIES}
|
||||||
${USER_EXTRA_LIB}
|
${USER_EXTRA_LIB}
|
||||||
|
Qt5::DBus
|
||||||
SHARED_LIB
|
SHARED_LIB
|
||||||
)
|
)
|
||||||
|
|
||||||
if( ECM_FOUND AND BUILD_TESTING )
|
calamares_add_test(
|
||||||
ecm_add_test(
|
userspasswordtest
|
||||||
|
SOURCES
|
||||||
PasswordTests.cpp
|
PasswordTests.cpp
|
||||||
SetPasswordJob.cpp
|
SetPasswordJob.cpp
|
||||||
TEST_NAME
|
LIBRARIES
|
||||||
passwordtest
|
|
||||||
LINK_LIBRARIES
|
|
||||||
${CALAMARES_LIBRARIES}
|
|
||||||
Qt5::Core
|
|
||||||
Qt5::Test
|
|
||||||
${CRYPT_LIBRARIES}
|
${CRYPT_LIBRARIES}
|
||||||
)
|
)
|
||||||
calamares_automoc( passwordtest )
|
|
||||||
endif()
|
calamares_add_test(
|
||||||
|
userstest
|
||||||
|
SOURCES
|
||||||
|
Tests.cpp
|
||||||
|
SetHostNameJob.cpp
|
||||||
|
LIBRARIES
|
||||||
|
Qt5::DBus
|
||||||
|
)
|
||||||
|
@ -2,7 +2,7 @@
|
|||||||
*
|
*
|
||||||
* Copyright 2014, Rohan Garg <rohan@kde.org>
|
* Copyright 2014, Rohan Garg <rohan@kde.org>
|
||||||
* Copyright 2015, Teo Mrnjavac <teo@kde.org>
|
* Copyright 2015, Teo Mrnjavac <teo@kde.org>
|
||||||
* Copyright 2018, Adriaan de Groot <groot@kde.org>
|
* Copyright 2018, 2020, Adriaan de Groot <groot@kde.org>
|
||||||
*
|
*
|
||||||
* Calamares is free software: you can redistribute it and/or modify
|
* Calamares is free software: you can redistribute it and/or modify
|
||||||
* it under the terms of the GNU General Public License as published by
|
* it under the terms of the GNU General Public License as published by
|
||||||
@ -22,14 +22,19 @@
|
|||||||
|
|
||||||
#include "GlobalStorage.h"
|
#include "GlobalStorage.h"
|
||||||
#include "JobQueue.h"
|
#include "JobQueue.h"
|
||||||
|
#include "utils/CalamaresUtilsSystem.h"
|
||||||
#include "utils/Logger.h"
|
#include "utils/Logger.h"
|
||||||
|
|
||||||
#include <QDir>
|
#include <QDir>
|
||||||
#include <QFile>
|
#include <QFile>
|
||||||
|
#include <QtDBus/QDBusConnection>
|
||||||
|
#include <QtDBus/QDBusInterface>
|
||||||
|
#include <QtDBus/QDBusReply>
|
||||||
|
|
||||||
SetHostNameJob::SetHostNameJob( const QString& hostname )
|
SetHostNameJob::SetHostNameJob( const QString& hostname, Actions a )
|
||||||
: Calamares::Job()
|
: Calamares::Job()
|
||||||
, m_hostname( hostname )
|
, m_hostname( hostname )
|
||||||
|
, m_actions( a )
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -53,6 +58,68 @@ SetHostNameJob::prettyStatusMessage() const
|
|||||||
return tr( "Setting hostname %1." ).arg( m_hostname );
|
return tr( "Setting hostname %1." ).arg( m_hostname );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
STATICTEST bool
|
||||||
|
setFileHostname( const QString& hostname )
|
||||||
|
{
|
||||||
|
return !( CalamaresUtils::System::instance()
|
||||||
|
->createTargetFile( QStringLiteral( "/etc/hostname" ), ( hostname + '\n' ).toUtf8() )
|
||||||
|
.failed() );
|
||||||
|
}
|
||||||
|
|
||||||
|
STATICTEST bool
|
||||||
|
writeFileEtcHosts( const QString& hostname )
|
||||||
|
{
|
||||||
|
// The actual hostname gets substituted in at %1
|
||||||
|
static const char etc_hosts[] = R"(# Host addresses
|
||||||
|
127.0.0.1 localhost
|
||||||
|
127.0.1.1 %1
|
||||||
|
::1 localhost ip6-localhost ip6-loopback
|
||||||
|
ff02::1 ip6-allnodes
|
||||||
|
ff02::2 ip6-allrouters
|
||||||
|
)";
|
||||||
|
|
||||||
|
return !( CalamaresUtils::System::instance()
|
||||||
|
->createTargetFile( QStringLiteral( "/etc/hosts" ), QString( etc_hosts ).arg( hostname ).toUtf8() )
|
||||||
|
.failed() );
|
||||||
|
}
|
||||||
|
|
||||||
|
STATICTEST bool
|
||||||
|
setSystemdHostname( const QString& hostname )
|
||||||
|
{
|
||||||
|
QDBusInterface hostnamed( "org.freedesktop.hostname1",
|
||||||
|
"/org/freedesktop/hostname1",
|
||||||
|
"org.freedesktop.hostname1",
|
||||||
|
QDBusConnection::systemBus() );
|
||||||
|
if ( !hostnamed.isValid() )
|
||||||
|
{
|
||||||
|
cWarning() << "Interface" << hostnamed.interface() << "is not valid.";
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool success = true;
|
||||||
|
// Static, writes /etc/hostname
|
||||||
|
{
|
||||||
|
QDBusReply< void > r = hostnamed.call( "SetStaticHostname", hostname, false );
|
||||||
|
if ( !r.isValid() )
|
||||||
|
{
|
||||||
|
cWarning() << "Could not set hostname through org.freedesktop.hostname1.SetStaticHostname." << r.error();
|
||||||
|
success = false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
// Dynamic, updates kernel
|
||||||
|
{
|
||||||
|
QDBusReply< void > r = hostnamed.call( "SetHostname", hostname, false );
|
||||||
|
if ( !r.isValid() )
|
||||||
|
{
|
||||||
|
cWarning() << "Could not set hostname through org.freedesktop.hostname1.SetHostname." << r.error();
|
||||||
|
success = false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return success;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
Calamares::JobResult
|
Calamares::JobResult
|
||||||
SetHostNameJob::exec()
|
SetHostNameJob::exec()
|
||||||
{
|
{
|
||||||
@ -71,43 +138,29 @@ SetHostNameJob::exec()
|
|||||||
return Calamares::JobResult::error( tr( "Internal Error" ) );
|
return Calamares::JobResult::error( tr( "Internal Error" ) );
|
||||||
}
|
}
|
||||||
|
|
||||||
QFile hostfile( destDir + "/etc/hostname" );
|
if ( m_actions & Action::EtcHostname )
|
||||||
if ( !hostfile.open( QFile::WriteOnly ) )
|
{
|
||||||
|
if ( !setFileHostname( m_hostname ) )
|
||||||
{
|
{
|
||||||
cError() << "Can't write to hostname file";
|
cError() << "Can't write to hostname file";
|
||||||
return Calamares::JobResult::error( tr( "Cannot write hostname to target system" ) );
|
return Calamares::JobResult::error( tr( "Cannot write hostname to target system" ) );
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
QTextStream hostfileout( &hostfile );
|
if ( m_actions & Action::WriteEtcHosts )
|
||||||
hostfileout << m_hostname << "\n";
|
{
|
||||||
hostfile.close();
|
if ( !writeFileEtcHosts( m_hostname ) )
|
||||||
|
|
||||||
QFile hostsfile( destDir + "/etc/hosts" );
|
|
||||||
if ( !hostsfile.open( QFile::WriteOnly ) )
|
|
||||||
{
|
{
|
||||||
cError() << "Can't write to hosts file";
|
cError() << "Can't write to hosts file";
|
||||||
return Calamares::JobResult::error( tr( "Cannot write hostname to target system" ) );
|
return Calamares::JobResult::error( tr( "Cannot write hostname to target system" ) );
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// We also need to write the appropriate entries for /etc/hosts
|
if ( m_actions & Action::SystemdHostname )
|
||||||
QTextStream hostsfileout( &hostsfile );
|
{
|
||||||
// ipv4 support
|
// Does its own logging
|
||||||
hostsfileout << "127.0.0.1"
|
setSystemdHostname( m_hostname );
|
||||||
<< "\t"
|
}
|
||||||
<< "localhost"
|
|
||||||
<< "\n";
|
|
||||||
hostsfileout << "127.0.1.1"
|
|
||||||
<< "\t" << m_hostname << "\n";
|
|
||||||
// ipv6 support
|
|
||||||
hostsfileout << "::1"
|
|
||||||
<< "\t"
|
|
||||||
<< "localhost ip6-localhost ip6-loopback"
|
|
||||||
<< "\n";
|
|
||||||
hostsfileout << "ff02::1 ip6-allnodes"
|
|
||||||
<< "\n"
|
|
||||||
<< "ff02::2 ip6-allrouters"
|
|
||||||
<< "\n";
|
|
||||||
hostsfile.close();
|
|
||||||
|
|
||||||
return Calamares::JobResult::ok();
|
return Calamares::JobResult::ok();
|
||||||
}
|
}
|
||||||
|
@ -2,6 +2,7 @@
|
|||||||
*
|
*
|
||||||
* Copyright 2014, Rohan Garg <rohan@kde.org>
|
* Copyright 2014, Rohan Garg <rohan@kde.org>
|
||||||
* Copyright 2015, Teo Mrnjavac <teo@kde.org>
|
* Copyright 2015, Teo Mrnjavac <teo@kde.org>
|
||||||
|
* Copyright 2020, Adriaan de Groot <groot@kde.org>
|
||||||
*
|
*
|
||||||
* Calamares is free software: you can redistribute it and/or modify
|
* Calamares is free software: you can redistribute it and/or modify
|
||||||
* it under the terms of the GNU General Public License as published by
|
* it under the terms of the GNU General Public License as published by
|
||||||
@ -26,7 +27,17 @@ class SetHostNameJob : public Calamares::Job
|
|||||||
{
|
{
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
public:
|
public:
|
||||||
SetHostNameJob( const QString& hostname );
|
enum Action
|
||||||
|
{
|
||||||
|
None = 0x0,
|
||||||
|
EtcHostname = 0x1, // Write to /etc/hostname directly
|
||||||
|
SystemdHostname = 0x2, // Set via hostnamed(1)
|
||||||
|
WriteEtcHosts = 0x4 // Write /etc/hosts (127.0.1.1 is this host)
|
||||||
|
};
|
||||||
|
Q_DECLARE_FLAGS( Actions, Action )
|
||||||
|
|
||||||
|
|
||||||
|
SetHostNameJob( const QString& hostname, Actions a );
|
||||||
QString prettyName() const override;
|
QString prettyName() const override;
|
||||||
QString prettyDescription() const override;
|
QString prettyDescription() const override;
|
||||||
QString prettyStatusMessage() const override;
|
QString prettyStatusMessage() const override;
|
||||||
@ -34,7 +45,9 @@ public:
|
|||||||
|
|
||||||
private:
|
private:
|
||||||
const QString m_hostname;
|
const QString m_hostname;
|
||||||
|
const Actions m_actions;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
Q_DECLARE_OPERATORS_FOR_FLAGS( SetHostNameJob::Actions )
|
||||||
|
|
||||||
#endif // SETHOSTNAMEJOB_CPP_H
|
#endif // SETHOSTNAMEJOB_CPP_H
|
||||||
|
145
src/modules/users/Tests.cpp
Normal file
145
src/modules/users/Tests.cpp
Normal file
@ -0,0 +1,145 @@
|
|||||||
|
/* === This file is part of Calamares - <https://github.com/calamares> ===
|
||||||
|
*
|
||||||
|
* Copyright 2020, Adriaan de Groot <groot@kde.org>
|
||||||
|
*
|
||||||
|
* Calamares is free software: you can redistribute it and/or modify
|
||||||
|
* it under the terms of the GNU General Public License as published by
|
||||||
|
* the Free Software Foundation, either version 3 of the License, or
|
||||||
|
* (at your option) any later version.
|
||||||
|
*
|
||||||
|
* Calamares is distributed in the hope that it will be useful,
|
||||||
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
* GNU General Public License for more details.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU General Public License
|
||||||
|
* along with Calamares. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#include "SetHostNameJob.h"
|
||||||
|
|
||||||
|
// Implementation details
|
||||||
|
extern bool setFileHostname( const QString& );
|
||||||
|
extern bool writeFileEtcHosts( const QString& );
|
||||||
|
extern bool setSystemdHostname( const QString& );
|
||||||
|
|
||||||
|
#include "GlobalStorage.h"
|
||||||
|
#include "JobQueue.h"
|
||||||
|
#include "utils/CalamaresUtilsSystem.h"
|
||||||
|
#include "utils/Logger.h"
|
||||||
|
#include "utils/Yaml.h"
|
||||||
|
|
||||||
|
#include <QTemporaryDir>
|
||||||
|
#include <QtTest/QtTest>
|
||||||
|
|
||||||
|
class UsersTests : public QObject
|
||||||
|
{
|
||||||
|
Q_OBJECT
|
||||||
|
public:
|
||||||
|
UsersTests();
|
||||||
|
virtual ~UsersTests() {}
|
||||||
|
|
||||||
|
private Q_SLOTS:
|
||||||
|
void initTestCase();
|
||||||
|
|
||||||
|
void testEtcHostname();
|
||||||
|
void testEtcHosts();
|
||||||
|
void testHostnamed();
|
||||||
|
|
||||||
|
void cleanup();
|
||||||
|
|
||||||
|
private:
|
||||||
|
QTemporaryDir m_dir;
|
||||||
|
};
|
||||||
|
|
||||||
|
UsersTests::UsersTests()
|
||||||
|
: m_dir( QStringLiteral( "/tmp/calamares-usertest" ) )
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
UsersTests::initTestCase()
|
||||||
|
{
|
||||||
|
Logger::setupLogLevel( Logger::LOGDEBUG );
|
||||||
|
cDebug() << "Users test started.";
|
||||||
|
cDebug() << "Test dir" << m_dir.path();
|
||||||
|
|
||||||
|
// Ensure we have a system object, expect it to be a "bogus" one
|
||||||
|
CalamaresUtils::System* system = CalamaresUtils::System::instance();
|
||||||
|
QVERIFY( system );
|
||||||
|
QVERIFY( system->doChroot() );
|
||||||
|
|
||||||
|
// Ensure we have a system-wide GlobalStorage with /tmp as root
|
||||||
|
if ( !Calamares::JobQueue::instance() )
|
||||||
|
{
|
||||||
|
cDebug() << "Creating new JobQueue";
|
||||||
|
(void)new Calamares::JobQueue();
|
||||||
|
}
|
||||||
|
Calamares::GlobalStorage* gs
|
||||||
|
= Calamares::JobQueue::instance() ? Calamares::JobQueue::instance()->globalStorage() : nullptr;
|
||||||
|
QVERIFY( gs );
|
||||||
|
gs->insert( "rootMountPoint", m_dir.path() );
|
||||||
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
UsersTests::testEtcHostname()
|
||||||
|
{
|
||||||
|
cDebug() << "Test dir" << m_dir.path();
|
||||||
|
|
||||||
|
QVERIFY( QFile::exists( m_dir.path() ) );
|
||||||
|
QVERIFY( !QFile::exists( m_dir.filePath( "etc" ) ) );
|
||||||
|
|
||||||
|
// Doesn't create intermediate directories
|
||||||
|
QVERIFY( !setFileHostname( QStringLiteral( "tubophone.calamares.io" ) ) );
|
||||||
|
|
||||||
|
QVERIFY( CalamaresUtils::System::instance()->createTargetDirs( "/etc" ) );
|
||||||
|
QVERIFY( QFile::exists( m_dir.filePath( "etc" ) ) );
|
||||||
|
|
||||||
|
// Does write the file
|
||||||
|
QVERIFY( setFileHostname( QStringLiteral( "tubophone.calamares.io" ) ) );
|
||||||
|
QVERIFY( QFile::exists( m_dir.filePath( "etc/hostname" ) ) );
|
||||||
|
|
||||||
|
// 22 for the test string, above, and 1 for the newline
|
||||||
|
QCOMPARE( QFileInfo( m_dir.filePath( "etc/hostname" ) ).size(), 22 + 1 );
|
||||||
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
UsersTests::testEtcHosts()
|
||||||
|
{
|
||||||
|
// Assume previous tests did their work
|
||||||
|
QVERIFY( QFile::exists( m_dir.path() ) );
|
||||||
|
QVERIFY( QFile::exists( m_dir.filePath( "etc" ) ) );
|
||||||
|
|
||||||
|
QVERIFY( writeFileEtcHosts( QStringLiteral( "tubophone.calamares.io" ) ) );
|
||||||
|
QVERIFY( QFile::exists( m_dir.filePath( "etc/hosts" ) ) );
|
||||||
|
// The skeleton contains %1 which has the hostname substituted in, so we lose two,
|
||||||
|
// and the rest of the blabla is 150 (according to Python)
|
||||||
|
QCOMPARE( QFileInfo( m_dir.filePath( "etc/hosts" ) ).size(), 150 + 22 - 2 );
|
||||||
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
UsersTests::testHostnamed()
|
||||||
|
{
|
||||||
|
// Since the service might not be running (e.g. non-systemd systems,
|
||||||
|
// FreeBSD, docker, ..) we're not going to fail a test here.
|
||||||
|
// There's also the permissions problem to think of.
|
||||||
|
QEXPECT_FAIL( "", "Hostname changes are access-controlled", Continue );
|
||||||
|
QVERIFY( setSystemdHostname( "tubophone.calamares.io" ) );
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void
|
||||||
|
UsersTests::cleanup()
|
||||||
|
{
|
||||||
|
if ( QTest::currentTestFailed() )
|
||||||
|
{
|
||||||
|
m_dir.setAutoRemove( false );
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
QTEST_GUILESS_MAIN( UsersTests )
|
||||||
|
|
||||||
|
#include "utils/moc-warnings.h"
|
||||||
|
|
||||||
|
#include "Tests.moc"
|
@ -3,6 +3,7 @@
|
|||||||
* Copyright 2014-2017, Teo Mrnjavac <teo@kde.org>
|
* Copyright 2014-2017, Teo Mrnjavac <teo@kde.org>
|
||||||
* Copyright 2017-2018, Adriaan de Groot <groot@kde.org>
|
* Copyright 2017-2018, Adriaan de Groot <groot@kde.org>
|
||||||
* Copyright 2019, Collabora Ltd <arnaud.ferraris@collabora.com>
|
* Copyright 2019, Collabora Ltd <arnaud.ferraris@collabora.com>
|
||||||
|
* Copyright 2020, Gabriel Craciunescu <crazy@frugalware.org>
|
||||||
*
|
*
|
||||||
* Portions from the Manjaro Installation Framework
|
* Portions from the Manjaro Installation Framework
|
||||||
* by Roland Singer <roland@manjaro.org>
|
* by Roland Singer <roland@manjaro.org>
|
||||||
@ -40,6 +41,7 @@
|
|||||||
#include "utils/String.h"
|
#include "utils/String.h"
|
||||||
|
|
||||||
#include <QBoxLayout>
|
#include <QBoxLayout>
|
||||||
|
#include <QFile>
|
||||||
#include <QLabel>
|
#include <QLabel>
|
||||||
#include <QLineEdit>
|
#include <QLineEdit>
|
||||||
#include <QRegExp>
|
#include <QRegExp>
|
||||||
@ -97,14 +99,12 @@ UsersPage::UsersPage( QWidget* parent )
|
|||||||
connect( ui->textBoxUserVerifiedPassword, &QLineEdit::textChanged, this, &UsersPage::onPasswordTextChanged );
|
connect( ui->textBoxUserVerifiedPassword, &QLineEdit::textChanged, this, &UsersPage::onPasswordTextChanged );
|
||||||
connect( ui->textBoxRootPassword, &QLineEdit::textChanged, this, &UsersPage::onRootPasswordTextChanged );
|
connect( ui->textBoxRootPassword, &QLineEdit::textChanged, this, &UsersPage::onRootPasswordTextChanged );
|
||||||
connect( ui->textBoxVerifiedRootPassword, &QLineEdit::textChanged, this, &UsersPage::onRootPasswordTextChanged );
|
connect( ui->textBoxVerifiedRootPassword, &QLineEdit::textChanged, this, &UsersPage::onRootPasswordTextChanged );
|
||||||
connect( ui->checkBoxValidatePassword, &QCheckBox::stateChanged, this, [this]( int )
|
connect( ui->checkBoxValidatePassword, &QCheckBox::stateChanged, this, [this]( int ) {
|
||||||
{
|
|
||||||
onPasswordTextChanged( ui->textBoxUserPassword->text() );
|
onPasswordTextChanged( ui->textBoxUserPassword->text() );
|
||||||
onRootPasswordTextChanged( ui->textBoxRootPassword->text() );
|
onRootPasswordTextChanged( ui->textBoxRootPassword->text() );
|
||||||
checkReady( isReady() );
|
checkReady( isReady() );
|
||||||
} );
|
} );
|
||||||
connect( ui->checkBoxReusePassword, &QCheckBox::stateChanged, this, [this]( int checked )
|
connect( ui->checkBoxReusePassword, &QCheckBox::stateChanged, this, [this]( int checked ) {
|
||||||
{
|
|
||||||
ui->labelChooseRootPassword->setVisible( !checked );
|
ui->labelChooseRootPassword->setVisible( !checked );
|
||||||
ui->labelRootPassword->setVisible( !checked );
|
ui->labelRootPassword->setVisible( !checked );
|
||||||
ui->labelRootPasswordError->setVisible( !checked );
|
ui->labelRootPasswordError->setVisible( !checked );
|
||||||
@ -166,6 +166,37 @@ UsersPage::isReady()
|
|||||||
return readyFields && m_readyRootPassword;
|
return readyFields && m_readyRootPassword;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
QString
|
||||||
|
UsersPage::getHostname() const
|
||||||
|
{
|
||||||
|
return ui->textBoxHostname->text();
|
||||||
|
}
|
||||||
|
|
||||||
|
QString
|
||||||
|
UsersPage::getRootPassword() const
|
||||||
|
{
|
||||||
|
if ( m_writeRootPassword )
|
||||||
|
{
|
||||||
|
if ( ui->checkBoxReusePassword->isChecked() )
|
||||||
|
{
|
||||||
|
return ui->textBoxUserPassword->text();
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
return ui->textBoxRootPassword->text();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
return QString();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
QPair< QString, QString >
|
||||||
|
UsersPage::getUserPassword() const
|
||||||
|
{
|
||||||
|
return QPair< QString, QString >( ui->textBoxUsername->text(), ui->textBoxUserPassword->text() );
|
||||||
|
}
|
||||||
|
|
||||||
QList< Calamares::job_ptr >
|
QList< Calamares::job_ptr >
|
||||||
UsersPage::createJobs( const QStringList& defaultGroupsList )
|
UsersPage::createJobs( const QStringList& defaultGroupsList )
|
||||||
@ -186,32 +217,10 @@ UsersPage::createJobs( const QStringList& defaultGroupsList )
|
|||||||
defaultGroupsList );
|
defaultGroupsList );
|
||||||
list.append( Calamares::job_ptr( j ) );
|
list.append( Calamares::job_ptr( j ) );
|
||||||
|
|
||||||
j = new SetPasswordJob( ui->textBoxUsername->text(), ui->textBoxUserPassword->text() );
|
|
||||||
list.append( Calamares::job_ptr( j ) );
|
|
||||||
|
|
||||||
if ( m_writeRootPassword )
|
if ( m_writeRootPassword )
|
||||||
{
|
{
|
||||||
gs->insert( "reuseRootPassword", ui->checkBoxReusePassword->isChecked() );
|
gs->insert( "reuseRootPassword", ui->checkBoxReusePassword->isChecked() );
|
||||||
if ( ui->checkBoxReusePassword->isChecked() )
|
|
||||||
{
|
|
||||||
j = new SetPasswordJob( "root", ui->textBoxUserPassword->text() );
|
|
||||||
}
|
}
|
||||||
else
|
|
||||||
{
|
|
||||||
j = new SetPasswordJob( "root", ui->textBoxRootPassword->text() );
|
|
||||||
}
|
|
||||||
list.append( Calamares::job_ptr( j ) );
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
j = new SetPasswordJob( "root",
|
|
||||||
"" ); //explicitly disable root password
|
|
||||||
list.append( Calamares::job_ptr( j ) );
|
|
||||||
}
|
|
||||||
|
|
||||||
j = new SetHostNameJob( ui->textBoxHostname->text() );
|
|
||||||
list.append( Calamares::job_ptr( j ) );
|
|
||||||
|
|
||||||
gs->insert( "hostname", ui->textBoxHostname->text() );
|
gs->insert( "hostname", ui->textBoxHostname->text() );
|
||||||
if ( ui->checkBoxAutoLogin->isChecked() )
|
if ( ui->checkBoxAutoLogin->isChecked() )
|
||||||
{
|
{
|
||||||
@ -269,6 +278,38 @@ UsersPage::onFullNameTextEdited( const QString& textRef )
|
|||||||
checkReady( isReady() );
|
checkReady( isReady() );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/** @brief Guess the machine's name
|
||||||
|
*
|
||||||
|
* If there is DMI data, use that; otherwise, just call the machine "-pc".
|
||||||
|
* Reads the DMI data just once.
|
||||||
|
*/
|
||||||
|
static QString
|
||||||
|
guessProductName()
|
||||||
|
{
|
||||||
|
static bool tried = false;
|
||||||
|
static QString dmiProduct;
|
||||||
|
|
||||||
|
if ( !tried )
|
||||||
|
{
|
||||||
|
// yes validateHostnameText() but these files can be a mess
|
||||||
|
QRegExp dmirx( "[^a-zA-Z0-9]", Qt::CaseInsensitive );
|
||||||
|
QFile dmiFile( QStringLiteral( "/sys/devices/virtual/dmi/id/product_name" ) );
|
||||||
|
|
||||||
|
if ( dmiFile.exists() && dmiFile.open( QIODevice::ReadOnly ) )
|
||||||
|
{
|
||||||
|
dmiProduct = QString::fromLocal8Bit( dmiFile.readAll().simplified().data() )
|
||||||
|
.toLower()
|
||||||
|
.replace( dmirx, " " )
|
||||||
|
.remove( ' ' );
|
||||||
|
}
|
||||||
|
if ( dmiProduct.isEmpty() )
|
||||||
|
{
|
||||||
|
dmiProduct = QStringLiteral( "-pc" );
|
||||||
|
}
|
||||||
|
tried = true;
|
||||||
|
}
|
||||||
|
return dmiProduct;
|
||||||
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
UsersPage::fillSuggestions()
|
UsersPage::fillSuggestions()
|
||||||
@ -303,7 +344,9 @@ UsersPage::fillSuggestions()
|
|||||||
{
|
{
|
||||||
if ( !cleanParts.isEmpty() && !cleanParts.first().isEmpty() )
|
if ( !cleanParts.isEmpty() && !cleanParts.first().isEmpty() )
|
||||||
{
|
{
|
||||||
QString hostnameSuggestion = QString( "%1-pc" ).arg( cleanParts.first() );
|
QString hostnameSuggestion;
|
||||||
|
QString productName = guessProductName();
|
||||||
|
hostnameSuggestion = QString( "%1-%2" ).arg( cleanParts.first() ).arg( productName );
|
||||||
if ( HOSTNAME_RX.indexIn( hostnameSuggestion ) != -1 )
|
if ( HOSTNAME_RX.indexIn( hostnameSuggestion ) != -1 )
|
||||||
{
|
{
|
||||||
ui->textBoxHostname->setText( hostnameSuggestion );
|
ui->textBoxHostname->setText( hostnameSuggestion );
|
||||||
@ -524,8 +567,8 @@ UsersPage::addPasswordCheck( const QString& key, const QVariant& value )
|
|||||||
{
|
{
|
||||||
if ( value.toBool() )
|
if ( value.toBool() )
|
||||||
{
|
{
|
||||||
m_passwordChecks.push_back( PasswordCheck(
|
m_passwordChecks.push_back(
|
||||||
[]() { return QCoreApplication::translate( "PWQ", "Password is empty" ); },
|
PasswordCheck( []() { return QCoreApplication::translate( "PWQ", "Password is empty" ); },
|
||||||
[]( const QString& s ) { return !s.isEmpty(); },
|
[]( const QString& s ) { return !s.isEmpty(); },
|
||||||
PasswordCheck::Weight( 1 ) ) );
|
PasswordCheck::Weight( 1 ) ) );
|
||||||
}
|
}
|
||||||
|
@ -63,6 +63,13 @@ public:
|
|||||||
*/
|
*/
|
||||||
void addPasswordCheck( const QString& key, const QVariant& value );
|
void addPasswordCheck( const QString& key, const QVariant& value );
|
||||||
|
|
||||||
|
///@brief Hostname as entered / auto-filled
|
||||||
|
QString getHostname() const;
|
||||||
|
///@brief Root password, depends on settings, may be empty
|
||||||
|
QString getRootPassword() const;
|
||||||
|
///@brief User name and password
|
||||||
|
QPair< QString, QString > getUserPassword() const;
|
||||||
|
|
||||||
protected slots:
|
protected slots:
|
||||||
void onFullNameTextEdited( const QString& );
|
void onFullNameTextEdited( const QString& );
|
||||||
void fillSuggestions();
|
void fillSuggestions();
|
||||||
|
@ -20,10 +20,12 @@
|
|||||||
|
|
||||||
#include "UsersViewStep.h"
|
#include "UsersViewStep.h"
|
||||||
|
|
||||||
|
#include "SetHostNameJob.h"
|
||||||
|
#include "SetPasswordJob.h"
|
||||||
#include "UsersPage.h"
|
#include "UsersPage.h"
|
||||||
|
|
||||||
// #include "utils/CalamaresUtils.h"
|
|
||||||
#include "utils/Logger.h"
|
#include "utils/Logger.h"
|
||||||
|
#include "utils/NamedEnum.h"
|
||||||
#include "utils/Variant.h"
|
#include "utils/Variant.h"
|
||||||
|
|
||||||
#include "GlobalStorage.h"
|
#include "GlobalStorage.h"
|
||||||
@ -31,9 +33,28 @@
|
|||||||
|
|
||||||
CALAMARES_PLUGIN_FACTORY_DEFINITION( UsersViewStepFactory, registerPlugin< UsersViewStep >(); )
|
CALAMARES_PLUGIN_FACTORY_DEFINITION( UsersViewStepFactory, registerPlugin< UsersViewStep >(); )
|
||||||
|
|
||||||
|
static const NamedEnumTable< SetHostNameJob::Action >&
|
||||||
|
hostnameActions()
|
||||||
|
{
|
||||||
|
using Action = SetHostNameJob::Action;
|
||||||
|
|
||||||
|
// *INDENT-OFF*
|
||||||
|
// clang-format off
|
||||||
|
static const NamedEnumTable< Action > names {
|
||||||
|
{ QStringLiteral( "none" ), Action::None },
|
||||||
|
{ QStringLiteral( "etcfile" ), Action::EtcHostname },
|
||||||
|
{ QStringLiteral( "hostnamed" ), Action::SystemdHostname }
|
||||||
|
};
|
||||||
|
// clang-format on
|
||||||
|
// *INDENT-ON*
|
||||||
|
|
||||||
|
return names;
|
||||||
|
}
|
||||||
|
|
||||||
UsersViewStep::UsersViewStep( QObject* parent )
|
UsersViewStep::UsersViewStep( QObject* parent )
|
||||||
: Calamares::ViewStep( parent )
|
: Calamares::ViewStep( parent )
|
||||||
, m_widget( new UsersPage() )
|
, m_widget( new UsersPage() )
|
||||||
|
, m_actions( SetHostNameJob::Action::None )
|
||||||
{
|
{
|
||||||
emit nextStatusChanged( true );
|
emit nextStatusChanged( true );
|
||||||
connect( m_widget, &UsersPage::checkReady, this, &UsersViewStep::nextStatusChanged );
|
connect( m_widget, &UsersPage::checkReady, this, &UsersViewStep::nextStatusChanged );
|
||||||
@ -109,14 +130,27 @@ void
|
|||||||
UsersViewStep::onLeave()
|
UsersViewStep::onLeave()
|
||||||
{
|
{
|
||||||
m_jobs.clear();
|
m_jobs.clear();
|
||||||
|
|
||||||
m_jobs.append( m_widget->createJobs( m_defaultGroups ) );
|
m_jobs.append( m_widget->createJobs( m_defaultGroups ) );
|
||||||
|
|
||||||
|
Calamares::Job* j;
|
||||||
|
|
||||||
|
auto userPW = m_widget->getUserPassword();
|
||||||
|
j = new SetPasswordJob( userPW.first, userPW.second );
|
||||||
|
m_jobs.append( Calamares::job_ptr( j ) );
|
||||||
|
|
||||||
|
j = new SetPasswordJob( "root", m_widget->getRootPassword() );
|
||||||
|
m_jobs.append( Calamares::job_ptr( j ) );
|
||||||
|
|
||||||
|
j = new SetHostNameJob( m_widget->getHostname(), m_actions );
|
||||||
|
m_jobs.append( Calamares::job_ptr( j ) );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void
|
void
|
||||||
UsersViewStep::setConfigurationMap( const QVariantMap& configurationMap )
|
UsersViewStep::setConfigurationMap( const QVariantMap& configurationMap )
|
||||||
{
|
{
|
||||||
|
using CalamaresUtils::getBool;
|
||||||
|
|
||||||
if ( configurationMap.contains( "defaultGroups" )
|
if ( configurationMap.contains( "defaultGroups" )
|
||||||
&& configurationMap.value( "defaultGroups" ).type() == QVariant::List )
|
&& configurationMap.value( "defaultGroups" ).type() == QVariant::List )
|
||||||
{
|
{
|
||||||
@ -142,25 +176,12 @@ UsersViewStep::setConfigurationMap( const QVariantMap& configurationMap )
|
|||||||
configurationMap.value( "sudoersGroup" ).toString() );
|
configurationMap.value( "sudoersGroup" ).toString() );
|
||||||
}
|
}
|
||||||
|
|
||||||
if ( configurationMap.contains( "setRootPassword" )
|
bool setRootPassword = getBool( configurationMap, "setRootPassword", true );
|
||||||
&& configurationMap.value( "setRootPassword" ).type() == QVariant::Bool )
|
Calamares::JobQueue::instance()->globalStorage()->insert( "setRootPassword", setRootPassword );
|
||||||
{
|
|
||||||
Calamares::JobQueue::instance()->globalStorage()->insert(
|
|
||||||
"setRootPassword", configurationMap.value( "setRootPassword" ).toBool() );
|
|
||||||
m_widget->setWriteRootPassword( configurationMap.value( "setRootPassword" ).toBool() );
|
|
||||||
}
|
|
||||||
|
|
||||||
if ( configurationMap.contains( "doAutologin" )
|
m_widget->setWriteRootPassword( setRootPassword );
|
||||||
&& configurationMap.value( "doAutologin" ).type() == QVariant::Bool )
|
m_widget->setAutologinDefault( getBool( configurationMap, "doAutologin", false ) );
|
||||||
{
|
m_widget->setReusePasswordDefault( getBool( configurationMap, "doReusePassword", false ) );
|
||||||
m_widget->setAutologinDefault( configurationMap.value( "doAutologin" ).toBool() );
|
|
||||||
}
|
|
||||||
|
|
||||||
if ( configurationMap.contains( "doReusePassword" )
|
|
||||||
&& configurationMap.value( "doReusePassword" ).type() == QVariant::Bool )
|
|
||||||
{
|
|
||||||
m_widget->setReusePasswordDefault( configurationMap.value( "doReusePassword" ).toBool() );
|
|
||||||
}
|
|
||||||
|
|
||||||
if ( configurationMap.contains( "passwordRequirements" )
|
if ( configurationMap.contains( "passwordRequirements" )
|
||||||
&& configurationMap.value( "passwordRequirements" ).type() == QVariant::Map )
|
&& configurationMap.value( "passwordRequirements" ).type() == QVariant::Map )
|
||||||
@ -173,8 +194,8 @@ UsersViewStep::setConfigurationMap( const QVariantMap& configurationMap )
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
m_widget->setPasswordCheckboxVisible( CalamaresUtils::getBool( configurationMap, "allowWeakPasswords", false ) );
|
m_widget->setPasswordCheckboxVisible( getBool( configurationMap, "allowWeakPasswords", false ) );
|
||||||
m_widget->setValidatePasswordDefault( !CalamaresUtils::getBool( configurationMap, "allowWeakPasswordsDefault", false) );
|
m_widget->setValidatePasswordDefault( !getBool( configurationMap, "allowWeakPasswordsDefault", false ) );
|
||||||
|
|
||||||
QString shell( QLatin1String( "/bin/bash" ) ); // as if it's not set at all
|
QString shell( QLatin1String( "/bin/bash" ) ); // as if it's not set at all
|
||||||
if ( configurationMap.contains( "userShell" ) )
|
if ( configurationMap.contains( "userShell" ) )
|
||||||
@ -184,4 +205,21 @@ UsersViewStep::setConfigurationMap( const QVariantMap& configurationMap )
|
|||||||
// Now it might be explicitly set to empty, which is ok
|
// Now it might be explicitly set to empty, which is ok
|
||||||
|
|
||||||
Calamares::JobQueue::instance()->globalStorage()->insert( "userShell", shell );
|
Calamares::JobQueue::instance()->globalStorage()->insert( "userShell", shell );
|
||||||
|
|
||||||
|
using Action = SetHostNameJob::Action;
|
||||||
|
|
||||||
|
QString hostnameActionString = CalamaresUtils::getString( configurationMap, "setHostname" );
|
||||||
|
if ( hostnameActionString.isEmpty() )
|
||||||
|
{
|
||||||
|
hostnameActionString = QStringLiteral( "EtcFile" );
|
||||||
|
}
|
||||||
|
bool ok = false;
|
||||||
|
auto hostnameAction = hostnameActions().find( hostnameActionString, ok );
|
||||||
|
if ( !ok )
|
||||||
|
{
|
||||||
|
hostnameAction = Action::EtcHostname;
|
||||||
|
}
|
||||||
|
|
||||||
|
Action hostsfileAction = getBool( configurationMap, "writeHostsFile", true ) ? Action::WriteEtcHosts : Action::None;
|
||||||
|
m_actions = hostsfileAction | hostnameAction;
|
||||||
}
|
}
|
||||||
|
@ -20,13 +20,13 @@
|
|||||||
#ifndef USERSPAGEPLUGIN_H
|
#ifndef USERSPAGEPLUGIN_H
|
||||||
#define USERSPAGEPLUGIN_H
|
#define USERSPAGEPLUGIN_H
|
||||||
|
|
||||||
|
#include "SetHostNameJob.h"
|
||||||
|
|
||||||
|
#include "DllMacro.h"
|
||||||
|
#include "utils/PluginFactory.h"
|
||||||
|
#include "viewpages/ViewStep.h"
|
||||||
|
|
||||||
#include <QObject>
|
#include <QObject>
|
||||||
|
|
||||||
#include <utils/PluginFactory.h>
|
|
||||||
#include <viewpages/ViewStep.h>
|
|
||||||
|
|
||||||
#include <PluginDllMacro.h>
|
|
||||||
|
|
||||||
#include <QVariant>
|
#include <QVariant>
|
||||||
|
|
||||||
class UsersPage;
|
class UsersPage;
|
||||||
@ -61,6 +61,7 @@ private:
|
|||||||
QList< Calamares::job_ptr > m_jobs;
|
QList< Calamares::job_ptr > m_jobs;
|
||||||
|
|
||||||
QStringList m_defaultGroups;
|
QStringList m_defaultGroups;
|
||||||
|
SetHostNameJob::Actions m_actions;
|
||||||
};
|
};
|
||||||
|
|
||||||
CALAMARES_PLUGIN_FACTORY_DECLARATION( UsersViewStepFactory )
|
CALAMARES_PLUGIN_FACTORY_DECLARATION( UsersViewStepFactory )
|
||||||
|
@ -122,3 +122,17 @@ allowWeakPasswordsDefault: false
|
|||||||
# - set, non-empty, use that path as shell. No validation is done
|
# - set, non-empty, use that path as shell. No validation is done
|
||||||
# that the shell actually exists or is executable.
|
# that the shell actually exists or is executable.
|
||||||
# userShell: /bin/bash
|
# userShell: /bin/bash
|
||||||
|
|
||||||
|
# Hostname setting
|
||||||
|
#
|
||||||
|
# The user can enter a hostname; this is configured into the system
|
||||||
|
# in some way; pick one of:
|
||||||
|
# - *None*, to not set the hostname at all
|
||||||
|
# - *EtcFile*, to write to `/etc/hostname` directly
|
||||||
|
# - *Hostnamed*, to use systemd hostnamed(1) over DBus
|
||||||
|
# The default is *EtcFile*.
|
||||||
|
setHostname: EtcFile
|
||||||
|
|
||||||
|
# Should /etc/hosts be written with a hostname for this machine
|
||||||
|
# (also adds localhost and some ipv6 standard entries).
|
||||||
|
writeHostsFile: true
|
||||||
|
@ -26,7 +26,7 @@
|
|||||||
#include <utils/PluginFactory.h>
|
#include <utils/PluginFactory.h>
|
||||||
#include <viewpages/ViewStep.h>
|
#include <viewpages/ViewStep.h>
|
||||||
|
|
||||||
#include <PluginDllMacro.h>
|
#include <DllMacro.h>
|
||||||
|
|
||||||
#include <QVariantMap>
|
#include <QVariantMap>
|
||||||
|
|
||||||
|
@ -40,13 +40,3 @@ calamares_add_plugin( welcome
|
|||||||
Qt5::Network
|
Qt5::Network
|
||||||
SHARED_LIB
|
SHARED_LIB
|
||||||
)
|
)
|
||||||
|
|
||||||
add_executable( welcomeqmltest qmlmain.cpp Config.cpp )
|
|
||||||
target_link_libraries( welcomeqmltest PRIVATE calamaresui Qt5::Core )
|
|
||||||
set_target_properties( welcomeqmltest
|
|
||||||
PROPERTIES
|
|
||||||
ENABLE_EXPORTS TRUE
|
|
||||||
RUNTIME_OUTPUT_NAME welcomeqmltest
|
|
||||||
)
|
|
||||||
calamares_automoc( welcomeqmltest )
|
|
||||||
calamares_autouic( welcomeqmltest )
|
|
||||||
|
@ -1,28 +0,0 @@
|
|||||||
/* === This file is part of Calamares - <https://github.com/calamares> ===
|
|
||||||
*
|
|
||||||
* Copyright 2019, Adriaan de Groot <groot@kde.org>
|
|
||||||
*
|
|
||||||
* Calamares is free software: you can redistribute it and/or modify
|
|
||||||
* it under the terms of the GNU General Public License as published by
|
|
||||||
* the Free Software Foundation, either version 3 of the License, or
|
|
||||||
* (at your option) any later version.
|
|
||||||
*
|
|
||||||
* Calamares is distributed in the hope that it will be useful,
|
|
||||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
||||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
||||||
* GNU General Public License for more details.
|
|
||||||
*
|
|
||||||
* You should have received a copy of the GNU General Public License
|
|
||||||
* along with Calamares. If not, see <http://www.gnu.org/licenses/>.
|
|
||||||
*/
|
|
||||||
|
|
||||||
#include "Config.h"
|
|
||||||
|
|
||||||
Config::Config()
|
|
||||||
: m_helpUrl( "https://www.kde.org/" )
|
|
||||||
{
|
|
||||||
}
|
|
||||||
|
|
||||||
Config::~Config()
|
|
||||||
{
|
|
||||||
}
|
|
@ -1,40 +0,0 @@
|
|||||||
/* === This file is part of Calamares - <https://github.com/calamares> ===
|
|
||||||
*
|
|
||||||
* Copyright 2019, Adriaan de Groot <groot@kde.org>
|
|
||||||
*
|
|
||||||
* Calamares is free software: you can redistribute it and/or modify
|
|
||||||
* it under the terms of the GNU General Public License as published by
|
|
||||||
* the Free Software Foundation, either version 3 of the License, or
|
|
||||||
* (at your option) any later version.
|
|
||||||
*
|
|
||||||
* Calamares is distributed in the hope that it will be useful,
|
|
||||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
||||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
||||||
* GNU General Public License for more details.
|
|
||||||
*
|
|
||||||
* You should have received a copy of the GNU General Public License
|
|
||||||
* along with Calamares. If not, see <http://www.gnu.org/licenses/>.
|
|
||||||
*/
|
|
||||||
|
|
||||||
#ifndef WELCOME_CONFIG_H
|
|
||||||
#define WELCOME_CONFIG_H
|
|
||||||
|
|
||||||
#include <QObject>
|
|
||||||
#include <QUrl>
|
|
||||||
|
|
||||||
class Config : public QObject
|
|
||||||
{
|
|
||||||
Q_OBJECT
|
|
||||||
Q_PROPERTY( QUrl helpUrl READ helpUrl WRITE setHelpUrl CONSTANT )
|
|
||||||
public:
|
|
||||||
Config();
|
|
||||||
virtual ~Config();
|
|
||||||
|
|
||||||
QUrl helpUrl() const { return m_helpUrl; }
|
|
||||||
void setHelpUrl( const QUrl& url ) { m_helpUrl = url; }
|
|
||||||
|
|
||||||
private:
|
|
||||||
QUrl m_helpUrl;
|
|
||||||
};
|
|
||||||
|
|
||||||
#endif
|
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue
Block a user