Commit 388cd8dd authored by Aard's avatar Aard

Add repo management from CLI, build documentation

parent 678531b8
......@@ -17,7 +17,6 @@
#include <QtXml/QDomDocument>
#include <ssudeviceinfo.h>
#include <ssusettings.h>
class Ssu: public QObject {
Q_OBJECT
......@@ -109,7 +108,7 @@ class Ssu: public QObject {
DisableRepoManager = 0x1, ///< Disable automagic repository management
RndMode = 0x2, ///< Enable RnD mode for device
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(){
}
int SsuCoreConfig::deviceMode(){
if (!contains("deviceMode")){
setValue("deviceMode", Ssu::ReleaseMode);
sync();
if (!contains("deviceMode"))
return Ssu::ReleaseMode;
} else
else
return value("deviceMode").toInt();
}
......
......@@ -191,6 +191,10 @@ QStringList SsuDeviceInfo::repos(bool rnd){
result.append(ssuSettings->allKeys());
ssuSettings->endGroup();
// read user-enabled repositories from ssu.ini
if (ssuSettings->contains("enabled-repos"))
result.append(ssuSettings->value("enabled-repos").toStringList());
result.removeDuplicates();
// read the disabled repositories for this device
......
......@@ -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(){
// - delete all non-ssu managed repositories (missing ssu_ prefix)
// - create list of ssu-repositories for current adaptation
......@@ -52,7 +115,7 @@ void SsuRepoManager::update(){
// strict mode enabled -> delete all repositories not prefixed by ssu
// assume configuration error if there are no device repos, and don't delete
// 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);
while (it.hasNext()){
it.next();
......
......@@ -18,9 +18,23 @@ class SsuRepoManager: public QObject {
public:
SsuRepoManager();
/**
* Look up all variables in the specified configuration file section,
* run them through the variable expander, and add them to the supplied
* QHash
* Add a repository
*/
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();
/**
......@@ -30,6 +44,7 @@ class SsuRepoManager: public QObject {
QString url(QString repoName, bool rndRepo=false,
QHash<QString, QString> repoParameters=QHash<QString, QString>(),
QHash<QString, QString> parametersOverride=QHash<QString, QString>());
};
#endif
......@@ -53,29 +53,47 @@ void RndSsuCli::optFlavour(QStringList opt){
void RndSsuCli::optMode(QStringList opt){
QTextStream qout(stdout);
qout << "Mode handling is currently not implemented" << endl;
// 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){
SsuRepoManager repoManager;
QTextStream qout(stdout);
qout << "Repository management is currently not implemented" << endl;
if (opt.count() == 3){
} else if (opt.count() == 4){
}
/*
switch(action){
case Add:
repoManager.add(opt.at(2));
repoManager.update();
break;
case Remove:
repoManager.remove(opt.at(2));
repoManager.update();
break;
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(){
......
* 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
- Add support for := in variable substitution
......
Name: ssu
Version: 0.27
Version: 0.28
Release: 1
Summary: SSU enabler for RND
Group: System/Base
......@@ -11,6 +11,8 @@ BuildRequires: pkgconfig(libzypp)
BuildRequires: pkgconfig(QtSystemInfo)
BuildRequires: pkgconfig(qt-boostable)
BuildRequires: pkgconfig(libsystemd-journal)
BuildRequires: oneshot
BuildRequires: doxygen
Requires(pre): shadow-utils
Requires(postun): shadow-utils
Requires: ssu-vendor-data
......@@ -25,6 +27,9 @@ Requires: ssu-vendor-data
%{_bindir}/ssu
%{_libdir}/*.so.*
%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
......@@ -93,6 +98,18 @@ Requires: rpm
%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
%setup -q -n %{name}-%{version}
......@@ -100,12 +117,16 @@ Requires: rpm
%build
qmake DEFINES+='TARGET_ARCH=\\\"\"%{_target_cpu}\"\\\"' -recursive
make %{?_smp_mflags}
doxygen doc/Doxyfile
%install
make INSTALL_ROOT=%{buildroot} install
mkdir -p %{buildroot}/%{_sysconfdir}/zypp/credentials.d
ln -s %{_bindir}/ssu %{buildroot}/%{_bindir}/rndssu
mkdir -p %{buildroot}/%{_docdir}/%{name}
cp -R doc/html/* %{buildroot}/%{_docdir}/%{name}/
%pre
groupadd -rf ssu
......@@ -124,4 +145,5 @@ if [ "$1" == 0 ]; then
getent group ssu >/dev/null && groupdel ssu
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
config.files = ssu.ini
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.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