summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorbill-auger <mr.j.spam.me@gmail.com>2017-10-30 12:22:24 -0400
committerbill-auger <mr.j.spam.me@gmail.com>2017-12-01 21:55:38 -0500
commit07f5780ea7d303861256ba163e8f5adc7d95c752 (patch)
treea2eeeffcacf5629586a306b3ee68071ce12cc887
parent2a7c72645064c00cb8fbbc0f5d611ae286fc8f6d (diff)
squashme - progress
-rw-r--r--src/libcalamares/GlobalStorage.cpp11
-rw-r--r--src/libcalamares/GlobalStorage.h15
-rw-r--r--src/libcalamares/JobQueue.cpp18
-rw-r--r--src/libcalamares/PacstrapCppJob.cpp343
-rw-r--r--src/libcalamares/PacstrapCppJob.h114
-rw-r--r--src/modules/pacstrap-base/pacstrap-base.cpp24
-rw-r--r--src/modules/pacstrap-gui/pacstrap-gui.cpp40
-rw-r--r--src/modules/welcome/checker/RequirementsChecker.cpp5
8 files changed, 318 insertions, 252 deletions
diff --git a/src/libcalamares/GlobalStorage.cpp b/src/libcalamares/GlobalStorage.cpp
index 36405ce87..ea09dabcb 100644
--- a/src/libcalamares/GlobalStorage.cpp
+++ b/src/libcalamares/GlobalStorage.cpp
@@ -166,4 +166,15 @@ GlobalStoragePythonWrapper::value( const std::string& key ) const
} // namespace CalamaresPython
+
+const QString GS::HAS_ISOREPO_KEY = "has-isorepo";
+const QString GS::IS_ONLINE_KEY = "hasInternet";
+const QString GS::DESKTOP_PACKAGES_KEY = "default-desktop" ;
+const QString GS::PARTITIONS_KEY = "partitions";
+const QString GS::DEVICE_KEY = "device";
+const QString GS::FS_KEY = "fs";
+const QString GS::MOUNTPOINT_KEY = "mountPoint";
+const QString GS::UUID_KEY = "uuid";
+
+
#endif // WITH_PYTHON
diff --git a/src/libcalamares/GlobalStorage.h b/src/libcalamares/GlobalStorage.h
index 0ff56ac62..7910e6873 100644
--- a/src/libcalamares/GlobalStorage.h
+++ b/src/libcalamares/GlobalStorage.h
@@ -100,4 +100,19 @@ private:
} // namespace CalamaresPython
#endif
+
+class GS
+{
+public:
+ static const QString HAS_ISOREPO_KEY;
+ static const QString IS_ONLINE_KEY;
+ static const QString DESKTOP_PACKAGES_KEY;
+ static const QString PARTITIONS_KEY;
+ static const QString DEVICE_KEY;
+ static const QString FS_KEY;
+ static const QString MOUNTPOINT_KEY;
+ static const QString UUID_KEY;
+} ;
+
+
#endif // CALAMARES_GLOBALSTORAGE_H
diff --git a/src/libcalamares/JobQueue.cpp b/src/libcalamares/JobQueue.cpp
index 06f9e205f..c922c8563 100644
--- a/src/libcalamares/JobQueue.cpp
+++ b/src/libcalamares/JobQueue.cpp
@@ -54,15 +54,11 @@ public:
for( auto job : m_jobs )
{
totalJobsWeight += job->getJobWeight();
-
-printf("JobThread::setJobs() += job->getJobWeight()=%f = totalJobsWeight=%f\n" , job->getJobWeight() , totalJobsWeight) ;
}
for( auto job : m_jobs )
{
qreal jobWeight = qreal( job->getJobWeight() / totalJobsWeight );
m_jobWeights.append( jobWeight ) ;
-
-printf("JobThread::setJobs(%d) << jobWeight=%f\n" , m_jobWeights.count() , jobWeight) ;
}
}
@@ -108,16 +104,18 @@ private:
for( auto jobWeight : m_jobWeights.mid( 0, m_jobIndex ) )
{
cumulativeProgress += jobWeight;
-
-printf("JobThread::emitProgress(%d) += jobWeight=%f => cumulativeProgress=%f\n" , m_jobIndex , jobWeight , cumulativeProgress) ;
}
qreal percent = m_jobIndex < jobCount
- ? cumulativeProgress + (m_jobWeights.at(m_jobIndex) * jobPercent)
+ ? cumulativeProgress + ( ( m_jobWeights.at( m_jobIndex ) ) * jobPercent )
: 1.0;
-// qreal percent = ( m_jobIndex + jobPercent ) / qreal( jobCount );
-
-printf("JobThread::emitProgress(%d) cumulativeProgress=%f jobPercent=%f gui_percent=%f\n" , m_jobIndex , cumulativeProgress , jobPercent , percent) ;
+ if (m_jobIndex < jobCount)
+ {
+ cLog() << "Progress for Job[" << m_jobIndex << "]: " << ( jobPercent * 100 ) << "% completed";
+ cLog() << "Progress Overall: " << ( cumulativeProgress * 100 ) << "% (accumulated) + "
+ << ( ( ( m_jobWeights.at( m_jobIndex ) ) * jobPercent ) * 100 ) << "% (this job) = "
+ << ( percent * 100 ) << "% (total)";
+ }
QMetaObject::invokeMethod( m_queue, "progress", Qt::QueuedConnection,
Q_ARG( qreal, percent ),
Q_ARG( QString, message )
diff --git a/src/libcalamares/PacstrapCppJob.cpp b/src/libcalamares/PacstrapCppJob.cpp
index a24817497..01d1db350 100644
--- a/src/libcalamares/PacstrapCppJob.cpp
+++ b/src/libcalamares/PacstrapCppJob.cpp
@@ -22,67 +22,7 @@
#include "JobQueue.h"
#include <PacstrapCppJob.h>
-
-
-/* PacstrapCppJob public class constants */
-
-const QString PacstrapCppJob::DESKTOP_PACKAGES_KEY = "default-desktop" ;
-
-
-/* PacstrapCppJob protected class constants */
-
-const QString PacstrapCppJob::MOUNTPOINT = "/tmp/pacstrap" ;
-const char* PacstrapCppJob::BASE_JOB_NAME = "Pacstrap Base C++ Job" ;
-const char* PacstrapCppJob::GUI_JOB_NAME = "Pacstrap Desktop C++ Job" ;
-const char* PacstrapCppJob::BASE_STATUS_MSG = "Installing root filesystem" ;
-const char* PacstrapCppJob::GUI_STATUS_MSG = "Installing graphical desktop environment" ;
-const qreal PacstrapCppJob::BASE_JOB_WEIGHT = 23.0 ; // progress-bar job weight (1.0 normal)
-const qreal PacstrapCppJob::GUI_JOB_WEIGHT = 69.0 ; // progress-bar job weight (1.0 normal)
-const QString PacstrapCppJob::BASE_PACKAGES_KEY = "base" ;
-const QString PacstrapCppJob::BOOTLODER_PACKAGES_KEY = "bootloader" ;
-const QString PacstrapCppJob::KERNEL_PACKAGES_KEY = "kernel" ;
-const QString PacstrapCppJob::APPLICATIONS_PACKAGES_KEY = "applications" ;
-const QString PacstrapCppJob::MULTIMEDIA_PACKAGES_KEY = "multimedia" ;
-const QString PacstrapCppJob::NETWORK_PACKAGES_KEY = "network" ;
-const QString PacstrapCppJob::THEMES_PACKAGES_KEY = "themes" ;
-const QString PacstrapCppJob::UTILITIES_PACKAGES_KEY = "utilities" ;
-const QString PacstrapCppJob::XSERVER_PACKAGES_KEY = "x-server" ;
-const QString PacstrapCppJob::MATE_PACKAGES_KEY = "mate" ;
-const QString PacstrapCppJob::LXDE_PACKAGES_KEY = "lxde" ;
-const QString PacstrapCppJob::PACSTRAP_FMT = "pacstrap -c -C %1 %2 %3" ;
-const QString PacstrapCppJob::PACSTRAP_ERROR_MSG = "Failed to install packages in chroot." ;
-
-
-/* PacstrapCppJob private class constants */
-
-const QDir PacstrapCppJob::PACKAGES_CACHE_DIR = QDir(MOUNTPOINT + "/var/cache/pacman/pkg") ;
-const QDir PacstrapCppJob::PACKAGES_METADATA_DIR = QDir(MOUNTPOINT + "/var/lib/pacman/local") ;
-const QString PacstrapCppJob::ONLINE_CONF_FILENAME = "/etc/pacman-online.conf" ;
-const QString PacstrapCppJob::OFFLINE_CONF_FILENAME = "/etc/pacman-offline.conf" ;
-const QString PacstrapCppJob::IS_ONLINE_KEY = "hasInternet" ;
-const QString PacstrapCppJob::PARTITIONS_KEY = "partitions" ;
-const QString PacstrapCppJob::DEVICE_KEY = "device" ;
-const QString PacstrapCppJob::FS_KEY = "fs" ;
-const QString PacstrapCppJob::MOUNTPOINT_KEY = "mountPoint" ;
-const QString PacstrapCppJob::UUID_KEY = "uuid" ;
-const QString PacstrapCppJob::SYSTEM_EXEC_FMT = "/bin/sh -c \"%1\"" ;
-// const QString PacstrapCppJob::KEYRING_CMD = "pacman -Sy --noconfirm parabola-keyring" ;
-// const QString PacstrapCppJob::KEYRING_CMD = "pacman -Sy --noconfirm parabola-keyring && \
-// pacman-key --populate parabola && \
-// pacman-key --refresh-keys " ;
-const QString PacstrapCppJob::MOUNT_FMT = "mkdir %2 2> /dev/null || true && mount %1 %2" ;
-const QString PacstrapCppJob::CHROOT_PREP_FMT = "mkdir -m 0755 -p {%1,%2}" ;
-const QString PacstrapCppJob::PACKAGES_SYNC_FMT = "pacman --print --config %1 --root %2 -Sy" ;
-const QString PacstrapCppJob::LIST_PACKAGES_FMT = "pacman --print --config %1 --root %2 -S %3" ;
-const QString PacstrapCppJob::UMOUNT_FMT = "umount %1" ;
-const QString PacstrapCppJob::CONFIG_ERROR_MSG = "Invalid configuration map." ;
-const QString PacstrapCppJob::TARGET_ERROR_MSG = "Target device for root filesystem is unspecified." ;
-const QString PacstrapCppJob::CONFFILE_ERROR_MSG = "Pacman configuration not found: '%1'." ;
-// const QString PacstrapCppJob::KEYRING_ERROR_MSG = "Failed to update the pacman keyring." ;
-const QString PacstrapCppJob::MOUNT_ERROR_MSG = "Failed to mount the pacstrap chroot." ;
-const QString PacstrapCppJob::CHROOT_PREP_ERROR_MSG = "Failed to prepare the pacstrap chroot." ;
-const QString PacstrapCppJob::PACMAN_SYNC_ERROR_MSG = "Failed to syncronize packages in the pacstrap chroot." ;
-const QString PacstrapCppJob::UMOUNT_ERROR_MSG = "Failed to unmount the pacstrap chroot." ;
+#include "utils/Logger.h"
/* PacstrapCppJob public constructors/destructors */
@@ -92,19 +32,17 @@ PacstrapCppJob::PacstrapCppJob(QString job_name , QString status_msg ,
jobName (job_name ) , statusMsg (status_msg) ,
jobWeight(job_weight) , Calamares::CppJob(parent )
{
-printf("PacstrapCppJob::PacstrapCppJob() '%s'\n" , jobName.toStdString().c_str()) ;
-
- this->globalStorage = Calamares::JobQueue::instance()->globalStorage() ;
- this->guiTimerId = startTimer(1000) ;
-// this->guiTimerId = -1 ; // deferred to exec()
- this->targetDevice = QString("") ; // deferred to exec()->runJob()
- this->confFile = QString("") ; // deferred to exec()->runJob()
- this->packages = QString("") ; // deferred to exec()->runJob()
- this->nPackages = 0 ; // deferred to exec()->runJob()
+ this->globalStorage = Calamares::JobQueue::instance()->globalStorage() ;
+ this->localStorage = QVariantMap() ; // deferred to setConfigurationMap()
+ this->targetDevice = QString("") ; // deferred to exec()
+ this->confFile = QString("") ; // deferred to exec()
+ this->packages = QString("") ; // deferred to exec()
+ this->nPreviousPackages = 0 ; // deferred to exec()
+ this->nPendingPackages = 0 ; // deferred to exec()
+ this->progressPercent = 0 ;
}
-PacstrapCppJob::~PacstrapCppJob() { killTimer(this->guiTimerId) ; }
-// PacstrapCppJob::~PacstrapCppJob() {}
+PacstrapCppJob::~PacstrapCppJob() {}
/* PacstrapCppJob public getters/setters */
@@ -122,41 +60,106 @@ QString PacstrapCppJob::prettyStatusMessage() const { return thi
Calamares::JobResult PacstrapCppJob::exec()
{
-// #include <QTimer>
-// QTimer* guiTimer = new QTimer() ;
-// connect(guiTimer , SIGNAL(timeout()) , this , SLOT(updateProgress())) ;
-// guiTimer->start((std::chrono::milliseconds)1000) ;
+ QVariantList partitions = this->globalStorage->value(GS::PARTITIONS_KEY ).toList() ;
+ bool has_isorepo = this->globalStorage->value(GS::HAS_ISOREPO_KEY).toBool() ;
+ bool has_internet = this->globalStorage->value(GS::IS_ONLINE_KEY ).toBool() ;
+ this->targetDevice = FindTargetDevice(partitions) ;
+ this->confFile = (!has_isorepo) ? DEFAULT_CONF_FILENAME :
+ (has_internet) ? ONLINE_CONF_FILENAME : OFFLINE_CONF_FILENAME ;
+ this->packages = getPackageList() ;
+
+ if (this->localStorage.empty() ) return JobError(CONFIG_ERROR_MSG) ;
+ if (this->targetDevice.isEmpty() ) return JobError(TARGET_ERROR_MSG) ;
+ if (!QFile(this->confFile).exists()) return JobError(CONFFILE_ERROR_MSG.arg(this->confFile)) ;
+
+// QString keyring_cmd = KEYRING_CMD ;
+ QString mount_cmd = MOUNT_FMT .arg(this->targetDevice , MOUNTPOINT) ;
+ QString chroot_prep_cmd = CHROOT_PREP_FMT .arg(PACKAGES_CACHE_DIR .absolutePath() ,
+ PACKAGES_METADATA_DIR.absolutePath() ) ;
+ QString pacman_sync_cmd = PACKAGES_SYNC_FMT.arg(this->confFile , MOUNTPOINT) ;
+ QString list_packages_cmd = LIST_PACKAGES_FMT.arg(this->confFile , MOUNTPOINT , this->packages) ;
+ QString umount_cmd = UMOUNT_FMT .arg(this->targetDevice) ;
-// this->guiTimerId = startTimer(1000) ;
- Calamares::JobResult retval = runJob() ;
+// if (!!execStatus(keyring_cmd )) return JobError(KEYRING_ERROR_MSG) ;
+ if (!!execStatus(mount_cmd )) return JobError(MOUNT_ERROR_MSG ) ;
+ if (!!execStatus(chroot_prep_cmd )) return JobError(CHROOT_PREP_ERROR_MSG) ;
+ if (!!execStatus(pacman_sync_cmd , PACMAN_SYNC_PROPORTION)) return JobError(PACMAN_SYNC_ERROR_MSG) ;
-// killTimer(this->guiTimerId) ;
-// guiTimer->stop() ;
+ if (!this->packages.isEmpty())
+ {
+ QString new_packages = execOutput(list_packages_cmd , LIST_PACKAGES_PROPORTION) ;
+ this->nPreviousPackages = NPackagesInstalled() ;
+// this->nPendingPackages = (has_isorepo) ? new_packages.count(QChar::LineFeed) :
+// new_packages.count(QChar::LineFeed) * 2 ;
+ this->nPendingPackages = new_packages.count(QChar::LineFeed) ;
- return retval ;
+ if (this->nPendingPackages > 0)
+ {
+ QString exec_error_msg = chrootExec() ;
+
+ if (exec_error_msg.isEmpty()) this->nPendingPackages = 0 ;
+ else return JobError(exec_error_msg) ;
+ }
+ }
+
+ if (!execStatus(umount_cmd)) this->progressPercent = emitProgress(1.0) ;
+ else return JobError(UMOUNT_ERROR_MSG) ;
+
+ return JobSuccess() ;
}
-/* PacstrapCppJob protected class methods */
+/* PacstrapCppJob protected instance methods */
-Calamares::JobResult PacstrapCppJob::JobErrorRetval(QString error_msg)
+QStringList PacstrapCppJob::execWithProgress(QString command_line , qreal task_proportion)
{
- return Calamares::JobResult::error(error_msg) ;
+ QProcess proc ;
+ int status ;
+ QString stdout = QString("") ;
+ QString stderr = QString("") ;
+
+ cDebug() << "[PACSTRAP]: executing shell command: " << command_line ;
+ cDebug() << "=================== [SHELL OUTPUT BEGIN] ===================" ;
+ proc.start(QString(SYSTEM_EXEC_FMT).arg(command_line)) ; proc.waitForStarted(-1) ;
+ while (proc.waitForFinished(250) || proc.state() != QProcess::NotRunning)
+ {
+ QString stdout_flush ; stdout += (stdout_flush = proc.readAllStandardOutput()) ;
+ QString stderr_flush ; stderr += (stderr_flush = proc.readAllStandardOutput()) ; ;
+
+ if (!stdout_flush.isEmpty()) printf("%s" , stdout_flush.toStdString().c_str()) ;
+ if (!stderr_flush.isEmpty()) printf("%s" , stderr_flush.toStdString().c_str()) ;
+
+ emitProgress(task_proportion * getTaskCompletion()) ;
+ }
+
+ this->progressPercent = emitProgress(task_proportion) ;
+ cDebug() << "==================== [SHELL OUTPUT END] ====================" ;
+
+ status = (proc.exitStatus() == QProcess::NormalExit) ? proc.exitCode() : 255 ;
+
+DEBUG_TRACE_EXECWITHPROGRESS
+
+ return (QStringList() << QString(status) << stdout << stderr) ;
}
-Calamares::JobResult PacstrapCppJob::JobSuccessRetval()
+int PacstrapCppJob::execStatus(QString command_line , qreal task_proportion)
{
- return Calamares::JobResult::ok() ;
+ return execWithProgress(command_line , task_proportion).at(0).toInt() ;
}
-QString PacstrapCppJob::QListToString(const QVariantList& package_list)
+QString PacstrapCppJob::execOutput(QString command_line , qreal task_proportion)
{
- QStringList result ;
- for (const QVariant& package : package_list) result.append(package.toString()) ;
+ return execWithProgress(command_line , task_proportion).at(1) ;
+}
- return result.join(' ') ;
+QString PacstrapCppJob::execError(QString command_line , qreal task_proportion)
+{
+ return execWithProgress(command_line , task_proportion).at(2) ;
}
+
+/* PacstrapCppJob private class methods */
+
QString PacstrapCppJob::FindTargetDevice(const QVariantList& partitions)
{
QString target_device = QString("") ;
@@ -164,124 +167,118 @@ QString PacstrapCppJob::FindTargetDevice(const QVariantList& partitions)
// locate target device for root filesystem
foreach (const QVariant& partition , partitions)
{
-QStringList result; for ( auto it = partition.toMap().constBegin(); it != partition.toMap().constEnd(); ++it ) result.append( it.key() + '=' + it.value().toString() );
-printf("[PACSTRAPCPP]: partition=[%s]\n" , result.join(',').toStdString().c_str()) ;
-
QVariantMap partition_map = partition.toMap() ;
- QString device = partition_map.value(DEVICE_KEY ).toString() ;
- QString fs = partition_map.value(FS_KEY ).toString() ;
- QString mountpoint = partition_map.value(MOUNTPOINT_KEY).toString() ;
- QString uuid = partition_map.value(UUID_KEY ).toString() ;
+ QString device = partition_map.value(GS::DEVICE_KEY ).toString() ;
+ QString fs = partition_map.value(GS::FS_KEY ).toString() ;
+ QString mountpoint = partition_map.value(GS::MOUNTPOINT_KEY).toString() ;
+ QString uuid = partition_map.value(GS::UUID_KEY ).toString() ;
if (mountpoint == "/") target_device = device ;
-
-if (mountpoint == "/") printf("[PACSTRAPCPP]: target_device=%s\n" , device.toStdString().c_str()) ;
}
- return target_device ;
-}
+DEBUG_TRACE_FINDTARGETDEVICE
-unsigned int PacstrapCppJob::NPackagesInstalled()
-{
- return (PACKAGES_CACHE_DIR .entryList(QDir::Files | QDir::NoDotAndDotDot).count() +
- PACKAGES_METADATA_DIR.entryList(QDir::Dirs | QDir::NoDotAndDotDot).count() ) / 2 ;
+ return target_device ;
}
-QStringList PacstrapCppJob::Exec(QString command_line)
+qint16 PacstrapCppJob::NPackagesInstalled()
{
- QProcess proc ;
-
- proc.start(QString(SYSTEM_EXEC_FMT).arg(command_line)) ; proc.waitForFinished(-1) ;
-
- int status = proc.exitStatus() ;
- QString stdout = proc.readAllStandardOutput() ;
- QString stderr = proc.readAllStandardError() ;
+ int n_packages_downloaded = PACKAGES_CACHE_DIR .entryList(QDir::Files).count() - 2 ;
+ int n_packages_installed = PACKAGES_METADATA_DIR.entryList(QDir::Dirs ).count() - 2 ;
-// printf("[PACSTRAPCPP_DEBUG]: PacstrapCppJob::ExecWithOutput() status=%d\n" , status) ;
-// printf("[PACSTRAPCPP_DEBUG]: PacstrapCppJob::ExecWithOutput() stdout=%s\n" , stdout) ;
-// printf("[PACSTRAPCPP_DEBUG]: PacstrapCppJob::ExecWithOutput() stderr=%s\n" , stderr) ;
-
- return (QStringList() << QString(status) << stdout << stderr) ;
+ return (n_packages_downloaded + n_packages_installed) / 2 ;
}
-int PacstrapCppJob::ExecWithStatus(QString command_line)
+Calamares::JobResult PacstrapCppJob::JobError(QString error_msg)
{
-printf("PacstrapCppJob::ExecWithStatus() command_line=%s\n" , command_line.toStdString().c_str()) ;
-
- return QProcess::execute(QString(SYSTEM_EXEC_FMT).arg(command_line)) ;
+ return Calamares::JobResult::error(error_msg) ;
}
-QString PacstrapCppJob::ExecWithOutput(QString command_line)
+Calamares::JobResult PacstrapCppJob::JobSuccess()
{
- return Exec(command_line).at(1) ;
+ return Calamares::JobResult::ok() ;
}
-QString PacstrapCppJob::ExecWithError(QString command_line)
+
+/* PacstrapCppJob private instance methods */
+
+qreal PacstrapCppJob::emitProgress(qreal transient_percent)
{
- return Exec(command_line).at(2) ;
-}
+ qreal progress_percent = qBound(0.0 , this->progressPercent + transient_percent , 1.0) ;
+DEBUG_TRACE_EMITPROGRESS
-/* PacstrapCppJob protected instance methods */
+ emit progress(progress_percent) ;
-void PacstrapCppJob::timerEvent(QTimerEvent* event)
-{
- if (event->timerId() == this->guiTimerId) updateProgress() ;
+ return progress_percent ;
}
-void PacstrapCppJob::updateProgress()
+qreal PacstrapCppJob::getTaskCompletion()
{
- if (this->nPackages == 0) return ;
+ if (this->nPendingPackages == 0) return 0.0 ;
- qreal progress_percent = qreal(NPackagesInstalled()) / this->nPackages ;
+ qreal n_new_packages = qreal(NPackagesInstalled() - this->nPreviousPackages) ;
+ qreal completion_percent = qreal(n_new_packages / this->nPendingPackages ) ;
-printf("\n[PACSTRAPCPP]: n_packages=%d this->nPackages=%d progress_percent=%f\n" , NPackagesInstalled() , this->nPackages , (float)progress_percent) ;
+DEBUG_TRACE_GETTASKCOMPLETION
- emit progress(progress_percent) ;
+ return completion_percent ;
}
-Calamares::JobResult PacstrapCppJob::runJob()
-{
- QVariantList partitions = this->globalStorage->value(PARTITIONS_KEY).toList() ;
- bool has_internet = this->globalStorage->value(IS_ONLINE_KEY ).toBool() ;
- this->targetDevice = FindTargetDevice(partitions) ;
- this->confFile = (has_internet) ? ONLINE_CONF_FILENAME : OFFLINE_CONF_FILENAME ;
- this->packages = getPackageList() ;
- if (this->localStorage.empty() ) return JobErrorRetval(CONFIG_ERROR_MSG) ;
- if (this->targetDevice.isEmpty() ) return JobErrorRetval(TARGET_ERROR_MSG) ;
- if (!QFile(this->confFile).exists()) return JobErrorRetval(CONFFILE_ERROR_MSG.arg(this->confFile)) ;
+/* PacstrapCppJob public class constants */
-// QString keyring_cmd = KEYRING_CMD ;
- QString mount_cmd = MOUNT_FMT .arg(this->targetDevice , MOUNTPOINT) ;
- QString chroot_prep_cmd = CHROOT_PREP_FMT .arg(PACKAGES_CACHE_DIR .absolutePath() ,
- PACKAGES_METADATA_DIR.absolutePath() ) ;
- QString pacman_sync_cmd = PACKAGES_SYNC_FMT.arg(this->confFile , MOUNTPOINT) ;
- QString list_packages_cmd = LIST_PACKAGES_FMT.arg(this->confFile , MOUNTPOINT , this->packages) ;
- QString umount_cmd = UMOUNT_FMT .arg(this->targetDevice) ;
+const QString PacstrapCppJob::BASE_PACKAGES_KEY = "base" ;
+const QString PacstrapCppJob::BOOTLODER_PACKAGES_KEY = "bootloader" ;
+const QString PacstrapCppJob::KERNEL_PACKAGES_KEY = "kernel" ;
+const QString PacstrapCppJob::APPLICATIONS_PACKAGES_KEY = "applications" ;
+const QString PacstrapCppJob::MULTIMEDIA_PACKAGES_KEY = "multimedia" ;
+const QString PacstrapCppJob::NETWORK_PACKAGES_KEY = "network" ;
+const QString PacstrapCppJob::THEMES_PACKAGES_KEY = "themes" ;
+const QString PacstrapCppJob::UTILITIES_PACKAGES_KEY = "utilities" ;
+const QString PacstrapCppJob::XSERVER_PACKAGES_KEY = "x-server" ;
+const QString PacstrapCppJob::MATE_PACKAGES_KEY = "mate" ;
+const QString PacstrapCppJob::LXDE_PACKAGES_KEY = "lxde" ;
-// if (!!ExecWithStatus(keyring_cmd )) return JobErrorRetval(KEYRING_ERROR_MSG) ;
-// "mkdir %2 2> /dev/null" "mount %1 %2"
- if (!!ExecWithStatus(mount_cmd )) return JobErrorRetval(MOUNT_ERROR_MSG ) ;
- if (!!ExecWithStatus(chroot_prep_cmd)) return JobErrorRetval(CHROOT_PREP_ERROR_MSG) ;
- if (!!ExecWithStatus(pacman_sync_cmd)) return JobErrorRetval(PACMAN_SYNC_ERROR_MSG) ;
- if (!this->packages.isEmpty())
- {
- QString new_packages = ExecWithOutput(list_packages_cmd) ;
- this->nPackages = NPackagesInstalled() + new_packages.count(QChar::LineFeed) ;
+/* PacstrapCppJob protected class constants */
- if (this->nPackages > 0)
- {
-// return Calamares::JobResult::error("just cause") ;
+const QString PacstrapCppJob::MOUNTPOINT = "/tmp/pacstrap" ;
+const char* PacstrapCppJob::BASE_JOB_NAME = "Pacstrap Base C++ Job" ;
+const char* PacstrapCppJob::GUI_JOB_NAME = "Pacstrap Desktop C++ Job" ;
+const char* PacstrapCppJob::BASE_STATUS_MSG = "Installing root filesystem" ;
+const char* PacstrapCppJob::GUI_STATUS_MSG = "Installing graphical desktop environment" ;
+const qreal PacstrapCppJob::BASE_JOB_WEIGHT = 20.0 ; // progress-bar job weight (1.0 normal)
+const qreal PacstrapCppJob::GUI_JOB_WEIGHT = 57.0 ; // progress-bar job weight (1.0 normal)
+const qreal PacstrapCppJob::PACMAN_SYNC_PROPORTION = 0.05 ; // per task progress-bar proportion
+const qreal PacstrapCppJob::LIST_PACKAGES_PROPORTION = 0.05 ; // per task progress-bar proportion
+const qreal PacstrapCppJob::CHROOT_TASK_PROPORTION = 0.9 ; // per task progress-bar proportion
+const QString PacstrapCppJob::PACSTRAP_FMT = "pacstrap -C %1 %2 %3" ;
+const QString PacstrapCppJob::PACSTRAP_ERROR_MSG = "Failed to install packages in chroot." ;
- QString exec_error_msg = chrootExec() ;
- if (!exec_error_msg.isEmpty()) return JobErrorRetval(exec_error_msg) ;
- }
- }
- else emit progress(this->jobWeight) ;
- if (!!ExecWithStatus(umount_cmd)) return JobErrorRetval(UMOUNT_ERROR_MSG) ;
+/* PacstrapCppJob private class constants */
- return JobSuccessRetval() ;
-}
+const QDir PacstrapCppJob::PACKAGES_CACHE_DIR = QDir(MOUNTPOINT + "/var/cache/pacman/pkg") ;
+const QDir PacstrapCppJob::PACKAGES_METADATA_DIR = QDir(MOUNTPOINT + "/var/lib/pacman/local") ;
+const QString PacstrapCppJob::DEFAULT_CONF_FILENAME = "/etc/pacman.conf" ;
+const QString PacstrapCppJob::ONLINE_CONF_FILENAME = "/etc/pacman-online.conf" ;
+const QString PacstrapCppJob::OFFLINE_CONF_FILENAME = "/etc/pacman-offline.conf" ;
+const QString PacstrapCppJob::SYSTEM_EXEC_FMT = "/bin/sh -c \"%1\"" ;
+// const QString PacstrapCppJob::KEYRING_CMD = "pacman -Sy --noconfirm parabola-keyring" ;
+// const QString PacstrapCppJob::KEYRING_CMD = "pacman -Sy --noconfirm parabola-keyring && \
+// pacman-key --populate parabola && \
+// pacman-key --refresh-keys " ;
+const QString PacstrapCppJob::MOUNT_FMT = "mkdir %2 2> /dev/null || true && mount %1 %2" ;
+const QString PacstrapCppJob::CHROOT_PREP_FMT = "mkdir -m 0755 -p {%1,%2}" ;
+const QString PacstrapCppJob::PACKAGES_SYNC_FMT = "pacman --print --config %1 --root %2 -Sy" ;
+const QString PacstrapCppJob::LIST_PACKAGES_FMT = "pacman --print --config %1 --root %2 -S %3" ;
+const QString PacstrapCppJob::UMOUNT_FMT = "umount %1" ;
+const QString PacstrapCppJob::CONFIG_ERROR_MSG = "Invalid configuration map." ;
+const QString PacstrapCppJob::TARGET_ERROR_MSG = "Target device for root filesystem is unspecified." ;
+const QString PacstrapCppJob::CONFFILE_ERROR_MSG = "Pacman configuration not found: '%1'." ;
+// const QString PacstrapCppJob::KEYRING_ERROR_MSG = "Failed to update the pacman keyring." ;
+const QString PacstrapCppJob::MOUNT_ERROR_MSG = "Failed to mount the pacstrap chroot." ;
+const QString PacstrapCppJob::CHROOT_PREP_ERROR_MSG = "Failed to prepare the pacstrap chroot." ;
+const QString PacstrapCppJob::PACMAN_SYNC_ERROR_MSG = "Failed to syncronize packages in the pacstrap chroot." ;
+const QString PacstrapCppJob::UMOUNT_ERROR_MSG = "Failed to unmount the pacstrap chroot." ;
diff --git a/src/libcalamares/PacstrapCppJob.h b/src/libcalamares/PacstrapCppJob.h
index f3017062a..4a05a32e8 100644
--- a/src/libcalamares/PacstrapCppJob.h
+++ b/src/libcalamares/PacstrapCppJob.h
@@ -50,30 +50,42 @@ public:
protected:
- static Calamares::JobResult JobErrorRetval (QString error_msg) ;
- static Calamares::JobResult JobSuccessRetval () ;
- static QString QListToString (const QVariantList& package_list) ;
- static QString FindTargetDevice (const QVariantList& partitions) ;
- static unsigned int NPackagesInstalled() ;
- static QStringList Exec (QString command_line) ;
- static int ExecWithStatus (QString command_line) ;
- static QString ExecWithOutput (QString command_line) ;
- static QString ExecWithError (QString command_line) ;
+ QStringList execWithProgress(QString command_line , qreal task_proportion = 0.0) ;
+ int execStatus (QString command_line , qreal task_proportion = 0.0) ;
+ QString execOutput (QString command_line , qreal task_proportion = 0.0) ;
+ QString execError (QString command_line , qreal task_proportion = 0.0) ;
virtual QString getPackageList() = 0 ;
virtual QString chrootExec () = 0 ;
- void timerEvent (QTimerEvent* event) override ;
- void updateProgress() ;
- Calamares::JobResult runJob () ;
+ QString jobName ;
+ QString statusMsg ;
+ qreal jobWeight ;
+ Calamares::GlobalStorage* globalStorage ;
+ QVariantMap localStorage ;
+ QString targetDevice ;
+ QString confFile ;
+ QString packages ;
+ qint16 nPreviousPackages ;
+ qint16 nPendingPackages ;
+ qreal progressPercent ;
+
+
+private:
+
+ static QString FindTargetDevice (const QVariantList& partitions) ;
+ static qint16 NPackagesInstalled() ;
+ static inline Calamares::JobResult JobError (QString error_msg) ;
+ static inline Calamares::JobResult JobSuccess () ;
+
+ qreal emitProgress (qreal transient_percent) ;
+ qreal getTaskCompletion() ;
+
+
+ /* constants */
+
+public:
- static const QString MOUNTPOINT ;
- static const char* BASE_JOB_NAME ;
- static const char* GUI_JOB_NAME ;
- static const char* BASE_STATUS_MSG ;
- static const char* GUI_STATUS_MSG ;
- static const qreal BASE_JOB_WEIGHT ;
- static const qreal GUI_JOB_WEIGHT ;
static const QString BASE_PACKAGES_KEY ;
static const QString BOOTLODER_PACKAGES_KEY ;
static const QString KERNEL_PACKAGES_KEY ;
@@ -85,33 +97,31 @@ protected:
static const QString XSERVER_PACKAGES_KEY ;
static const QString MATE_PACKAGES_KEY ;
static const QString LXDE_PACKAGES_KEY ;
+
+
+protected:
+
+ static const QString MOUNTPOINT ;
+ static const char* BASE_JOB_NAME ;
+ static const char* GUI_JOB_NAME ;
+ static const char* BASE_STATUS_MSG ;
+ static const char* GUI_STATUS_MSG ;
+ static const qreal BASE_JOB_WEIGHT ;
+ static const qreal GUI_JOB_WEIGHT ;
+ static const qreal PACMAN_SYNC_PROPORTION ;
+ static const qreal LIST_PACKAGES_PROPORTION ;
+ static const qreal CHROOT_TASK_PROPORTION ;
static const QString PACSTRAP_FMT ;
static const QString PACSTRAP_ERROR_MSG ;
- QString jobName ;
- QString statusMsg ;
- qreal jobWeight ;
- Calamares::GlobalStorage* globalStorage ;
- unsigned int guiTimerId ;
- QString targetDevice ;
- QString confFile ;
- QString packages ;
- unsigned int nPackages ;
- QVariantMap localStorage ;
-
private:
static const QDir PACKAGES_CACHE_DIR ;
static const QDir PACKAGES_METADATA_DIR ;
+ static const QString DEFAULT_CONF_FILENAME ;
static const QString ONLINE_CONF_FILENAME ;
static const QString OFFLINE_CONF_FILENAME ;
- static const QString IS_ONLINE_KEY ;
- static const QString PARTITIONS_KEY ;
- static const QString DEVICE_KEY ;
- static const QString FS_KEY ;
- static const QString MOUNTPOINT_KEY ;
- static const QString UUID_KEY ;
static const QString SYSTEM_EXEC_FMT ;
// static const QString KEYRING_CMD ;
static const QString MOUNT_FMT ;
@@ -130,4 +140,36 @@ private:
} ;
+/* debug */
+
+
+#define DEBUG_TRACE_EXECWITHPROGRESS \
+ cDebug(LOGVERBOSE) << "[PACSTRAP]: status=" , status ; \
+ cDebug(LOGVERBOSE) << "[PACSTRAP]: stdout=" , stdout ; \
+ cDebug(LOGVERBOSE) << "[PACSTRAP]: stderr=" , stderr ;
+
+#define DEBUG_TRACE_FINDTARGETDEVICE if (!target_device.isEmpty()) \
+ cDebug() << "[PACSTRAP]: mounting target_device: " << target_device ;
+
+#define DEBUG_TRACE_EMITPROGRESS cDebug() << "[PACSTRAP]: " << \
+ "this->progressPercent=" << this->progressPercent << \
+ " transient_percent=" << transient_percent << \
+ " emmitting=" << progress_percent ;
+
+#define DEBUG_TRACE_GETTASKCOMPLETION cDebug() << "[PACSTRAP]: " << \
+ "this->nPreviousPackages=" << this->nPreviousPackages << \
+ " NPackagesInstalled()=" << NPackagesInstalled() << \
+ "\nn_new_packages=" << (int)n_new_packages << \
+ " this->nPendingPackages=" << this->nPendingPackages << \
+ " completion_percent=" << completion_percent ;
+
+#ifndef QT_NO_DEBUG
+# define DEBUG_TRACE_DESKTOPPACKAGES \
+ printf("[PACSTRAP-GUI]: installing default_desktop: %s\n" , \
+ globalStorage->value(GS::DESKTOP_PACKAGES_KEY).toString().toStdString().c_str()) ;
+#else // QT_NO_DEBUG
+# define DEBUG_TRACE_DESKTOPPACKAGES ;
+#endif // QT_NO_DEBUG
+
+
#endif // PACSTRAPCPPJOB_H
diff --git a/src/modules/pacstrap-base/pacstrap-base.cpp b/src/modules/pacstrap-base/pacstrap-base.cpp
index 138400160..9641a1a08 100644
--- a/src/modules/pacstrap-base/pacstrap-base.cpp
+++ b/src/modules/pacstrap-base/pacstrap-base.cpp
@@ -22,12 +22,6 @@
#include "pacstrap-base.h"
-/* PacstrapBaseJob private class constants */
-
-const QString PacstrapBaseJob::GRUB_THEME_FMT = "sed -i 's|[#]GRUB_THEME=.*|GRUB_THEME=/boot/grub/themes/GNUAxiom/theme.txt|' %1/etc/default/grub" ;
-const QString PacstrapBaseJob::GRUB_THEME_ERROR_MSG = "The grub theme installation command has failed." ;
-
-
/* PacstrapBaseJob public instance methods */
PacstrapBaseJob::PacstrapBaseJob(QObject* parent) : PacstrapCppJob(tr(BASE_JOB_NAME) ,
@@ -40,9 +34,9 @@ PacstrapBaseJob::PacstrapBaseJob(QObject* parent) : PacstrapCppJob(tr(BASE_JOB_N
QString PacstrapBaseJob::getPackageList()
{
- return QListToString(this->localStorage.value(BASE_PACKAGES_KEY ).toList() +
- this->localStorage.value(BOOTLODER_PACKAGES_KEY).toList() +
- this->localStorage.value(KERNEL_PACKAGES_KEY ).toList() ) ;
+ return (this->localStorage.value(BASE_PACKAGES_KEY ).toStringList() +
+ this->localStorage.value(BOOTLODER_PACKAGES_KEY).toStringList() +
+ this->localStorage.value(KERNEL_PACKAGES_KEY ).toStringList() ).join(' ') ;
}
@@ -53,20 +47,26 @@ QString PacstrapBaseJob::chrootExec()
QString pacstrap_cmd = PACSTRAP_FMT .arg(this->confFile , MOUNTPOINT , packages) ;
QString grub_theme_cmd = GRUB_THEME_FMT.arg(MOUNTPOINT) ;
- if (!!ExecWithStatus(pacstrap_cmd)) return PACSTRAP_ERROR_MSG ;
+ if (!!execStatus(pacstrap_cmd , CHROOT_TASK_PROPORTION)) return PACSTRAP_ERROR_MSG ;
QString grub_theme_kludge_cmd = QString("echo GRUB_THEME=/boot/grub/themes/GNUAxiom/theme.txt >> %1/etc/default/grub").
arg(MOUNTPOINT) ;
printf("[PACSTRAP-BASE]: grub_theme_cmd=%s\n" , grub_theme_cmd.toStdString().c_str()) ;
printf("[PACSTRAP-BASE]: grub_theme_cmd IN:\n"); QProcess::execute(QString("/bin/sh -c \"cat %1/etc/default/grub\"").arg(MOUNTPOINT));
- if (!!ExecWithStatus(grub_theme_cmd)) return GRUB_THEME_ERROR_MSG ;
+ if (!!execStatus(grub_theme_cmd)) return GRUB_THEME_ERROR_MSG ;
-if (!!ExecWithStatus(grub_theme_kludge_cmd)) return "grub_theme_kludge_cmd failed" ;
+if (!!execStatus(grub_theme_kludge_cmd)) return "grub_theme_kludge_cmd failed" ;
printf("[PACSTRAP-BASE]: grub_theme_cmd OUT:\n"); QProcess::execute(QString("/bin/sh -c \"cat %1/etc/default/grub\"").arg(MOUNTPOINT));
return QString("") ;
}
+/* PacstrapBaseJob private class constants */
+
+const QString PacstrapBaseJob::GRUB_THEME_FMT = "sed -i 's|[#]GRUB_THEME=.*|GRUB_THEME=/boot/grub/themes/GNUAxiom/theme.txt|' %1/etc/default/grub" ;
+const QString PacstrapBaseJob::GRUB_THEME_ERROR_MSG = "The grub theme installation command has failed." ;
+
+
CALAMARES_PLUGIN_FACTORY_DEFINITION(PacstrapBaseJobFactory , registerPlugin<PacstrapBaseJob>() ;)
diff --git a/src/modules/pacstrap-gui/pacstrap-gui.cpp b/src/modules/pacstrap-gui/pacstrap-gui.cpp
index b405bb9b1..233e5896d 100644
--- a/src/modules/pacstrap-gui/pacstrap-gui.cpp
+++ b/src/modules/pacstrap-gui/pacstrap-gui.cpp
@@ -22,12 +22,6 @@
#include "pacstrap-gui.h"
-/* PacstrapGuiJob private class constants */
-
-const QString PacstrapGuiJob::WALLPAPER_FMT = "cp /etc/wallpaper.png %1/etc/" ;
-const QString PacstrapGuiJob::WALLPAPER_ERROR_MSG = "The wallpaper installation command has failed." ;
-
-
/* PacstrapGuiJob public instance methods */
PacstrapGuiJob::PacstrapGuiJob(QObject* parent) : PacstrapCppJob(tr(GUI_JOB_NAME) ,
@@ -40,18 +34,18 @@ PacstrapGuiJob::PacstrapGuiJob(QObject* parent) : PacstrapCppJob(tr(GUI_JOB_NAME
QString PacstrapGuiJob::getPackageList()
{
-globalStorage->insert(DESKTOP_PACKAGES_KEY , MATE_PACKAGES_KEY) ; // TODO: per user option via globalStorage
-printf("[PACSTRAP-GUI]: DesktopCppJob::getPackageList() default_desktop=%s" , globalStorage->value(DESKTOP_PACKAGES_KEY).toString().toStdString().c_str()) ;
-
- QString desktop = this->globalStorage->value(DESKTOP_PACKAGES_KEY).toString() ;
-
- return QListToString(this->localStorage.value(APPLICATIONS_PACKAGES_KEY).toList() +
- this->localStorage.value(MULTIMEDIA_PACKAGES_KEY ).toList() +
- this->localStorage.value(NETWORK_PACKAGES_KEY ).toList() +
- this->localStorage.value(THEMES_PACKAGES_KEY ).toList() +
- this->localStorage.value(UTILITIES_PACKAGES_KEY ).toList() +
- this->localStorage.value(XSERVER_PACKAGES_KEY ).toList() +
- this->localStorage.value(desktop ).toList() ) ;
+globalStorage->insert(GS::DESKTOP_PACKAGES_KEY , MATE_PACKAGES_KEY) ; // TODO: per user option via globalStorage
+DEBUG_TRACE_DESKTOPPACKAGES
+
+ QString desktop = this->globalStorage->value(GS::DESKTOP_PACKAGES_KEY).toString() ;
+
+ return (this->localStorage.value(APPLICATIONS_PACKAGES_KEY).toStringList() +
+ this->localStorage.value(MULTIMEDIA_PACKAGES_KEY ).toStringList() +
+ this->localStorage.value(NETWORK_PACKAGES_KEY ).toStringList() +
+ this->localStorage.value(THEMES_PACKAGES_KEY ).toStringList() +
+ this->localStorage.value(UTILITIES_PACKAGES_KEY ).toStringList() +
+ this->localStorage.value(XSERVER_PACKAGES_KEY ).toStringList() +
+ this->localStorage.value(desktop ).toStringList() ).join(' ') ;
}
@@ -62,14 +56,14 @@ QString PacstrapGuiJob::chrootExec()
QString pacstrap_cmd = PACSTRAP_FMT .arg(this->confFile , MOUNTPOINT , packages) ;
QString wallpaper_cmd = WALLPAPER_FMT.arg(MOUNTPOINT) ;
- if (!!ExecWithStatus(pacstrap_cmd)) return PACSTRAP_ERROR_MSG ;
+ if (!!execStatus(pacstrap_cmd , CHROOT_TASK_PROPORTION)) return PACSTRAP_ERROR_MSG ;
printf("[PACSTRAP-GUI]: ls /etc/skel") ; QProcess::execute(QString("/bin/sh -c \"ls -al /etc/skel/\"" ) ) ;
printf("[PACSTRAP-GUI]: ls chroot/etc/skel/") ; QProcess::execute(QString("/bin/sh -c \"ls -al %1/etc/skel/\"" ).arg(MOUNTPOINT)) ;
printf("[PACSTRAP-GUI]: ls chroot/etc/wallpaper.png") ; QProcess::execute(QString("/bin/sh -c \"ls -al %1/etc/wallpaper.png\"").arg(MOUNTPOINT)) ;
printf("[PACSTRAP-GUI]: ls chroot/etc/sudoers*") ; QProcess::execute(QString("/bin/sh -c \"ls -al %1/etc/sudoers*\"" ).arg(MOUNTPOINT)) ;
- if (!!ExecWithStatus(wallpaper_cmd)) return WALLPAPER_ERROR_MSG ;
+ if (!!execStatus(wallpaper_cmd)) return WALLPAPER_ERROR_MSG ;
printf("[PACSTRAP-GUI]: ls chroot/etc/wallpaper.png") ; QProcess::execute(QString("/bin/sh -c \"ls -al %1/etc/wallpaper.png\"").arg(MOUNTPOINT)) ;
@@ -77,4 +71,10 @@ printf("[PACSTRAP-GUI]: ls chroot/etc/wallpaper.png") ; QProcess::execute(QStrin
}
+/* PacstrapGuiJob private class constants */
+
+const QString PacstrapGuiJob::WALLPAPER_FMT = "cp /etc/wallpaper.png %1/etc/" ;
+const QString PacstrapGuiJob::WALLPAPER_ERROR_MSG = "The wallpaper installation command has failed." ;
+
+
CALAMARES_PLUGIN_FACTORY_DEFINITION(PacstrapGuiJobFactory , registerPlugin<PacstrapGuiJob>() ;)
diff --git a/src/modules/welcome/checker/RequirementsChecker.cpp b/src/modules/welcome/checker/RequirementsChecker.cpp
index 2339b060b..acd588711 100644
--- a/src/modules/welcome/checker/RequirementsChecker.cpp
+++ b/src/modules/welcome/checker/RequirementsChecker.cpp
@@ -296,7 +296,10 @@ RequirementsChecker::setConfigurationMap( const QVariantMap& configurationMap )
<< configurationMap;
}
- if (QDir("/isorepo").exists("isorepo.db.tar.gz"))
+ Calamares::GlobalStorage* globalStorage = Calamares::JobQueue::instance()->globalStorage();
+ bool has_isorepo = QDir("/isorepo").exists("isorepo.db.tar.gz");
+ globalStorage->insert( GS::HAS_ISOREPO_KEY, has_isorepo );
+ if ( has_isorepo )
{
m_entriesToCheck.removeAll("internet") ;
m_entriesToRequire.removeAll("internet") ;