mirror of
https://gitdl.cn/https://github.com/chakralinux/desktop.git
synced 2025-01-24 02:22:13 +08:00
132 lines
5.6 KiB
Diff
132 lines
5.6 KiB
Diff
diff --git a/scripts/postinstall-functions/20-job-install-grub2 b/scripts/postinstall-functions/20-job-install-grub2
|
|
index fbc3b415ec246b3dbf4d911cf69bdd636f75de7e..199aefbfa60f401b67b4ed5ac096cfdfedf3d838 100644
|
|
--- a/scripts/postinstall-functions/20-job-install-grub2
|
|
+++ b/scripts/postinstall-functions/20-job-install-grub2
|
|
@@ -14,7 +14,14 @@ job_install_grub2()
|
|
echo "GRUB2___ >>>> mountpoint: ${mountpoint}"
|
|
echo "GRUB2___ >>>> target_boot: ${target_boot}"
|
|
echo "GRUB2___ >>>> device: ${_device}"
|
|
- chroot ${mountpoint} grub-install /dev/${_device} --no-floppy > /tmp/grub2.log 2>&1
|
|
+
|
|
+ _grub_efi_args=""
|
|
+ # system is efi
|
|
+ if [ -d /sys/firmware/efi ] && [ "$(ls -A /sys/firmware/efi)" ]; then
|
|
+ _grub_efi_args="--efi-directory=/boot"
|
|
+ fi
|
|
+
|
|
+ chroot ${mountpoint} grub-install /dev/${_device} --no-floppy $_grub_efi_args > /tmp/grub2.log 2>&1
|
|
|
|
if [ -e "/tmp/catalyst" ] ; then
|
|
msg "Adding nomodeset for catalyst to kernel line"
|
|
diff --git a/src/pages/partitionpage.cpp b/src/pages/partitionpage.cpp
|
|
index 22af3ff686a949464afdb0ebdc8839fcf5aabfb2..8d4baf805b76abe03f7cce278fbef16069220a5b 100644
|
|
--- a/src/pages/partitionpage.cpp
|
|
+++ b/src/pages/partitionpage.cpp
|
|
@@ -16,6 +16,7 @@
|
|
#include <QPainter>
|
|
#include <QtAlgorithms>
|
|
#include <QTimeLine>
|
|
+#include <QDir>
|
|
|
|
#include <KLineEdit>
|
|
#include <KMessageBox>
|
|
@@ -803,12 +804,18 @@ QTreeWidgetItem* PartitionPage::createItem(const Partition* p, Device *dev)
|
|
return item;
|
|
}
|
|
|
|
+bool isEFISystem()
|
|
+{
|
|
+ const QDir efiDir = QDir("/sys/firmware/efi");
|
|
+ return efiDir.exists() && efiDir.entryInfoList(QDir::NoDotAndDotDot|QDir::AllEntries|QDir::Hidden|QDir::System).count() != 0;
|
|
+}
|
|
+
|
|
void PartitionPage::aboutToGoToNext()
|
|
{
|
|
bool foundRoot = false;
|
|
bool unmount = false;
|
|
- bool bootPartition = false;
|
|
Device *bootDevice = NULL;
|
|
+ const Partition *bootPartition = NULL;
|
|
|
|
QTreeWidgetItemIterator it(m_ui->treeWidget);
|
|
while (*it) {
|
|
@@ -817,6 +824,10 @@ void PartitionPage::aboutToGoToNext()
|
|
if (text.startsWith('/')) {
|
|
const Partition *partition = (*it)->data(0, PARTITION_ROLE).value<const Partition*>();
|
|
Device *device = (*it)->data(0, DEVICE_ROLE).value<Device*>();
|
|
+ if (text == "/boot") {
|
|
+ bootDevice = device;
|
|
+ bootPartition = partition;
|
|
+ }
|
|
|
|
if (partition->isMounted() && unmount == false) {
|
|
KDialog *dialog = new KDialog(this, Qt::FramelessWindowHint);
|
|
@@ -890,8 +901,6 @@ void PartitionPage::aboutToGoToNext()
|
|
}
|
|
PMHandler::instance()->addSectorToMountList(device, partition->firstSector(), text);
|
|
}
|
|
- } else if (text == "/boot") {
|
|
- bootDevice = (*it)->data(0, DEVICE_ROLE).value<Device*>();
|
|
} else if (!text.isEmpty() && text != "None") {
|
|
KMessageBox::error(this, i18n("You have selected '%1' as a mountpoint, which is not valid. A valid mountpoint "
|
|
"always starts with '/' and represents a directory on disk", text),
|
|
@@ -908,26 +917,42 @@ void PartitionPage::aboutToGoToNext()
|
|
return;
|
|
}
|
|
|
|
- if (bootDevice && bootDevice->partitionTable()->type() == PartitionTable::gpt) {
|
|
- int f = 1;
|
|
-
|
|
- foreach(const Partition* p, bootDevice->partitionTable()->children()) {
|
|
- while(!(PartitionTable::flagName(static_cast<PartitionTable::Flag>(f))).isEmpty())
|
|
- {
|
|
- if (p->availableFlags() & f &&
|
|
- p->activeFlags() & f &&
|
|
- p->fileSystem().type() == FileSystem::Unknown) {
|
|
- bootPartition = true;
|
|
- break;
|
|
- }
|
|
- f <<= 1;
|
|
- }
|
|
+ bool isEFI = isEFISystem();
|
|
+ if (isEFI) {
|
|
+ // we kinds force people to use EFI partition as /boot
|
|
+ if (!bootPartition ||
|
|
+ !(bootPartition->availableFlags() & PartitionTable::FlagBoot) ||
|
|
+ !(bootPartition->activeFlags() & PartitionTable::FlagBoot)) {
|
|
+ KMessageBox::error(this, i18n("You need to set mount point of EFI Partition as /boot!"));
|
|
+ return;
|
|
}
|
|
|
|
- if (!bootPartition) {
|
|
- KMessageBox::error(this, i18n("When using a GPT Partition Table you need to have a unformatted partition with the bios_grub flag!"));
|
|
+ if (bootPartition->fileSystem().type() != FileSystem::Fat32) {
|
|
+ KMessageBox::error(this, i18n("File system of EFI Partition need to be fat32!"));
|
|
return;
|
|
}
|
|
+
|
|
+ // force to use gpt when it's EFI system
|
|
+ if (!bootDevice || bootDevice->partitionTable()->type() != PartitionTable::gpt) {
|
|
+ KMessageBox::error(this, i18n("When boot from EFI you need to use gpt partition table!"));
|
|
+ return;
|
|
+ }
|
|
+ } else {
|
|
+ bool biosGrubPartition = false;
|
|
+ if (bootDevice && bootDevice->partitionTable()->type() == PartitionTable::gpt) {
|
|
+ foreach(const Partition* p, bootDevice->partitionTable()->children()) {
|
|
+ if ((p->availableFlags() & PartitionTable::FlagBiosGrubBoot) &&
|
|
+ (p->activeFlags() & PartitionTable::FlagBiosGrubBoot)) {
|
|
+ biosGrubPartition = true;
|
|
+ break;
|
|
+ }
|
|
+ }
|
|
+
|
|
+ if (!biosGrubPartition) {
|
|
+ KMessageBox::error(this, i18n("When using a GPT Partition Table you need to have a unformatted partition with the bios_grub flag!"));
|
|
+ return;
|
|
+ }
|
|
+ }
|
|
}
|
|
|
|
s_partitionToMountPoint.clear();
|