1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
|
/* === This file is part of Calamares - <http://github.com/calamares> ===
*
* Copyright 2016, Kevin Kofler <kevin.kofler@chello.at>
*
* 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 PACSTRAPCPPJOB_H
#define PACSTRAPCPPJOB_H
#include <QDir>
#include <QObject>
#include <QTimerEvent>
#include <QVariantMap>
#include <CppJob.h>
#include "GlobalStorage.h"
class PacstrapCppJob : public Calamares::CppJob
{
Q_OBJECT
public:
explicit PacstrapCppJob(QString job_name , QString status_msg ,
qreal job_weight = 1.0 , QObject* parent = nullptr ) ;
virtual ~PacstrapCppJob() ;
void setConfigurationMap(const QVariantMap& config) override ;
qreal getJobWeight () const override ;
QString prettyName () const override ;
QString prettyStatusMessage() const override ;
Calamares::JobResult exec () override ;
static const QString DESKTOP_PACKAGES_KEY ;
protected:
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 ;
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 BASE_PACKAGES_KEY ;
static const QString BOOTLODER_PACKAGES_KEY ;
static const QString KERNEL_PACKAGES_KEY ;
static const QString APPLICATIONS_PACKAGES_KEY ;
static const QString MULTIMEDIA_PACKAGES_KEY ;
static const QString NETWORK_PACKAGES_KEY ;
static const QString THEMES_PACKAGES_KEY ;
static const QString UTILITIES_PACKAGES_KEY ;
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 ;
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 SYSTEM_EXEC_FMT ;
// static const QString KEYRING_CMD ;
static const QString MOUNT_FMT ;
static const QString CHROOT_PREP_FMT ;
static const QString PACKAGES_SYNC_FMT ;
static const QString LIST_PACKAGES_FMT ;
static const QString UMOUNT_FMT ;
static const QString CONFIG_ERROR_MSG ;
static const QString TARGET_ERROR_MSG ;
static const QString CONFFILE_ERROR_MSG ;
// static const QString KEYRING_ERROR_MSG ;
static const QString MOUNT_ERROR_MSG ;
static const QString CHROOT_PREP_ERROR_MSG ;
static const QString PACMAN_SYNC_ERROR_MSG ;
static const QString UMOUNT_ERROR_MSG ;
} ;
/* 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
|