summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--backend/modules/hdmap9
-rw-r--r--backend/modules/partitions11
-rw-r--r--mainwizard.cpp2
-rw-r--r--mainwizard.h1
-rw-r--r--wizard/hdmap.cpp97
-rw-r--r--wizard/hdmap.h29
-rw-r--r--wizard/hdmap.ui30
-rw-r--r--wizard/rootpartition.cpp15
-rw-r--r--wizard/rootpartition.h1
-rw-r--r--wizard/rootpartition.ui3
10 files changed, 191 insertions, 7 deletions
diff --git a/backend/modules/hdmap b/backend/modules/hdmap
index 3056b93..ef669a3 100644
--- a/backend/modules/hdmap
+++ b/backend/modules/hdmap
@@ -339,8 +339,9 @@ function prepare_partitions_for_install()
done <<<"$cfg_hdmap"
}
-function get_full_hd_map()
+function fill_hdmap()
{
+ cfg_set hdmap "$(
(
echo "$cfg_hdmap"
root_disk="$(get_disk "$(hdmap_get device of mountpoint /)")"
@@ -360,6 +361,10 @@ function get_full_hd_map()
echo "$part:/media/$(basename "$part")::auto"
fi
done
- ) | sort -u -t: -k1,1
+ for part in $(list_dm_partitions)
+ do
+ echo "$part:::"
+ done
+ ) | sort -u -t: -k1,1)"
}
diff --git a/backend/modules/partitions b/backend/modules/partitions
index 0d59323..c869053 100644
--- a/backend/modules/partitions
+++ b/backend/modules/partitions
@@ -36,6 +36,17 @@ function list_all_partitions()
awk -vli="$(awk '{if($2=="sd") print $1;}' /proc/devices)" 'BEGIN{m=split(li,list," ")}{for(i=1;i<=m;i++) if($1==list[i]&&$2%16!=0) print "/dev/"$4;}' /proc/partitions
}
+# Synopsis: list_dm_partitions
+#
+# This function lists all device-mapper partitions
+# Output example:
+# /dev/mapper/volg-home
+# /dev/mapper/cryptoroot
+function list_dm_partitions()
+{
+ ls /dev/mapper/* 2>/dev/null | fmt -w1 | grep -v "/control$"
+}
+
# Synopsis: (e.g.) list_all_partitions | partitions_usage_details
#
# This function lists usage details for a list of partitions from STDIN
diff --git a/mainwizard.cpp b/mainwizard.cpp
index a54b98d..61b14a1 100644
--- a/mainwizard.cpp
+++ b/mainwizard.cpp
@@ -7,6 +7,7 @@
#include "wizard/partmansel.h"
#include "wizard/partman.h"
#include "wizard/rootpartition.h"
+#include "wizard/hdmap.h"
#include "wizard/bootloader.h"
#include "wizard/rootpwd.h"
#include "wizard/usercfg.h"
@@ -30,6 +31,7 @@ MainWizard::MainWizard()
setPage(Page_PartManSel, new wpPartManSel(this));
setPage(Page_PartMan, new wpPartMan(this));
setPage(Page_RootPartition, new wpRootPartition(this));
+ setPage(Page_HdMap, new wpHdMap(this));
setPage(Page_Bootloader, new wpBootloader(this));
setPage(Page_RootPwd, new wpRootPwd(this));
setPage(Page_UserCfg, new wpUserCfg(this));
diff --git a/mainwizard.h b/mainwizard.h
index 9fa9839..ec68de5 100644
--- a/mainwizard.h
+++ b/mainwizard.h
@@ -15,6 +15,7 @@ class MainWizard : public QWizard
Page_PartManSel,
Page_PartMan,
Page_RootPartition,
+ Page_HdMap,
Page_Bootloader,
Page_RootPwd,
Page_UserCfg,
diff --git a/wizard/hdmap.cpp b/wizard/hdmap.cpp
new file mode 100644
index 0000000..526ebef
--- /dev/null
+++ b/wizard/hdmap.cpp
@@ -0,0 +1,97 @@
+#include <QtGui>
+#include "hdmap.h"
+#include "../listdelegate.h"
+#include "../listitem.h"
+
+wpHdMap::wpHdMap(QWidget *parent) : QWizardPage(parent)
+{
+ setupUi(this);
+ backend = Backend::instance();
+ connect(backend, SIGNAL(receivedDataLine(QString,QString)), this, SLOT(receivedDataLine(QString,QString)));
+ connect(backend, SIGNAL(finishedCommand(QString)), this, SLOT(backendFinishedCommand(QString)));
+ tableWidget->horizontalHeader()->setResizeMode(QHeaderView::Stretch);
+}
+
+void wpHdMap::initializePage()
+{
+ clearPage();
+}
+
+void wpHdMap::clearPage()
+{
+ backend->exec("send_possible_root_filesystems");
+ filesystems.clear();
+ backend->exec("fill_hdmap");
+
+ tableWidget->setColumnCount(4);
+ tableWidget->setHorizontalHeaderLabels(QStringList() << tr("Partition") << tr("Mountpoint") << tr("Format with") << tr("Automount"));
+
+// tableWidget->horizontalHeader()->setResizeMode(1,QHeaderView::Stretch);
+// tableWidget->horizontalHeader()->setResizeMode(2,QHeaderView::Stretch);
+// tableWidget->horizontalHeader()->setResizeMode(3,QHeaderView::Stretch);
+}
+
+void wpHdMap::receivedDataLine(QString data, QString line)
+{
+ if(data == "possible_root_filesystems")
+ {
+ filesystems << line.trimmed();
+ }
+}
+
+void wpHdMap::backendFinishedCommand(QString command)
+{
+ if(command == "fill_hdmap")
+ {
+
+ QStringList hdmap = backend->cfg("hdmap").split("\n");
+
+ tableWidget->setRowCount(hdmap.count());
+ for(int row = 0; row < hdmap.count(); row++)
+ {
+ QTableWidgetItem *partition = new QTableWidgetItem(hdmap.at(row).section(":",0,0));
+ partition->setFlags(Qt::ItemIsSelectable|Qt::ItemIsEnabled);
+ tableWidget->setItem(row, 0, partition);
+ QLineEdit *mountpoint = new QLineEdit(this);
+ mountpoint->setText(hdmap.at(row).section(":",1,1));
+ tableWidget->setCellWidget(row, 1, mountpoint);
+ QComboBox *filesystem = new QComboBox(this);
+ filesystem->addItem("");
+ filesystem->addItems(filesystems);
+ filesystem->setCurrentIndex(filesystems.indexOf(hdmap.at(row).section(":",2,2))+1);
+ tableWidget->setCellWidget(row, 2, filesystem);
+ QCheckBox *automount = new QCheckBox(this);
+ automount->setText(tr("mount on boot"));
+ if(hdmap.at(row).section(":",3,3) == "auto") automount->setChecked(true); else automount->setChecked(false);
+ tableWidget->setCellWidget(row, 3, automount);
+ }
+ }
+}
+
+void wpHdMap::updateComplete()
+{
+ emit completeChanged();
+}
+
+bool wpHdMap::isComplete() const
+{
+// if(!rootPartitionDev->currentItem()) return false;
+ return true;
+}
+
+bool wpHdMap::validatePage()
+{
+ if(!isComplete()) return false;
+ QStringList* hdmap = new QStringList();
+ for(int row = 0; row < tableWidget->rowCount(); row++)
+ {
+ hdmap->append(QString("%1:%2:%3:%4")
+ .arg(tableWidget->item(row,0)->text())
+ .arg(qobject_cast<QLineEdit*>(tableWidget->cellWidget(row,1))->text())
+ .arg(qobject_cast<QComboBox*>(tableWidget->cellWidget(row,2))->currentText())
+ .arg(qobject_cast<QCheckBox*>(tableWidget->cellWidget(row,3))->isChecked() ? "auto" : ""));
+ }
+ backend->cfg("hdmap", hdmap->join("\n"));
+// backend->exec(QString("hdmap_set %1").arg(hdmap->join("\n")));
+ return true;
+}
diff --git a/wizard/hdmap.h b/wizard/hdmap.h
new file mode 100644
index 0000000..306266c
--- /dev/null
+++ b/wizard/hdmap.h
@@ -0,0 +1,29 @@
+#ifndef hdmap_H
+#define hdmap_H
+
+#include "ui_hdmap.h"
+#include "../backend.h"
+
+class wpHdMap : public QWizardPage, Ui::wpHdMap
+{
+ Q_OBJECT
+
+ public:
+ wpHdMap(QWidget *parent = 0);
+ void initializePage();
+ void clearPage();
+ bool isComplete() const;
+ bool validatePage();
+
+ private:
+ Backend* backend;
+ QStringList filesystems;
+
+ private slots:
+ void receivedDataLine(QString data, QString line);
+ void updateComplete();
+ void backendFinishedCommand(QString command);
+
+};
+
+#endif // hdmap_H
diff --git a/wizard/hdmap.ui b/wizard/hdmap.ui
new file mode 100644
index 0000000..ae01743
--- /dev/null
+++ b/wizard/hdmap.ui
@@ -0,0 +1,30 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<ui version="4.0">
+ <class>wpHdMap</class>
+ <widget class="QWizardPage" name="wpHdMap">
+ <property name="geometry">
+ <rect>
+ <x>0</x>
+ <y>0</y>
+ <width>400</width>
+ <height>300</height>
+ </rect>
+ </property>
+ <property name="windowTitle">
+ <string>WizardPage</string>
+ </property>
+ <property name="title">
+ <string>Partitions</string>
+ </property>
+ <property name="subTitle">
+ <string>HD Map</string>
+ </property>
+ <layout class="QGridLayout" name="gridLayout">
+ <item row="0" column="0">
+ <widget class="QTableWidget" name="tableWidget"/>
+ </item>
+ </layout>
+ </widget>
+ <resources/>
+ <connections/>
+</ui>
diff --git a/wizard/rootpartition.cpp b/wizard/rootpartition.cpp
index 6341a0f..f60f5e8 100644
--- a/wizard/rootpartition.cpp
+++ b/wizard/rootpartition.cpp
@@ -2,6 +2,7 @@
#include "rootpartition.h"
#include "../listdelegate.h"
#include "../listitem.h"
+#include "../mainwizard.h"
wpRootPartition::wpRootPartition(QWidget *parent) : QWizardPage(parent)
{
@@ -9,6 +10,7 @@ wpRootPartition::wpRootPartition(QWidget *parent) : QWizardPage(parent)
backend = Backend::instance();
connect(backend, SIGNAL(receivedDataLine(QString,QString)), this, SLOT(receivedDataLine(QString,QString)));
connect(rootPartitionDev, SIGNAL(currentItemChanged(QListWidgetItem*,QListWidgetItem*)), this, SLOT(updateComplete()));
+ connect(chkAdvanced, SIGNAL(stateChanged(int)), this, SLOT(updateComplete()));
}
void wpRootPartition::initializePage()
@@ -44,15 +46,24 @@ void wpRootPartition::updateComplete()
bool wpRootPartition::isComplete() const
{
- if(!rootPartitionDev->currentItem()) return false;
+ if(!chkAdvanced->isChecked() && !rootPartitionDev->currentItem()) return false;
return true;
}
bool wpRootPartition::validatePage()
{
if(!isComplete()) return false;
- backend->exec(QString("hdmap_set %1:/:%2:auto")
+ if(rootPartitionDev->currentItem())
+ backend->exec(QString("hdmap_set %1:/:%2:auto")
.arg(rootPartitionDev->currentItem()->text().section(" ",0,0))
.arg(chkFormat->isChecked() ? rootPartitionFs->currentText() : ""));
return true;
}
+
+int wpRootPartition::nextId() const
+{
+ if(chkAdvanced->isChecked())
+ return MainWizard::Page_HdMap;
+ else
+ return MainWizard::Page_Bootloader;
+}
diff --git a/wizard/rootpartition.h b/wizard/rootpartition.h
index 16e95ef..393ec22 100644
--- a/wizard/rootpartition.h
+++ b/wizard/rootpartition.h
@@ -12,6 +12,7 @@ class wpRootPartition : public QWizardPage, Ui::wpRootPartition
wpRootPartition(QWidget *parent = 0);
void initializePage();
void clearPage();
+ int nextId() const;
bool isComplete() const;
bool validatePage();
diff --git a/wizard/rootpartition.ui b/wizard/rootpartition.ui
index 119c00f..f582e32 100644
--- a/wizard/rootpartition.ui
+++ b/wizard/rootpartition.ui
@@ -107,9 +107,6 @@
</item>
<item row="4" column="1">
<widget class="QCheckBox" name="chkAdvanced">
- <property name="enabled">
- <bool>false</bool>
- </property>
<property name="text">
<string>advanced partition options</string>
</property>