Commit 388cd8dd authored by Aard's avatar Aard

Add repo management from CLI, build documentation

parent 678531b8
...@@ -17,7 +17,6 @@ ...@@ -17,7 +17,6 @@
#include <QtXml/QDomDocument> #include <QtXml/QDomDocument>
#include <ssudeviceinfo.h> #include <ssudeviceinfo.h>
#include <ssusettings.h>
class Ssu: public QObject { class Ssu: public QObject {
Q_OBJECT Q_OBJECT
...@@ -106,10 +105,10 @@ class Ssu: public QObject { ...@@ -106,10 +105,10 @@ class Ssu: public QObject {
* now any mode where RndMode is not set is treated as ReleaseMode. * now any mode where RndMode is not set is treated as ReleaseMode.
*/ */
enum DeviceMode { enum DeviceMode {
DisableRepoManager = 0x1, ///< Disable automagic repository management DisableRepoManager = 0x1, ///< Disable automagic repository management
RndMode = 0x2, ///< Enable RnD mode for device RndMode = 0x2, ///< Enable RnD mode for device
ReleaseMode = 0x4, ///< Enable Release mode ReleaseMode = 0x4, ///< Enable Release mode
StrictMode = 0x8 ///< Enable strict mode (i.e., delete unmanaged repositories) LenientMode = 0x8 ///< Disable strict mode (i.e., keep unmanaged repositories)
}; };
/** /**
......
...@@ -51,11 +51,9 @@ QString SsuCoreConfig::flavour(){ ...@@ -51,11 +51,9 @@ QString SsuCoreConfig::flavour(){
} }
int SsuCoreConfig::deviceMode(){ int SsuCoreConfig::deviceMode(){
if (!contains("deviceMode")){ if (!contains("deviceMode"))
setValue("deviceMode", Ssu::ReleaseMode);
sync();
return Ssu::ReleaseMode; return Ssu::ReleaseMode;
} else else
return value("deviceMode").toInt(); return value("deviceMode").toInt();
} }
......
...@@ -191,6 +191,10 @@ QStringList SsuDeviceInfo::repos(bool rnd){ ...@@ -191,6 +191,10 @@ QStringList SsuDeviceInfo::repos(bool rnd){
result.append(ssuSettings->allKeys()); result.append(ssuSettings->allKeys());
ssuSettings->endGroup(); ssuSettings->endGroup();
// read user-enabled repositories from ssu.ini
if (ssuSettings->contains("enabled-repos"))
result.append(ssuSettings->value("enabled-repos").toStringList());
result.removeDuplicates(); result.removeDuplicates();
// read the disabled repositories for this device // read the disabled repositories for this device
......
...@@ -22,6 +22,69 @@ SsuRepoManager::SsuRepoManager(): QObject() { ...@@ -22,6 +22,69 @@ SsuRepoManager::SsuRepoManager(): QObject() {
} }
void SsuRepoManager::add(QString repo, QString repoUrl){
SsuCoreConfig *ssuSettings = SsuCoreConfig::instance();
if (repoUrl == ""){
// just enable a repository which has URL in repos.ini
QStringList enabledRepos;
if (ssuSettings->contains("enabled-repos"))
enabledRepos = ssuSettings->value("enabled-repos").toStringList();
enabledRepos.append(repo);
enabledRepos.removeDuplicates();
ssuSettings->setValue("enabled-repos", enabledRepos);
} else
ssuSettings->setValue("repository-urls/" + repo, repoUrl);
ssuSettings->sync();
}
void SsuRepoManager::disable(QString repo){
SsuCoreConfig *ssuSettings = SsuCoreConfig::instance();
QStringList disabledRepos;
if (ssuSettings->contains("disabled-repos"))
disabledRepos = ssuSettings->value("disabled-repos").toStringList();
disabledRepos.append(repo);
disabledRepos.removeDuplicates();
ssuSettings->setValue("disabled-repos", disabledRepos);
ssuSettings->sync();
}
void SsuRepoManager::enable(QString repo){
SsuCoreConfig *ssuSettings = SsuCoreConfig::instance();
QStringList disabledRepos;
if (ssuSettings->contains("disabled-repos"))
disabledRepos = ssuSettings->value("disabled-repos").toStringList();
disabledRepos.removeAll(repo);
disabledRepos.removeDuplicates();
ssuSettings->setValue("disabled-repos", disabledRepos);
ssuSettings->sync();
}
void SsuRepoManager::remove(QString repo){
SsuCoreConfig *ssuSettings = SsuCoreConfig::instance();
if (ssuSettings->contains("repository-urls/" + repo))
ssuSettings->remove("repository-urls/" + repo);
if (ssuSettings->contains("enabled-repos")){
QStringList enabledRepos = ssuSettings->value("enabled-repos").toStringList();
if (enabledRepos.contains(repo)){
enabledRepos.removeAll(repo);
enabledRepos.removeDuplicates();
ssuSettings->setValue("enabled-repos", enabledRepos);
}
}
ssuSettings->sync();
}
void SsuRepoManager::update(){ void SsuRepoManager::update(){
// - delete all non-ssu managed repositories (missing ssu_ prefix) // - delete all non-ssu managed repositories (missing ssu_ prefix)
// - create list of ssu-repositories for current adaptation // - create list of ssu-repositories for current adaptation
...@@ -52,7 +115,7 @@ void SsuRepoManager::update(){ ...@@ -52,7 +115,7 @@ void SsuRepoManager::update(){
// strict mode enabled -> delete all repositories not prefixed by ssu // strict mode enabled -> delete all repositories not prefixed by ssu
// assume configuration error if there are no device repos, and don't delete // assume configuration error if there are no device repos, and don't delete
// anything, even in strict mode // anything, even in strict mode
if ((deviceMode & Ssu::StrictMode) == Ssu::StrictMode && !repos.isEmpty()){ if ((deviceMode & Ssu::LenientMode) != Ssu::LenientMode && !repos.isEmpty()){
QDirIterator it(ZYPP_REPO_PATH, QDir::AllEntries|QDir::NoDot|QDir::NoDotDot); QDirIterator it(ZYPP_REPO_PATH, QDir::AllEntries|QDir::NoDot|QDir::NoDotDot);
while (it.hasNext()){ while (it.hasNext()){
it.next(); it.next();
......
...@@ -18,9 +18,23 @@ class SsuRepoManager: public QObject { ...@@ -18,9 +18,23 @@ class SsuRepoManager: public QObject {
public: public:
SsuRepoManager(); SsuRepoManager();
/** /**
* Look up all variables in the specified configuration file section, * Add a repository
* run them through the variable expander, and add them to the supplied */
* QHash void add(QString repo, QString repoUrl="");
/**
* Disable a repository
*/
void disable(QString repo);
/**
* Enable a repository, given it's not disabled by board configuration
*/
void enable(QString repo);
/**
* Remove a repository
*/
void remove(QString repo);
/**
* Update the repository files on disk
*/ */
void update(); void update();
/** /**
...@@ -30,6 +44,7 @@ class SsuRepoManager: public QObject { ...@@ -30,6 +44,7 @@ class SsuRepoManager: public QObject {
QString url(QString repoName, bool rndRepo=false, QString url(QString repoName, bool rndRepo=false,
QHash<QString, QString> repoParameters=QHash<QString, QString>(), QHash<QString, QString> repoParameters=QHash<QString, QString>(),
QHash<QString, QString> parametersOverride=QHash<QString, QString>()); QHash<QString, QString> parametersOverride=QHash<QString, QString>());
}; };
#endif #endif
...@@ -53,29 +53,47 @@ void RndSsuCli::optFlavour(QStringList opt){ ...@@ -53,29 +53,47 @@ void RndSsuCli::optFlavour(QStringList opt){
void RndSsuCli::optMode(QStringList opt){ void RndSsuCli::optMode(QStringList opt){
QTextStream qout(stdout); QTextStream qout(stdout);
qout << "Mode handling is currently not implemented" << endl;
state = Idle; // TODO: allow setting meaningful names instead of numbers
if (opt.count() == 2){
qout << "Device mode is: " << ssu.deviceMode() << endl;
state = Idle;
} else if (opt.count() == 3){
qout << "Setting device mode from " << ssu.deviceMode()
<< " to " << opt.at(2) << endl;
ssu.setDeviceMode(opt.at(2).toInt());
state = Idle;
}
} }
void RndSsuCli::optModifyRepo(int action, QStringList opt){ void RndSsuCli::optModifyRepo(int action, QStringList opt){
SsuRepoManager repoManager; SsuRepoManager repoManager;
QTextStream qout(stdout); QTextStream qout(stdout);
qout << "Repository management is currently not implemented" << endl;
if (opt.count() == 3){ if (opt.count() == 3){
switch(action){
} else if (opt.count() == 4){ case Add:
repoManager.add(opt.at(2));
} repoManager.update();
/* break;
switch(action){ case Remove:
case Add: repoManager.remove(opt.at(2));
case Remove: repoManager.update();
case Disable: break;
case Enable: case Disable:
repoManager.disable(opt.at(2));
repoManager.update();
break;
case Enable:
repoManager.enable(opt.at(2));
repoManager.update();
break;
}
} else if (opt.count() == 4 && action == Add){
repoManager.add(opt.at(2), opt.at(3));
repoManager.update();
} }
*/
} }
void RndSsuCli::optRegister(){ void RndSsuCli::optRegister(){
......
* Sat Mar 30 2013 Bernd Wachter <bernd.wachter@jollamobile.com> - 0.28
- Add repository management
- Add basic device mode handling
- Disable credentials handling for insecure repositories
* Wed Mar 27 2013 Bernd Wachter <bernd.wachter@jollamobile.com> - 0.27 * Wed Mar 27 2013 Bernd Wachter <bernd.wachter@jollamobile.com> - 0.27
- Add support for := in variable substitution - Add support for := in variable substitution
......
Name: ssu Name: ssu
Version: 0.27 Version: 0.28
Release: 1 Release: 1
Summary: SSU enabler for RND Summary: SSU enabler for RND
Group: System/Base Group: System/Base
...@@ -11,6 +11,8 @@ BuildRequires: pkgconfig(libzypp) ...@@ -11,6 +11,8 @@ BuildRequires: pkgconfig(libzypp)
BuildRequires: pkgconfig(QtSystemInfo) BuildRequires: pkgconfig(QtSystemInfo)
BuildRequires: pkgconfig(qt-boostable) BuildRequires: pkgconfig(qt-boostable)
BuildRequires: pkgconfig(libsystemd-journal) BuildRequires: pkgconfig(libsystemd-journal)
BuildRequires: oneshot
BuildRequires: doxygen
Requires(pre): shadow-utils Requires(pre): shadow-utils
Requires(postun): shadow-utils Requires(postun): shadow-utils
Requires: ssu-vendor-data Requires: ssu-vendor-data
...@@ -25,6 +27,9 @@ Requires: ssu-vendor-data ...@@ -25,6 +27,9 @@ Requires: ssu-vendor-data
%{_bindir}/ssu %{_bindir}/ssu
%{_libdir}/*.so.* %{_libdir}/*.so.*
%dir %{_sysconfdir}/zypp/credentials.d %dir %{_sysconfdir}/zypp/credentials.d
# ssu itself does not use the package-update triggers, but provides
# them for the vendor data packages to use
%attr(0755, -, -) %{_oneshotdir}/*
%package vendor-data-example %package vendor-data-example
...@@ -93,6 +98,18 @@ Requires: rpm ...@@ -93,6 +98,18 @@ Requires: rpm
%attr(0755, -, -) /usr/sbin/ssu-repos.sh %attr(0755, -, -) /usr/sbin/ssu-repos.sh
%package doc
Summary: Documentation for %{name}
Group: Documentation
%description doc
%{summary}.
%files doc
%defattr(-,root,root,-)
%{_docdir}/%{name}
%prep %prep
%setup -q -n %{name}-%{version} %setup -q -n %{name}-%{version}
...@@ -100,12 +117,16 @@ Requires: rpm ...@@ -100,12 +117,16 @@ Requires: rpm
%build %build
qmake DEFINES+='TARGET_ARCH=\\\"\"%{_target_cpu}\"\\\"' -recursive qmake DEFINES+='TARGET_ARCH=\\\"\"%{_target_cpu}\"\\\"' -recursive
make %{?_smp_mflags} make %{?_smp_mflags}
doxygen doc/Doxyfile
%install %install
make INSTALL_ROOT=%{buildroot} install make INSTALL_ROOT=%{buildroot} install
mkdir -p %{buildroot}/%{_sysconfdir}/zypp/credentials.d mkdir -p %{buildroot}/%{_sysconfdir}/zypp/credentials.d
ln -s %{_bindir}/ssu %{buildroot}/%{_bindir}/rndssu ln -s %{_bindir}/ssu %{buildroot}/%{_bindir}/rndssu
mkdir -p %{buildroot}/%{_docdir}/%{name}
cp -R doc/html/* %{buildroot}/%{_docdir}/%{name}/
%pre %pre
groupadd -rf ssu groupadd -rf ssu
...@@ -124,4 +145,5 @@ if [ "$1" == 0 ]; then ...@@ -124,4 +145,5 @@ if [ "$1" == 0 ]; then
getent group ssu >/dev/null && groupdel ssu getent group ssu >/dev/null && groupdel ssu
fi fi
%post -p /sbin/ldconfig %post
/sbin/ldconfig
#!/bin/sh
if [ -z "$MIC_RUN" ]; then
/usr/bin/ssu updaterepos
else
exit 1
fi
...@@ -20,7 +20,10 @@ tests.depends = libssu ...@@ -20,7 +20,10 @@ tests.depends = libssu
config.files = ssu.ini config.files = ssu.ini
config.path = /etc/ssu config.path = /etc/ssu
oneshot.files = ssu-update-repos
oneshot.path = /usr/lib/oneshot.d
static_config.files = repos.ini ssu-defaults.ini board-mappings.ini static_config.files = repos.ini ssu-defaults.ini board-mappings.ini
static_config.path = /usr/share/ssu static_config.path = /usr/share/ssu
INSTALLS += config static_config INSTALLS += config static_config oneshot
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