Changeset View
Changeset View
Standalone View
Standalone View
src/helper.cpp
Show First 20 Lines • Show All 59 Lines • ▼ Show 20 Line(s) | 58 | if (QFile::exists("/usr/sbin/update-alternatives")) { | |||
---|---|---|---|---|---|
60 | QDir dir(QStringLiteral(PLYMOUTH_THEMES_DIR) + theme); | 60 | QDir dir(QStringLiteral(PLYMOUTH_THEMES_DIR) + theme); | ||
61 | QStringList themeFile = dir.entryList(QStringList() << "*.plymouth"); | 61 | QStringList themeFile = dir.entryList(QStringList() << "*.plymouth"); | ||
62 | if (themeFile.count() != 1) { | 62 | if (themeFile.count() != 1) { | ||
63 | reply = ActionReply::BackendError; | 63 | reply = ActionReply::BackendError; | ||
64 | reply.setErrorDescription(i18n("Theme corrupted: .plymouth file not found inside theme.")); | 64 | reply.setErrorDescription(i18n("Theme corrupted: .plymouth file not found inside theme.")); | ||
65 | return reply; | 65 | return reply; | ||
66 | } | 66 | } | ||
67 | int ret = 0; | 67 | int ret = 0; | ||
68 | QProcess checkProcess; | ||||
69 | QByteArray data; | ||||
70 | qDebug() << "Running update-alternatives --list default.plymouth now"; | ||||
fvogt: Should be `update-alternatives` here. | |||||
71 | checkProcess.start("update-alternatives --list default.plymouth"); | ||||
72 | if (!checkProcess.waitForStarted()) { | ||||
73 | reply = ActionReply::BackendError; | ||||
74 | reply.setErrorDescription(i18n("Cannot start update-alternatives.")); | ||||
75 | return reply; | ||||
76 | } | ||||
77 | if (!checkProcess.waitForFinished()) { | ||||
78 | reply = ActionReply::BackendError; | ||||
79 | reply.setErrorDescription(i18n("update-alternatives failed to run.")); | ||||
80 | return reply; | ||||
81 | } | ||||
82 | else { | ||||
83 | data = checkProcess.readAllStandardOutput(); | ||||
84 | } | ||||
85 | ret = checkProcess.exitCode(); | ||||
86 | | ||||
87 | if (ret != 0) { | ||||
88 | reply = ActionReply(ActionReply::HelperErrorReply()); | ||||
89 | reply.setErrorCode(static_cast<ActionReply::Error>(ret)); | ||||
90 | reply.setErrorDescription(i18n("update-alternatives returned with error condition %1.", ret)); | ||||
91 | return reply; | ||||
92 | } | ||||
93 | QString installFile = dir.path() + QChar('/') + themeFile.first(); | ||||
94 | if (!data.contains(installFile.toUtf8())) { | ||||
95 | qDebug() << "Plymouth file not found in update-alternatives. So install it"; | ||||
96 | QProcess installProcess; | ||||
97 | installProcess.start("update-alternatives", QStringList() << "--install" << "/usr/share/plymouth/themes/default.plymouth" << "default.plymouth" << installFile << "100"); | ||||
98 | | ||||
99 | if (!installProcess.waitForStarted()) { | ||||
100 | reply = ActionReply::BackendError; | ||||
101 | reply.setErrorDescription(i18n("Cannot start update-alternatives.")); | ||||
102 | return reply; | ||||
103 | } | ||||
104 | if (!installProcess.waitForFinished()) { | ||||
105 | reply = ActionReply::BackendError; | ||||
106 | reply.setErrorDescription(i18n("update-alternatives failed to run.")); | ||||
107 | return reply; | ||||
108 | } | ||||
109 | ret = installProcess.exitCode(); | ||||
110 | | ||||
111 | if (ret != 0) { | ||||
112 | reply = ActionReply(ActionReply::HelperErrorReply()); | ||||
113 | reply.setErrorCode(static_cast<ActionReply::Error>(ret)); | ||||
114 | reply.setErrorDescription(i18n("update-alternatives returned with error condition %1.", ret)); | ||||
115 | return reply; | ||||
116 | } | ||||
117 | } | ||||
118 | else { | ||||
119 | qDebug() << "Running update-alternatives --set now"; | ||||
68 | QProcess process; | 120 | QProcess process; | ||
69 | process.start("update-alternatives", QStringList() << "--set" << "default.plymouth" << dir.path() + QChar('/') + themeFile.first()); | 121 | process.start("update-alternatives", QStringList() << "--set" << "default.plymouth" << installFile); | ||
70 | if (!process.waitForStarted()) { | 122 | if (!process.waitForStarted()) { | ||
71 | reply = ActionReply::BackendError; | 123 | reply = ActionReply::BackendError; | ||
72 | reply.setErrorDescription(i18n("Cannot start update-alternatives.")); | 124 | reply.setErrorDescription(i18n("Cannot start update-alternatives.")); | ||
73 | return reply; | 125 | return reply; | ||
74 | } | 126 | } | ||
75 | if (!process.waitForFinished()) { | 127 | if (!process.waitForFinished()) { | ||
76 | reply = ActionReply::BackendError; | 128 | reply = ActionReply::BackendError; | ||
77 | reply.setErrorDescription(i18n("update-alternatives failed to run.")); | 129 | reply.setErrorDescription(i18n("update-alternatives failed to run.")); | ||
78 | return reply; | 130 | return reply; | ||
79 | } | 131 | } | ||
80 | ret = process.exitCode(); | 132 | ret = process.exitCode(); | ||
81 | 133 | | |||
82 | if (ret != 0) { | 134 | if (ret != 0) { | ||
83 | reply = ActionReply(ActionReply::HelperErrorReply()); | 135 | reply = ActionReply(ActionReply::HelperErrorReply()); | ||
84 | reply.setErrorCode(static_cast<ActionReply::Error>(ret)); | 136 | reply.setErrorCode(static_cast<ActionReply::Error>(ret)); | ||
85 | reply.setErrorDescription(i18n("update-alternatives returned with error condition %1.", ret)); | 137 | reply.setErrorDescription(i18n("update-alternatives returned with error condition %1.", ret)); | ||
86 | return reply; | 138 | return reply; | ||
87 | } | 139 | } | ||
88 | } | 140 | } | ||
141 | } | ||||
89 | 142 | | |||
90 | int ret = 0; | 143 | int ret = 0; | ||
91 | 144 | | |||
92 | QProcess process; | 145 | QProcess process; | ||
146 | qDebug() << "Running update-initramfs -u now"; | ||||
93 | process.start("/usr/sbin/update-initramfs", QStringList() << "-u"); | 147 | process.start("/usr/sbin/update-initramfs", QStringList() << "-u"); | ||
94 | if (!process.waitForStarted()) { | 148 | if (!process.waitForStarted()) { | ||
95 | reply = ActionReply::BackendError; | 149 | reply = ActionReply::BackendError; | ||
96 | reply.setErrorDescription(i18n("Cannot start initramfs.")); | 150 | reply.setErrorDescription(i18n("Cannot start initramfs.")); | ||
97 | return reply; | 151 | return reply; | ||
98 | } | 152 | } | ||
99 | if (!process.waitForFinished(60000)) { | 153 | if (!process.waitForFinished(60000)) { | ||
100 | reply = ActionReply::BackendError; | 154 | reply = ActionReply::BackendError; | ||
▲ Show 20 Lines • Show All 186 Lines • Show Last 20 Lines |
Should be update-alternatives here.