Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
[ssu] Slipstream provider
  • Loading branch information
thp committed Feb 13, 2015
1 parent 0b1a248 commit 7a0a669
Show file tree
Hide file tree
Showing 8 changed files with 186 additions and 1 deletion.
3 changes: 3 additions & 0 deletions repos.ini
Expand Up @@ -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)/
Expand Down Expand Up @@ -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
11 changes: 11 additions & 0 deletions rpm/ssu.spec
Expand Up @@ -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
Expand Down
3 changes: 2 additions & 1 deletion ssu.pro
Expand Up @@ -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
Expand All @@ -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
Expand Down
39 changes: 39 additions & 0 deletions ssuslipstream/main.cpp
@@ -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();
}
78 changes: 78 additions & 0 deletions ssuslipstream/ssuslipstream.cpp
@@ -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()));
}
36 changes: 36 additions & 0 deletions ssuslipstream/ssuslipstream.h
@@ -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 */
15 changes: 15 additions & 0 deletions ssuslipstream/ssuslipstream.pro
@@ -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
2 changes: 2 additions & 0 deletions ssuslipstream/ssuslipstream_dependencies.pri
@@ -0,0 +1,2 @@
include(../libssu/libssu.pri)
include(../libssunetworkproxy/libssunetworkproxy.pri)

0 comments on commit 7a0a669

Please sign in to comment.