Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Browse files
Browse the repository at this point in the history
Merge pull request #36 from thp/slipstream
[ssu] Slipstream provider
- Loading branch information
Showing
8 changed files
with
186 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
/** | ||
* 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 <QCoreApplication> | ||
#include <QTimer> | ||
|
||
#include "libssunetworkproxy/ssunetworkproxy.h" | ||
|
||
#include "ssuslipstream.h" | ||
|
||
|
||
int main(int argc, char *argv[]) | ||
{ | ||
QCoreApplication app(argc, argv); | ||
|
||
set_application_proxy_factory(); | ||
|
||
SsuSlipstream slipstream; | ||
QTimer::singleShot(0, &slipstream, SLOT(run())); | ||
|
||
return app.exec(); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,78 @@ | ||
/** | ||
* 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" | ||
#include "libssu/ssucoreconfig.h" | ||
|
||
|
||
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())); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
/** | ||
* 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. | ||
**/ | ||
|
||
#ifndef SSU_SLIPSTREAM_H | ||
#define SSU_SLIPSTREAM_H | ||
|
||
#include <QObject> | ||
|
||
class SsuSlipstream : public QObject { | ||
Q_OBJECT | ||
|
||
public: | ||
SsuSlipstream(); | ||
|
||
public slots: | ||
void run(); | ||
}; | ||
|
||
#endif /* SSU_SLIPSTREAM_H */ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
TARGET = ssuslipstream | ||
|
||
include(../ssuapplication.pri) | ||
include(ssuslipstream_dependencies.pri) | ||
|
||
QT += network | ||
CONFIG += link_pkgconfig | ||
|
||
SOURCES += ssuslipstream.cpp | ||
HEADERS += ssuslipstream.h | ||
|
||
SOURCES += main.cpp | ||
|
||
CONFIG += link_pkgconfig | ||
PKGCONFIG += libsystemd-journal |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
include(../libssu/libssu.pri) | ||
include(../libssunetworkproxy/libssunetworkproxy.pri) |