diff --git a/repos.ini b/repos.ini index c0a6695..e211ac3 100644 --- a/repos.ini +++ b/repos.ini @@ -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 diff --git a/rpm/ssu.spec b/rpm/ssu.spec index f7180f4..a03f01d 100644 --- a/rpm/ssu.spec +++ b/rpm/ssu.spec @@ -81,6 +81,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 diff --git a/ssu.pro b/ssu.pro index a22950f..b78cbfb 100644 --- a/ssu.pro +++ b/ssu.pro @@ -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 diff --git a/ssuslipstream/main.cpp b/ssuslipstream/main.cpp new file mode 100644 index 0000000..d53e7c3 --- /dev/null +++ b/ssuslipstream/main.cpp @@ -0,0 +1,39 @@ +/** + * ssu: Seamless Software Update + * Copyright (C) 2015 Jolla Ltd. + * Contact: Thomas Perl + * + * 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 +#include + +#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(); +} diff --git a/ssuslipstream/ssuslipstream.cpp b/ssuslipstream/ssuslipstream.cpp new file mode 100644 index 0000000..fdba6cc --- /dev/null +++ b/ssuslipstream/ssuslipstream.cpp @@ -0,0 +1,78 @@ +/** + * ssu: Seamless Software Update + * Copyright (C) 2015 Jolla Ltd. + * Contact: Thomas Perl + * + * 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 +#include +#include + +#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 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())); +} diff --git a/ssuslipstream/ssuslipstream.h b/ssuslipstream/ssuslipstream.h new file mode 100644 index 0000000..5ee9d17 --- /dev/null +++ b/ssuslipstream/ssuslipstream.h @@ -0,0 +1,36 @@ +/** + * ssu: Seamless Software Update + * Copyright (C) 2015 Jolla Ltd. + * Contact: Thomas Perl + * + * 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 + +class SsuSlipstream : public QObject { + Q_OBJECT + +public: + SsuSlipstream(); + +public slots: + void run(); +}; + +#endif /* SSU_SLIPSTREAM_H */ diff --git a/ssuslipstream/ssuslipstream.pro b/ssuslipstream/ssuslipstream.pro new file mode 100644 index 0000000..dfacae3 --- /dev/null +++ b/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 diff --git a/ssuslipstream/ssuslipstream_dependencies.pri b/ssuslipstream/ssuslipstream_dependencies.pri new file mode 100644 index 0000000..ed2d69a --- /dev/null +++ b/ssuslipstream/ssuslipstream_dependencies.pri @@ -0,0 +1,2 @@ +include(../libssu/libssu.pri) +include(../libssunetworkproxy/libssunetworkproxy.pri)