/
ssuslipstream.cpp
78 lines (63 loc) · 2.42 KB
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
/**
* ssu: Seamless Software Update
* Copyright (C) 2015 Jolla Ltd.
* Contact: Thomas Perl <thomas.perl@jolla.com>
*
* This program 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 2 of the License, or
* (at your option) any later version.
*
* This program 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 this program; if not, write to the Free Software Foundation, Inc.,
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
**/
#include "ssuslipstream.h"
#include <QCoreApplication>
#include <QTimer>
#include <QUrl>
#include "libssu/ssu.h"
#include "libssu/ssudeviceinfo.h"
29
#include "libssu/ssucoreconfig_p.h"
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
SsuSlipstream::SsuSlipstream()
: QObject()
{
}
void SsuSlipstream::run()
{
QTextStream err(stderr, QIODevice::WriteOnly);
QString partition = QString::fromUtf8(qgetenv("SSU_SLIPSTREAM_PARTITION"));
if (partition.isEmpty()) {
err << "Nothing to do\n";
QCoreApplication::exit(1);
return;
}
Ssu ssu;
// XXX: Do we need ssu.isRegistered() + updateCredentials() here?
QPair<QString, QString> credentials = ssu.credentials("store");
QString release = ssu.release(false);
QString release_override = QString::fromUtf8(qgetenv("SSU_SLIPSTREAM_RELEASE"));
if (!release_override.isEmpty()) {
err << QString("Forcing release to: %1\n").arg(release_override);
release = release_override;
}
SsuCoreConfig *settings = SsuCoreConfig::instance();
const QString KEY("slipstream-url");
QString ssuCredentialsUrl = settings->value(KEY, ssu.repoUrl(KEY)).toString();
if (ssuCredentialsUrl.isEmpty()) {
err << "URL for slipstream update not set (config key 'slipstream-url')\n";
QCoreApplication::exit(1);
return;
}
QUrl url(ssuCredentialsUrl);
url.setUserName(credentials.first);
url.setPassword(credentials.second);
QTextStream out(stdout, QIODevice::WriteOnly);
out << url.toString() << '/' << release << '/' << partition << '\n';
QTimer::singleShot(0, QCoreApplication::instance(), SLOT(quit()));
}