From 572a273a33d05cb2811df32bccd361e3b99a7c61 Mon Sep 17 00:00:00 2001 From: cui-gaoleng <562344211@qq.com> Date: Fri, 8 Nov 2024 02:44:45 +0800 Subject: [PATCH 4/4] modules Commit without .png, .svg, and .svgz files --- src/modules/bootloader/bootloader.conf | 8 +- src/modules/bootloader/main.py | 45 +- src/modules/fstab/main.py | 0 src/modules/initcpiocfg/initcpiocfg.conf | 2 +- src/modules/initramfscfg/encrypt_hook | 0 src/modules/initramfscfg/encrypt_hook_nokey | 0 src/modules/keyboard/KeyboardPage.cpp | 39 +- src/modules/keyboard/KeyboardPage.ui | 4 +- src/modules/locale/Config.cpp | 14 + src/modules/locale/Config.h | 4 + src/modules/locale/LocalePage.cpp | 54 +- src/modules/locale/LocalePage.h | 1 + src/modules/locale/SetTimezoneJob.cpp | 4 + src/modules/locale/locale.conf | 6 +- src/modules/localeq/localeq.conf | 2 +- src/modules/mount/mount.conf | 9 + src/modules/packagechooser/Config.cpp | 2 +- .../packagechooser/PackageChooserPage.cpp | 24 +- .../packagechooser/packagechooser.conf | 41 +- src/modules/packagechooser/packagechooser.qrc | 6 + src/modules/packages/main.py | 132 +++- src/modules/packages/packages.conf | 37 +- src/modules/partition/PartitionViewStep.cpp | 3 +- src/modules/partition/gui/BootInfoWidget.cpp | 10 +- src/modules/partition/gui/ChoicePage.cpp | 10 +- .../partition/gui/DeviceInfoWidget.cpp | 13 +- src/modules/partition/gui/EncryptWidget.cpp | 2 +- src/modules/summary/SummaryPage.cpp | 9 +- src/modules/umount/UmountJob.cpp | 23 + src/modules/unpackfs/main.py | 82 +- src/modules/unpackfs/unpackfs.conf | 12 +- src/modules/users/UsersPage.cpp | 2 +- src/modules/users/page_usersetup.ui | 158 ++-- src/modules/users/users.conf | 2 +- src/modules/welcome/Config.cpp | 3 +- src/modules/welcome/WelcomePage.cpp | 143 ++-- src/modules/welcome/WelcomePage.ui | 73 +- .../welcome/checker/ResultsListWidget.cpp | 20 +- src/modules/welcome/welcome.conf | 6 +- src/modules/welcome/welcome.qrc | 10 +- src/modules/welcomeq/welcomeq.conf | 2 +- 43 files changed, 1392 insertions(+), 340 deletions(-) mode change 100755 => 100644 src/modules/fstab/main.py mode change 100755 => 100644 src/modules/initramfscfg/encrypt_hook mode change 100755 => 100644 src/modules/initramfscfg/encrypt_hook_nokey diff --git a/src/modules/bootloader/bootloader.conf b/src/modules/bootloader/bootloader.conf index 9679f66..acaf424 100644 --- a/src/modules/bootloader/bootloader.conf +++ b/src/modules/bootloader/bootloader.conf @@ -41,10 +41,10 @@ kernelParams: [ "quiet" ] # GRUB functionality (notably grub-probe) to work. As needed, you may use # complete paths like `/usr/bin/efibootmgr` for the executables. # -grubInstall: "grub-install" -grubMkconfig: "grub-mkconfig" -grubCfg: "/boot/grub/grub.cfg" -grubProbe: "grub-probe" +grubInstall: "grub2-install" +grubMkconfig: "grub2-mkconfig" +grubCfg: "/boot/grub2/grub.cfg" +grubProbe: "grub2-probe" efiBootMgr: "efibootmgr" # Optionally set the bootloader ID to use for EFI. This is passed to diff --git a/src/modules/bootloader/main.py b/src/modules/bootloader/main.py index 0a9e965..570fc87 100644 --- a/src/modules/bootloader/main.py +++ b/src/modules/bootloader/main.py @@ -25,7 +25,7 @@ import os import re import shutil import subprocess - +import platform import libcalamares from libcalamares.utils import check_target_env_call @@ -567,7 +567,6 @@ def get_grub_efi_parameters(): set for the current machine. May return unsuitable values if the host architecture is unknown (e.g. defaults to x86_64). """ - import platform efi_bitness = efi_word_size() cpu_type = platform.machine() @@ -594,6 +593,8 @@ def run_grub_mkconfig(partitions, output_file): :param output_file: A string containing the path to the generating grub config file :return: """ + fw_type = libcalamares.globalstorage.value("firmwareType") + efi_directory = libcalamares.globalstorage.value("efiSystemPartition") # zfs needs an environment variable set for grub-mkconfig if any([is_zfs_root(partition) for partition in partitions]): @@ -602,7 +603,14 @@ def run_grub_mkconfig(partitions, output_file): else: # The input file /etc/default/grub should already be filled out by the # grubcfg job module. - check_target_env_call([libcalamares.job.configuration["grubMkconfig"], "-o", output_file]) + if fw_type == "efi": + assert efi_directory is not None + efi_bootloader_id = efi_label(efi_directory) + check_target_env_call([libcalamares.job.configuration["grubMkconfig"], + "-o", os.path.join(efi_directory, "EFI", + efi_bootloader_id, "grub.cfg")]) + else: + check_target_env_call([libcalamares.job.configuration["grubMkconfig"], "-o", output_file]) def run_grub_install(fw_type, partitions, efi_directory): @@ -614,6 +622,9 @@ def run_grub_install(fw_type, partitions, efi_directory): :param efi_directory: The path of the efi directory relative to the root of the install :return: """ + cpu_type = platform.machine() + + installation_root_path = libcalamares.globalstorage.value("rootMountPoint") is_zfs = any([is_zfs_root(partition) for partition in partitions]) @@ -631,11 +642,29 @@ def run_grub_install(fw_type, partitions, efi_directory): + " --target=" + efi_target + " --efi-directory=" + efi_directory + " --bootloader-id=" + efi_bootloader_id + " --force"]) else: - check_target_env_call([libcalamares.job.configuration["grubInstall"], - "--target=" + efi_target, - "--efi-directory=" + efi_directory, - "--bootloader-id=" + efi_bootloader_id, - "--force"]) + install_efi_directory = installation_root_path + efi_directory + + efi_disk = subprocess.check_output([ + libcalamares.job.configuration["grubProbe"], + "-t", "disk", "--device-map=", install_efi_directory]).decode("ascii").strip() + if cpu_type == "aarch64": + check_target_env_call([ + "efibootmgr", + "--create", + "--disk", efi_disk, + "--part", "1", + "--label", "shim", + "--loader", "/EFI/openEuler/shimaa64.efi" + ]) + else: + check_target_env_call([ + "efibootmgr", + "--create", + "--disk", efi_disk, + "--part", "1", + "--label", "shim", + "--loader", "/EFI/openEuler/shimx64.efi" + ]) else: assert efi_directory is None if libcalamares.globalstorage.value("bootLoader") is None: diff --git a/src/modules/fstab/main.py b/src/modules/fstab/main.py old mode 100755 new mode 100644 diff --git a/src/modules/initcpiocfg/initcpiocfg.conf b/src/modules/initcpiocfg/initcpiocfg.conf index a660393..549157c 100644 --- a/src/modules/initcpiocfg/initcpiocfg.conf +++ b/src/modules/initcpiocfg/initcpiocfg.conf @@ -35,4 +35,4 @@ hooks: # does not match the target in a useful way. If unset or # empty, defaults to /etc/mkinitcpio.conf # -source: "/etc/mkinitcpio.conf" +source: "/etc/dracut.conf" diff --git a/src/modules/initramfscfg/encrypt_hook b/src/modules/initramfscfg/encrypt_hook old mode 100755 new mode 100644 diff --git a/src/modules/initramfscfg/encrypt_hook_nokey b/src/modules/initramfscfg/encrypt_hook_nokey old mode 100755 new mode 100644 diff --git a/src/modules/keyboard/KeyboardPage.cpp b/src/modules/keyboard/KeyboardPage.cpp index dbb80c6..3f06158 100644 --- a/src/modules/keyboard/KeyboardPage.cpp +++ b/src/modules/keyboard/KeyboardPage.cpp @@ -43,13 +43,14 @@ LayoutItem::~LayoutItem() {} KeyboardPage::KeyboardPage( Config* config, QWidget* parent ) : QWidget( parent ) , ui( new Ui::Page_Keyboard ) - , m_keyboardPreview( new KeyBoardPreview( this ) ) + , m_keyboardPreview( nullptr ) , m_config( config ) { ui->setupUi( this ); - + this->setContentsMargins(50,0,50,0); // Keyboard Preview - ui->KBPreviewLayout->addWidget( m_keyboardPreview ); + // ui->KBPreviewLayout->addWidget( m_keyboardPreview ); + { auto* model = config->keyboardModels(); @@ -92,27 +93,27 @@ KeyboardPage::KeyboardPage( Config* config, QWidget* parent ) &QItemSelectionModel::currentChanged, [ this ]( const QModelIndex& current ) { m_config->keyboardLayouts()->setCurrentIndex( current.row() ); } ); - connect( config->keyboardLayouts(), - &KeyboardLayoutModel::currentIndexChanged, - [ this ]( int index ) - { - ui->layoutSelector->setCurrentIndex( m_config->keyboardLayouts()->index( index ) ); - m_keyboardPreview->setLayout( m_config->keyboardLayouts()->key( index ) ); - m_keyboardPreview->setVariant( - m_config->keyboardVariants()->key( m_config->keyboardVariants()->currentIndex() ) ); - } ); + // connect( config->keyboardLayouts(), + // &KeyboardLayoutModel::currentIndexChanged, + // [ this ]( int index ) + // { + // ui->layoutSelector->setCurrentIndex( m_config->keyboardLayouts()->index( index ) ); + // m_keyboardPreview->setLayout( m_config->keyboardLayouts()->key( index ) ); + // m_keyboardPreview->setVariant( + // m_config->keyboardVariants()->key( m_config->keyboardVariants()->currentIndex() ) ); + // } ); connect( ui->variantSelector->selectionModel(), &QItemSelectionModel::currentChanged, [ this ]( const QModelIndex& current ) { m_config->keyboardVariants()->setCurrentIndex( current.row() ); } ); - connect( config->keyboardVariants(), - &KeyboardVariantsModel::currentIndexChanged, - [ this ]( int index ) - { - ui->variantSelector->setCurrentIndex( m_config->keyboardVariants()->index( index ) ); - m_keyboardPreview->setVariant( m_config->keyboardVariants()->key( index ) ); - } ); + // connect( config->keyboardVariants(), + // &KeyboardVariantsModel::currentIndexChanged, + // [ this ]( int index ) + // { + // ui->variantSelector->setCurrentIndex( m_config->keyboardVariants()->index( index ) ); + // m_keyboardPreview->setVariant( m_config->keyboardVariants()->key( index ) ); + // } ); connect( ui->groupSelector, QOverload< int >::of( &QComboBox::currentIndexChanged ), diff --git a/src/modules/keyboard/KeyboardPage.ui b/src/modules/keyboard/KeyboardPage.ui index e131e5c..1d6afbf 100644 --- a/src/modules/keyboard/KeyboardPage.ui +++ b/src/modules/keyboard/KeyboardPage.ui @@ -45,9 +45,9 @@ SPDX-License-Identifier: GPL-3.0-or-later - + diff --git a/src/modules/locale/Config.cpp b/src/modules/locale/Config.cpp index 8fa17a7..0d70ff3 100644 --- a/src/modules/locale/Config.cpp +++ b/src/modules/locale/Config.cpp @@ -305,6 +305,7 @@ Config::setCurrentLocation( const Calamares::Locale::TimeZoneData* location ) m_selectedLocaleConfiguration.lc_identification = newLocale.lc_identification; emit currentLCStatusChanged( currentLCStatus() ); + emit currentZoneChanged( currentTimeZoneStatus() ); } emit currentLocationChanged( m_currentLocation ); // Other signals come from the LocationChanged signal @@ -370,6 +371,7 @@ Config::setLCLocaleExplicitly( const QString& locale ) m_selectedLocaleConfiguration.explicit_lc = true; emit currentLCStatusChanged( currentLCStatus() ); + emit currentZoneChanged( currentTimeZoneStatus() ); emit currentLCCodeChanged( currentLCCode() ); } @@ -424,6 +426,18 @@ Config::currentLCStatus() const .arg( localeLabel( m_selectedLocaleConfiguration.lc_numeric ) ); } +QString +Config::currentTimeZoneStatus() const +{ + QString zone = m_currentLocation->zone(); + if(zone == "Hong_Kong(China)") + { + zone = "Hong Kong(China)"; + } + return tr("The timezone will be set to %1.","@info") + .arg( zone ); +} + QString Config::prettyStatus() const { diff --git a/src/modules/locale/Config.h b/src/modules/locale/Config.h index a26d25a..6a8bea1 100644 --- a/src/modules/locale/Config.h +++ b/src/modules/locale/Config.h @@ -34,6 +34,7 @@ class Config : public QObject // Status are complete, human-readable, messages Q_PROPERTY( QString currentLocationStatus READ currentLocationStatus NOTIFY currentLanguageStatusChanged ) + Q_PROPERTY( QString currentLocationStatus READ currentLocationStatus NOTIFY currentZoneChanged) Q_PROPERTY( QString currentLanguageStatus READ currentLanguageStatus NOTIFY currentLanguageStatusChanged ) Q_PROPERTY( QString currentLCStatus READ currentLCStatus NOTIFY currentLCStatusChanged ) // Name are shorter human-readable names @@ -72,6 +73,8 @@ public: /// The human-readable summary of what the module will do QString prettyStatus() const; + QString currentTimeZoneStatus() const; + // A long list of locale codes (e.g. en_US.UTF-8) const QStringList& supportedLocales() const { return m_localeGenLines; } // All the regions (Africa, America, ...) @@ -139,6 +142,7 @@ signals: void currentLCCodeChanged( const QString& ) const; void currentTimezoneCodeChanged( const QString& ) const; void currentTimezoneNameChanged( const QString& ) const; + void currentZoneChanged( const QString&) const; private: /// A list of supported locale identifiers (e.g. "en_US.UTF-8") diff --git a/src/modules/locale/LocalePage.cpp b/src/modules/locale/LocalePage.cpp index e74373a..0568067 100644 --- a/src/modules/locale/LocalePage.cpp +++ b/src/modules/locale/LocalePage.cpp @@ -31,20 +31,21 @@ LocalePage::LocalePage( Config* config, QWidget* parent ) , m_blockTzWidgetSet( false ) { QBoxLayout* mainLayout = new QVBoxLayout; - - QBoxLayout* tzwLayout = new QHBoxLayout; - m_tzWidget = new TimeZoneWidget( m_config->zonesModel(), this ); - tzwLayout->addStretch(); - tzwLayout->addWidget( m_tzWidget ); - tzwLayout->addStretch(); + mainLayout->setContentsMargins(50,0,50,0); + //QBoxLayout* tzwLayout = new QHBoxLayout; + //m_tzWidget = new TimeZoneWidget( m_config->zonesModel(), this ); + //tzwLayout->addStretch(); + //tzwLayout->addWidget( m_tzWidget ); + //tzwLayout->addStretch(); // Adjust for margins and spacing in this page - m_tzWidget->setMinimumHeight( m_tzWidget->minimumHeight() + 12 ); // 2 * spacing + //m_tzWidget->setMinimumHeight( m_tzWidget->minimumHeight() + 12 ); // 2 * spacing - QBoxLayout* zoneAndRegionLayout = new QHBoxLayout; + QBoxLayout* zoneAndRegionLayout = new QVBoxLayout; m_regionLabel = new QLabel( this ); zoneAndRegionLayout->addWidget( m_regionLabel ); m_regionCombo = new QComboBox( this ); + m_regionCombo->setFixedSize(400,30); zoneAndRegionLayout->addWidget( m_regionCombo ); m_regionCombo->setSizePolicy( QSizePolicy::Expanding, QSizePolicy::Preferred ); m_regionLabel->setBuddy( m_regionCombo ); @@ -52,9 +53,11 @@ LocalePage::LocalePage( Config* config, QWidget* parent ) zoneAndRegionLayout->addSpacing( 20 ); m_zoneLabel = new QLabel( this ); + zoneAndRegionLayout->addWidget( m_zoneLabel ); m_zoneCombo = new QComboBox( this ); + m_zoneCombo->setFixedSize(400,30); m_zoneCombo->setSizePolicy( QSizePolicy::Expanding, QSizePolicy::Preferred ); zoneAndRegionLayout->addWidget( m_zoneCombo ); m_zoneLabel->setBuddy( m_zoneCombo ); @@ -65,10 +68,17 @@ LocalePage::LocalePage( Config* config, QWidget* parent ) m_localeLabel->setWordWrap( true ); m_localeLabel->setSizePolicy( QSizePolicy::Expanding, QSizePolicy::Preferred ); localeLayout->addWidget( m_localeLabel ); - m_localeChangeButton = new QPushButton( this ); m_localeChangeButton->setSizePolicy( QSizePolicy::Preferred, QSizePolicy::Preferred ); localeLayout->addWidget( m_localeChangeButton ); + localeLayout->addSpacing(20); + + QBoxLayout* timezoneLayout = new QHBoxLayout; + m_timezoneLabel = new QLabel( this ); + m_timezoneLabel->setWordWrap( true ); + m_timezoneLabel->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Preferred); + timezoneLayout->addWidget( m_timezoneLabel ); + timezoneLayout->addSpacing( 20 ); QBoxLayout* formatsLayout = new QHBoxLayout; m_formatsLabel = new QLabel( this ); @@ -79,16 +89,22 @@ LocalePage::LocalePage( Config* config, QWidget* parent ) m_formatsChangeButton = new QPushButton( this ); m_formatsChangeButton->setSizePolicy( QSizePolicy::Preferred, QSizePolicy::Preferred ); formatsLayout->addWidget( m_formatsChangeButton ); - - mainLayout->addLayout( tzwLayout ); + formatsLayout->addSpacing(20); + //mainLayout->addLayout( tzwLayout ); mainLayout->addStretch(); mainLayout->addLayout( zoneAndRegionLayout ); mainLayout->addStretch(); mainLayout->addLayout( localeLayout ); + mainLayout->addSpacing(20); mainLayout->addLayout( formatsLayout ); - setMinimumWidth( m_tzWidget->width() ); + mainLayout->addSpacing(20); + mainLayout->addLayout( timezoneLayout ); + mainLayout->addStretch(); + //setMinimumWidth( m_tzWidget->width() ); setLayout( mainLayout ); + m_localeChangeButton->hide(); + m_formatsChangeButton->hide(); // Set up the location before connecting signals, to avoid a signal // storm as various parts interact. { @@ -98,18 +114,19 @@ LocalePage::LocalePage( Config* config, QWidget* parent ) zones->setRegion( location->region() ); m_regionCombo->setModel( regions ); m_zoneCombo->setModel( zones ); - m_tzWidget->setCurrentLocation( location ); + //m_tzWidget->setCurrentLocation( location ); locationChanged( location ); // doesn't inform TZ widget } connect( config, &Config::currentLCStatusChanged, m_formatsLabel, &QLabel::setText ); connect( config, &Config::currentLanguageStatusChanged, m_localeLabel, &QLabel::setText ); - connect( config, &Config::currentLocationChanged, m_tzWidget, &TimeZoneWidget::setCurrentLocation ); + connect( config, &Config::currentZoneChanged, m_timezoneLabel , &QLabel::setText); + //connect( config, &Config::currentLocationChanged, m_tzWidget, &TimeZoneWidget::setCurrentLocation ); connect( config, &Config::currentLocationChanged, this, &LocalePage::locationChanged ); - connect( m_tzWidget, - &TimeZoneWidget::locationChanged, - config, - QOverload< const Calamares::Locale::TimeZoneData* >::of( &Config::setCurrentLocation ) ); + // connect( m_tzWidget, + // &TimeZoneWidget::locationChanged, + // config, + // QOverload< const Calamares::Locale::TimeZoneData* >::of( &Config::setCurrentLocation ) ); connect( m_regionCombo, QOverload< int >::of( &QComboBox::currentIndexChanged ), this, &LocalePage::regionChanged ); connect( m_zoneCombo, QOverload< int >::of( &QComboBox::currentIndexChanged ), this, &LocalePage::zoneChanged ); @@ -133,6 +150,7 @@ LocalePage::updateLocaleLabels() m_formatsChangeButton->setText( tr( "&Change…", "@button" ) ); m_localeLabel->setText( m_config->currentLanguageStatus() ); m_formatsLabel->setText( m_config->currentLCStatus() ); + m_timezoneLabel->setText( m_config->currentTimeZoneStatus()) ; } diff --git a/src/modules/locale/LocalePage.h b/src/modules/locale/LocalePage.h index 66502e6..b5fb06d 100644 --- a/src/modules/locale/LocalePage.h +++ b/src/modules/locale/LocalePage.h @@ -58,6 +58,7 @@ private: QPushButton* m_localeChangeButton; QLabel* m_formatsLabel; QPushButton* m_formatsChangeButton; + QLabel* m_timezoneLabel; bool m_blockTzWidgetSet; diff --git a/src/modules/locale/SetTimezoneJob.cpp b/src/modules/locale/SetTimezoneJob.cpp index 3d88bd0..2a586f7 100644 --- a/src/modules/locale/SetTimezoneJob.cpp +++ b/src/modules/locale/SetTimezoneJob.cpp @@ -50,6 +50,10 @@ SetTimezoneJob::exec() QString localtimeSlink( "/etc/localtime" ); QString zoneinfoPath( "/usr/share/zoneinfo" ); + if(m_zone.contains("(China)")) + { + m_zone.remove("(China)"); + } zoneinfoPath.append( QDir::separator() + m_region ); zoneinfoPath.append( QDir::separator() + m_zone ); diff --git a/src/modules/locale/locale.conf b/src/modules/locale/locale.conf index 4463f7a..028071f 100644 --- a/src/modules/locale/locale.conf +++ b/src/modules/locale/locale.conf @@ -17,8 +17,8 @@ # Note that useSystemTimezone and GeoIP settings can change the # starting time zone. # -region: "America" -zone: "New_York" +region: "Asia" +zone: "Beijing" # Instead of using *region* and *zone* specified above, # you can use the system's notion of the timezone, instead. @@ -117,7 +117,7 @@ zone: "New_York" # Also, note the analogous feature in src/modules/welcome/welcome.conf. # geoip: - style: "json" + style: "none" url: "https://geoip.kde.org/v1/calamares" selector: "" # leave blank for the default diff --git a/src/modules/localeq/localeq.conf b/src/modules/localeq/localeq.conf index bb2a7e8..35a819a 100644 --- a/src/modules/localeq/localeq.conf +++ b/src/modules/localeq/localeq.conf @@ -95,6 +95,6 @@ zone: "New_York" # Also, note the analogous feature in src/modules/welcome/welcome.conf. # geoip: - style: "json" + style: "none" url: "https://geoip.kde.org/v1/calamares" selector: "" # leave blank for the default diff --git a/src/modules/mount/mount.conf b/src/modules/mount/mount.conf index da95395..bf06fe9 100644 --- a/src/modules/mount/mount.conf +++ b/src/modules/mount/mount.conf @@ -28,12 +28,21 @@ extraMounts: - device: /dev mountPoint: /dev options: [ bind ] + - device: /dev/pts + mountPoint: /dev/pts + options: [ bind ] - device: tmpfs fs: tmpfs mountPoint: /run - device: /run/udev mountPoint: /run/udev options: [ bind ] + - device: /run/initramfs + mountPoint: /run/initramfs + options: [ bind ] + - device: /run/initramfs/live + mountPoint: /run/initramfs/live + options: [ bind ] - device: efivarfs fs: efivarfs mountPoint: /sys/firmware/efi/efivars diff --git a/src/modules/packagechooser/Config.cpp b/src/modules/packagechooser/Config.cpp index 642311b..0abeafa 100644 --- a/src/modules/packagechooser/Config.cpp +++ b/src/modules/packagechooser/Config.cpp @@ -238,7 +238,7 @@ Config::setPackageChoice( const QString& packageChoice ) QString Config::prettyName() const { - return m_stepName ? m_stepName->get() : tr( "Packages" ); + return tr( "Packages"); } QString diff --git a/src/modules/packagechooser/PackageChooserPage.cpp b/src/modules/packagechooser/PackageChooserPage.cpp index 44a570d..53bd82a 100644 --- a/src/modules/packagechooser/PackageChooserPage.cpp +++ b/src/modules/packagechooser/PackageChooserPage.cpp @@ -16,7 +16,8 @@ #include "utils/Retranslator.h" #include - +#include +#include PackageChooserPage::PackageChooserPage( PackageChooserMode mode, QWidget* parent ) : QWidget( parent ) , ui( new Ui::PackageChooserPage ) @@ -29,7 +30,7 @@ PackageChooserPage::PackageChooserPage( PackageChooserMode mode, QWidget* parent ui->setupUi( this ); CALAMARES_RETRANSLATE( updateLabels(); ); - + this->setContentsMargins(50,15,50,0); switch ( mode ) { case PackageChooserMode::Optional: @@ -69,7 +70,24 @@ PackageChooserPage::currentChanged( const QModelIndex& index ) } else { - ui->productScreenshot->setPixmap( currentScreenshot ); + QVariant screenshotVariant = model->data( index, PackageListModel::ScreenshotRole ); + QString imagePath = screenshotVariant.toString(); + QPixmap currentScreenshot; + if(imagePath.toLower().endsWith(".svg")){ + QSvgRenderer svgRenderer(imagePath); + if(svgRenderer.isValid()){ + currentScreenshot = QPixmap(svgRenderer.defaultSize()); + currentScreenshot.fill(Qt::transparent); + QPainter painter(¤tScreenshot); + svgRenderer.render(&painter); + painter.end(); + } + } + else{ + ui->productScreenshot->setPixmap( model->data( index, PackageListModel::ScreenshotRole ).value< QPixmap >() ); + } + + } } } diff --git a/src/modules/packagechooser/packagechooser.conf b/src/modules/packagechooser/packagechooser.conf index 5b40aeb..e7b9b00 100644 --- a/src/modules/packagechooser/packagechooser.conf +++ b/src/modules/packagechooser/packagechooser.conf @@ -9,7 +9,7 @@ # Possible modes are "optional", "required" (for zero-or-one or exactly-one) # or "optionalmultiple", "requiredmultiple" (for zero-or-more # or one-or-more). -mode: required +mode: optionalmultiple # Software installation method: # @@ -46,7 +46,7 @@ mode: required # are no jobs that this module provides. You should put **other** # modules, either *contextualprocess* or *packages* or some custom # module, in the `exec` section to do the actual work. -method: legacy +method: packages # Human-visible strings in this module. These are all optional. @@ -150,23 +150,32 @@ labels: items: - id: "" # packages: [] # This item installs no packages - name: "No Desktop" + name: "Minimal Install" name[nl]: "Geen desktop" + name[zh]: "最小安装" description: "Please pick a desktop environment from the list. If you don't want to install a desktop, that's fine, your system will start up in text-only mode and you can install a desktop environment later." description[nl]: "Kies eventueel een desktop-omgeving uit deze lijst. Als u geen desktop-omgeving wenst te gebruiken, kies er dan geen. In dat geval start het systeem straks op in tekst-modus en kunt u later alsnog een desktop-omgeving installeren." - screenshot: ":/images/no-selection.png" - - id: kde - packages: [ kde-frameworks, kde-plasma, kde-gear ] - name: Plasma Desktop - description: "KDE Plasma Desktop, simple by default, a clean work area for real-world usage which intends to stay out of your way. Plasma is powerful when needed, enabling the user to create the workflow that makes them more effective to complete their tasks." - screenshot: ":/images/kde.png" + description[zh]: "请选择一个桌面环境。如果您不想安装桌面环境也没关系,您可以稍后再为系统安装桌面环境。" + screenshot: ":/images/Minimal-Install.png" + # - id: kde + # packages: [ kde-frameworks, kde-plasma, kde-gear ] + # name: Plasma Desktop + # description: "KDE Plasma Desktop, simple by default, a clean work area for real-world usage which intends to stay out of your way. Plasma is powerful when needed, enabling the user to create the workflow that makes them more effective to complete their tasks." + # screenshot: ":/images/Plasma.png" - id: gnome - packages: [ gnome-all ] - name: GNOME + packages: [ checkpolicy, code, xorg-*, dejavu-fonts, liberation-fonts, gnu-*-fonts, google-*-fonts, adwaita-icon-theme, atk, atkmm, at-spi2-atk, at-spi2-core, baobab, abattis-cantarell-fonts, cheese, clutter, clutter-gst3, clutter-gtk, cogl, dconf, dconf-editor, devhelp, eog, epiphany, evince, evolution-data-server, file-roller, folks, gcab, gcr, gdk-pixbuf2, gdm, gedit, geocode-glib, gfbgraph, gjs, glib2, glibmm24, glib-networking, gmime30, gnome-autoar, gnome-backgrounds, gnome-bluetooth, gnome-builder, gnome-calculator, gnome-calendar, gnome-characters, gnome-clocks, gnome-color-manager, gnome-contacts, gnome-control-center, gnome-desktop3, gnome-disk-utility, gnome-font-viewer, gnome-getting-started-docs, gnome-initial-setup, gnome-keyring, gnome-logs, gnome-menus, gnome-music, gnome-online-accounts, gnome-online-miners, gnome-photos, gnome-remote-desktop, gnome-screenshot, gnome-session, gnome-settings-daemon, gnome-shell, gnome-shell-extensions, gnome-software, gnome-system-monitor, gnome-terminal, gnome-tour, gnome-user-docs, gnome-user-share, gnome-video-effects, gnome-weather, gobject-introspection, gom, grilo, grilo-plugins, gsettings-desktop-schemas, gsound, gspell, gssdp, gtk3, gtk4, gtk-doc, gtkmm30, gtksourceview4, gtk-vnc2, gupnp, gupnp-av, gupnp-dlna, gvfs, json-glib, libchamplain, libdazzle, libgdata, libgee, libgnomekbd, libgsf, libgtop2, libgweather, libgxps, libhandy, libmediaart, libnma, libnotify, libpeas, librsvg2, libsecret, libsigc++20, libsoup, mm-common, mutter, nautilus, orca, pango, pangomm, libphodav, python3-pyatspi, python3-gobject, rest, rygel, simple-scan, sushi, sysprof, tepl, totem, totem-pl-parser, tracker3, tracker3-miners, vala, vte291, yelp, yelp-tools, yelp-xsl, zenity, devstation-config, ibus-libpinyin ] + name: DevStation + name[zh]: DevStation description: GNU Networked Object Modeling Environment Desktop + description[zh]: Devstation系统桌面 screenshot: ":/images/gnome.png" - - id: calamares - appdata: ../io.calamares.calamares.appdata.xml - screenshot: ":/images/calamares.png" - - id: kate - appstream: org.kde.kwrite.desktop + #- id: ukui + # packages: [ ukui ] + # name: UKUI + # description: Linux Desktop + # screenshot: ":/images/UKUI.png" + # - id: calamares + # appdata: ../io.calamares.calamares.appdata.xml + # screenshot: ":/images/calamares.png" + # - id: kate + # appstream: org.kde.kwrite.desktop diff --git a/src/modules/packagechooser/packagechooser.qrc b/src/modules/packagechooser/packagechooser.qrc index 3b9c96a..05944ce 100644 --- a/src/modules/packagechooser/packagechooser.qrc +++ b/src/modules/packagechooser/packagechooser.qrc @@ -2,5 +2,11 @@ images/no-selection.png images/calamares.png + + images/gnome.png + + + + images/Minimal-Install.png diff --git a/src/modules/packages/main.py b/src/modules/packages/main.py index d2a2552..8c165e8 100644 --- a/src/modules/packages/main.py +++ b/src/modules/packages/main.py @@ -123,7 +123,7 @@ class PackageManager(metaclass=abc.ABCMeta): if script != "": check_target_env_call(script.split(" ")) - def install_package(self, packagedata, from_local=False): + def install_package(self, packagedata, from_local=False, options=None): """ Install a package from a single entry in the install list. This can be either a single package name, or an object @@ -135,11 +135,18 @@ class PackageManager(metaclass=abc.ABCMeta): see install.from_local """ if isinstance(packagedata, str): - self.install([packagedata], from_local=from_local) + self.install([packagedata], from_local=from_local, options=options) else: self.run(packagedata["pre-script"]) - self.install([packagedata["package"]], from_local=from_local) - self.run(packagedata["post-script"]) + if isinstance(packagedata["package"], list): + self.install(packagedata["package"], from_local=from_local, options=options) + else: + self.install([packagedata["package"]], from_local=from_local, options=options) + if isinstance(packagedata["post-script"], list): + for script in packagedata["post-script"]: + self.run(script) + else: + self.run(packagedata["post-script"]) def remove_package(self, packagedata): """ @@ -155,9 +162,15 @@ class PackageManager(metaclass=abc.ABCMeta): else: self.run(packagedata["pre-script"]) self.remove([packagedata["package"]]) - self.run(packagedata["post-script"]) + if isinstance(packagedata["post-script"], list): + for script in packagedata["post-script"]: + self.run(script) + else: + self.run(packagedata["post-script"]) + - def operation_install(self, package_list, from_local=False): + + def operation_install(self, package_list, from_local=False, options=None): """ Installs the list of packages named in @p package_list . These can be strings -- plain package names -- or @@ -172,11 +185,14 @@ class PackageManager(metaclass=abc.ABCMeta): NOTE: exceptions are expected to leave this method, to indicate failure of the installation. """ + if options is None: + options = [] + if all([isinstance(x, str) for x in package_list]): - self.install(package_list, from_local=from_local) + self.install(package_list, from_local=from_local, options=options) else: for package in package_list: - self.install_package(package, from_local=from_local) + self.install_package(package, from_local=from_local, options=options) def operation_try_install(self, package_list): """ @@ -286,8 +302,10 @@ class PMDnf(PackageManager): """ backend = "dnf" - def install(self, pkgs, from_local=False): - check_target_env_call(["dnf-3", "-y", "install"] + pkgs) + def install(self, pkgs, from_local=False, options=None): + if options is None: + options = [] + check_target_env_call(["dnf-3", "-y", "install"] + options + pkgs) def remove(self, pkgs): # ignore the error code for now because dnf thinks removing a @@ -651,6 +669,55 @@ def subst_locale(plist): locale is 'en' (e.g. English, US) then these localized packages are dropped from the list. + @param plist: list[str|dict] + Candidate packages to install. + @return: list[str|dict] + """ + locale = libcalamares.globalstorage.value("locale") + if not locale: + # It is possible to skip the locale-setting entirely. + # Then pretend it is "en", so that {LOCALE}-decorated + # package names are removed from the list. + locale = "en" + + ret = [] + for packagedata in plist: + if isinstance(packagedata, str): + packagename = packagedata + else: + if isinstance(packagedata["package"], list): + packagename = [ + Template(pkg).safe_substitute(LOCALE=locale) + if locale != "en" or 'LOCALE' not in pkg else None + for pkg in packagedata["package"] + ] + packagename = [pkg for pkg in packagename if pkg is not None] + else: + packagename = packagedata["package"] + if locale != "en": + packagename = Template(packagename).safe_substitute(LOCALE=locale) + elif 'LOCALE' in packagename: + packagename = None + + if packagename: + if isinstance(packagedata, str): + packagedata = packagename + else: + packagedata["package"] = packagename + + ret.append(packagedata) + + return ret + + +def subst_locale_orig(plist): + """ + Returns a locale-aware list of packages, based on @p plist. + Package names that contain LOCALE are localized with the + BCP47 name of the chosen system locale; if the system + locale is 'en' (e.g. English, US) then these localized + packages are dropped from the list. + @param plist: list[str|dict] Candidate packages to install. @return: list[str|dict] @@ -688,7 +755,24 @@ def subst_locale(plist): return ret -def run_operations(pkgman, entry): +def handle_packagechooser(entry): + """ + Handle special logic for entries with source "packagechooser@packagechooser". + Modifies the entry to include specific pre- and post-scripts. + + :param entry: dict + The operation entry to process. + """ + if "install" in entry: + item = { + "package": entry["install"], + "pre-script": "", + "post-script": ["/bin/bash /etc/add_selinux_policy.sh", "systemctl enable gdm", "systemctl set-default graphical.target"] + } + entry["install"] = [item] + + +def run_operations(pkgman, entry, options): """ Call package manager with suitable parameters for the given package actions. @@ -705,24 +789,28 @@ def run_operations(pkgman, entry): """ global group_packages, completed_packages, mode_packages + if "source" in entry and entry["source"] == "packagechooser@packagechooser": + handle_packagechooser(entry) + for key in entry.keys(): package_list = subst_locale(entry[key]) group_packages = len(package_list) + if key == "install": _change_mode(INSTALL) - pkgman.operation_install(package_list) + pkgman.operation_install(package_list, options=options) elif key == "try_install": _change_mode(INSTALL) - pkgman.operation_try_install(package_list) + pkgman.operation_try_install(package_list, options=options) elif key == "remove": _change_mode(REMOVE) - pkgman.operation_remove(package_list) + pkgman.operation_remove(package_list, options=options) elif key == "try_remove": _change_mode(REMOVE) - pkgman.operation_try_remove(package_list) + pkgman.operation_try_remove(package_list, options=options) elif key == "localInstall": _change_mode(INSTALL) - pkgman.operation_install(package_list, from_local=True) + pkgman.operation_install(package_list, from_local=True, options=options) elif key == "source": libcalamares.utils.debug("Package-list from {!s}".format(entry[key])) else: @@ -796,12 +884,21 @@ def run(): if not total_packages: # Avoids potential divide-by-zero in progress reporting return None + + options = [] + for entry in operations: + option = entry.get("options", []) + if isinstance(option, list): + options.extend(option) + else: + options.append(option) for entry in operations: group_packages = 0 libcalamares.utils.debug(pretty_name()) try: - run_operations(pkgman, entry) + check_target_env_call(["dnf-3", "clean", "all"]) + run_operations(pkgman, entry, options) except subprocess.CalledProcessError as e: libcalamares.utils.warning(str(e)) libcalamares.utils.debug("stdout:" + str(e.stdout)) @@ -811,6 +908,7 @@ def run(): .format(e.cmd, e.returncode)) mode_packages = None + check_target_env_call(["rm", "-f", "/etc/yum.repos.d/local.repo"]) libcalamares.job.setprogress(1.0) diff --git a/src/modules/packages/packages.conf b/src/modules/packages/packages.conf index b9777f6..490c289 100644 --- a/src/modules/packages/packages.conf +++ b/src/modules/packages/packages.conf @@ -36,7 +36,7 @@ # Not actually a package manager, but suitable for testing: # - dummy - Dummy manager, only logs # -backend: dummy +backend: dnf # # Often package installation needs an internet connection. @@ -202,13 +202,32 @@ pacman: # "binutils", and then a second time for "wget". When installing large numbers # of packages, this can lead to a considerable time savings. # +sources: + - /etc/yum.repos.d/local.repo + operations: - install: - - vi - - vi-${LOCALE} - - wget - - binutils - - remove: - - vi - - wget - - binutils + - openssh + - iproute + - dhcp + - kernel + - bash + - coreutils + - efibootmgr + - shim + - java-11-openjdk-devel + - vim + - gdb + - perf + - CUnit + - CUnit-devel + - firewalld + - gtest + - gtest-devel + - python3-pytest + + options: + - --nogpgcheck + - --setopt=sslverify=0 + - --disablerepo=* + - --enablerepo=local-repo diff --git a/src/modules/partition/PartitionViewStep.cpp b/src/modules/partition/PartitionViewStep.cpp index db087b5..2f98fe1 100644 --- a/src/modules/partition/PartitionViewStep.cpp +++ b/src/modules/partition/PartitionViewStep.cpp @@ -48,8 +48,7 @@ PartitionViewStep::PartitionViewStep( QObject* parent ) , m_choicePage( nullptr ) , m_manualPartitionPage( nullptr ) { - m_widget->setContentsMargins( 0, 0, 0, 0 ); - + m_widget->setContentsMargins( 50, 20, 50, 0 ); m_waitingWidget = new WaitingWidget( QString() ); m_widget->addWidget( m_waitingWidget ); CALAMARES_RETRANSLATE( diff --git a/src/modules/partition/gui/BootInfoWidget.cpp b/src/modules/partition/gui/BootInfoWidget.cpp index b4339be..eb70b4a 100644 --- a/src/modules/partition/gui/BootInfoWidget.cpp +++ b/src/modules/partition/gui/BootInfoWidget.cpp @@ -42,7 +42,8 @@ BootInfoWidget::BootInfoWidget( QWidget* parent ) QFontMetrics fm = QFontMetrics( QFont() ); m_bootLabel->setMinimumWidth( fm.boundingRect( "BIOS" ).width() + Calamares::defaultFontHeight() / 2 ); m_bootLabel->setAlignment( Qt::AlignCenter ); - + m_bootLabel->setStyleSheet("background-color:#FFFFFF;"); + m_bootIcon->setStyleSheet("background-color:#FFFFFF;"); QPalette palette; palette.setBrush( WindowText, QColor( "#4D4D4D" ) ); //dark grey @@ -62,7 +63,12 @@ BootInfoWidget::retranslateUi() "Modern systems usually use EFI, but " "may also show up as BIOS if started in compatibility " "mode." ) ); - + m_bootIcon->setStyleSheet( + "QLabel {" + "background-color: #ffffff;" + "color: black;" + "}" + ); QString bootToolTip; if ( PartUtils::isEfiSystem() ) { diff --git a/src/modules/partition/gui/ChoicePage.cpp b/src/modules/partition/gui/ChoicePage.cpp index 62cf0f6..6185d3f 100644 --- a/src/modules/partition/gui/ChoicePage.cpp +++ b/src/modules/partition/gui/ChoicePage.cpp @@ -1344,7 +1344,7 @@ ChoicePage::setupActions() "You will be able to review and confirm your choices " "before any change is made to the storage device." ) ); - m_eraseButton->setText( tr( "Erase disk
" + m_eraseButton->setText( tr( "Automatic partitioning
" "This will delete all data " "currently present on the selected storage device." ) ); @@ -1381,7 +1381,7 @@ ChoicePage::setupActions() "The installer will shrink a partition to make room for %1." ) .arg( Calamares::Branding::instance()->shortVersionedName() ) ); - m_eraseButton->setText( tr( "Erase disk
" + m_eraseButton->setText( tr( "Automatic partitioning
" "This will delete all data " "currently present on the selected storage device." ) ); @@ -1402,7 +1402,7 @@ ChoicePage::setupActions() "The installer will shrink a partition to make room for %1." ) .arg( Calamares::Branding::instance()->shortVersionedName() ) ); - m_eraseButton->setText( tr( "Erase disk
" + m_eraseButton->setText( tr( "Automatic partitioning
" "This will delete all data " "currently present on the selected storage device." ) ); @@ -1427,7 +1427,7 @@ ChoicePage::setupActions() "The installer will shrink a partition to make room for %1." ) .arg( Calamares::Branding::instance()->shortVersionedName() ) ); - m_eraseButton->setText( tr( "Erase disk
" + m_eraseButton->setText( tr( "Automatic partitioning
" "This will delete all data " "currently present on the selected storage device." ) ); @@ -1593,7 +1593,7 @@ ChoicePage::calculateNextEnabled() const { case EncryptWidget::Encryption::Unconfirmed: cDebug() << "No passphrase provided or passphrase mismatch."; - return false; + //return false; case EncryptWidget::Encryption::Disabled: case EncryptWidget::Encryption::Confirmed: // Checkbox not checked, **or** passphrases match diff --git a/src/modules/partition/gui/DeviceInfoWidget.cpp b/src/modules/partition/gui/DeviceInfoWidget.cpp index f57ed91..a22344d 100644 --- a/src/modules/partition/gui/DeviceInfoWidget.cpp +++ b/src/modules/partition/gui/DeviceInfoWidget.cpp @@ -52,7 +52,18 @@ DeviceInfoWidget::DeviceInfoWidget( QWidget* parent ) m_ptLabel->setAutoFillBackground( true ); m_ptIcon->setPalette( palette ); m_ptLabel->setPalette( palette ); - + m_ptLabel->setStyleSheet( + "QLabel {" + "background-color: #ffffff;" + "color: black;" + "}" + ); + m_ptIcon->setStyleSheet( + "QLabel {" + "background-color: #ffffff;" + "color: black;" + "}" + ); CALAMARES_RETRANSLATE_SLOT( &DeviceInfoWidget::retranslateUi ); } diff --git a/src/modules/partition/gui/EncryptWidget.cpp b/src/modules/partition/gui/EncryptWidget.cpp index 8726df1..ebb076e 100644 --- a/src/modules/partition/gui/EncryptWidget.cpp +++ b/src/modules/partition/gui/EncryptWidget.cpp @@ -59,7 +59,7 @@ EncryptWidget::EncryptWidget( QWidget* parent ) m_ui->m_encryptionUnsupportedLabel->setText( QStringLiteral( "🔓" ) ); m_ui->m_encryptionUnsupportedLabel->show(); } - + m_ui->m_encryptCheckBox->hide(); connect( m_ui->m_encryptCheckBox, &QCheckBox::stateChanged, this, &EncryptWidget::onCheckBoxStateChanged ); connect( m_ui->m_passphraseLineEdit, &QLineEdit::textEdited, this, &EncryptWidget::onPassphraseEdited ); connect( m_ui->m_confirmLineEdit, &QLineEdit::textEdited, this, &EncryptWidget::onPassphraseEdited ); diff --git a/src/modules/summary/SummaryPage.cpp b/src/modules/summary/SummaryPage.cpp index 41881e4..08a4d51 100644 --- a/src/modules/summary/SummaryPage.cpp +++ b/src/modules/summary/SummaryPage.cpp @@ -35,7 +35,7 @@ SummaryPage::SummaryPage( Config* config, QWidget* parent ) Q_UNUSED( parent ) this->setObjectName( "summaryStep" ); - + this->setContentsMargins(50,15,50,0); QVBoxLayout* layout = new QVBoxLayout( this ); layout->setContentsMargins( 0, 0, 0, 0 ); @@ -118,6 +118,9 @@ ensureSize( QWidget* parent, QScrollArea* container, Calamares::ViewStep* viewst emit viewstep->ensureSize( widgetSize ); // Only expand height } + else{ + container->setVerticalScrollBarPolicy(Qt::ScrollBarAlwaysOff); + } } // Adds a widget for those ViewSteps that want a summary; @@ -131,10 +134,10 @@ SummaryPage::buildWidgets( Config* config, SummaryViewStep* viewstep ) m_contentWidget = new QWidget; m_layout = new QVBoxLayout( m_contentWidget ); Calamares::unmarginLayout( m_layout ); - + m_contentWidget->setStyleSheet("background-color:#FFFFFF"); QFont titleFont = font(); titleFont.setWeight( QFont::Light ); - titleFont.setPointSize( Calamares::defaultFontSize() * 2 ); + titleFont.setPointSize( Calamares::defaultFontSize() * 1.3 ); QPalette bodyPalette( palette() ); bodyPalette.setColor( WindowBackground, palette().window().color().lighter( 108 ) ); diff --git a/src/modules/umount/UmountJob.cpp b/src/modules/umount/UmountJob.cpp index 83cf2f1..90f2373 100644 --- a/src/modules/umount/UmountJob.cpp +++ b/src/modules/umount/UmountJob.cpp @@ -42,6 +42,29 @@ UmountJob::prettyName() const static Calamares::JobResult unmountTargetMounts( const QString& rootMountPoint ) { + // 先删除 /etc/yum.repos.d/local.repo 文件 + QString repoFilePath = rootMountPoint + "/etc/yum.repos.d/local.repo"; + if ( QFile::exists( repoFilePath ) ) + { + if ( !QFile::remove( repoFilePath ) ) + { + return Calamares::JobResult::internalError( + QCoreApplication::translate( UmountJob::staticMetaObject.className(), "Could not remove local.repo." ), + QCoreApplication::translate( UmountJob::staticMetaObject.className(), + "Failed to remove '%1'. Check permissions." ) + .arg( repoFilePath ), + Calamares::JobResult::GenericError ); + } + else + { + cDebug() << "Removed local repo file:" << repoFilePath; + } + } + else + { + cDebug() << "No local.repo file to remove at" << repoFilePath; + } + QDir targetMount( rootMountPoint ); if ( !targetMount.exists() ) { diff --git a/src/modules/unpackfs/main.py b/src/modules/unpackfs/main.py index 814556f..4148720 100644 --- a/src/modules/unpackfs/main.py +++ b/src/modules/unpackfs/main.py @@ -23,6 +23,7 @@ import sys import tempfile import libcalamares +import platform import gettext _ = gettext.translation("calamares-python", @@ -153,6 +154,40 @@ def global_excludes(): return lst +def create_se_content(): + te_content = """ +#!/bin/bash + +# 恢复sshd和rpmdb SELinux上下文 +chcon -t sshd_exec_t /usr/sbin/sshd +chcon -t rpm_var_lib_t /var/lib/rpm/Index.db + +# 创建 TE 文件 +cat < gdm_policy.te +module gdm_policy 1.0; + +require { + type unconfined_service_t; + type unconfined_t; + class process { transition }; +} + +# Allow unconfined_service_t to transition to unconfined_t +allow unconfined_service_t unconfined_t:process transition; +EOF + +# 编译 TE 文件 +checkmodule -M -m -o gdm_policy.mod gdm_policy.te + +# 生成策略模块包 +semodule_package -o gdm_policy.pp -m gdm_policy.mod + +# 安装策略模块 +semodule -i gdm_policy.pp +""".strip() + with open('/etc/add_selinux_policy.sh', 'w') as te_file: + te_file.write(te_content) + def file_copy(source, entry, progress_cb): """ Extract given image using rsync. @@ -226,9 +261,44 @@ def file_copy(source, entry, progress_cb): counter.last_timestamp_reported = now counter.last_total_reported = num_files_total_local progress_cb(num_files_copied, num_files_total_local) - try: - returncode = libcalamares.utils.host_env_process_output(args, output_cb) + returncode = 0 + arch = platform.machine() + + libcalamares.utils.host_env_process_output(["mkdir", "-p", entry.destination + "/etc/yum.repos.d/"], output_cb) + libcalamares.utils.host_env_process_output(["multipath", "-F"], output_cb) + + create_se_content() + libcalamares.utils.host_env_process_output(["cp", "-af", "/etc/add_selinux_policy.sh", entry.destination + "/etc/add_selinux_policy.sh"], output_cb) + libcalamares.utils.host_env_process_output(["chmod", "+x", entry.destination + "/etc/add_selinux_policy.sh"], output_cb) + + if os.path.exists("/etc/yum.repos.d/local.repo"): + libcalamares.utils.host_env_process_output( + ["cp", "-af", "/etc/yum.repos.d/local.repo", entry.destination + "/etc/yum.repos.d/"], output_cb) + + if arch == "aarch64": + packages = ["yum", "grub2-efi", "passwd", "sudo"] + else: + packages = ["yum", "grub2", "grub2-efi-x64", "grub2-pc", "passwd", "sudo"] + + libcalamares.utils.host_env_process_output( + ["yum", "--installroot=" + entry.destination, "--disablerepo=*", "--enablerepo=local-repo", + "--releasever=/", "--nogpgcheck", "--setopt=sslverify=0", "install", "-y"] + packages, output_cb) + else: + libcalamares.utils.host_env_process_output( + ["cp", "-af", "/etc/yum.repos.d/openEuler.repo", entry.destination + "/etc/yum.repos.d/"], output_cb) + if arch == "aarch64": + packages = ["yum", "grub2-efi", "passwd", "sudo"] + else: + packages = ["yum", "grub2", "grub2-efi-x64", "grub2-pc", "passwd", "sudo"] + + libcalamares.utils.host_env_process_output( + ["yum", "--installroot=" + entry.destination, "--releasever=/", "--nogpgcheck", "--setopt=sslverify=0", + "install", "-y"] + packages, output_cb) + + libcalamares.utils.host_env_process_output(["rm", "-f", entry.destination + "/etc/shadow"], output_cb) + libcalamares.utils.host_env_process_output(["cp", "-af", "/etc/shadow", entry.destination + "/etc/shadow"], output_cb) + except subprocess.CalledProcessError as e: returncode = e.returncode @@ -454,10 +524,10 @@ def run(): libcalamares.utils.warning(" ... modprobe {} may solve the problem".format(sourcefs)) return (_("Bad unpackfs configuration"), _("The filesystem for \"{}\" ({}) is not supported by your current kernel").format(source, sourcefs)) - if not os.path.exists(source): - libcalamares.utils.warning("The source filesystem \"{}\" does not exist".format(source)) - return (_("Bad unpackfs configuration"), - _("The source filesystem \"{}\" does not exist").format(source)) + #if not os.path.exists(source): + # libcalamares.utils.warning("The source filesystem \"{}\" does not exist".format(source)) + # return (_("Bad unpackfs configuration"), + # _("The source filesystem \"{}\" does not exist").format(source)) if sourcefs == "squashfs": if shutil.which("unsquashfs") is None: libcalamares.utils.warning("Failed to find unsquashfs") diff --git a/src/modules/unpackfs/unpackfs.conf b/src/modules/unpackfs/unpackfs.conf index d12110b..1b053a6 100644 --- a/src/modules/unpackfs/unpackfs.conf +++ b/src/modules/unpackfs/unpackfs.conf @@ -88,13 +88,7 @@ # for its destination name, as in the example below. unpack: - - source: ../CHANGES - sourcefs: file - destination: "/tmp/changes.txt" + - source: "/dev/mapper/live-base" + sourcefs: "ext4" + destination: "" weight: 1 # Single file - - source: src/qml/calamares/slideshow - sourcefs: file - destination: "/tmp/slideshow/" - exclude: [ "*.qmlc", "qmldir" ] - weight: 5 # Lots of files - # excludeFile: /etc/calamares/modules/unpackfs/exclude-list.txt diff --git a/src/modules/users/UsersPage.cpp b/src/modules/users/UsersPage.cpp index 1ecc0eb..72fb3e0 100644 --- a/src/modules/users/UsersPage.cpp +++ b/src/modules/users/UsersPage.cpp @@ -82,7 +82,7 @@ UsersPage::UsersPage( Config* config, QWidget* parent ) , m_config( config ) { ui->setupUi( this ); - + this->setContentsMargins(50,15,50,0); // Connect signals and slots ui->textBoxUserPassword->setText( config->userPassword() ); connect( ui->textBoxUserPassword, &QLineEdit::textChanged, config, &Config::setUserPassword ); diff --git a/src/modules/users/page_usersetup.ui b/src/modules/users/page_usersetup.ui index 6e6e542..2a5ccd2 100644 --- a/src/modules/users/page_usersetup.ui +++ b/src/modules/users/page_usersetup.ui @@ -21,10 +21,10 @@ SPDX-License-Identifier: GPL-3.0-or-later - Qt::Vertical + Qt::Orientation::Vertical - QSizePolicy::Fixed + QSizePolicy::Policy::Fixed @@ -34,15 +34,27 @@ SPDX-License-Identifier: GPL-3.0-or-later - - - - What is your name? - - - + + + + + 0 + 0 + + + + + 150 + 24 + + + + your name + + + @@ -105,31 +117,43 @@ SPDX-License-Identifier: GPL-3.0-or-later - Qt::Vertical + Qt::Orientation::Vertical - QSizePolicy::Fixed + QSizePolicy::Policy::Fixed - 20 - 6 + 5 + 5 - - - - What name do you want to use to log in? - - - false - - - + + + + + 0 + 0 + + + + + 150 + 24 + + + + user name + + + false + + + @@ -192,7 +216,7 @@ SPDX-License-Identifier: GPL-3.0-or-later - Qt::AlignVCenter + Qt::AlignmentFlag::AlignVCenter true @@ -204,31 +228,43 @@ SPDX-License-Identifier: GPL-3.0-or-later - Qt::Vertical + Qt::Orientation::Vertical - QSizePolicy::Fixed + QSizePolicy::Policy::Fixed - 20 - 6 + 5 + 5 - - - - What is the name of this computer? - - - false - - - + + + + + 0 + 0 + + + + + 150 + 24 + + + + computer name + + + false + + + @@ -294,7 +330,7 @@ SPDX-License-Identifier: GPL-3.0-or-later - Qt::AlignVCenter + Qt::AlignmentFlag::AlignVCenter true @@ -306,15 +342,15 @@ SPDX-License-Identifier: GPL-3.0-or-later - Qt::Vertical + Qt::Orientation::Vertical - QSizePolicy::Fixed + QSizePolicy::Policy::Fixed 20 - 6 + 20 @@ -349,7 +385,7 @@ SPDX-License-Identifier: GPL-3.0-or-later <small>Enter the same password twice, so that it can be checked for typing errors. A good password will contain a mixture of letters, numbers and punctuation, should be at least eight characters long, and should be changed at regular intervals.</small> - QLineEdit::Password + QLineEdit::EchoMode::Password Password @@ -374,7 +410,7 @@ SPDX-License-Identifier: GPL-3.0-or-later <small>Enter the same password twice, so that it can be checked for typing errors. A good password will contain a mixture of letters, numbers and punctuation, should be at least eight characters long, and should be changed at regular intervals.</small> - QLineEdit::Password + QLineEdit::EchoMode::Password Repeat Password @@ -424,7 +460,7 @@ SPDX-License-Identifier: GPL-3.0-or-later - Qt::AlignVCenter + Qt::AlignmentFlag::AlignVCenter true @@ -436,15 +472,15 @@ SPDX-License-Identifier: GPL-3.0-or-later - Qt::Vertical + Qt::Orientation::Vertical - QSizePolicy::Fixed + QSizePolicy::Policy::Fixed - 20 - 6 + 5 + 5 @@ -469,22 +505,22 @@ SPDX-License-Identifier: GPL-3.0-or-later - Use the same password for the administrator account. + Use the same password for the root account. - Qt::Vertical + Qt::Orientation::Vertical - QSizePolicy::Fixed + QSizePolicy::Policy::Fixed - 20 - 6 + 5 + 5 @@ -519,7 +555,7 @@ SPDX-License-Identifier: GPL-3.0-or-later <small>Enter the same password twice, so that it can be checked for typing errors.</small> - QLineEdit::Password + QLineEdit::EchoMode::Password Password @@ -544,7 +580,7 @@ SPDX-License-Identifier: GPL-3.0-or-later <small>Enter the same password twice, so that it can be checked for typing errors.</small> - QLineEdit::Password + QLineEdit::EchoMode::Password Repeat Password @@ -594,7 +630,7 @@ SPDX-License-Identifier: GPL-3.0-or-later - Qt::AlignVCenter + Qt::AlignmentFlag::AlignVCenter true @@ -606,10 +642,10 @@ SPDX-License-Identifier: GPL-3.0-or-later - Qt::Vertical + Qt::Orientation::Vertical - QSizePolicy::Fixed + QSizePolicy::Policy::Fixed @@ -666,7 +702,7 @@ SPDX-License-Identifier: GPL-3.0-or-later - QLineEdit::Password + QLineEdit::EchoMode::Password @@ -693,7 +729,7 @@ SPDX-License-Identifier: GPL-3.0-or-later - Qt::Vertical + Qt::Orientation::Vertical diff --git a/src/modules/users/users.conf b/src/modules/users/users.conf index e6910bc..57a82dd 100644 --- a/src/modules/users/users.conf +++ b/src/modules/users/users.conf @@ -88,7 +88,7 @@ setRootPassword: true # When checked, the user password is used for the root account too. # # NOTE: *doReusePassword* requires *setRootPassword* to be enabled. -doReusePassword: true +doReusePassword: false ### PASSWORDS AND LOGIN diff --git a/src/modules/welcome/Config.cpp b/src/modules/welcome/Config.cpp index 2bce564..7e50dc6 100644 --- a/src/modules/welcome/Config.cpp +++ b/src/modules/welcome/Config.cpp @@ -77,8 +77,7 @@ Config::retranslate() } else { - m_warningMessage = tr( "This program will ask you some questions and " - "set up %2 on your computer." ) + m_warningMessage = tr( "" ) .arg( branding ? branding->productName() : QString() ); } diff --git a/src/modules/welcome/WelcomePage.cpp b/src/modules/welcome/WelcomePage.cpp index 30e3d6b..88f38c2 100644 --- a/src/modules/welcome/WelcomePage.cpp +++ b/src/modules/welcome/WelcomePage.cpp @@ -44,10 +44,10 @@ WelcomePage::WelcomePage( Config* config, QWidget* parent ) , m_conf( config ) { using Branding = Calamares::Branding; - + const int defaultFontHeight = Calamares::defaultFontHeight(); ui->setupUi( this ); - + // insert system-check widget below welcome text const int welcome_text_idx = ui->verticalLayout->indexOf( ui->mainText ); ui->verticalLayout->insertWidget( welcome_text_idx + 1, m_checkingWidget ); @@ -72,7 +72,12 @@ WelcomePage::WelcomePage( Config* config, QWidget* parent ) } initLanguages(); - + ui->languageWidget->setStyleSheet( + "QLabel {" + "background-color: #ffffff;" + "color: black;" + "}" + ); CALAMARES_RETRANSLATE_SLOT( &WelcomePage::retranslate ); connect( Calamares::ModuleManager::instance(), @@ -89,17 +94,17 @@ void WelcomePage::init() { //setup the url buttons - setupButton( WelcomePage::Button::Support, m_conf->supportUrl() ); - setupButton( WelcomePage::Button::KnownIssues, m_conf->knownIssuesUrl() ); - setupButton( WelcomePage::Button::ReleaseNotes, m_conf->releaseNotesUrl() ); - setupButton( WelcomePage::Button::Donate, m_conf->donateUrl() ); + // setupButton( WelcomePage::Button::Support, m_conf->supportUrl() ); + // setupButton( WelcomePage::Button::KnownIssues, m_conf->knownIssuesUrl() ); + // setupButton( WelcomePage::Button::ReleaseNotes, m_conf->releaseNotesUrl() ); + // setupButton( WelcomePage::Button::Donate, m_conf->donateUrl() ); //language icon - auto icon = Calamares::Branding::instance()->image( m_conf->languageIcon(), QSize( 48, 48 ) ); - if ( !icon.isNull() ) - { - setLanguageIcon( icon ); - } + // auto icon = Calamares::Branding::instance()->image( m_conf->languageIcon(), QSize( 48, 48 ) ); + // if ( !icon.isNull() ) + // { + // setLanguageIcon( icon ); + // } } void @@ -120,56 +125,56 @@ WelcomePage::initLanguages() &Config::setLocaleIndex ); } -void -WelcomePage::setupButton( Button role, const QString& url ) -{ - QPushButton* button = nullptr; - Calamares::ImageType icon = Calamares::Information; - - switch ( role ) - { - case Button::Donate: - button = ui->donateButton; - icon = Calamares::Donate; - break; - case Button::KnownIssues: - button = ui->knownIssuesButton; - icon = Calamares::Bugs; - break; - case Button::ReleaseNotes: - button = ui->releaseNotesButton; - icon = Calamares::Release; - break; - case Button::Support: - button = ui->supportButton; - icon = Calamares::Help; - break; - } - if ( !button ) - { - cWarning() << "Unknown button role" << smash( role ); - return; - } - - if ( url.isEmpty() ) - { - button->hide(); - return; - } - - QUrl u( url ); - if ( u.isValid() ) - { - auto size = 2 * QSize( Calamares::defaultFontHeight(), Calamares::defaultFontHeight() ); - button->setIcon( Calamares::defaultPixmap( icon, Calamares::Original, size ) ); - connect( button, &QPushButton::clicked, [ u ]() { QDesktopServices::openUrl( u ); } ); - } - else - { - cWarning() << "Welcome button" << smash( role ) << "URL" << url << "is invalid."; - button->hide(); - } -} +// void +// WelcomePage::setupButton( Button role, const QString& url ) +// { +// QPushButton* button = nullptr; +// Calamares::ImageType icon = Calamares::Information; + +// switch ( role ) +// { +// case Button::Donate: +// button = ui->donateButton; +// icon = Calamares::Donate; +// break; +// case Button::KnownIssues: +// button = ui->knownIssuesButton; +// icon = Calamares::Bugs; +// break; +// case Button::ReleaseNotes: +// button = ui->releaseNotesButton; +// icon = Calamares::Release; +// break; +// case Button::Support: +// button = ui->supportButton; +// icon = Calamares::Help; +// break; +// } +// if ( !button ) +// { +// cWarning() << "Unknown button role" << smash( role ); +// return; +// } + +// if ( url.isEmpty() ) +// { +// button->hide(); +// return; +// } + +// QUrl u( url ); +// if ( u.isValid() ) +// { +// auto size = 2 * QSize( Calamares::defaultFontHeight(), Calamares::defaultFontHeight() ); +// button->setIcon( Calamares::defaultPixmap( icon, Calamares::Original, size ) ); +// connect( button, &QPushButton::clicked, [ u ]() { QDesktopServices::openUrl( u ); } ); +// } +// else +// { +// cWarning() << "Welcome button" << smash( role ) << "URL" << url << "is invalid."; +// button->hide(); +// } +// } void WelcomePage::focusInEvent( QFocusEvent* e ) @@ -196,11 +201,11 @@ WelcomePage::externallySelectedLanguage( int row ) } } -void -WelcomePage::setLanguageIcon( QPixmap i ) -{ - ui->languageIcon->setPixmap( i ); -} +// void +// WelcomePage::setLanguageIcon( QPixmap i ) +// { +// ui->languageIcon->setPixmap( i ); +// } void WelcomePage::retranslate() @@ -209,8 +214,8 @@ WelcomePage::retranslate() ui->mainText->setText( message.arg( Calamares::Branding::instance()->versionedName() ) ); ui->retranslateUi( this ); - ui->supportButton->setText( - tr( "%1 Support", "@action" ).arg( Calamares::Branding::instance()->shortProductName() ) ); + // ui->supportButton->setText( + // tr( "%1 Support", "@action" ).arg( Calamares::Branding::instance()->shortProductName() ) ); } void diff --git a/src/modules/welcome/WelcomePage.ui b/src/modules/welcome/WelcomePage.ui index 0e3dcb0..b25b4e0 100644 --- a/src/modules/welcome/WelcomePage.ui +++ b/src/modules/welcome/WelcomePage.ui @@ -17,6 +17,9 @@ SPDX-License-Identifier: GPL-3.0-or-later Form + + + @@ -56,7 +59,7 @@ SPDX-License-Identifier: GPL-3.0-or-later - + @@ -78,11 +81,12 @@ SPDX-License-Identifier: GPL-3.0-or-later Select application and system language + + + + - - - - :/welcome/language-icon-48px.png + language @@ -97,6 +101,9 @@ SPDX-License-Identifier: GPL-3.0-or-later Select application and system language + + background-color:rbga(248,250,255,1) + @@ -132,62 +139,6 @@ SPDX-License-Identifier: GPL-3.0-or-later
- - - - - - Open donations website - - - &Donate - - - true - - - - - - - Open help and support website - - - &Support - - - true - - - - - - - Open issues and bug-tracking website - - - &Known issues - - - true - - - - - - - Open release notes website - - - &Release notes - - - true - - - - - diff --git a/src/modules/welcome/checker/ResultsListWidget.cpp b/src/modules/welcome/checker/ResultsListWidget.cpp index 3f70c61..e191b26 100644 --- a/src/modules/welcome/checker/ResultsListWidget.cpp +++ b/src/modules/welcome/checker/ResultsListWidget.cpp @@ -26,7 +26,8 @@ #include #include #include - +#include +#include ResultsListWidget::ResultsListWidget( Config* config, QWidget* parent ) : QWidget( parent ) , m_config( config ) @@ -91,21 +92,28 @@ ResultsListWidget::requirementsComplete() if ( !Calamares::Branding::instance()->imagePath( Calamares::Branding::ProductWelcome ).isEmpty() ) { - QPixmap theImage - = QPixmap( Calamares::Branding::instance()->imagePath( Calamares::Branding::ProductWelcome ) ); - if ( !theImage.isNull() ) + QString imagePath = Calamares::Branding::instance()->imagePath( Calamares::Branding::ProductWelcome ); + QSvgRenderer renderer(imagePath); + renderer.load(imagePath); + if ( renderer.isValid() ) { + QPixmap pixmap(renderer.defaultSize()); + pixmap.fill(Qt::transparent); + + QPainter painter(&pixmap); + renderer.render(&painter); + QLabel* imageLabel; if ( Calamares::Branding::instance()->welcomeExpandingLogo() ) { FixedAspectRatioLabel* p = new FixedAspectRatioLabel; - p->setPixmap( theImage ); + p->setPixmap( pixmap ); imageLabel = p; } else { imageLabel = new QLabel; - imageLabel->setPixmap( theImage ); + imageLabel->setPixmap( pixmap ); } imageLabel->setContentsMargins( 4, Calamares::defaultFontHeight() * 3 / 4, 4, 4 ); diff --git a/src/modules/welcome/welcome.conf b/src/modules/welcome/welcome.conf index b988eb2..15e08ce 100644 --- a/src/modules/welcome/welcome.conf +++ b/src/modules/welcome/welcome.conf @@ -81,9 +81,9 @@ requirements: # boolean values, so should be quoted. check: - storage - - ram + #- ram - power - - internet + #- internet - root - screen - "false" @@ -95,7 +95,7 @@ requirements: # continue past the welcome page. required: # - storage - - ram + #- ram # - root # GeoIP checking diff --git a/src/modules/welcome/welcome.qrc b/src/modules/welcome/welcome.qrc index f270ee5..8806101 100644 --- a/src/modules/welcome/welcome.qrc +++ b/src/modules/welcome/welcome.qrc @@ -1,6 +1,8 @@ - - language-icon-128px.png - language-icon-48px.png - + + + WelcomePage.cpp + language-icon-128px.png + language-icon-48px.png + diff --git a/src/modules/welcomeq/welcomeq.conf b/src/modules/welcomeq/welcomeq.conf index 2efc514..0ffb4b8 100644 --- a/src/modules/welcomeq/welcomeq.conf +++ b/src/modules/welcomeq/welcomeq.conf @@ -26,7 +26,7 @@ requirements: - storage - ram - power - - internet + #- internet - root - screen required: -- 2.43.0