Commit bb83192e authored by Aard's avatar Aard

[ssuks] Add device specific pack script section

/usr/share/ssu/kickstart/pack/<model>, with default fallback
parent b2dca5a2
...@@ -144,20 +144,27 @@ QStringList SsuKickstarter::packages(){ ...@@ -144,20 +144,27 @@ QStringList SsuKickstarter::packages(){
} }
// we intentionally don't support device-specific post scriptlets // we intentionally don't support device-specific post scriptlets
QStringList SsuKickstarter::scriptletSection(QString name, bool chroot){ QStringList SsuKickstarter::scriptletSection(QString name, int flags){
QStringList result; QStringList result;
QString path; QString path;
QDir dir; QDir dir;
if (chroot) if ((flags & NoChroot) == NoChroot)
path = Sandbox::map(QString("/%1/kickstart/%2/") path = Sandbox::map(QString("/%1/kickstart/%2_nochroot/")
.arg(SSU_DATA_DIR) .arg(SSU_DATA_DIR)
.arg(name)); .arg(name));
else else
path = Sandbox::map(QString("/%1/kickstart/%2_nochroot/") path = Sandbox::map(QString("/%1/kickstart/%2/")
.arg(SSU_DATA_DIR) .arg(SSU_DATA_DIR)
.arg(name)); .arg(name));
if ((flags & DeviceSpecific) == DeviceSpecific){
if (dir.exists(path + "/" + replaceSpaces(deviceModel.toLower())))
path = path + "/" + replaceSpaces(deviceModel.toLower());
else
path = path + "/default";
}
dir.setPath(path); dir.setPath(path);
QStringList scriptlets = dir.entryList(QDir::AllEntries|QDir::NoDot|QDir::NoDotDot, QStringList scriptlets = dir.entryList(QDir::AllEntries|QDir::NoDot|QDir::NoDotDot,
QDir::Name); QDir::Name);
...@@ -177,10 +184,11 @@ QStringList SsuKickstarter::scriptletSection(QString name, bool chroot){ ...@@ -177,10 +184,11 @@ QStringList SsuKickstarter::scriptletSection(QString name, bool chroot){
result.prepend(QString("export SSU_RELEASE_TYPE=%1") result.prepend(QString("export SSU_RELEASE_TYPE=%1")
.arg(rndMode ? "rnd" : "release")); .arg(rndMode ? "rnd" : "release"));
if (chroot) if ((flags & NoChroot) == NoChroot)
result.prepend("%" + name);
else
result.prepend("%" + name + " --nochroot"); result.prepend("%" + name + " --nochroot");
else
result.prepend("%" + name);
result.append("%end"); result.append("%end");
} }
...@@ -317,10 +325,11 @@ bool SsuKickstarter::write(QString kickstart){ ...@@ -317,10 +325,11 @@ bool SsuKickstarter::write(QString kickstart){
} }
kout << repos().join("\n") << endl << endl; kout << repos().join("\n") << endl << endl;
kout << packages().join("\n") << endl << endl; kout << packages().join("\n") << endl << endl;
kout << scriptletSection("pre", true).join("\n") << endl << endl; // TODO: now that extending scriptlet section is might make sense to make it configurable
kout << scriptletSection("post", true).join("\n") << endl << endl; kout << scriptletSection("pre", Chroot).join("\n") << endl << endl;
kout << scriptletSection("post", false).join("\n") << endl << endl; kout << scriptletSection("post", Chroot).join("\n") << endl << endl;
// add flags as bitmask? kout << scriptletSection("post", NoChroot).join("\n") << endl << endl;
kout << scriptletSection("pack", DeviceSpecific).join("\n") << endl << endl;
// POST, die-on-error // POST, die-on-error
return true; return true;
......
...@@ -21,6 +21,13 @@ class SsuKickstarter { ...@@ -21,6 +21,13 @@ class SsuKickstarter {
void setRepoParameters(QHash<QString, QString> parameters); void setRepoParameters(QHash<QString, QString> parameters);
bool write(QString kickstart=""); bool write(QString kickstart="");
enum ScriptletFlags {
/// Chroot is not useful, but helps in making the code more readable
Chroot = 0,
NoChroot = 0x1,
DeviceSpecific = 0x2,
};
private: private:
QHash<QString, QString> repoOverride; QHash<QString, QString> repoOverride;
Ssu ssu; Ssu ssu;
...@@ -32,7 +39,7 @@ class SsuKickstarter { ...@@ -32,7 +39,7 @@ class SsuKickstarter {
QStringList packages(); QStringList packages();
QString replaceSpaces(const QString &value); QString replaceSpaces(const QString &value);
QStringList repos(); QStringList repos();
QStringList scriptletSection(QString name, bool chroot=true); QStringList scriptletSection(QString name, int flags=Chroot);
}; };
#endif #endif
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