From 0c7b7ed0892958851a28e4d532a06d541152343b Mon Sep 17 00:00:00 2001
From: Teo Mrnjavac <teo@kde.org>
Date: Wed, 9 Mar 2016 12:54:59 +0100
Subject: [PATCH] Warn the user if going ahead from manual partitioning without
 ESP.

---
 .../partition/gui/PartitionViewStep.cpp       | 50 +++++++++++++++++++
 1 file changed, 50 insertions(+)

diff --git a/src/modules/partition/gui/PartitionViewStep.cpp b/src/modules/partition/gui/PartitionViewStep.cpp
index 607c878399..b48efd82a6 100644
--- a/src/modules/partition/gui/PartitionViewStep.cpp
+++ b/src/modules/partition/gui/PartitionViewStep.cpp
@@ -45,8 +45,10 @@
 
 // Qt
 #include <QApplication>
+#include <QDir>
 #include <QFormLayout>
 #include <QLabel>
+#include <QMessageBox>
 #include <QProcess>
 #include <QStackedWidget>
 #include <QTimer>
@@ -292,6 +294,54 @@ PartitionViewStep::next()
         cDebug() << "Choice applied: " << m_choicePage->currentChoice();
         return;
     }
+    else if ( m_manualPartitionPage == m_widget->currentWidget() )
+    {
+        if ( QDir( "/sys/firmware/efi/efivars" ).exists() )
+        {
+            QString espMountPoint = Calamares::JobQueue::instance()->globalStorage()->
+                                        value( "efiSystemPartition").toString();
+            Partition* esp = m_core->findPartitionByMountPoint( espMountPoint );
+
+            QString message;
+            QString description;
+            if ( !esp )
+            {
+                message = tr( "No EFI system partition configured" );
+                description = tr( "An EFI system partition is necessary to start %1. "
+                                  "To configure an EFI system partition, go back and "
+                                  "select or create a FAT32 filesystem with the "
+                                  "<strong>esp</strong> flag enabled and mount point "
+                                  "%2.<br/>"
+                                  "You can continue without setting up an EFI system "
+                                  "partition but your system may fail to start." )
+                              .arg( Calamares::Branding::instance()->
+                                    string( Calamares::Branding::ShortProductName ) )
+                              .arg( espMountPoint );
+            }
+            else if ( esp && !esp->activeFlags().testFlag( PartitionTable::FlagEsp ) )
+            {
+                message = tr( "EFI system partition flag not set" );
+                description = tr( "An EFI system partition is necessary to start %1. "
+                                  "A partition was configured with mount point "
+                                  "%2 but its <strong>esp</strong> flag is not set. "
+                                  "To set the flag, go back and edit the partition.<br/>"
+                                  "You can continue without setting the flag but your "
+                                  "system may fail to start." )
+                              .arg( Calamares::Branding::instance()->
+                                    string( Calamares::Branding::ShortProductName ) )
+                              .arg( espMountPoint );
+            }
+
+            if ( !message.isEmpty() )
+            {
+                QMessageBox::warning( m_manualPartitionPage,
+                                      message,
+                                      description );
+                emit done();
+                return;
+            }
+        }
+    }
     emit done();
 }
 
-- 
GitLab