Commit 7a0a669c authored by Thomas Perl's avatar Thomas Perl

[ssu] Slipstream provider

parent 0b1a2487
......@@ -51,6 +51,7 @@
credentials=jolla
credentials-url=https://%(ssuRegDomain)/%(ssuRegPath)/%1/credentials.xml
register-url=https://%(ssuRegDomain)/%(ssuRegPath)/%1/register.xml
slipstream-url=https://%(ssuSlipstreamDomain)/%(deviceModel)
[release]
jolla=https://%(packagesDomain)/releases/%(release)/jolla/%(arch)/
......@@ -84,10 +85,12 @@ dumpDomain=dump.example.com
packagesDomain=packages.example.com
ssuRegDomain=ssu.example.com
ssuRegPath=ssu/device
ssuSlipstreamDomain=slipstream.example.com
# fallback if domain is not matched or not set
[default-domain]
dumpDomain=dump.testing.com
packagesDomain=packages.testing.com
ssuRegDomain=ssu.testing.com
ssuSlipstreamDomain=slipstream.testing.com
ssuRegPath=ssu/device
......@@ -80,6 +80,17 @@ Provides: rpm-macros
%{_bindir}/ssuks
%package slipstream
Summary: %{name} OS factory snapshot download provider
Group: System/Base
%description slipstream
Helper utility to authenticate downloads of factory snapshot manifests.
%files slipstream
%defattr(-,root,root,-)
%{_bindir}/ssuslipstream
%package devel
Summary: Development files for %{name}
Group: Development/Libraries
......
......@@ -4,7 +4,7 @@ contains(QT_VERSION, ^4\\.[0-7]\\..*) {
TEMPLATE = subdirs
SUBDIRS = libssu libssunetworkproxy ssud
SUBDIRS += ssucli ssuurlresolver ssuks
SUBDIRS += ssucli ssuurlresolver ssuks ssuslipstream
ssuconfhack {
SUBDIRS += ssuconfperm
......@@ -18,6 +18,7 @@ ssuurlresolver.depends = libssu
tests.depends = libssu
ssuks.depends = libssu
ssud.depends = libssu
ssuslipstream.depends = libssu
config.files = ssu.ini
config.path = /etc/ssu
......
/**
* 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();
}
/**
* 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()));
}
/**
* 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 */
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
include(../libssu/libssu.pri)
include(../libssunetworkproxy/libssunetworkproxy.pri)
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment