Merge branch 'development' into 3.2.x-stable
This commit is contained in:
commit
d37abf561f
14
CHANGES
14
CHANGES
@ -3,6 +3,20 @@ contributors are listed. Note that Calamares does not have a historical
|
||||
changelog -- this log starts with version 3.2.0. The release notes on the
|
||||
website will have to do for older versions.
|
||||
|
||||
# 3.2.21 (unreleased) #
|
||||
|
||||
This release contains contributions from (alphabetically by first name):
|
||||
- No external contributors yet
|
||||
|
||||
## Core ##
|
||||
- Python job modules (such as *unpackfs* or *packages*) can now provide
|
||||
a `pretty_status_message()` function, like the existing `pretty_name()`
|
||||
function, that is used to update the status during install. #1330
|
||||
|
||||
## Modules ##
|
||||
- *packages* now reports more details in the installation progress-bar.
|
||||
|
||||
|
||||
# 3.2.20 (2020-02-27) #
|
||||
|
||||
This release contains contributions from (alphabetically by first name):
|
||||
|
@ -40,10 +40,10 @@
|
||||
|
||||
cmake_minimum_required( VERSION 3.3 FATAL_ERROR )
|
||||
project( CALAMARES
|
||||
VERSION 3.2.20
|
||||
VERSION 3.2.21
|
||||
LANGUAGES C CXX )
|
||||
|
||||
set( CALAMARES_VERSION_RC 0 ) # Set to 0 during release cycle, 1 during development
|
||||
set( CALAMARES_VERSION_RC 1 ) # Set to 0 during release cycle, 1 during development
|
||||
|
||||
### OPTIONS
|
||||
#
|
||||
|
@ -6,6 +6,11 @@
|
||||
# You can pass in directory names, in which case the files
|
||||
# in that directory (NOT below it) are processed.
|
||||
#
|
||||
LANG=C
|
||||
LC_ALL=C
|
||||
LC_NUMERIC=C
|
||||
export LANG LC_ALL LC_NUMERIC
|
||||
|
||||
AS=$( which astyle )
|
||||
|
||||
for _cf in clang-format-7 clang-format-8 clang-format70 clang-format80 clang-format
|
||||
|
@ -105,8 +105,20 @@ public:
|
||||
* how much work is (relatively) done.
|
||||
*/
|
||||
virtual qreal getJobWeight() const;
|
||||
/** @brief The human-readable name of this job
|
||||
*
|
||||
* This should be a very short statement of what the job does.
|
||||
* For status and state information, see prettyStatusMessage().
|
||||
*/
|
||||
virtual QString prettyName() const = 0;
|
||||
// TODO: Unused
|
||||
virtual QString prettyDescription() const;
|
||||
/** @brief A human-readable status for progress reporting
|
||||
*
|
||||
* This is called from the JobQueue when progress is made, and should
|
||||
* return a not-too-long description of the job's status. This
|
||||
* is made visible in the progress bar of the execution view step.
|
||||
*/
|
||||
virtual QString prettyStatusMessage() const;
|
||||
virtual JobResult exec() = 0;
|
||||
|
||||
|
@ -204,8 +204,6 @@ variantHashFromPyDict( const boost::python::dict& pyDict )
|
||||
}
|
||||
|
||||
|
||||
Helper* Helper::s_instance = nullptr;
|
||||
|
||||
static inline void
|
||||
add_if_lib_exists( const QDir& dir, const char* name, QStringList& list )
|
||||
{
|
||||
@ -221,48 +219,46 @@ add_if_lib_exists( const QDir& dir, const char* name, QStringList& list )
|
||||
}
|
||||
}
|
||||
|
||||
Helper::Helper( QObject* parent )
|
||||
: QObject( parent )
|
||||
Helper::Helper()
|
||||
: QObject( nullptr )
|
||||
{
|
||||
// Let's make extra sure we only call Py_Initialize once
|
||||
if ( !s_instance )
|
||||
if ( !Py_IsInitialized() )
|
||||
{
|
||||
if ( !Py_IsInitialized() )
|
||||
{
|
||||
Py_Initialize();
|
||||
}
|
||||
|
||||
m_mainModule = bp::import( "__main__" );
|
||||
m_mainNamespace = m_mainModule.attr( "__dict__" );
|
||||
|
||||
// If we're running from the build dir
|
||||
add_if_lib_exists( QDir::current(), "libcalamares.so", m_pythonPaths );
|
||||
|
||||
QDir calaPythonPath( CalamaresUtils::systemLibDir().absolutePath() + QDir::separator() + "calamares" );
|
||||
add_if_lib_exists( calaPythonPath, "libcalamares.so", m_pythonPaths );
|
||||
|
||||
bp::object sys = bp::import( "sys" );
|
||||
|
||||
foreach ( QString path, m_pythonPaths )
|
||||
{
|
||||
bp::str dir = path.toLocal8Bit().data();
|
||||
sys.attr( "path" ).attr( "append" )( dir );
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
cWarning() << "creating PythonHelper more than once. This is very bad.";
|
||||
return;
|
||||
Py_Initialize();
|
||||
}
|
||||
|
||||
s_instance = this;
|
||||
m_mainModule = bp::import( "__main__" );
|
||||
m_mainNamespace = m_mainModule.attr( "__dict__" );
|
||||
|
||||
// If we're running from the build dir
|
||||
add_if_lib_exists( QDir::current(), "libcalamares.so", m_pythonPaths );
|
||||
|
||||
QDir calaPythonPath( CalamaresUtils::systemLibDir().absolutePath() + QDir::separator() + "calamares" );
|
||||
add_if_lib_exists( calaPythonPath, "libcalamares.so", m_pythonPaths );
|
||||
|
||||
bp::object sys = bp::import( "sys" );
|
||||
|
||||
foreach ( QString path, m_pythonPaths )
|
||||
{
|
||||
bp::str dir = path.toLocal8Bit().data();
|
||||
sys.attr( "path" ).attr( "append" )( dir );
|
||||
}
|
||||
}
|
||||
|
||||
Helper::~Helper()
|
||||
Helper::~Helper() {}
|
||||
|
||||
Helper*
|
||||
Helper::instance()
|
||||
{
|
||||
s_instance = nullptr;
|
||||
}
|
||||
static Helper* s_helper = nullptr;
|
||||
|
||||
if ( !s_helper )
|
||||
{
|
||||
s_helper = new Helper;
|
||||
}
|
||||
return s_helper;
|
||||
}
|
||||
|
||||
boost::python::dict
|
||||
Helper::createCleanNamespace()
|
||||
|
@ -50,16 +50,15 @@ class Helper : public QObject
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
virtual ~Helper();
|
||||
|
||||
boost::python::dict createCleanNamespace();
|
||||
|
||||
QString handleLastError();
|
||||
|
||||
static Helper* instance();
|
||||
|
||||
private:
|
||||
friend Helper* Calamares::PythonJob::helper();
|
||||
explicit Helper( QObject* parent = nullptr );
|
||||
static Helper* s_instance;
|
||||
virtual ~Helper();
|
||||
explicit Helper();
|
||||
|
||||
boost::python::object m_mainModule;
|
||||
boost::python::object m_mainNamespace;
|
||||
|
@ -165,6 +165,10 @@ BOOST_PYTHON_MODULE( libcalamares )
|
||||
namespace Calamares
|
||||
{
|
||||
|
||||
struct PythonJob::Private
|
||||
{
|
||||
bp::object m_prettyStatusMessage;
|
||||
};
|
||||
|
||||
PythonJob::PythonJob( const ModuleSystem::InstanceKey& instance,
|
||||
const QString& scriptFile,
|
||||
@ -172,6 +176,7 @@ PythonJob::PythonJob( const ModuleSystem::InstanceKey& instance,
|
||||
const QVariantMap& moduleConfiguration,
|
||||
QObject* parent )
|
||||
: Job( parent )
|
||||
, m_d( std::make_unique< Private >() )
|
||||
, m_scriptFile( scriptFile )
|
||||
, m_workingPath( workingPath )
|
||||
, m_description()
|
||||
@ -199,6 +204,7 @@ PythonJob::prettyName() const
|
||||
QString
|
||||
PythonJob::prettyStatusMessage() const
|
||||
{
|
||||
// The description is updated when progress is reported, see emitProgress()
|
||||
if ( m_description.isEmpty() )
|
||||
{
|
||||
return tr( "Running %1 operation." ).arg( QDir( m_workingPath ).dirName() );
|
||||
@ -209,6 +215,18 @@ PythonJob::prettyStatusMessage() const
|
||||
}
|
||||
}
|
||||
|
||||
static QString
|
||||
pythonStringMethod( bp::dict& script, const char* funcName )
|
||||
{
|
||||
bp::object func = script.get( funcName, bp::object() );
|
||||
if ( !func.is_none() )
|
||||
{
|
||||
bp::extract< std::string > result( func() );
|
||||
return result.check() ? QString::fromStdString( result() ).trimmed() : QString();
|
||||
}
|
||||
return QString();
|
||||
}
|
||||
|
||||
|
||||
JobResult
|
||||
PythonJob::exec()
|
||||
@ -233,7 +251,7 @@ PythonJob::exec()
|
||||
|
||||
try
|
||||
{
|
||||
bp::dict scriptNamespace = helper()->createCleanNamespace();
|
||||
bp::dict scriptNamespace = CalamaresPython::Helper::instance()->createCleanNamespace();
|
||||
|
||||
bp::object calamaresModule = bp::import( "libcalamares" );
|
||||
bp::dict calamaresNamespace = bp::extract< bp::dict >( calamaresModule.attr( "__dict__" ) );
|
||||
@ -242,27 +260,13 @@ PythonJob::exec()
|
||||
calamaresNamespace[ "globalstorage" ]
|
||||
= CalamaresPython::GlobalStoragePythonWrapper( JobQueue::instance()->globalStorage() );
|
||||
|
||||
cDebug() << "Job file" << scriptFI.absoluteFilePath();
|
||||
bp::object execResult
|
||||
= bp::exec_file( scriptFI.absoluteFilePath().toLocal8Bit().data(), scriptNamespace, scriptNamespace );
|
||||
|
||||
bp::object entryPoint = scriptNamespace[ "run" ];
|
||||
bp::object prettyNameFunc = scriptNamespace.get( "pretty_name", bp::object() );
|
||||
|
||||
cDebug() << "Job file" << scriptFI.absoluteFilePath();
|
||||
if ( !prettyNameFunc.is_none() )
|
||||
{
|
||||
bp::extract< std::string > prettyNameResult( prettyNameFunc() );
|
||||
if ( prettyNameResult.check() )
|
||||
{
|
||||
m_description = QString::fromStdString( prettyNameResult() ).trimmed();
|
||||
}
|
||||
if ( !m_description.isEmpty() )
|
||||
{
|
||||
cDebug() << "Job description from pretty_name" << prettyName() << "=" << m_description;
|
||||
emit progress( 0 );
|
||||
}
|
||||
}
|
||||
|
||||
m_d->m_prettyStatusMessage = scriptNamespace.get( "pretty_status_message", bp::object() );
|
||||
m_description = pythonStringMethod( scriptNamespace, "pretty_name" );
|
||||
if ( m_description.isEmpty() )
|
||||
{
|
||||
bp::extract< std::string > entryPoint_doc_attr( entryPoint.attr( "__doc__" ) );
|
||||
@ -275,10 +279,14 @@ PythonJob::exec()
|
||||
{
|
||||
m_description.truncate( i_newline );
|
||||
}
|
||||
cDebug() << "Job description from __doc__" << prettyName() << "=" << m_description;
|
||||
emit progress( 0 );
|
||||
cDebug() << "Job description from __doc__" << prettyName() << '=' << m_description;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
cDebug() << "Job description from pretty_name" << prettyName() << '=' << m_description;
|
||||
}
|
||||
emit progress( 0 );
|
||||
|
||||
bp::object runResult = entryPoint();
|
||||
|
||||
@ -299,7 +307,7 @@ PythonJob::exec()
|
||||
QString msg;
|
||||
if ( PyErr_Occurred() )
|
||||
{
|
||||
msg = helper()->handleLastError();
|
||||
msg = CalamaresPython::Helper::instance()->handleLastError();
|
||||
}
|
||||
bp::handle_exception();
|
||||
PyErr_Clear();
|
||||
@ -312,20 +320,21 @@ PythonJob::exec()
|
||||
void
|
||||
PythonJob::emitProgress( qreal progressValue )
|
||||
{
|
||||
// This is called from the JobApi (and only from there) from the Job thread,
|
||||
// so it is safe to call into the Python interpreter. Update the description
|
||||
// as needed (don't call this from prettyStatusMessage(), which can be
|
||||
// called from other threads as well).
|
||||
if ( m_d && !m_d->m_prettyStatusMessage.is_none() )
|
||||
{
|
||||
QString r;
|
||||
bp::extract< std::string > result( m_d->m_prettyStatusMessage() );
|
||||
r = result.check() ? QString::fromStdString( result() ).trimmed() : QString();
|
||||
if ( !r.isEmpty() )
|
||||
{
|
||||
m_description = r;
|
||||
}
|
||||
}
|
||||
emit progress( progressValue );
|
||||
}
|
||||
|
||||
|
||||
CalamaresPython::Helper*
|
||||
PythonJob::helper()
|
||||
{
|
||||
auto ptr = CalamaresPython::Helper::s_instance;
|
||||
if ( !ptr )
|
||||
{
|
||||
ptr = new CalamaresPython::Helper;
|
||||
}
|
||||
return ptr;
|
||||
}
|
||||
|
||||
|
||||
} // namespace Calamares
|
||||
|
@ -53,11 +53,12 @@ public:
|
||||
virtual qreal getJobWeight() const override;
|
||||
|
||||
private:
|
||||
friend class CalamaresPython::Helper;
|
||||
struct Private;
|
||||
|
||||
friend class CalamaresPython::PythonJobInterface;
|
||||
void emitProgress( double progressValue );
|
||||
|
||||
CalamaresPython::Helper* helper();
|
||||
std::unique_ptr< Private > m_d;
|
||||
QString m_scriptFile;
|
||||
QString m_workingPath;
|
||||
QString m_description;
|
||||
|
@ -171,7 +171,7 @@ PythonJobInterface::PythonJobInterface( Calamares::PythonJob* parent )
|
||||
void
|
||||
PythonJobInterface::setprogress( qreal progress )
|
||||
{
|
||||
if ( progress >= 0 && progress <= 1 )
|
||||
if ( progress >= 0.0 && progress <= 1.0 )
|
||||
{
|
||||
m_parent->emitProgress( progress );
|
||||
}
|
||||
|
@ -44,6 +44,10 @@ static unsigned int s_threshold =
|
||||
#endif
|
||||
static QMutex s_mutex;
|
||||
|
||||
static const char s_Continuation[] = "\n ";
|
||||
static const char s_SubEntry[] = " .. ";
|
||||
|
||||
|
||||
namespace Logger
|
||||
{
|
||||
|
||||
@ -172,22 +176,39 @@ setupLogfile()
|
||||
qInstallMessageHandler( CalamaresLogHandler );
|
||||
}
|
||||
|
||||
CLog::CLog( unsigned int debugLevel )
|
||||
CDebug::CDebug( unsigned int debugLevel, const char* func )
|
||||
: QDebug( &m_msg )
|
||||
, m_debugLevel( debugLevel )
|
||||
, m_funcinfo( func )
|
||||
{
|
||||
if ( debugLevel <= LOGERROR )
|
||||
{
|
||||
m_msg = QStringLiteral( "ERROR:" );
|
||||
}
|
||||
else if ( debugLevel <= LOGWARNING )
|
||||
{
|
||||
m_msg = QStringLiteral( "WARNING:" );
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
CLog::~CLog()
|
||||
CDebug::~CDebug()
|
||||
{
|
||||
if ( m_funcinfo )
|
||||
{
|
||||
m_msg.prepend( s_Continuation ); // Prepending, so back-to-front
|
||||
m_msg.prepend( m_funcinfo );
|
||||
}
|
||||
log( m_msg.toUtf8().data(), m_debugLevel );
|
||||
}
|
||||
|
||||
CDebug::~CDebug() {}
|
||||
constexpr FuncSuppressor::FuncSuppressor( const char s[] )
|
||||
: m_s( s )
|
||||
{
|
||||
}
|
||||
|
||||
const char Continuation[] = "\n ";
|
||||
const char SubEntry[] = " .. ";
|
||||
const constexpr FuncSuppressor Continuation( s_Continuation );
|
||||
const constexpr FuncSuppressor SubEntry( s_SubEntry );
|
||||
|
||||
QString
|
||||
toString( const QVariant& v )
|
||||
|
@ -27,8 +27,14 @@
|
||||
|
||||
namespace Logger
|
||||
{
|
||||
DLLEXPORT extern const char Continuation[];
|
||||
DLLEXPORT extern const char SubEntry[];
|
||||
struct FuncSuppressor
|
||||
{
|
||||
explicit constexpr FuncSuppressor( const char[] );
|
||||
const char* m_s;
|
||||
};
|
||||
|
||||
DLLEXPORT extern const FuncSuppressor Continuation;
|
||||
DLLEXPORT extern const FuncSuppressor SubEntry;
|
||||
|
||||
enum
|
||||
{
|
||||
@ -41,34 +47,32 @@ enum
|
||||
LOGVERBOSE = 8
|
||||
};
|
||||
|
||||
class DLLEXPORT CLog : public QDebug
|
||||
class DLLEXPORT CDebug : public QDebug
|
||||
{
|
||||
public:
|
||||
explicit CLog( unsigned int debugLevel );
|
||||
virtual ~CLog();
|
||||
explicit CDebug( unsigned int debugLevel = LOGDEBUG, const char* func = nullptr );
|
||||
virtual ~CDebug();
|
||||
|
||||
friend QDebug& operator<<( CDebug&&, const FuncSuppressor& );
|
||||
|
||||
private:
|
||||
QString m_msg;
|
||||
unsigned int m_debugLevel;
|
||||
const char* m_funcinfo = nullptr;
|
||||
};
|
||||
|
||||
class DLLEXPORT CDebug : public CLog
|
||||
inline QDebug&
|
||||
operator<<( CDebug&& s, const FuncSuppressor& f )
|
||||
{
|
||||
public:
|
||||
CDebug( unsigned int debugLevel = LOGDEBUG )
|
||||
: CLog( debugLevel )
|
||||
{
|
||||
if ( debugLevel <= LOGERROR )
|
||||
{
|
||||
*this << "ERROR:";
|
||||
}
|
||||
else if ( debugLevel <= LOGWARNING )
|
||||
{
|
||||
*this << "WARNING:";
|
||||
}
|
||||
}
|
||||
virtual ~CDebug();
|
||||
};
|
||||
s.m_funcinfo = nullptr;
|
||||
return s << f.m_s;
|
||||
}
|
||||
|
||||
inline QDebug&
|
||||
operator<<( QDebug& s, const FuncSuppressor& f )
|
||||
{
|
||||
return s << f.m_s;
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief The full path of the log file.
|
||||
@ -219,8 +223,8 @@ operator<<( QDebug& s, const DebugMap& t )
|
||||
}
|
||||
} // namespace Logger
|
||||
|
||||
#define cDebug() (Logger::CDebug( Logger::LOGDEBUG ) << Q_FUNC_INFO << Logger::Continuation)
|
||||
#define cWarning() Logger::CDebug( Logger::LOGWARNING )
|
||||
#define cError() Logger::CDebug( Logger::LOGERROR )
|
||||
#define cDebug() Logger::CDebug( Logger::LOGDEBUG, Q_FUNC_INFO )
|
||||
#define cWarning() Logger::CDebug( Logger::LOGWARNING, Q_FUNC_INFO )
|
||||
#define cError() Logger::CDebug( Logger::LOGERROR, Q_FUNC_INFO )
|
||||
|
||||
#endif
|
||||
|
@ -26,14 +26,8 @@
|
||||
#include "JobQueue.h"
|
||||
|
||||
#include <QDir>
|
||||
// #include <QTemporaryFile>
|
||||
|
||||
#include <QtTest/QtTest>
|
||||
|
||||
// #include <fcntl.h>
|
||||
// #include <sys/stat.h>
|
||||
// #include <unistd.h>
|
||||
|
||||
class TestPaths : public QObject
|
||||
{
|
||||
Q_OBJECT
|
||||
|
@ -25,9 +25,9 @@
|
||||
|
||||
#include "ImageRegistry.h"
|
||||
|
||||
#include <QIcon>
|
||||
#include <QPainter>
|
||||
#include <QSvgRenderer>
|
||||
#include <qicon.h>
|
||||
|
||||
static QHash< QString, QHash< int, QHash< qint64, QPixmap > > > s_cache;
|
||||
|
||||
|
@ -20,7 +20,7 @@
|
||||
#ifndef EXECUTIONVIEWSTEP_H
|
||||
#define EXECUTIONVIEWSTEP_H
|
||||
|
||||
#include <viewpages/ViewStep.h>
|
||||
#include "ViewStep.h"
|
||||
|
||||
#include <QStringList>
|
||||
|
||||
|
@ -23,11 +23,11 @@
|
||||
#include <QObject>
|
||||
#include <QVariantMap>
|
||||
|
||||
#include <CppJob.h>
|
||||
#include "CppJob.h"
|
||||
|
||||
#include <utils/PluginFactory.h>
|
||||
#include "utils/PluginFactory.h"
|
||||
|
||||
#include <DllMacro.h>
|
||||
#include "DllMacro.h"
|
||||
|
||||
class PLUGINDLLEXPORT DracutLuksCfgJob : public Calamares::CppJob
|
||||
{
|
||||
|
@ -23,11 +23,11 @@
|
||||
#include <QObject>
|
||||
#include <QVariantMap>
|
||||
|
||||
#include <CppJob.h>
|
||||
#include "CppJob.h"
|
||||
|
||||
#include <utils/PluginFactory.h>
|
||||
#include "utils/PluginFactory.h"
|
||||
|
||||
#include <DllMacro.h>
|
||||
#include "DllMacro.h"
|
||||
|
||||
class PLUGINDLLEXPORT DummyCppJob : public Calamares::CppJob
|
||||
{
|
||||
|
@ -43,6 +43,10 @@ _ = gettext.translation("calamares-python",
|
||||
def pretty_name():
|
||||
return _("Dummy python job.")
|
||||
|
||||
status = _("Dummy python step {}").format(0)
|
||||
|
||||
def pretty_status_message():
|
||||
return status
|
||||
|
||||
def run():
|
||||
"""Dummy python job."""
|
||||
@ -92,8 +96,10 @@ def run():
|
||||
except KeyError:
|
||||
configlist = ["no list"]
|
||||
|
||||
global status
|
||||
c = 1
|
||||
for k in configlist:
|
||||
status = _("Dummy python step {}").format(str(c) + ":" + repr(k))
|
||||
libcalamares.utils.debug(_("Dummy python step {}").format(str(k)))
|
||||
sleep(1)
|
||||
libcalamares.job.setprogress(c * 1.0 / len(configlist))
|
||||
|
@ -22,13 +22,13 @@
|
||||
#include <QObject>
|
||||
#include <QVariantMap>
|
||||
|
||||
#include <CppJob.h>
|
||||
#include "CppJob.h"
|
||||
|
||||
#include "partition/KPMManager.h"
|
||||
#include "partition/PartitionSize.h"
|
||||
#include "utils/PluginFactory.h"
|
||||
|
||||
#include <DllMacro.h>
|
||||
#include "DllMacro.h"
|
||||
|
||||
class CoreBackend; // From KPMCore
|
||||
class Device; // From KPMCore
|
||||
|
@ -23,9 +23,9 @@
|
||||
#include "utils/CalamaresUtilsGui.h"
|
||||
#include "utils/Logger.h"
|
||||
|
||||
#include <KF5/KService/kservice.h>
|
||||
#include <KF5/KParts/kde_terminal_interface.h>
|
||||
#include <KF5/KParts/kparts/readonlypart.h>
|
||||
#include <KService>
|
||||
#include <KParts/kde_terminal_interface.h>
|
||||
#include <KParts/ReadOnlyPart>
|
||||
|
||||
#include <QApplication>
|
||||
#include <QDir>
|
||||
|
@ -22,10 +22,10 @@
|
||||
|
||||
#include <QObject>
|
||||
|
||||
#include <utils/PluginFactory.h>
|
||||
#include <viewpages/ViewStep.h>
|
||||
#include "utils/PluginFactory.h"
|
||||
#include "viewpages/ViewStep.h"
|
||||
|
||||
#include <DllMacro.h>
|
||||
#include "DllMacro.h"
|
||||
|
||||
class InteractiveTerminalPage;
|
||||
|
||||
|
@ -22,10 +22,10 @@
|
||||
|
||||
#include <QObject>
|
||||
|
||||
#include <utils/PluginFactory.h>
|
||||
#include <viewpages/ViewStep.h>
|
||||
#include "utils/PluginFactory.h"
|
||||
#include "viewpages/ViewStep.h"
|
||||
|
||||
#include <DllMacro.h>
|
||||
#include "DllMacro.h"
|
||||
|
||||
class KeyboardPage;
|
||||
|
||||
|
@ -22,7 +22,7 @@
|
||||
* along with Calamares. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#include <SetKeyboardLayoutJob.h>
|
||||
#include "SetKeyboardLayoutJob.h"
|
||||
|
||||
#include "JobQueue.h"
|
||||
#include "GlobalStorage.h"
|
||||
|
@ -20,7 +20,7 @@
|
||||
#ifndef SETKEYBOARDLAYOUTJOB_H
|
||||
#define SETKEYBOARDLAYOUTJOB_H
|
||||
|
||||
#include <Job.h>
|
||||
#include "Job.h"
|
||||
|
||||
|
||||
class SetKeyboardLayoutJob : public Calamares::Job
|
||||
|
@ -20,9 +20,9 @@
|
||||
#ifndef LICENSEPAGEPLUGIN_H
|
||||
#define LICENSEPAGEPLUGIN_H
|
||||
|
||||
#include <DllMacro.h>
|
||||
#include <utils/PluginFactory.h>
|
||||
#include <viewpages/ViewStep.h>
|
||||
#include "DllMacro.h"
|
||||
#include "utils/PluginFactory.h"
|
||||
#include "viewpages/ViewStep.h"
|
||||
|
||||
#include <QObject>
|
||||
#include <QUrl>
|
||||
|
@ -17,7 +17,7 @@
|
||||
* along with Calamares. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#include <SetTimezoneJob.h>
|
||||
#include "SetTimezoneJob.h"
|
||||
|
||||
#include "GlobalStorage.h"
|
||||
#include "JobQueue.h"
|
||||
|
@ -19,7 +19,7 @@
|
||||
#ifndef SETTIMEZONEJOB_H
|
||||
#define SETTIMEZONEJOB_H
|
||||
|
||||
#include <Job.h>
|
||||
#include "Job.h"
|
||||
|
||||
|
||||
class SetTimezoneJob : public Calamares::Job
|
||||
|
@ -22,11 +22,11 @@
|
||||
#include <QObject>
|
||||
#include <QVariantMap>
|
||||
|
||||
#include <CppJob.h>
|
||||
#include "CppJob.h"
|
||||
|
||||
#include <utils/PluginFactory.h>
|
||||
#include "utils/PluginFactory.h"
|
||||
|
||||
#include <DllMacro.h>
|
||||
#include "DllMacro.h"
|
||||
|
||||
class PLUGINDLLEXPORT MachineIdJob : public Calamares::CppJob
|
||||
{
|
||||
|
@ -19,10 +19,10 @@
|
||||
#ifndef OEMVIEWSTEP_H
|
||||
#define OEMVIEWSTEP_H
|
||||
|
||||
#include <utils/PluginFactory.h>
|
||||
#include <viewpages/ViewStep.h>
|
||||
#include "utils/PluginFactory.h"
|
||||
#include "viewpages/ViewStep.h"
|
||||
|
||||
#include <DllMacro.h>
|
||||
#include "DllMacro.h"
|
||||
|
||||
#include <QVariantMap>
|
||||
|
||||
|
@ -56,6 +56,10 @@ def _change_mode(mode):
|
||||
|
||||
|
||||
def pretty_name():
|
||||
return _("Install packages.")
|
||||
|
||||
|
||||
def pretty_status_message():
|
||||
if not group_packages:
|
||||
if (total_packages > 0):
|
||||
# Outside the context of an operation
|
||||
@ -332,19 +336,23 @@ class PMDummy(PackageManager):
|
||||
backend = "dummy"
|
||||
|
||||
def install(self, pkgs, from_local=False):
|
||||
libcalamares.utils.debug("Installing " + str(pkgs))
|
||||
from time import sleep
|
||||
libcalamares.utils.debug("Dummy backend: Installing " + str(pkgs))
|
||||
sleep(3)
|
||||
|
||||
def remove(self, pkgs):
|
||||
libcalamares.utils.debug("Removing " + str(pkgs))
|
||||
from time import sleep
|
||||
libcalamares.utils.debug("Dummy backend: Removing " + str(pkgs))
|
||||
sleep(3)
|
||||
|
||||
def update_db(self):
|
||||
libcalamares.utils.debug("Updating DB")
|
||||
libcalamares.utils.debug("Dummy backend: Updating DB")
|
||||
|
||||
def update_system(self):
|
||||
libcalamares.utils.debug("Updating System")
|
||||
libcalamares.utils.debug("Dummy backend: Updating System")
|
||||
|
||||
def run(self, script):
|
||||
libcalamares.utils.debug("Running script '" + str(script) + "'")
|
||||
libcalamares.utils.debug("Dummy backend: Running script '" + str(script) + "'")
|
||||
|
||||
|
||||
class PMPisi(PackageManager):
|
||||
@ -502,7 +510,7 @@ def run_operations(pkgman, entry):
|
||||
libcalamares.utils.warning("Unknown package-operation key {!s}".format(key))
|
||||
completed_packages += len(package_list)
|
||||
libcalamares.job.setprogress(completed_packages * 1.0 / total_packages)
|
||||
libcalamares.utils.debug(pretty_name())
|
||||
libcalamares.utils.debug("Pretty name: {!s}, setting progress..".format(pretty_name()))
|
||||
|
||||
group_packages = 0
|
||||
_change_mode(None)
|
||||
|
@ -587,19 +587,19 @@ ChoicePage::doAlongsideSetupSplitter( const QModelIndex& current,
|
||||
void
|
||||
ChoicePage::onEncryptWidgetStateChanged()
|
||||
{
|
||||
EncryptWidget::State state = m_encryptWidget->state();
|
||||
EncryptWidget::Encryption state = m_encryptWidget->state();
|
||||
if ( m_choice == Erase )
|
||||
{
|
||||
if ( state == EncryptWidget::EncryptionConfirmed ||
|
||||
state == EncryptWidget::EncryptionDisabled )
|
||||
if ( state == EncryptWidget::Encryption::Confirmed ||
|
||||
state == EncryptWidget::Encryption::Disabled )
|
||||
applyActionChoice( m_choice );
|
||||
}
|
||||
else if ( m_choice == Replace )
|
||||
{
|
||||
if ( m_beforePartitionBarsView &&
|
||||
m_beforePartitionBarsView->selectionModel()->currentIndex().isValid() &&
|
||||
( state == EncryptWidget::EncryptionConfirmed ||
|
||||
state == EncryptWidget::EncryptionDisabled ) )
|
||||
( state == EncryptWidget::Encryption::Confirmed ||
|
||||
state == EncryptWidget::Encryption::Disabled ) )
|
||||
{
|
||||
doReplaceSelectedPartition( m_beforePartitionBarsView->
|
||||
selectionModel()->
|
||||
@ -1474,7 +1474,7 @@ ChoicePage::updateNextEnabled()
|
||||
|
||||
if ( m_choice != Manual &&
|
||||
m_encryptWidget->isVisible() &&
|
||||
m_encryptWidget->state() == EncryptWidget::EncryptionUnconfirmed )
|
||||
m_encryptWidget->state() == EncryptWidget::Encryption::Unconfirmed )
|
||||
enabled = false;
|
||||
|
||||
if ( enabled == m_nextEnabled )
|
||||
|
@ -204,7 +204,7 @@ CreatePartitionDialog::createPartition()
|
||||
|
||||
Partition* partition = nullptr;
|
||||
QString luksPassphrase = m_ui->encryptWidget->passphrase();
|
||||
if ( m_ui->encryptWidget->state() == EncryptWidget::EncryptionConfirmed &&
|
||||
if ( m_ui->encryptWidget->state() == EncryptWidget::Encryption::Confirmed &&
|
||||
!luksPassphrase.isEmpty() )
|
||||
{
|
||||
partition = KPMHelpers::createNewEncryptedPartition(
|
||||
|
@ -1,6 +1,7 @@
|
||||
/* === This file is part of Calamares - <https://github.com/calamares> ===
|
||||
*
|
||||
* Copyright 2016, Teo Mrnjavac <teo@kde.org>
|
||||
* 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
|
||||
@ -19,42 +20,45 @@
|
||||
|
||||
#include "EncryptWidget.h"
|
||||
|
||||
#include <utils/CalamaresUtilsGui.h>
|
||||
#include "ui_EncryptWidget.h"
|
||||
|
||||
#include "utils/CalamaresUtilsGui.h"
|
||||
#include "utils/Retranslator.h"
|
||||
|
||||
EncryptWidget::EncryptWidget( QWidget* parent )
|
||||
: QWidget( parent )
|
||||
, m_state( EncryptionDisabled )
|
||||
, m_ui( new Ui::EncryptWidget )
|
||||
, m_state( Encryption::Disabled )
|
||||
{
|
||||
setupUi( this );
|
||||
m_ui->setupUi( this );
|
||||
|
||||
m_iconLabel->setFixedWidth( m_iconLabel->height() );
|
||||
m_passphraseLineEdit->hide();
|
||||
m_confirmLineEdit->hide();
|
||||
m_iconLabel->hide();
|
||||
m_ui->m_iconLabel->setFixedWidth( m_ui->m_iconLabel->height() );
|
||||
m_ui->m_passphraseLineEdit->hide();
|
||||
m_ui->m_confirmLineEdit->hide();
|
||||
m_ui->m_iconLabel->hide();
|
||||
|
||||
connect( m_encryptCheckBox, &QCheckBox::stateChanged,
|
||||
this, &EncryptWidget::onCheckBoxStateChanged );
|
||||
connect( m_passphraseLineEdit, &QLineEdit::textEdited,
|
||||
this, &EncryptWidget::onPassphraseEdited );
|
||||
connect( m_confirmLineEdit, &QLineEdit::textEdited,
|
||||
this, &EncryptWidget::onPassphraseEdited );
|
||||
connect( m_ui->m_encryptCheckBox, &QCheckBox::stateChanged, this, &EncryptWidget::onCheckBoxStateChanged );
|
||||
connect( m_ui->m_passphraseLineEdit, &QLineEdit::textEdited, this, &EncryptWidget::onPassphraseEdited );
|
||||
connect( m_ui->m_confirmLineEdit, &QLineEdit::textEdited, this, &EncryptWidget::onPassphraseEdited );
|
||||
|
||||
setFixedHeight( m_passphraseLineEdit->height() ); // Avoid jumping up and down
|
||||
setFixedHeight( m_ui->m_passphraseLineEdit->height() ); // Avoid jumping up and down
|
||||
updateState();
|
||||
|
||||
CALAMARES_RETRANSLATE_SLOT( &EncryptWidget::retranslate )
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
EncryptWidget::reset()
|
||||
{
|
||||
m_passphraseLineEdit->clear();
|
||||
m_confirmLineEdit->clear();
|
||||
m_ui->m_passphraseLineEdit->clear();
|
||||
m_ui->m_confirmLineEdit->clear();
|
||||
|
||||
m_encryptCheckBox->setChecked( false );
|
||||
m_ui->m_encryptCheckBox->setChecked( false );
|
||||
}
|
||||
|
||||
|
||||
EncryptWidget::State
|
||||
EncryptWidget::Encryption
|
||||
EncryptWidget::state() const
|
||||
{
|
||||
return m_state;
|
||||
@ -64,53 +68,48 @@ EncryptWidget::state() const
|
||||
void
|
||||
EncryptWidget::setText( const QString& text )
|
||||
{
|
||||
m_encryptCheckBox->setText( text );
|
||||
m_ui->m_encryptCheckBox->setText( text );
|
||||
}
|
||||
|
||||
|
||||
QString
|
||||
EncryptWidget::passphrase() const
|
||||
{
|
||||
if ( m_state == EncryptionConfirmed )
|
||||
return m_passphraseLineEdit->text();
|
||||
if ( m_state == Encryption::Confirmed )
|
||||
{
|
||||
return m_ui->m_passphraseLineEdit->text();
|
||||
}
|
||||
return QString();
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
EncryptWidget::changeEvent( QEvent* e )
|
||||
EncryptWidget::retranslate()
|
||||
{
|
||||
QWidget::changeEvent( e );
|
||||
switch ( e->type() )
|
||||
{
|
||||
case QEvent::LanguageChange:
|
||||
retranslateUi( this );
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
m_ui->retranslateUi( this );
|
||||
onPassphraseEdited(); // For the tooltip
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
EncryptWidget::updateState()
|
||||
{
|
||||
State newState;
|
||||
if ( m_encryptCheckBox->isChecked() )
|
||||
Encryption newState;
|
||||
if ( m_ui->m_encryptCheckBox->isChecked() )
|
||||
{
|
||||
if ( !m_passphraseLineEdit->text().isEmpty() &&
|
||||
m_passphraseLineEdit->text() == m_confirmLineEdit->text() )
|
||||
if ( !m_ui->m_passphraseLineEdit->text().isEmpty()
|
||||
&& m_ui->m_passphraseLineEdit->text() == m_ui->m_confirmLineEdit->text() )
|
||||
{
|
||||
newState = EncryptionConfirmed;
|
||||
newState = Encryption::Confirmed;
|
||||
}
|
||||
else
|
||||
{
|
||||
newState = EncryptionUnconfirmed;
|
||||
newState = Encryption::Unconfirmed;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
newState = EncryptionDisabled;
|
||||
newState = Encryption::Disabled;
|
||||
}
|
||||
|
||||
if ( newState != m_state )
|
||||
@ -120,35 +119,38 @@ EncryptWidget::updateState()
|
||||
}
|
||||
}
|
||||
|
||||
///@brief Give @p label the @p pixmap from the standard-pixmaps
|
||||
static void
|
||||
applyPixmap( QLabel* label, CalamaresUtils::ImageType pixmap )
|
||||
{
|
||||
label->setFixedWidth( label->height() );
|
||||
label->setPixmap( CalamaresUtils::defaultPixmap( pixmap, CalamaresUtils::Original, label->size() ) );
|
||||
}
|
||||
|
||||
void
|
||||
EncryptWidget::onPassphraseEdited()
|
||||
{
|
||||
if ( !m_iconLabel->isVisible() )
|
||||
m_iconLabel->show();
|
||||
if ( !m_ui->m_iconLabel->isVisible() )
|
||||
{
|
||||
m_ui->m_iconLabel->show();
|
||||
}
|
||||
|
||||
QString p1 = m_passphraseLineEdit->text();
|
||||
QString p2 = m_confirmLineEdit->text();
|
||||
QString p1 = m_ui->m_passphraseLineEdit->text();
|
||||
QString p2 = m_ui->m_confirmLineEdit->text();
|
||||
|
||||
m_iconLabel->setToolTip( QString() );
|
||||
m_ui->m_iconLabel->setToolTip( QString() );
|
||||
if ( p1.isEmpty() && p2.isEmpty() )
|
||||
{
|
||||
m_iconLabel->clear();
|
||||
m_ui->m_iconLabel->clear();
|
||||
}
|
||||
else if ( p1 == p2 )
|
||||
{
|
||||
m_iconLabel->setFixedWidth( m_iconLabel->height() );
|
||||
m_iconLabel->setPixmap( CalamaresUtils::defaultPixmap( CalamaresUtils::Yes,
|
||||
CalamaresUtils::Original,
|
||||
m_iconLabel->size() ) );
|
||||
applyPixmap( m_ui->m_iconLabel, CalamaresUtils::Yes );
|
||||
}
|
||||
else
|
||||
{
|
||||
m_iconLabel->setFixedWidth( m_iconLabel->height() );
|
||||
m_iconLabel->setPixmap( CalamaresUtils::defaultPixmap( CalamaresUtils::No,
|
||||
CalamaresUtils::Original,
|
||||
m_iconLabel->size() ) );
|
||||
m_iconLabel->setToolTip( tr( "Please enter the same passphrase in both boxes." ) );
|
||||
applyPixmap( m_ui->m_iconLabel, CalamaresUtils::No );
|
||||
m_ui->m_iconLabel->setToolTip( tr( "Please enter the same passphrase in both boxes." ) );
|
||||
}
|
||||
|
||||
updateState();
|
||||
@ -156,14 +158,15 @@ EncryptWidget::onPassphraseEdited()
|
||||
|
||||
|
||||
void
|
||||
EncryptWidget::onCheckBoxStateChanged( int state )
|
||||
EncryptWidget::onCheckBoxStateChanged( int checked )
|
||||
{
|
||||
m_passphraseLineEdit->setVisible( state );
|
||||
m_confirmLineEdit->setVisible( state );
|
||||
m_iconLabel->setVisible( state );
|
||||
m_passphraseLineEdit->clear();
|
||||
m_confirmLineEdit->clear();
|
||||
m_iconLabel->clear();
|
||||
// @p checked is a Qt::CheckState, 0 is "unchecked" and 2 is "checked"
|
||||
m_ui->m_passphraseLineEdit->setVisible( checked );
|
||||
m_ui->m_confirmLineEdit->setVisible( checked );
|
||||
m_ui->m_iconLabel->setVisible( checked );
|
||||
m_ui->m_passphraseLineEdit->clear();
|
||||
m_ui->m_confirmLineEdit->clear();
|
||||
m_ui->m_iconLabel->clear();
|
||||
|
||||
updateState();
|
||||
}
|
||||
|
@ -1,6 +1,7 @@
|
||||
/* === This file is part of Calamares - <https://github.com/calamares> ===
|
||||
*
|
||||
* Copyright 2016, Teo Mrnjavac <teo@kde.org>
|
||||
* 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
|
||||
@ -20,41 +21,46 @@
|
||||
#ifndef ENCRYPTWIDGET_H
|
||||
#define ENCRYPTWIDGET_H
|
||||
|
||||
#include "ui_EncryptWidget.h"
|
||||
#include <QWidget>
|
||||
|
||||
class EncryptWidget : public QWidget, private Ui::EncryptWidget
|
||||
namespace Ui
|
||||
{
|
||||
class EncryptWidget;
|
||||
}
|
||||
|
||||
class EncryptWidget : public QWidget
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
enum State : unsigned short
|
||||
enum class Encryption : unsigned short
|
||||
{
|
||||
EncryptionDisabled = 0,
|
||||
EncryptionUnconfirmed,
|
||||
EncryptionConfirmed
|
||||
Disabled = 0,
|
||||
Unconfirmed,
|
||||
Confirmed
|
||||
};
|
||||
|
||||
explicit EncryptWidget( QWidget* parent = nullptr );
|
||||
|
||||
void reset();
|
||||
|
||||
State state() const;
|
||||
Encryption state() const;
|
||||
void setText( const QString& text );
|
||||
|
||||
QString passphrase() const;
|
||||
|
||||
signals:
|
||||
void stateChanged( State );
|
||||
void retranslate();
|
||||
|
||||
protected:
|
||||
void changeEvent( QEvent* e );
|
||||
signals:
|
||||
void stateChanged( Encryption );
|
||||
|
||||
private:
|
||||
void updateState();
|
||||
void onPassphraseEdited();
|
||||
void onCheckBoxStateChanged( int state );
|
||||
void onCheckBoxStateChanged( int checked );
|
||||
|
||||
State m_state;
|
||||
Ui::EncryptWidget* m_ui;
|
||||
Encryption m_state;
|
||||
};
|
||||
|
||||
#endif // ENCRYPTWIDGET_H
|
||||
#endif // ENCRYPTWIDGET_H
|
||||
|
@ -18,16 +18,14 @@
|
||||
*/
|
||||
#include "gui/PartitionBarsView.h"
|
||||
|
||||
#include <core/PartitionModel.h>
|
||||
#include <core/ColorUtils.h>
|
||||
#include "core/PartitionModel.h"
|
||||
#include "core/ColorUtils.h"
|
||||
|
||||
#include "utils/CalamaresUtilsGui.h"
|
||||
#include "utils/Logger.h"
|
||||
|
||||
#include <kpmcore/core/device.h>
|
||||
|
||||
#include <utils/CalamaresUtilsGui.h>
|
||||
#include <utils/Logger.h>
|
||||
|
||||
|
||||
// Qt
|
||||
#include <QDebug>
|
||||
#include <QGuiApplication>
|
||||
#include <QMouseEvent>
|
||||
|
@ -21,10 +21,10 @@
|
||||
#ifndef PARTITIONVIEWSTEP_H
|
||||
#define PARTITIONVIEWSTEP_H
|
||||
|
||||
#include <utils/PluginFactory.h>
|
||||
#include <viewpages/ViewStep.h>
|
||||
#include "utils/PluginFactory.h"
|
||||
#include "viewpages/ViewStep.h"
|
||||
|
||||
#include <DllMacro.h>
|
||||
#include "DllMacro.h"
|
||||
|
||||
#include "core/PartitionActions.h"
|
||||
|
||||
|
@ -69,7 +69,7 @@ CreatePartitionTableJob::prettyStatusMessage() const
|
||||
|
||||
|
||||
static inline QDebug&
|
||||
operator <<( QDebug& s, PartitionIterator& it )
|
||||
operator <<( QDebug&& s, PartitionIterator& it )
|
||||
{
|
||||
s << ( ( *it ) ? ( *it )->deviceNode() : QString( "<null device>" ) );
|
||||
return s;
|
||||
|
@ -18,23 +18,21 @@
|
||||
* along with Calamares. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#include <PartitionJobTests.h>
|
||||
#include "PartitionJobTests.h"
|
||||
|
||||
#include "core/KPMHelpers.h"
|
||||
#include "jobs/CreatePartitionJob.h"
|
||||
#include "jobs/CreatePartitionTableJob.h"
|
||||
#include "jobs/ResizePartitionJob.h"
|
||||
|
||||
#include "partition/KPMManager.h"
|
||||
#include "partition/PartitionQuery.h"
|
||||
#include "utils/Logger.h"
|
||||
#include "utils/Units.h"
|
||||
|
||||
#include <core/KPMHelpers.h>
|
||||
#include <jobs/CreatePartitionJob.h>
|
||||
#include <jobs/CreatePartitionTableJob.h>
|
||||
#include <jobs/ResizePartitionJob.h>
|
||||
|
||||
// CalaPM
|
||||
#include <backend/corebackend.h>
|
||||
#include <fs/filesystemfactory.h>
|
||||
|
||||
// Qt
|
||||
#include <QEventLoop>
|
||||
#include <QProcess>
|
||||
#include <QtTest/QtTest>
|
||||
|
@ -19,7 +19,7 @@
|
||||
#ifndef PARTITIONJOBTESTS_H
|
||||
#define PARTITIONJOBTESTS_H
|
||||
|
||||
#include <JobQueue.h>
|
||||
#include "JobQueue.h"
|
||||
|
||||
// CalaPM
|
||||
#include <core/device.h>
|
||||
|
@ -22,7 +22,7 @@
|
||||
#include <QObject>
|
||||
#include <QVariantMap>
|
||||
|
||||
#include <Job.h>
|
||||
#include "Job.h"
|
||||
|
||||
class PlasmaLnfJob : public Calamares::Job
|
||||
{
|
||||
|
@ -19,9 +19,9 @@
|
||||
#ifndef PLASMALNFVIEWSTEP_H
|
||||
#define PLASMALNFVIEWSTEP_H
|
||||
|
||||
#include <utils/PluginFactory.h>
|
||||
#include <viewpages/ViewStep.h>
|
||||
#include <DllMacro.h>
|
||||
#include "utils/PluginFactory.h"
|
||||
#include "viewpages/ViewStep.h"
|
||||
#include "DllMacro.h"
|
||||
|
||||
#include <QObject>
|
||||
#include <QUrl>
|
||||
|
9
src/modules/removeuser/CMakeLists.txt
Normal file
9
src/modules/removeuser/CMakeLists.txt
Normal file
@ -0,0 +1,9 @@
|
||||
calamares_add_plugin( removeuser
|
||||
TYPE job
|
||||
EXPORT_MACRO PLUGINDLLEXPORT_PRO
|
||||
SOURCES
|
||||
RemoveUserJob.cpp
|
||||
LINK_PRIVATE_LIBRARIES
|
||||
calamares
|
||||
SHARED_LIB
|
||||
)
|
74
src/modules/removeuser/RemoveUserJob.cpp
Normal file
74
src/modules/removeuser/RemoveUserJob.cpp
Normal file
@ -0,0 +1,74 @@
|
||||
/* === This file is part of Calamares - <https://github.com/calamares> ===
|
||||
*
|
||||
* Copyright 2015, Teo Mrnjavac <teo@kde.org>
|
||||
* Copyright 2017. Alf Gaida <agaida@siduction.org>
|
||||
* Copyright 2019-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 "RemoveUserJob.h"
|
||||
|
||||
#include "GlobalStorage.h"
|
||||
#include "JobQueue.h"
|
||||
#include "utils/CalamaresUtilsSystem.h"
|
||||
#include "utils/Logger.h"
|
||||
#include "utils/Variant.h"
|
||||
|
||||
#include <QFile>
|
||||
|
||||
RemoveUserJob::RemoveUserJob( QObject* parent )
|
||||
: Calamares::CppJob( parent )
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
RemoveUserJob::~RemoveUserJob() {}
|
||||
|
||||
|
||||
QString
|
||||
RemoveUserJob::prettyName() const
|
||||
{
|
||||
return tr( "Remove live user from target system" );
|
||||
}
|
||||
|
||||
Calamares::JobResult
|
||||
RemoveUserJob::exec()
|
||||
{
|
||||
if ( m_username.isEmpty() )
|
||||
{
|
||||
cWarning() << "Ignoring an empty username.";
|
||||
return Calamares::JobResult::ok();
|
||||
}
|
||||
|
||||
auto* s = CalamaresUtils::System::instance();
|
||||
auto r = s->targetEnvCommand( { QStringLiteral( "userdel" ),
|
||||
QStringLiteral( "-f" ), // force
|
||||
QStringLiteral( "-r" ), // remove home-dir and mail
|
||||
m_username } );
|
||||
if ( r.getExitCode() != 0 )
|
||||
{
|
||||
cWarning() << "Cannot remove user" << m_username << "userdel terminated with exit code" << r.getExitCode();
|
||||
}
|
||||
return Calamares::JobResult::ok();
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
RemoveUserJob::setConfigurationMap( const QVariantMap& map )
|
||||
{
|
||||
m_username = CalamaresUtils::getString( map, "username" );
|
||||
}
|
||||
|
||||
CALAMARES_PLUGIN_FACTORY_DEFINITION( RemoveUserJobFactory, registerPlugin< RemoveUserJob >(); )
|
49
src/modules/removeuser/RemoveUserJob.h
Normal file
49
src/modules/removeuser/RemoveUserJob.h
Normal file
@ -0,0 +1,49 @@
|
||||
/* === 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/>.
|
||||
*/
|
||||
|
||||
#ifndef REMOVEUSERJOB_H
|
||||
#define REMOVEUSERJOB_H
|
||||
|
||||
#include "CppJob.h"
|
||||
#include "DllMacro.h"
|
||||
#include "utils/PluginFactory.h"
|
||||
|
||||
#include <QObject>
|
||||
#include <QVariantMap>
|
||||
|
||||
class PLUGINDLLEXPORT RemoveUserJob : public Calamares::CppJob
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
explicit RemoveUserJob( QObject* parent = nullptr );
|
||||
virtual ~RemoveUserJob() override;
|
||||
|
||||
QString prettyName() const override;
|
||||
|
||||
Calamares::JobResult exec() override;
|
||||
|
||||
void setConfigurationMap( const QVariantMap& configurationMap ) override;
|
||||
|
||||
private:
|
||||
QString m_username;
|
||||
};
|
||||
|
||||
CALAMARES_PLUGIN_FACTORY_DECLARATION( RemoveUserJobFactory )
|
||||
|
||||
#endif // REMOVEUSERJOB_H
|
@ -1,50 +0,0 @@
|
||||
#!/usr/bin/env python3
|
||||
# -*- coding: utf-8 -*-
|
||||
#
|
||||
# === This file is part of Calamares - <https://github.com/calamares> ===
|
||||
#
|
||||
# Copyright 2015, Teo Mrnjavac <teo@kde.org>
|
||||
# Copyright 2017. Alf Gaida <agaida@siduction.org>
|
||||
# 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/>.
|
||||
|
||||
import subprocess
|
||||
import libcalamares
|
||||
|
||||
import gettext
|
||||
_ = gettext.translation("calamares-python",
|
||||
localedir=libcalamares.utils.gettext_path(),
|
||||
languages=libcalamares.utils.gettext_languages(),
|
||||
fallback=True).gettext
|
||||
|
||||
|
||||
def pretty_name():
|
||||
return _("Remove live user from target system")
|
||||
|
||||
|
||||
def run():
|
||||
"""
|
||||
Remove live user from target system
|
||||
"""
|
||||
username = libcalamares.job.configuration["username"]
|
||||
|
||||
try:
|
||||
libcalamares.utils.check_target_env_call(["userdel", "-f",
|
||||
"-r", username])
|
||||
except subprocess.CalledProcessError as e:
|
||||
libcalamares.utils.debug("Cannot remove user. "
|
||||
"'userdel' terminated with exit code "
|
||||
"{}.".format(e.returncode))
|
||||
return None
|
@ -1,6 +0,0 @@
|
||||
---
|
||||
type: "job"
|
||||
name: "removeuser"
|
||||
interface: "python"
|
||||
requires: []
|
||||
script: "main.py"
|
@ -1,6 +1,10 @@
|
||||
# Removes a single user (with userdel) from the system.
|
||||
# This is typically used in OEM setups or if the live user
|
||||
# spills into the target system.
|
||||
#
|
||||
# The module never fails; if userdel fails, this is logged
|
||||
# but the module still reports success and installation / setup
|
||||
# continues as normal.
|
||||
---
|
||||
# Username in the target system to be removed.
|
||||
username: live
|
||||
|
@ -21,10 +21,10 @@
|
||||
|
||||
#include <QObject>
|
||||
|
||||
#include <utils/PluginFactory.h>
|
||||
#include <viewpages/ViewStep.h>
|
||||
#include "utils/PluginFactory.h"
|
||||
#include "viewpages/ViewStep.h"
|
||||
|
||||
#include <DllMacro.h>
|
||||
#include "DllMacro.h"
|
||||
|
||||
class SummaryPage;
|
||||
|
||||
|
@ -21,9 +21,9 @@
|
||||
|
||||
#include "TrackingType.h"
|
||||
|
||||
#include <DllMacro.h>
|
||||
#include <utils/PluginFactory.h>
|
||||
#include <viewpages/ViewStep.h>
|
||||
#include "DllMacro.h"
|
||||
#include "utils/PluginFactory.h"
|
||||
#include "viewpages/ViewStep.h"
|
||||
|
||||
#include <QObject>
|
||||
#include <QUrl>
|
||||
|
@ -17,7 +17,7 @@
|
||||
* along with Calamares. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#include <CreateUserJob.h>
|
||||
#include "CreateUserJob.h"
|
||||
|
||||
#include "GlobalStorage.h"
|
||||
#include "JobQueue.h"
|
||||
|
@ -19,7 +19,7 @@
|
||||
#ifndef CREATEUSERJOB_H
|
||||
#define CREATEUSERJOB_H
|
||||
|
||||
#include <Job.h>
|
||||
#include "Job.h"
|
||||
|
||||
#include <QStringList>
|
||||
|
||||
|
@ -21,7 +21,7 @@
|
||||
#ifndef SETHOSTNAMEJOB_CPP_H
|
||||
#define SETHOSTNAMEJOB_CPP_H
|
||||
|
||||
#include <Job.h>
|
||||
#include "Job.h"
|
||||
|
||||
class SetHostNameJob : public Calamares::Job
|
||||
{
|
||||
|
@ -17,7 +17,7 @@
|
||||
* along with Calamares. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#include <SetPasswordJob.h>
|
||||
#include "SetPasswordJob.h"
|
||||
|
||||
#include "GlobalStorage.h"
|
||||
#include "JobQueue.h"
|
||||
|
@ -20,7 +20,7 @@
|
||||
#ifndef SETPASSWORDJOB_H
|
||||
#define SETPASSWORDJOB_H
|
||||
|
||||
#include <Job.h>
|
||||
#include "Job.h"
|
||||
|
||||
|
||||
class SetPasswordJob : public Calamares::Job
|
||||
|
@ -23,10 +23,10 @@
|
||||
|
||||
#include "WebViewConfig.h"
|
||||
|
||||
#include <utils/PluginFactory.h>
|
||||
#include <viewpages/ViewStep.h>
|
||||
#include "utils/PluginFactory.h"
|
||||
#include "viewpages/ViewStep.h"
|
||||
|
||||
#include <DllMacro.h>
|
||||
#include "DllMacro.h"
|
||||
|
||||
#include <QVariantMap>
|
||||
|
||||
|
@ -19,14 +19,11 @@
|
||||
#ifndef WELCOMEPAGEPLUGIN_H
|
||||
#define WELCOMEPAGEPLUGIN_H
|
||||
|
||||
#include "DllMacro.h"
|
||||
#include "utils/PluginFactory.h"
|
||||
#include "viewpages/ViewStep.h"
|
||||
|
||||
#include <QObject>
|
||||
|
||||
#include <modulesystem/Requirement.h>
|
||||
#include <utils/PluginFactory.h>
|
||||
#include <viewpages/ViewStep.h>
|
||||
|
||||
#include <DllMacro.h>
|
||||
|
||||
#include <QVariantMap>
|
||||
|
||||
class WelcomePage;
|
||||
|
Loading…
Reference in New Issue
Block a user