Compare commits

..

75 Commits

Author SHA1 Message Date
Adriaan de Groot
c2ee0c6ed4 CMake: bump version number 2017-12-20 04:22:06 -05:00
Adriaan de Groot
d42210eb93 Merge branch '3.1-pinebook' into 3.1.x-stable 2017-12-19 11:13:21 -05:00
Adriaan de Groot
d5b46dfb86 [plasmalnf] Improve theme-listing handling
- if key is missing or badly typed, enable all (explicitly)
 - document settings and code
2017-12-19 12:51:56 +01:00
Adriaan de Groot
f2aeecf546 [plasmalnf] Improve screenshot view
- make screenies smaller
 - use view-preview to indicate no-screenshot-specified
2017-12-19 12:28:42 +01:00
Adriaan de Groot
10e71bab30 [plasmalnf] Add Breeze 'view-preview' icon for missing screenshots 2017-12-19 12:21:05 +01:00
Adriaan de Groot
e73d54767d [plasmalnf] Expand explanation, drop CSS 2017-12-18 07:57:19 -05:00
Adriaan de Groot
cf39dddbf3 [plasmalnf] Prevent duplicate widgets
- Only create widgets for themes once
 - Update visible texts as needed
2017-12-18 07:25:59 -05:00
Adriaan de Groot
3f258d4bd9 [plasmalnf] Fallback for image-not-found
- calculate a hash of the filename, and use that
 - makes it possible to distinguish different screenshots
   even when the image file is missing / badly configured
 - most colors will be dreadful
2017-12-18 07:07:47 -05:00
Adriaan de Groot
2db485bb33 [plasmalnf] Improve layout of theme widget 2017-12-14 17:04:16 -05:00
Adriaan de Groot
244919d6fe [plasmalnf] Add description to theme widget 2017-12-14 17:01:59 -05:00
Adriaan de Groot
8b3f71af40 [plasmalnf] Widget for showing theme info
- Radio button + group for button action
 - Use a (still very primitive) widget for displaying theme information
2017-12-13 11:04:34 -05:00
Adriaan de Groot
755c0cba18 [plasmalnf] Prep-work for UI changes 2017-12-13 09:55:54 -05:00
Adriaan de Groot
11fc3e0507 [plasmalnf] minor documentation
- Code documentation
 - Add another broken example theme, as test for winnowing
2017-12-13 09:53:41 -05:00
Adriaan de Groot
afbdcc3782 [hwclock] Be more lenient.
Patch by Gabriel C. (@abucodonosor).

 - use libcalamares functions
 - no need to copy /etc/adjtime over we can run hwclock in chroot
   since we have /proc , /sys , /dev , /run/* already bind mounted.
 - added RTC and ISA probing methode ( see issue #873)
    - we probe default from /dev/rtc* ,
    - fall back to ISA
    - still doesn't work we just print a BIOS/Kernel BUG message and continue
- NOTE: issue #873 is about broken ArchLinux kernel config but there
  are HP boxes with real RTC problems no matter what kernel config
  is used so let us be nice and don't error out..

FIXES #873
2017-12-13 06:27:04 -05:00
Adriaan de Groot
748ccf94e9 [plasmalnf] Enrich config file
- Extend the config file format to allow theme, image pairs
   as well as just naming the themes.
 - Reduce verbosity when querying Plasma themes.
2017-12-12 06:59:25 -05:00
Adriaan de Groot
0116465303 CMake: bump version 2017-12-07 08:42:49 -05:00
Adriaan de Groot
6bd8c67ca9 [plasmalnf] Allow filtering the selectable lnf themes
- empty list allows all of them
 - always suppress hidden, invalid themes, and those named
2017-12-04 12:27:30 -05:00
Adriaan de Groot
ad69eda337 [plasmalnf] Complain again if poorly configured 2017-12-04 11:54:33 -05:00
Adriaan de Groot
98b9f67e39 [plasmalnf] Complain more loudly (and more often) when badly configured 2017-12-04 11:51:16 -05:00
Adriaan de Groot
02dfe51d55 [welcome] Improve error reporting from requirements checker 2017-12-04 10:47:26 -05:00
Adriaan de Groot
e628ddfdbf [plasmalnf] Try to get back to the live user before changing themes 2017-12-04 09:37:34 -05:00
Adriaan de Groot
b10b19e9ee [plasmalnf] C++ style and reduce includes 2017-12-04 09:11:10 -05:00
Adriaan de Groot
eb92755b0a [plasmalnf] Enable translations
- Move tool-running to the view-step
 - Enable translations by showing name instead of theme-id
 - More verbose logging
2017-12-04 06:40:13 -05:00
Adriaan de Groot
71966b5330 [plasmalnf] Wait longer for the tool to finish 2017-12-03 16:09:34 -05:00
Adriaan de Groot
1de2e94fd0 [plasmalnf] Simplify code, reduce copies of lnftool setting 2017-12-03 15:41:52 -05:00
Adriaan de Groot
fe8ff3ab05 [plasmalnf] Simplify code, remove redundant implementations 2017-12-03 15:34:06 -05:00
Adriaan de Groot
4e2e55a935 [plasmalnf] Needs to run as target user in all cases 2017-12-03 15:24:39 -05:00
Adriaan de Groot
ac92d4911d Compatibility: revert conveniences from master 2017-12-03 12:58:54 -05:00
Adriaan de Groot
3a94f02547 CMake: look for ECM at top-level, add to search path if found. 2017-12-03 12:48:23 -05:00
Adriaan de Groot
cddc4699aa [plasmalnf] Import Plasma Look-and-Feel module independently 2017-12-03 12:47:41 -05:00
Adriaan de Groot
1f49f764a6 [libcalamares] Allow retrieving chroot mode from system (as well as settings) 2017-12-03 12:46:33 -05:00
Adriaan de Groot
65a236cd60 [packages] Fix previous.
This, kids, is why you don't switch writing C++ and Python too often.
The C++ code isn't a syntax error in Python, although this would fail
at runtime.
2017-12-02 06:14:17 -05:00
Adriaan de Groot
3e3cd08ff3 [packages] Fix previous (false vs False) 2017-12-02 05:20:13 -05:00
Adriaan de Groot
150007c138 [packages] Feature: skip if no internet.
Update documentation, add a new key *skip_if_no_internet* to support
systems that **recommend** having an internet connection (but don't
require it), and which also use the packages module. This prevents
a long delay while the package manager tries to access the internet
and times out (repeatedly).

Existing configurations are unchanged.
2017-12-02 05:17:15 -05:00
Adriaan de Groot
7b145c2a36 [packages] Improve message when no packages are processed at all. 2017-12-01 16:48:02 -05:00
Adriaan de Groot
517dbfab06 [libcalamares] The script namespace is actually a dict
Use dict methods, in particular d.get(k, v), to retrieve
the pretty_name() function (or None if it isn't there).
Using getattr() on a dict will not return values in the
dict.
2017-12-01 16:42:56 -05:00
Adriaan de Groot
fe61925f31 [packages] Update module documentation 2017-12-01 13:46:59 -05:00
Adriaan de Groot
63af8c1b92 Drop -rc status 2017-11-29 08:50:22 -05:00
Adriaan de Groot
12369abaa4 [libcalamares] Refactor to reduce compiler warnings 2017-11-29 08:49:44 -05:00
Adriaan de Groot
93ab6432c4 [netinstall] Special-case the root node.
Root is always selected, can't be unselected, and has its own explicit
constructor and name. This resolves issue reported where unchecking
all *visible* groups caused the root to be unchecked, after which
hidden-but-still-selected subgroups were not installed.

Reported by crazy@
2017-11-24 07:52:52 -05:00
bill-auger
452cefd482 use orphaned Branding::ProductLogo as sidebar image 2017-11-21 07:25:39 -05:00
Adriaan de Groot
aa0fa37492 [netinstall] Hidden groups follow selectedness of parents.
If a subgroup is hidden, then it should be considered
selected if its parent is selected or partially-selected.
If the parent group is totally unselected, then the hidden
subgroup shouldn't be installed either. This allows putting
required-packages into a group, without cluttering the
interface.

FIXES #864
2017-11-21 06:16:30 -05:00
Adriaan de Groot
71e80f680e [netinstall] Only update selectedness of parents with children.
While walking up the tree, only switch the selectedness states
of parents with children. This avoids the case where a parent
has a first subgroup that is hidden -- in which case the
parent ends up with no children, and is unselected even though
it is marked as selected in the config file.

FIXES #864
2017-11-21 05:36:38 -05:00
Adriaan de Groot
7e2e2cabfe CMake: bump version to 3.1.9rc1 (no functional changes yet) 2017-11-21 04:25:32 -05:00
Adriaan de Groot
848d532a58 CMake: drop -rc status 2017-11-14 10:18:58 -05:00
Adriaan de Groot
51c74c6abb [netinstall] Convenience typedefs 2017-11-06 05:42:13 -05:00
Adriaan de Groot
91e949f8fc [netinstall] Apply Calamares C++ style 2017-11-06 05:34:57 -05:00
Adriaan de Groot
f424af36d3 [netinstall] Avoid crash when do groups are available
- m_groups is only set to a non-nullptr value when data is received
   and fully processed,
 - avoid nullptr dereference when paging *back* from a netinstall
   page that hasn't loaded groups data.

FIXES #859
2017-11-06 05:33:01 -05:00
Adriaan de Groot
ee0b3b85dc [netinstall] Improve 'next' button handling
- Document netinstall.conf a little,
 - Add setting *required* which influences whether next is enabled or not
   in case of missing or corrupt data,
 - Enable *next* button only once some (any!) data is received.

This can be used to disallow stepping past the netinstall step when
there is no data (e.g. internet has failed between the welcome page
and the netinstall page).
2017-11-06 05:33:01 -05:00
Adriaan de Groot
35f5612ec1 [locale] Fix GeoIP (reported by demm, crazy)
- data has already been read, don't try to read more from the QNM reply
 - regression introduced in 7e25909e
2017-11-01 11:07:18 +01:00
Adriaan de Groot
4ea8b2e6ef CMake: report on the example-distro feature correctly 2017-10-30 11:43:37 -04:00
Adriaan de Groot
5474dc6d2b [partition] allow KPMcore 3.0.2 (with warning) 2017-10-30 11:43:37 -04:00
Adriaan de Groot
a179c6c765 Merge pull request #846 from stikonas/3.1.x-stable
Use KPMcore Resize Operation.
2017-10-30 11:22:53 -04:00
Adriaan de Groot
12f4104fe1 Merge pull request #850 from abucodonosor/3.1.x-stable
NetInstallPage.cpp: fix displaying for Name and Description
2017-10-30 11:18:52 -04:00
Gabriel Craciunescu
d2ea83a0b2 NetInstallPage.cpp: fix displaying for Name and Description
- fixes 1d7ad9e045 which sets
  both header's labels to 0 so 'Name' was always overridden
  by Description and Description never displayed
2017-10-28 02:18:36 +02:00
Andrius Štikonas
fb1522f6ca Use KPMcore Resize Operation. 2017-10-27 14:00:32 +01:00
Adriaan de Groot
951e5ad7f4 Merge pull request #845 from stikonas/3.1.x-stable
Fix reported partition size.
2017-10-27 04:43:11 -04:00
Andrius Štikonas
274025d04e Fix reported partition size. 2017-10-27 02:51:44 +01:00
Adriaan de Groot
3b30bbde67 Bump version number, pretending 3.1.8-rc1 is pending 2017-10-25 08:55:59 -04:00
Adriaan de Groot
a64e6efb85 Bump version number 2017-10-24 07:46:03 -04:00
Adriaan de Groot
e6e1e2226c [netinstall] logging about the number of packages to process 2017-10-24 06:44:37 -04:00
Adriaan de Groot
41f17892d6 [packages] Document run_operations() some more 2017-10-24 06:44:37 -04:00
Philip
df84208abc [bootloader] use generic file names instead of grub
- this fixes #839
2017-10-23 12:53:34 -04:00
Adriaan de Groot
58414666c8 Netinstall: optimize structure for packages
- If there's no scripts involved in a package for netinstall, just
   name it without the scripts; this lets the packages module
   optimize to fewer package manager calls.
2017-10-23 11:23:14 -04:00
Adriaan de Groot
4314f2c4ad Netinstall: fix datatype passed to packages module
- Each element of the (list) packageOperations needs to be a
   package operation, which is a dictionary with keys (identifying actions)
   and lists of packages (which may be strings or script-info dictionaries).
2017-10-23 11:23:14 -04:00
Adriaan de Groot
aabcd6ba86 Bump version 2017-10-13 16:45:37 -03:00
Adriaan de Groot
c6c6c2f22f Testing: refactor so that C++ and Python modules all get yaml-config tests 2017-10-12 13:37:54 -03:00
Adriaan de Groot
6000cbaae2 Testing: test each module's config files 2017-10-12 13:03:13 -03:00
Adriaan de Groot
e9205125ea Testing: add test to check the shipped config-files for correctness. 2017-10-12 12:55:07 -03:00
Adriaan de Groot
b805a8df74 CMake: minor docs, typo's 2017-10-12 12:33:03 -03:00
Adriaan de Groot
8b76b861ad Code-formatting, add (unused for now) overload of getLocationPosition() 2017-10-12 12:26:50 -03:00
Adriaan de Groot
00fa7bff1c Code-formatting, add copyright notice 2017-10-12 07:08:21 -07:00
Gabriel C
c10d7470bb finished: fix configuration file syntax
- fixes commit 74c19fc02d
- fixes #829
2017-10-12 07:05:28 -07:00
Adriaan de Groot
78031636af Correct for distortion of globe.
In the timezone widget, locations in the far north -- Inuvik,
Thule, Longyearbyen -- were displayed too far south, because the
map location calculation assumes a linear gradient, which places
90 degrees north at about 70 degrees. Change calculation to
pretend the world is flat south of 62 degrees north, and then
'bend' the remaining 28 degrees of latitude to the top of the
image. This puts most places in the right spot, although Yellowknife
is now on the south shore of Great Slave.

Fort Nelson should be north of Dawson Creek, too -- the math still
needs a little work.

While here, put Antarctica in the south, otherwise Rothera keeps
showing up in Greenland.
2017-10-09 13:14:53 -07:00
Adriaan de Groot
b1bae4152a Missing import; thanks to crazy on IRC 2017-10-04 05:32:23 -04:00
53 changed files with 1512 additions and 857 deletions

View File

@@ -50,7 +50,7 @@ if( CMAKE_CXX_COMPILER_ID MATCHES "Clang" )
# Clang warnings: doing *everything* is counter-productive, since it warns
# about things which we can't fix (e.g. C++98 incompatibilities, but
# Calaares is C++14).
# Calamares is C++14).
foreach( CLANG_WARNINGS
-Weverything
-Wno-c++98-compat
@@ -88,6 +88,8 @@ else()
set( SUPPRESS_BOOST_WARNINGS "" )
endif()
# Use mark_thirdparty_code() to reduce warnings from the compiler
# on code that we're not going to fix. Call this with a list of files.
macro(mark_thirdparty_code)
set_source_files_properties( ${ARGV}
PROPERTIES
@@ -112,6 +114,16 @@ find_package( Qt5 ${QT_VERSION} CONFIG REQUIRED Core Gui Widgets LinguistTools S
find_package( YAMLCPP 0.5.1 REQUIRED )
find_package( PolkitQt5-1 REQUIRED )
# Find ECM once, and add it to the module search path; Calamares
# modules that need ECM can do
# find_package(ECM ${ECM_VERSION} REQUIRED NO_MODULE),
# no need to mess with the module path after.
set( ECM_VERSION 5.10.0 )
find_package(ECM ${ECM_VERSION} NO_MODULE)
if( ECM_FOUND )
set(CMAKE_MODULE_PATH ${ECM_MODULE_PATH} ${CMAKE_MODULE_PATH})
endif()
option( INSTALL_CONFIG "Install configuration files" ON )
option( WITH_PYTHON "Enable Python modules API (requires Boost.Python)." ON )
option( WITH_PYTHONQT "Enable next generation Python modules API (experimental, requires PythonQt)." OFF )
@@ -164,7 +176,7 @@ set( CALAMARES_TRANSLATION_LANGUAGES ar ast bg ca cs_CZ da de el en en_GB es_MX
### Bump version here
set( CALAMARES_VERSION_MAJOR 3 )
set( CALAMARES_VERSION_MINOR 1 )
set( CALAMARES_VERSION_PATCH 5 )
set( CALAMARES_VERSION_PATCH 11 )
set( CALAMARES_VERSION_RC 0 )
set( CALAMARES_VERSION ${CALAMARES_VERSION_MAJOR}.${CALAMARES_VERSION_MINOR}.${CALAMARES_VERSION_PATCH} )
@@ -265,12 +277,9 @@ else()
endif()
# Doesn't list mksquashfs as an optional dep, though, because it
# hasn't been sent through the find_package() scheme.
set_package_properties( mksquashfs PROPERTIES
DESCRIPTION "Create squashed filesystems"
URL "http://tldp.org/HOWTO/SquashFS-HOWTO/creatingandusing.html"
PURPOSE "Create example distro"
TYPE OPTIONAL
)
#
# "http://tldp.org/HOWTO/SquashFS-HOWTO/creatingandusing.html"
add_feature_info( ExampleDistro ${mksquashfs_FOUND} "Create example-distro target.")
# add_subdirectory( thirdparty )
add_subdirectory( src )

View File

@@ -6,9 +6,12 @@ set( MODULE_DATA_DESTINATION share/calamares/modules )
function( calamares_add_module_subdirectory )
set( SUBDIRECTORY ${ARGV0} )
set( MODULE_CONFIG_FILES "" )
# If this subdirectory has a CMakeLists.txt, we add_subdirectory it...
if( EXISTS "${CMAKE_CURRENT_SOURCE_DIR}/${SUBDIRECTORY}/CMakeLists.txt" )
add_subdirectory( ${SUBDIRECTORY} )
file( GLOB MODULE_CONFIG_FILES RELATIVE ${CMAKE_CURRENT_SOURCE_DIR}/${SUBDIRECTORY} "${SUBDIRECTORY}/*.conf" )
# ...otherwise, we look for a module.desc.
elseif( EXISTS "${CMAKE_CURRENT_SOURCE_DIR}/${SUBDIRECTORY}/module.desc" )
set( MODULES_DIR ${CMAKE_INSTALL_LIBDIR}/calamares/modules )
@@ -39,7 +42,7 @@ function( calamares_add_module_subdirectory )
# message( " ${Green}FILES:${ColorReset} ${MODULE_FILES}" )
message( " ${Green}MODULE_DESTINATION:${ColorReset} ${MODULE_DESTINATION}" )
if( MODULE_CONFIG_FILES )
if (INSTALL_CONFIG)
if ( INSTALL_CONFIG )
message( " ${Green}CONFIGURATION_FILES:${ColorReset} ${MODULE_CONFIG_FILES} => ${MODULE_DATA_DESTINATION}" )
else()
message( " ${Green}CONFIGURATION_FILES:${ColorReset} ${MODULE_CONFIG_FILES} => [Skipping installation]" )
@@ -56,9 +59,23 @@ function( calamares_add_module_subdirectory )
RENAME calamares-${SUBDIRECTORY}.mo
)
endif()
else()
message( "-- ${BoldYellow}Warning:${ColorReset} tried to add module subdirectory ${BoldRed}${SUBDIRECTORY}${ColorReset} which has no CMakeLists.txt or module.desc." )
message( "" )
endif()
# Check any config files for basic correctness
if ( BUILD_TESTING AND MODULE_CONFIG_FILES )
set( _count 0 )
foreach( _config_file ${MODULE_CONFIG_FILES} )
set( _count_str "-${_count}" )
if ( _count EQUAL 0 )
set( _count_str "" )
endif()
add_test(
NAME config-${SUBDIRECTORY}${_count_str}
COMMAND test_conf ${CMAKE_CURRENT_BINARY_DIR}/${SUBDIRECTORY}/${_config_file} )
math( EXPR _count "${_count} + 1" )
endforeach()
endif()
endfunction()

View File

@@ -96,7 +96,7 @@ CalamaresWindow::CalamaresWindow( QWidget* parent )
logoLabel->setAlignment( Qt::AlignCenter );
logoLabel->setFixedSize( 80, 80 );
logoLabel->setPixmap( Calamares::Branding::instance()->
image( Calamares::Branding::ProductIcon,
image( Calamares::Branding::ProductLogo,
logoLabel->size() ) );
logoLayout->addWidget( logoLabel );
logoLayout->addStretch();

View File

@@ -183,6 +183,16 @@ variantHashFromPyDict( const boost::python::dict& pyDict )
Helper* Helper::s_instance = nullptr;
static inline void add_if_lib_exists( const QDir& dir, const char* name, QStringList& list )
{
if ( ! ( dir.exists() && dir.isReadable() ) )
return;
QFileInfo fi( dir.absoluteFilePath( name ) );
if ( fi.exists() && fi.isReadable() )
list.append( fi.dir().absolutePath() );
}
Helper::Helper( QObject* parent )
: QObject( parent )
{
@@ -196,20 +206,11 @@ Helper::Helper( QObject* parent )
m_mainNamespace = m_mainModule.attr( "__dict__" );
// If we're running from the build dir
QFileInfo fi( QDir::current().absoluteFilePath( "libcalamares.so" ) );
if ( fi.exists() && fi.isReadable() )
m_pythonPaths.append( fi.dir().absolutePath() );
add_if_lib_exists( QDir::current(), "libcalamares.so", m_pythonPaths );
QDir calaPythonPath( CalamaresUtils::systemLibDir().absolutePath() +
QDir::separator() + "calamares" );
if ( calaPythonPath.exists() &&
calaPythonPath.isReadable() )
{
QFileInfo fi( calaPythonPath.absoluteFilePath( "libcalamares.so" ) );
if ( fi.exists() && fi.isReadable() )
m_pythonPaths.append( fi.dir().absolutePath() );
}
add_if_lib_exists( calaPythonPath, "libcalamares.so", m_pythonPaths );
bp::object sys = bp::import( "sys" );
@@ -232,7 +233,7 @@ Helper::~Helper()
{}
boost::python::object
boost::python::dict
Helper::createCleanNamespace()
{
// To make sure we run each script with a clean namespace, we only fetch the

View File

@@ -51,7 +51,7 @@ public:
explicit Helper( QObject* parent = nullptr );
virtual ~Helper();
boost::python::object createCleanNamespace();
boost::python::dict createCleanNamespace();
QString handleLastError();

View File

@@ -216,10 +216,10 @@ BOOST_PYTHON_MODULE( libcalamares )
"in the original string."
);
bp::def(
"gettext_languages",
&CalamaresPython::gettext_languages,
bp::def(
"gettext_languages",
&CalamaresPython::gettext_languages,
"Returns list of languages (most to least-specific) for gettext."
);
@@ -296,7 +296,7 @@ PythonJob::exec()
try
{
bp::object scriptNamespace = helper()->createCleanNamespace();
bp::dict scriptNamespace = helper()->createCleanNamespace();
bp::object calamaresModule = bp::import( "libcalamares" );
bp::dict calamaresNamespace = bp::extract< bp::dict >( calamaresModule.attr( "__dict__" ) );
@@ -310,7 +310,7 @@ PythonJob::exec()
scriptNamespace );
bp::object entryPoint = scriptNamespace[ "run" ];
bp::object prettyNameFunc = bp::getattr(scriptNamespace, "pretty_name", bp::object());
bp::object prettyNameFunc = scriptNamespace.get("pretty_name", bp::object());
cDebug() << "Job file" << scriptFI.absoluteFilePath();
if ( !prettyNameFunc.is_none() )

View File

@@ -256,5 +256,10 @@ System::getTotalMemoryB()
#endif
}
bool
System::doChroot() const
{
return m_doChroot;
}
} // namespace

View File

@@ -114,6 +114,8 @@ public:
*/
DLLEXPORT QPair<quint64, float> getTotalMemoryB();
DLLEXPORT bool doChroot() const;
private:
static System* s_instance;

View File

@@ -1,5 +1,10 @@
include( CMakeColors )
if( BUILD_TESTING )
add_executable( test_conf test_conf.cpp )
target_link_libraries( test_conf ${YAMLCPP_LIBRARY} )
endif()
file( GLOB SUBDIRECTORIES RELATIVE ${CMAKE_CURRENT_SOURCE_DIR} "*" )
string( REPLACE " " ";" SKIP_LIST "${SKIP_MODULES}" )
foreach( SUBDIRECTORY ${SUBDIRECTORIES} )

View File

@@ -8,7 +8,7 @@
# Copyright 2014, Daniel Hillenbrand <codeworkx@bbqlinux.org>
# Copyright 2014, Benjamin Vaudour <benjamin.vaudour@yahoo.fr>
# Copyright 2014, Kevin Kofler <kevin.kofler@chello.at>
# Copyright 2015, Philip Mueller <philm@manjaro.org>
# Copyright 2015-2017, Philip Mueller <philm@manjaro.org>
# Copyright 2016-2017, Teo Mrnjavac <teo@kde.org>
# Copyright 2017, Alf Gaida <agaida@siduction.org>
# Copyright 2017, Adriaan de Groot <groot@kde.org>
@@ -266,7 +266,13 @@ def install_grub(efi_directory, fw_type):
"64": os.path.join(install_efi_directory_firmware,
efi_bootloader_id,
"grubx64.efi")}
shutil.copy2(efi_file_source[efi_bitness], install_efi_boot_directory)
efi_file_target = {"32": os.path.join(install_efi_boot_directory,
"bootia32.efi"),
"64": os.path.join(install_efi_boot_directory,
"bootx64.efi")}
shutil.copy2(efi_file_source[efi_bitness], efi_file_target[efi_bitness])
else:
print("Bootloader: grub (bios)")
if libcalamares.globalstorage.value("bootLoader") is None:

View File

@@ -1,5 +1,5 @@
Configuration for the "finished" page, which is usually shown only at
the end of the installation (successful or not).
# Configuration for the "finished" page, which is usually shown only at
# the end of the installation (successful or not).
---
# The finished page can hold a "restart system now" checkbox.
# If this is false, no checkbox is show and the system is not restarted

View File

@@ -5,7 +5,8 @@
#
# Copyright 2014 - 2015, Philip Müller <philm@manjaro.org>
# Copyright 2014, Teo Mrnjavac <teo@kde.org>
# Copyright 2017. Alf Gaida <agaida@siduction.org>
# Copyright 2017, Alf Gaida <agaida@siduction.org>
# Copyright 2017, Gabriel Craciunescu <crazy@frugalware.org>
#
# Calamares is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
@@ -20,26 +21,33 @@
# You should have received a copy of the GNU General Public License
# along with Calamares. If not, see <http://www.gnu.org/licenses/>.
import subprocess
import shutil
import libcalamares
def run():
"""
Set hardware clock.
"""
hwclock_rtc = ["hwclock", "--systohc", "--utc"]
hwclock_isa = ["hwclock", "--systohc", "--utc", "--directisa"]
is_broken_rtc = False
is_broken_isa = False
root_mount_point = libcalamares.globalstorage.value("rootMountPoint")
try:
subprocess.check_call(["hwclock", "--systohc", "--utc"])
except subprocess.CalledProcessError as e:
return (
"Cannot set hardware clock.",
"hwclock terminated with exit code {}.".format(e.returncode)
)
shutil.copy2("/etc/adjtime", "{!s}/etc/".format(root_mount_point))
ret = libcalamares.utils.target_env_call(hwclock_rtc)
if ret != 0:
is_broken_rtc = True
libcalamares.utils.debug("Hwclock returned error code {}".format(ret))
libcalamares.utils.debug(" .. RTC method failed, trying ISA bus method.")
else:
libcalamares.utils.debug("Hwclock set using RTC method.")
if is_broken_rtc:
ret = libcalamares.utils.target_env_call(hwclock_isa)
if ret != 0:
is_broken_isa = True
libcalamares.utils.debug("Hwclock returned error code {}".format(ret))
libcalamares.utils.debug(" .. ISA bus method failed.")
else:
libcalamares.utils.debug("Hwclock set using ISA bus methode.")
if is_broken_rtc and is_broken_isa:
libcalamares.utils.debug("BIOS or Kernel BUG: Setting hwclock failed.")
return None

View File

@@ -24,6 +24,8 @@
# along with Calamares. If not, see <http://www.gnu.org/licenses/>.
import libcalamares
import inspect
import os
import shutil

View File

@@ -1,5 +1,4 @@
find_package(ECM 5.10.0 REQUIRED NO_MODULE)
set(CMAKE_MODULE_PATH ${ECM_MODULE_PATH} ${CMAKE_MODULE_PATH})
find_package(ECM ${ECM_VERSION} REQUIRED NO_MODULE)
include(KDEInstallDirs)
include(GenerateExportHeader)

View File

@@ -120,7 +120,7 @@ LocaleViewStep::fetchGeoIpTimezone()
try
{
YAML::Node doc = YAML::Load( reply->readAll() );
YAML::Node doc = YAML::Load( data );
QVariant var = CalamaresUtils::yamlToVariant( doc );
if ( !var.isNull() &&

View File

@@ -1,6 +1,7 @@
/* === This file is part of Calamares - <http://github.com/calamares> ===
*
* Copyright 2014-2015, Teo Mrnjavac <teo@kde.org>
* Copyright 2017, Adriaan de Groot <groot@kde.org>
*
* Originally from the Manjaro Installation Framework
* by Roland Singer <roland@manjaro.org>
@@ -20,61 +21,70 @@
* along with Calamares. If not, see <http://www.gnu.org/licenses/>.
*/
#include <cmath>
#include "timezonewidget.h"
TimeZoneWidget::TimeZoneWidget(QWidget* parent) :
QWidget(parent)
constexpr double MATH_PI = 3.14159265;
TimeZoneWidget::TimeZoneWidget( QWidget* parent ) :
QWidget( parent )
{
setMouseTracking(false);
setCursor(Qt::PointingHandCursor);
setMouseTracking( false );
setCursor( Qt::PointingHandCursor );
// Font
font.setPointSize(12);
font.setBold(false);
font.setPointSize( 12 );
font.setBold( false );
// Images
background = QImage(":/images/bg.png").scaled(X_SIZE, Y_SIZE, Qt::IgnoreAspectRatio, Qt::SmoothTransformation);
pin = QImage(":/images/pin.png");
background = QImage( ":/images/bg.png" ).scaled( X_SIZE, Y_SIZE, Qt::IgnoreAspectRatio, Qt::SmoothTransformation );
pin = QImage( ":/images/pin.png" );
// Set size
setMinimumSize(background.size());
setMaximumSize(background.size());
setMinimumSize( background.size() );
setMaximumSize( background.size() );
// Zone images
QStringList zones = QString(ZONES).split(" ", QString::SkipEmptyParts);
for (int i = 0; i < zones.size(); ++i)
timeZoneImages.append(QImage(":/images/timezone_" + zones.at(i) + ".png").scaled(X_SIZE, Y_SIZE, Qt::IgnoreAspectRatio, Qt::SmoothTransformation));
QStringList zones = QString( ZONES ).split( " ", QString::SkipEmptyParts );
for ( int i = 0; i < zones.size(); ++i )
timeZoneImages.append( QImage( ":/images/timezone_" + zones.at( i ) + ".png" ).scaled( X_SIZE, Y_SIZE, Qt::IgnoreAspectRatio, Qt::SmoothTransformation ) );
}
void TimeZoneWidget::setCurrentLocation(QString region, QString zone) {
void TimeZoneWidget::setCurrentLocation( QString region, QString zone )
{
QHash<QString, QList<LocaleGlobal::Location> > hash = LocaleGlobal::getLocations();
if (!hash.contains(region))
if ( !hash.contains( region ) )
return;
QList<LocaleGlobal::Location> locations = hash.value(region);
for (int i = 0; i < locations.size(); ++i) {
if (locations.at(i).zone == zone) {
setCurrentLocation(locations.at(i));
QList<LocaleGlobal::Location> locations = hash.value( region );
for ( int i = 0; i < locations.size(); ++i )
{
if ( locations.at( i ).zone == zone )
{
setCurrentLocation( locations.at( i ) );
break;
}
}
}
void TimeZoneWidget::setCurrentLocation(LocaleGlobal::Location location) {
void TimeZoneWidget::setCurrentLocation( LocaleGlobal::Location location )
{
currentLocation = location;
// Set zone
QPoint pos = getLocationPosition(currentLocation.longitude, currentLocation.latitude);
QPoint pos = getLocationPosition( currentLocation.longitude, currentLocation.latitude );
for (int i = 0; i < timeZoneImages.size(); ++i) {
for ( int i = 0; i < timeZoneImages.size(); ++i )
{
QImage zone = timeZoneImages[i];
// If not transparent set as current
if (zone.pixel(pos) != RGB_TRANSPARENT) {
if ( zone.pixel( pos ) != RGB_TRANSPARENT )
{
currentZoneImage = zone;
break;
}
@@ -91,74 +101,87 @@ void TimeZoneWidget::setCurrentLocation(LocaleGlobal::Location location) {
//###
QPoint TimeZoneWidget::getLocationPosition(double longitude, double latitude) {
QPoint TimeZoneWidget::getLocationPosition( double longitude, double latitude )
{
const int width = this->width();
const int height = this->height();
double x = (width / 2.0 + (width / 2.0) * longitude / 180.0) + MAP_X_OFFSET * width;
double y = (height / 2.0 - (height / 2.0) * latitude / 90.0) + MAP_Y_OFFSET * height;
double x = ( width / 2.0 + ( width / 2.0 ) * longitude / 180.0 ) + MAP_X_OFFSET * width;
double y = ( height / 2.0 - ( height / 2.0 ) * latitude / 90.0 ) + MAP_Y_OFFSET * height;
if (x < 0)
//Far north, the MAP_Y_OFFSET no longer holds, cancel the Y offset; it's noticeable
// from 62 degrees north, so scale those 28 degrees as if the world is flat south
// of there, and we have a funny "rounded" top of the world. In practice the locations
// of the different cities / regions looks ok -- at least Thule ends up in the right
// country, and Inuvik isn't in the ocean.
if ( latitude > 62.0 )
y -= sin( MATH_PI * ( latitude - 62.0 ) / 56.0 ) * MAP_Y_OFFSET * height;
// Antarctica isn't shown on the map, but you could try clicking there
if ( latitude < -60 )
y = height - 1;
if ( x < 0 )
x = width+x;
if (x >= width)
if ( x >= width )
x -= width;
if (y < 0)
if ( y < 0 )
y = height+y;
if (y >= height)
if ( y >= height )
y -= height;
return QPoint((int)x, (int)y);
return QPoint( ( int )x, ( int )y );
}
void TimeZoneWidget::paintEvent(QPaintEvent*) {
void TimeZoneWidget::paintEvent( QPaintEvent* )
{
const int width = this->width();
const int height = this->height();
QFontMetrics fontMetrics(font);
QPainter painter(this);
QFontMetrics fontMetrics( font );
QPainter painter( this );
painter.setRenderHint(QPainter::Antialiasing);
painter.setFont(font);
painter.setRenderHint( QPainter::Antialiasing );
painter.setFont( font );
// Draw background
painter.drawImage(0, 0, background);
painter.drawImage( 0, 0, background );
// Draw zone image
painter.drawImage(0, 0, currentZoneImage);
painter.drawImage( 0, 0, currentZoneImage );
// Draw pin
QPoint point = getLocationPosition(currentLocation.longitude, currentLocation.latitude);
painter.drawImage(point.x() - pin.width()/2, point.y() - pin.height()/2, pin);
QPoint point = getLocationPosition( currentLocation.longitude, currentLocation.latitude );
painter.drawImage( point.x() - pin.width()/2, point.y() - pin.height()/2, pin );
// Draw text and box
const int textWidth = fontMetrics.width(LocaleGlobal::Location::pretty(currentLocation.zone));
const int textWidth = fontMetrics.width( LocaleGlobal::Location::pretty( currentLocation.zone ) );
const int textHeight = fontMetrics.height();
QRect rect = QRect(point.x() - textWidth/2 - 5, point.y() - textHeight - 8, textWidth + 10, textHeight - 2);
QRect rect = QRect( point.x() - textWidth/2 - 5, point.y() - textHeight - 8, textWidth + 10, textHeight - 2 );
if (rect.x() <= 5)
rect.moveLeft(5);
if (rect.right() >= width-5)
rect.moveRight(width - 5);
if (rect.y() <= 5)
rect.moveTop(5);
if (rect.y() >= height-5)
rect.moveBottom(height-5);
if ( rect.x() <= 5 )
rect.moveLeft( 5 );
if ( rect.right() >= width-5 )
rect.moveRight( width - 5 );
if ( rect.y() <= 5 )
rect.moveTop( 5 );
if ( rect.y() >= height-5 )
rect.moveBottom( height-5 );
painter.setPen(QPen()); // no pen
painter.setBrush(QColor(40, 40, 40));
painter.drawRoundedRect(rect, 3, 3);
painter.setPen(Qt::white);
painter.drawText(rect.x() + 5, rect.bottom() - 4, LocaleGlobal::Location::pretty(currentLocation.zone));
painter.setPen( QPen() ); // no pen
painter.setBrush( QColor( 40, 40, 40 ) );
painter.drawRoundedRect( rect, 3, 3 );
painter.setPen( Qt::white );
painter.drawText( rect.x() + 5, rect.bottom() - 4, LocaleGlobal::Location::pretty( currentLocation.zone ) );
painter.end();
}
void TimeZoneWidget::mousePressEvent(QMouseEvent* event) {
if (event->button() != Qt::LeftButton)
void TimeZoneWidget::mousePressEvent( QMouseEvent* event )
{
if ( event->button() != Qt::LeftButton )
return;
// Set nearest location
@@ -167,14 +190,17 @@ void TimeZoneWidget::mousePressEvent(QMouseEvent* event) {
QHash<QString, QList<LocaleGlobal::Location> > hash = LocaleGlobal::getLocations();
QHash<QString, QList<LocaleGlobal::Location> >::iterator iter = hash.begin();
while (iter != hash.end()) {
while ( iter != hash.end() )
{
QList<LocaleGlobal::Location> locations = iter.value();
for (int i = 0; i < locations.size(); ++i) {
for ( int i = 0; i < locations.size(); ++i )
{
LocaleGlobal::Location loc = locations[i];
QPoint locPos = getLocationPosition(loc.longitude, loc.latitude);
QPoint locPos = getLocationPosition( loc.longitude, loc.latitude );
if ((abs(mX - locPos.x()) + abs(mY - locPos.y()) < abs(mX - nX) + abs(mY - nY))) {
if ( ( abs( mX - locPos.x() ) + abs( mY - locPos.y() ) < abs( mX - nX ) + abs( mY - nY ) ) )
{
currentLocation = loc;
nX = locPos.x();
nY = locPos.y();
@@ -185,8 +211,8 @@ void TimeZoneWidget::mousePressEvent(QMouseEvent* event) {
}
// Set zone image and repaint widget
setCurrentLocation(currentLocation);
setCurrentLocation( currentLocation );
// Emit signal
emit locationChanged(currentLocation);
emit locationChanged( currentLocation );
}

View File

@@ -48,14 +48,17 @@ class TimeZoneWidget : public QWidget
{
Q_OBJECT
public:
explicit TimeZoneWidget(QWidget* parent = 0);
explicit TimeZoneWidget( QWidget* parent = 0 );
LocaleGlobal::Location getCurrentLocation() { return currentLocation; }
void setCurrentLocation(QString region, QString zone);
void setCurrentLocation(LocaleGlobal::Location location);
LocaleGlobal::Location getCurrentLocation()
{
return currentLocation;
}
void setCurrentLocation( QString region, QString zone );
void setCurrentLocation( LocaleGlobal::Location location );
signals:
void locationChanged(LocaleGlobal::Location location);
void locationChanged( LocaleGlobal::Location location );
private:
QFont font;
@@ -63,10 +66,14 @@ private:
QList<QImage> timeZoneImages;
LocaleGlobal::Location currentLocation;
QPoint getLocationPosition(double longitude, double latitude);
QPoint getLocationPosition( const LocaleGlobal::Location& l )
{
return getLocationPosition( l.longitude, l.latitude );
}
QPoint getLocationPosition( double longitude, double latitude );
void paintEvent(QPaintEvent* event);
void mousePressEvent(QMouseEvent* event);
void paintEvent( QPaintEvent* event );
void mousePressEvent( QMouseEvent* event );
};
#endif // TIMEZONEWIDGET_H

View File

@@ -3,6 +3,7 @@
* Copyright 2016, Lisa Vitolo <shainer@chakraos.org>
* Copyright 2017, Kyle Robbertze <krobbertze@gmail.com>
* Copyright 2017, Adriaan de Groot <groot@kde.org>
* Copyright 2017, Gabriel Craciunescu <crazy@frugalware.org>
*
* Calamares is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
@@ -56,14 +57,6 @@ NetInstallPage::NetInstallPage( QWidget* parent )
ui->setupUi( this );
}
bool
NetInstallPage::isReady()
{
// nothing to wait for, the data are immediately ready
// if the user does not select any group nothing is installed
return true;
}
bool
NetInstallPage::readGroups( const QByteArray& yamlData )
{
@@ -77,7 +70,7 @@ NetInstallPage::readGroups( const QByteArray& yamlData )
m_groups = new PackageModel( groups );
CALAMARES_RETRANSLATE(
m_groups->setHeaderData( 0, Qt::Horizontal, tr( "Name" ) );
m_groups->setHeaderData( 0, Qt::Horizontal, tr( "Description" ) ); )
m_groups->setHeaderData( 1, Qt::Horizontal, tr( "Description" ) ); )
return true;
}
@@ -91,10 +84,13 @@ NetInstallPage::readGroups( const QByteArray& yamlData )
void
NetInstallPage::dataIsHere( QNetworkReply* reply )
{
// If m_required is *false* then we still say we're ready
// even if the reply is corrupt or missing.
if ( reply->error() != QNetworkReply::NoError )
{
cDebug() << reply->errorString();
ui->netinst_status->setText( tr( "Network Installation. (Disabled: Unable to fetch package lists, check your network connection)" ) );
emit checkReady( !m_required );
return;
}
@@ -103,6 +99,7 @@ NetInstallPage::dataIsHere( QNetworkReply* reply )
cDebug() << "Netinstall groups data was received, but invalid.";
ui->netinst_status->setText( tr( "Network Installation. (Disabled: Unable to fetch package lists, check your network connection)" ) );
reply->deleteLater();
emit checkReady( !m_required );
return;
}
@@ -111,15 +108,23 @@ NetInstallPage::dataIsHere( QNetworkReply* reply )
ui->groupswidget->header()->setSectionResizeMode( 1, QHeaderView::Stretch );
reply->deleteLater();
emit checkReady( isReady() );
emit checkReady( true );
}
QList<PackageTreeItem::ItemData> NetInstallPage::selectedPackages() const
PackageModel::PackageItemDataList
NetInstallPage::selectedPackages() const
{
return m_groups->getPackages();
if ( m_groups )
return m_groups->getPackages();
else
{
cDebug() << "WARNING: no netinstall groups are available.";
return PackageModel::PackageItemDataList();
}
}
void NetInstallPage::loadGroupList()
void
NetInstallPage::loadGroupList()
{
QString confUrl(
Calamares::JobQueue::instance()->globalStorage()->value(
@@ -138,7 +143,15 @@ void NetInstallPage::loadGroupList()
m_networkManager.get( request );
}
void NetInstallPage::onActivate()
void
NetInstallPage::setRequired( bool b )
{
m_required = b;
}
void
NetInstallPage::onActivate()
{
ui->groupswidget->setFocus();
}

View File

@@ -46,17 +46,24 @@ public:
void onActivate();
bool isReady();
// Retrieves the groups, with name, description and packages, from
// the remote URL configured in the settings. Assumes the URL is already
// in the global storage. This should be called before displaying the page.
void loadGroupList();
// Sets the "required" state of netinstall data. Influences whether
// corrupt or unavailable data causes checkReady() to be emitted
// true (not-required) or false.
void setRequired( bool );
bool getRequired() const
{
return m_required;
}
// Returns the list of packages belonging to groups that are
// selected in the view in this given moment. No data is cached here, so
// this function does not have constant time.
QList<PackageTreeItem::ItemData> selectedPackages() const;
PackageModel::PackageItemDataList selectedPackages() const;
public slots:
void dataIsHere( QNetworkReply* );
@@ -76,6 +83,7 @@ private:
QNetworkAccessManager m_networkManager;
PackageModel* m_groups;
bool m_required;
};
#endif // NETINSTALLPAGE_H

View File

@@ -2,6 +2,7 @@
* Copyright 2016, Luca Giambonini <almack@chakraos.org>
* Copyright 2016, Lisa Vitolo <shainer@chakraos.org>
* Copyright 2017, Kyle Robbertze <krobbertze@gmail.com>
* Copyright 2017, Adriaan de Groot <groot@kde.org>
*
* Calamares is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
@@ -30,11 +31,11 @@ CALAMARES_PLUGIN_FACTORY_DEFINITION( NetInstallViewStepFactory, registerPlugin<N
NetInstallViewStep::NetInstallViewStep( QObject* parent )
: Calamares::ViewStep( parent )
, m_widget( new NetInstallPage() )
, m_nextEnabled( true )
, m_nextEnabled( false )
{
emit nextStatusChanged( true );
connect( m_widget, &NetInstallPage::checkReady,
this, &NetInstallViewStep::nextStatusChanged );
this, &NetInstallViewStep::nextIsReady );
}
@@ -126,18 +127,26 @@ NetInstallViewStep::onLeave()
cDebug() << "Leaving netinstall, adding packages to be installed"
<< "to global storage";
QMap<QString, QVariant> packagesWithOperation;
QList<PackageTreeItem::ItemData> packages = m_widget->selectedPackages();
PackageModel::PackageItemDataList packages = m_widget->selectedPackages();
QVariantList installPackages;
QVariantList tryInstallPackages;
cDebug() << "Processing";
QVariantList packageOperations;
cDebug() << "Processing" << packages.length() << "packages from netinstall.";
for ( auto package : packages )
{
QMap<QString, QVariant> details;
details.insert( "pre-script", package.preScript );
details.insert( "package", package.packageName );
details.insert( "post-script", package.postScript );
QVariant details( package.packageName );
// If it's a package with a pre- or post-script, replace
// with the more complicated datastructure.
if ( !package.preScript.isEmpty() || !package.postScript.isEmpty() )
{
QMap<QString, QVariant> sdetails;
sdetails.insert( "pre-script", package.preScript );
sdetails.insert( "package", package.packageName );
sdetails.insert( "post-script", package.postScript );
details = sdetails;
}
if ( package.isCritical )
installPackages.append( details );
else
@@ -145,14 +154,24 @@ NetInstallViewStep::onLeave()
}
if ( !installPackages.empty() )
packagesWithOperation.insert( "install", QVariant( installPackages ) );
{
QMap<QString, QVariant> op;
op.insert( "install", QVariant( installPackages ) );
packageOperations.append( op );
cDebug() << " .." << installPackages.length() << "critical packages.";
}
if ( !tryInstallPackages.empty() )
packagesWithOperation.insert( "try_install", QVariant( tryInstallPackages ) );
{
QMap<QString, QVariant> op;
op.insert( "try_install", QVariant( tryInstallPackages ) );
packageOperations.append( op );
cDebug() << " .." << tryInstallPackages.length() << "non-critical packages.";
}
if ( !packagesWithOperation.isEmpty() )
if ( !packageOperations.isEmpty() )
{
Calamares::GlobalStorage* gs = Calamares::JobQueue::instance()->globalStorage();
gs->insert( "packageOperations", QVariant( packagesWithOperation ) );
gs->insert( "packageOperations", QVariant( packageOperations ) );
}
}
@@ -160,6 +179,11 @@ NetInstallViewStep::onLeave()
void
NetInstallViewStep::setConfigurationMap( const QVariantMap& configurationMap )
{
m_widget->setRequired(
configurationMap.contains( "required" ) &&
configurationMap.value( "required" ).type() == QVariant::Bool &&
configurationMap.value( "required" ).toBool() );
if ( configurationMap.contains( "groupsUrl" ) &&
configurationMap.value( "groupsUrl" ).type() == QVariant::String )
{
@@ -168,3 +192,10 @@ NetInstallViewStep::setConfigurationMap( const QVariantMap& configurationMap )
m_widget->loadGroupList();
}
}
void
NetInstallViewStep::nextIsReady( bool b )
{
m_nextEnabled = b;
emit nextStatusChanged( b );
}

View File

@@ -60,6 +60,9 @@ public:
void setConfigurationMap( const QVariantMap& configurationMap ) override;
public slots:
void nextIsReady( bool );
private:
NetInstallPage* m_widget;
bool m_nextEnabled;

View File

@@ -163,7 +163,8 @@ PackageModel::getPackages() const
{
QList<PackageTreeItem*> items = getItemPackages( m_rootItem );
for ( auto package : m_hiddenItems )
items.append( getItemPackages( package ) );
if ( package->hiddenSelected() )
items.append( getItemPackages( package ) );
QList<PackageTreeItem::ItemData> packages;
for ( auto item : items )
{

View File

@@ -1,3 +1,4 @@
/* === This file is part of Calamares - <http://github.com/calamares> ===
*
* Copyright (c) 2017, Kyle Robbertze <kyle@aims.ac.za>
@@ -28,14 +29,13 @@
#include <yaml-cpp/yaml.h>
// Required forward declarations
class PackageTreeItem;
class PackageModel : public QAbstractItemModel
{
Q_OBJECT
public:
using PackageItemDataList = QList< PackageTreeItem::ItemData >;
explicit PackageModel( const YAML::Node& data, QObject* parent = nullptr );
~PackageModel() override;
@@ -52,7 +52,7 @@ public:
QModelIndex parent( const QModelIndex& index ) const override;
int rowCount( const QModelIndex& parent = QModelIndex() ) const override;
int columnCount( const QModelIndex& parent = QModelIndex() ) const override;
QList<PackageTreeItem::ItemData> getPackages() const;
PackageItemDataList getPackages() const;
QList<PackageTreeItem*> getItemPackages( PackageTreeItem* item ) const;
private:

View File

@@ -19,6 +19,8 @@
#include "PackageTreeItem.h"
#include "utils/Logger.h"
PackageTreeItem::PackageTreeItem( const ItemData& data, PackageTreeItem* parent )
: m_parentItem( parent )
, m_data( data )
@@ -36,7 +38,15 @@ PackageTreeItem::PackageTreeItem( const QString packageName, PackageTreeItem* pa
PackageTreeItem::PackageTreeItem( PackageTreeItem* parent ) :
m_parentItem( parent )
{ }
{
}
PackageTreeItem::PackageTreeItem::PackageTreeItem() :
PackageTreeItem( QString(), nullptr )
{
m_data.selected = Qt::Checked;
m_data.name = QLatin1Literal( "<root>" );
}
PackageTreeItem::~PackageTreeItem()
{
@@ -101,6 +111,13 @@ PackageTreeItem::parentItem()
return m_parentItem;
}
const PackageTreeItem*
PackageTreeItem::parentItem() const
{
return m_parentItem;
}
QString
PackageTreeItem::prettyName() const
{
@@ -143,6 +160,26 @@ PackageTreeItem::setHidden( bool isHidden )
m_data.isHidden = isHidden;
}
bool
PackageTreeItem::hiddenSelected() const
{
Q_ASSERT( m_data.isHidden );
if (! m_data.selected )
return false;
const PackageTreeItem* currentItem = parentItem();
while ( currentItem != nullptr )
{
if ( !currentItem->isHidden() )
return currentItem->isSelected() != Qt::Unchecked;
currentItem = currentItem->parentItem();
}
/* Has no non-hiddent parents */
return m_data.selected;
}
bool
PackageTreeItem::isCritical() const
{
@@ -164,34 +201,47 @@ PackageTreeItem::isSelected() const
void
PackageTreeItem::setSelected( Qt::CheckState isSelected )
{
if ( parentItem() == nullptr )
// This is the root, it is always checked so don't change state
return;
m_data.selected = isSelected;
setChildrenSelected( isSelected );
// Look for suitable parent item which may change checked-state
// when one of its children changes.
PackageTreeItem* currentItem = parentItem();
while ( currentItem != nullptr )
while ( ( currentItem != nullptr ) && ( currentItem->childCount() == 0 ) )
{
int childrenSelected = 0;
bool isChildPartiallySelected = false;
for ( int i = 0; i < currentItem->childCount(); i++ )
{
if ( currentItem->child( i )->isSelected() == Qt::Checked )
childrenSelected++;
if ( currentItem->child( i )->isSelected() == Qt::PartiallyChecked )
isChildPartiallySelected = true;
}
if ( !childrenSelected && !isChildPartiallySelected )
currentItem->m_data.selected = Qt::Unchecked;
else if ( childrenSelected == currentItem->childCount() )
currentItem->m_data.selected = Qt::Checked;
else
currentItem->m_data.selected = Qt::PartiallyChecked;
currentItem = currentItem->parentItem();
}
if ( currentItem == nullptr )
// Reached the root .. don't bother
return;
// Figure out checked-state based on the children
int childrenSelected = 0;
int childrenPartiallySelected = 0;
for ( int i = 0; i < currentItem->childCount(); i++ )
{
if ( currentItem->child( i )->isSelected() == Qt::Checked )
childrenSelected++;
if ( currentItem->child( i )->isSelected() == Qt::PartiallyChecked )
childrenPartiallySelected++;
}
if ( !childrenSelected && !childrenPartiallySelected)
currentItem->setSelected( Qt::Unchecked );
else if ( childrenSelected == currentItem->childCount() )
currentItem->setSelected( Qt::Checked );
else
currentItem->setSelected( Qt::PartiallyChecked );
}
void
PackageTreeItem::setChildrenSelected( Qt::CheckState isSelected )
{
if ( isSelected != Qt::PartiallyChecked )
// Children are never root; don't need to use setSelected on them.
for ( auto child : m_childItems )
{
child->m_data.selected = isSelected;

View File

@@ -40,7 +40,8 @@ public:
};
explicit PackageTreeItem( const ItemData& data, PackageTreeItem* parent = nullptr );
explicit PackageTreeItem( const QString packageName, PackageTreeItem* parent = nullptr );
explicit PackageTreeItem( PackageTreeItem* parent = nullptr );
explicit PackageTreeItem( PackageTreeItem* parent );
explicit PackageTreeItem(); // The root of the tree; always selected, named <root>
~PackageTreeItem() override;
void appendChild( PackageTreeItem* child );
@@ -49,16 +50,30 @@ public:
int columnCount() const;
QVariant data( int column ) const override;
int row() const;
PackageTreeItem* parentItem();
const PackageTreeItem* parentItem() const;
QString prettyName() const;
QString description() const;
QString preScript() const;
QString packageName() const;
QString postScript() const;
bool isHidden() const;
void setHidden( bool isHidden );
/**
* @brief Is this hidden item, considered "selected"?
*
* This asserts when called on a non-hidden item.
* A hidden item has its own selected state, but really
* falls under the selectedness of the parent item.
*/
bool hiddenSelected() const;
bool isCritical() const;
void setCritical( bool isCritical );
Qt::CheckState isSelected() const;
void setSelected( Qt::CheckState isSelected );
void setChildrenSelected( Qt::CheckState isSelected );

View File

@@ -1,2 +1,13 @@
---
# This is the URL that is retrieved to get the netinstall groups-and-packages
# data (which should be in the format described in netinstall.yaml).
groupsUrl: http://chakraos.org/netinstall.php
# If the installation can proceed without netinstall (e.g. the Live CD
# can create a working installed system, but netinstall is preferred
# to bring it up-to-date or extend functionality) leave this set to
# false (the default). If set to true, the netinstall data is required.
#
# This only has an effect if the netinstall data cannot be retrieved,
# or is corrupt: having "required" set, means the install cannot proceed.
required: false

View File

@@ -55,8 +55,12 @@ def _change_mode(mode):
def pretty_name():
if not group_packages:
# Outside the context of an operation
s = _("Processing packages (%(count)d / %(total)d)")
if (total_packages > 0):
# Outside the context of an operation
s = _("Processing packages (%(count)d / %(total)d)")
else:
s = _("Install packages.")
elif mode_packages is INSTALL:
s = _n("Installing one package.",
"Installing %(num)d packages.", group_packages)
@@ -344,10 +348,18 @@ def subst_locale(plist):
def run_operations(pkgman, entry):
"""
Call package manager with given parameters.
Call package manager with suitable parameters for the given
package actions.
:param pkgman:
:param entry:
:param pkgman: PackageManager
This is the manager that does the actual work.
:param entry: dict
Keys are the actions -- e.g. "install" -- to take, and the values
are the (list of) packages to apply the action to. The actions are
not iterated in a specific order, so it is recommended to use only
one action per dictionary. The list of packages may be package
names (strings) or package information dictionaries with pre-
and post-scripts.
"""
global group_packages, completed_packages, mode_packages
@@ -414,6 +426,11 @@ def run():
else:
return "Bad backend", "backend=\"{}\"".format(backend)
skip_this = libcalamares.job.configuration.get("skip_if_no_internet", False)
if skip_this and not libcalamares.globalstorage.value("hasInternet"):
libcalamares.utils.debug( "WARNING: packages installation has been skipped: no internet" )
return None
update_db = libcalamares.job.configuration.get("update_db", False)
if update_db and libcalamares.globalstorage.value("hasInternet"):
pkgman.update_db()

View File

@@ -14,9 +14,20 @@
#
backend: dummy
# If set to true, a package-manager specific update procedure
# is run first (only if there is internet) to update the list
# of packages and dependencies.
# Often package installation needs an internet connection.
# Since you may allow system installation without a connection
# and want to offer **optional** package installation, it's
# possible to have no internet, yet have this packages module
# enabled in settings.
#
# You can skip the whole module when there is no internet
# by setting *skip_if_no_internet* to true.
#
# You can run a package-manager specific update procedure
# before installing packages (for instance, to update the
# list of packages and dependencies); this is done only if there
# is an internet connection. Set *update_db* to true to do so.
skip_if_no_internet: false
update_db: true
#
@@ -29,9 +40,10 @@ update_db: true
# packages that need to be installed or removed can run before
# this one. Distro developers may want to install locale packages
# or remove drivers not needed on the installed system.
# This job will populate a list of dictionaries in the global
# storage called "packageOperations" and it is processed
# after the static list in the job configuration.
# Such a job would populate a list of dictionaries in the global
# storage called "packageOperations" and that list is processed
# after the static list in the job configuration (i.e. the list
# that is in this configuration file).
#
# Allowed package operations are:
# - install, try_install: will call the package manager to
@@ -49,7 +61,7 @@ update_db: true
# while try_remove carries on. Packages may be listed as
# (localized) names.
#
# There are two formats for naming packages: as a name # or as package-data,
# There are two formats for naming packages: as a name or as package-data,
# which is an object notation providing package-name, as well as pre- and
# post-install scripts.
#
@@ -74,15 +86,16 @@ update_db: true
#
# - if the system locale is English (generally US English; en_GB is a valid
# localization), then the package is not installed at all,
# - otherwise LOCALE is replaced by the Bcp47 name of the selected system
# locale, e.g. nl_BE.
# - otherwise $LOCALE or ${LOCALE} is replaced by the Bcp47 name of the selected
# system locale, e.g. nl_BE. Note that just plain LOCALE will not be replaced,
# so foo-LOCALE will be unchanged, while foo-$LOCALE will be changed.
#
# The following installs localizations for vi, if they are relevant; if
# there is no localization, installation continues normally.
#
# - install
# - vi-LOCALE
# - package: vi-LOCALE
# - vi-$LOCALE
# - package: vi-${LOCALE}
# pre-script: touch /tmp/installing-vi
# post-script: rm -f /tmp/installing-vi
#

View File

@@ -1,5 +1,4 @@
find_package(ECM 5.10.0 REQUIRED NO_MODULE)
set(CMAKE_MODULE_PATH ${ECM_MODULE_PATH} ${CMAKE_MODULE_PATH})
find_package(ECM ${ECM_VERSION} REQUIRED NO_MODULE)
include(KDEInstallDirs)
include(GenerateExportHeader)
@@ -9,10 +8,22 @@ find_package( KF5 REQUIRED CoreAddons )
find_package( KF5 REQUIRED Config I18n IconThemes KIO Service )
find_package( KPMcore 3.1.50 QUIET )
if ( ${KPMcore_FOUND} )
if ( KPMcore_FOUND )
add_definitions(-DWITH_KPMCORE22)
endif()
find_package( KPMcore 3.0.3 REQUIRED )
find_package( KPMcore 3.0.3 QUIET )
# 3.0.3 and newer has fixes for NVMe support; allow 3.0.2, but warn
# about it .. needs to use a different feature name because it otherwise
# gets reported as KPMcore (the package).
if ( KPMcore_FOUND )
message( STATUS "KPMCore supports NVMe operations" )
add_feature_info( KPMcoreNVMe KPMcore_FOUND "KPMcore with NVMe support" )
else()
find_package( KPMcore 3.0.2 REQUIRED )
message( WARNING "KPMCore 3.0.2 is known to have bugs with NVMe devices" )
add_feature_info( KPMcoreNVMe KPMcore_FOUND "Older KPMcore with no NVMe support" )
endif()
find_library( atasmart_LIB atasmart )
find_library( blkid_LIB blkid )
if( NOT atasmart_LIB )
@@ -58,7 +69,6 @@ calamares_add_plugin( partition
gui/PrettyRadioButton.cpp
gui/ScanningDialog.cpp
gui/ReplaceWidget.cpp
jobs/CheckFileSystemJob.cpp
jobs/ClearMountsJob.cpp
jobs/ClearTempMountsJob.cpp
jobs/CreatePartitionJob.cpp
@@ -66,7 +76,6 @@ calamares_add_plugin( partition
jobs/DeletePartitionJob.cpp
jobs/FillGlobalStorageJob.cpp
jobs/FormatPartitionJob.cpp
jobs/MoveFileSystemJob.cpp
jobs/PartitionJob.cpp
jobs/ResizePartitionJob.cpp
jobs/SetPartitionFlagsJob.cpp

View File

@@ -1,83 +0,0 @@
/* === This file is part of Calamares - <http://github.com/calamares> ===
*
* Copyright 2014, Aurélien Gâteau <agateau@kde.org>
* Copyright 2016, Teo Mrnjavac <teo@kde.org>
*
* Calamares is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* Calamares is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with Calamares. If not, see <http://www.gnu.org/licenses/>.
*/
#include "jobs/CheckFileSystemJob.h"
#include <utils/Logger.h>
// KPMcore
#include <kpmcore/core/partition.h>
#include <kpmcore/fs/filesystem.h>
#include <kpmcore/util/report.h>
#include <QThread>
CheckFileSystemJob::CheckFileSystemJob( Partition* partition )
: PartitionJob( partition )
{}
QString
CheckFileSystemJob::prettyName() const
{
QString path = partition()->partitionPath();
return tr( "Checking file system on partition %1." ).arg( path );
}
QString
CheckFileSystemJob::prettyStatusMessage() const
{
return prettyName();
}
Calamares::JobResult
CheckFileSystemJob::exec()
{
FileSystem& fs = partition()->fileSystem();
// if we cannot check, assume everything is fine
if ( fs.supportCheck() != FileSystem::cmdSupportFileSystem )
return Calamares::JobResult::ok();
Report report( nullptr );
bool ok = fs.check( report, partition()->partitionPath() );
int retries = 0;
const int MAX_RETRIES = 10;
while ( !ok )
{
cDebug() << "Partition" << partition()->partitionPath()
<< "might not be ready yet, retrying (" << ++retries
<< "/" << MAX_RETRIES << ") ...";
QThread::sleep( 2 /*seconds*/ );
ok = fs.check( report, partition()->partitionPath() );
if ( retries == MAX_RETRIES )
break;
}
if ( !ok )
return Calamares::JobResult::error(
tr( "The file system check on partition %1 failed." )
.arg( partition()->partitionPath() ),
report.toText()
);
return Calamares::JobResult::ok();
}

View File

@@ -1,239 +0,0 @@
/* === This file is part of Calamares - <http://github.com/calamares> ===
*
* Copyright 2014, Aurélien Gâteau <agateau@kde.org>
*
* Calamares is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* Calamares is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with Calamares. If not, see <http://www.gnu.org/licenses/>.
*/
// This class is heavily based on the MoveFileSystemJob class from KDE Partition
// Manager.
// The copyBlock functions come from Partition Manager Job class.
// Original copyright follow:
/***************************************************************************
* Copyright (C) 2008 by Volker Lanz <vl@fidra.de> *
* *
* This program is free software; you can redistribute it and/or modify *
* it under the terms of the GNU General Public License as published by *
* the Free Software Foundation; either version 2 of the License, or *
* (at your option) any later version. *
* *
* This program is distributed in the hope that it will be useful, *
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
* GNU General Public License for more details. *
* *
* You should have received a copy of the GNU General Public License *
* along with this program; if not, write to the *
* Free Software Foundation, Inc., *
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA *
***************************************************************************/
#include <jobs/MoveFileSystemJob.h>
#include <utils/Logger.h>
// KPMcore
#include <kpmcore/core/copysourcedevice.h>
#include <kpmcore/core/copytargetdevice.h>
#include <kpmcore/core/device.h>
#include <kpmcore/core/partition.h>
#include <kpmcore/fs/filesystem.h>
#include <kpmcore/util/report.h>
MoveFileSystemJob::MoveFileSystemJob( Device* device, Partition* partition, qint64 oldFirstSector, qint64 newFirstSector, qint64 length )
: PartitionJob( partition )
, m_device( device )
, m_oldFirstSector( oldFirstSector )
, m_newFirstSector( newFirstSector )
, m_length( length )
{}
QString
MoveFileSystemJob::prettyName() const
{
return tr( "Move file system of partition %1." ).arg( partition()->partitionPath() );
}
Calamares::JobResult
MoveFileSystemJob::exec()
{
Report report( nullptr );
QString partitionPath = partition()->partitionPath();
CopySourceDevice moveSource( *m_device, m_oldFirstSector, m_oldFirstSector + m_length - 1 );
CopyTargetDevice moveTarget( *m_device, m_newFirstSector, m_newFirstSector + m_length - 1 );
if ( !moveSource.open() )
return Calamares::JobResult::error(
QString(),
tr( "Could not open file system on partition %1 for moving." ).arg( partitionPath )
);
if ( !moveTarget.open() )
return Calamares::JobResult::error(
QString(),
tr( "Could not create target for moving file system on partition %1." ).arg( partitionPath )
);
bool ok = copyBlocks( report, moveTarget, moveSource );
if ( !ok )
{
if ( rollbackCopyBlocks( report, moveTarget, moveSource ) )
return Calamares::JobResult::error(
QString(),
tr( "Moving of partition %1 failed, changes have been rolled back." ).arg( partitionPath )
+ '\n' + report.toText()
);
else
return Calamares::JobResult::error(
QString(),
tr( "Moving of partition %1 failed. Roll back of the changes have failed." ).arg( partitionPath )
+ '\n' + report.toText()
);
}
FileSystem& fs = partition()->fileSystem();
fs.setFirstSector( m_newFirstSector );
fs.setLastSector( m_newFirstSector + m_length - 1 );
if ( !fs.updateBootSector( report, partitionPath ) )
return Calamares::JobResult::error(
QString(),
tr( "Updating boot sector after the moving of partition %1 failed." ).arg( partitionPath )
+ '\n' + report.toText()
);
return Calamares::JobResult::ok();
}
bool
MoveFileSystemJob::copyBlocks( Report& report, CopyTargetDevice& target, CopySourceDevice& source )
{
/** @todo copyBlocks() assumes that source.sectorSize() == target.sectorSize(). */
if ( source.sectorSize() != target.sectorSize() )
{
report.line() << tr( "The logical sector sizes in the source and target for copying are not the same. This is currently unsupported." );
return false;
}
bool rval = true;
const qint64 blockSize = 16065 * 8; // number of sectors per block to copy
const qint64 blocksToCopy = source.length() / blockSize;
qint64 readOffset = source.firstSector();
qint64 writeOffset = target.firstSector();
qint32 copyDir = 1;
if ( target.firstSector() > source.firstSector() )
{
readOffset = source.firstSector() + source.length() - blockSize;
writeOffset = target.firstSector() + source.length() - blockSize;
copyDir = -1;
}
qint64 blocksCopied = 0;
Q_ASSERT( blockSize > 0 );
Q_ASSERT( source.sectorSize() > 0 );
Q_ASSERT( blockSize * source.sectorSize() > 0 );
void* buffer = malloc( size_t( blockSize * source.sectorSize() ) );
qint64 percent = 0;
while ( blocksCopied < blocksToCopy )
{
rval = source.readSectors( buffer, readOffset + blockSize * blocksCopied * copyDir, blockSize );
if ( !rval )
break;
rval = target.writeSectors( buffer, writeOffset + blockSize * blocksCopied * copyDir, blockSize );
if ( !rval )
break;
if ( ++blocksCopied * 100 / blocksToCopy != percent )
{
percent = blocksCopied * 100 / blocksToCopy;
progress( percent / 100. );
}
}
const qint64 lastBlock = source.length() % blockSize;
// copy the remainder
if ( rval && lastBlock > 0 )
{
Q_ASSERT( lastBlock < blockSize );
const qint64 lastBlockReadOffset = copyDir > 0 ? readOffset + blockSize * blocksCopied : source.firstSector();
const qint64 lastBlockWriteOffset = copyDir > 0 ? writeOffset + blockSize * blocksCopied : target.firstSector();
rval = source.readSectors( buffer, lastBlockReadOffset, lastBlock );
if ( rval )
rval = target.writeSectors( buffer, lastBlockWriteOffset, lastBlock );
if ( rval )
emit progress( 1.0 );
}
free( buffer );
return rval;
}
bool
MoveFileSystemJob::rollbackCopyBlocks( Report& report, CopyTargetDevice& origTarget, CopySourceDevice& origSource )
{
if ( !origSource.overlaps( origTarget ) )
{
report.line() << tr( "Source and target for copying do not overlap: Rollback is not required." );
return true;
}
// default: use values as if we were copying from front to back.
qint64 undoSourceFirstSector = origTarget.firstSector();
qint64 undoSourceLastSector = origTarget.firstSector() + origTarget.sectorsWritten() - 1;
qint64 undoTargetFirstSector = origSource.firstSector();
qint64 undoTargetLastSector = origSource.firstSector() + origTarget.sectorsWritten() - 1;
if ( origTarget.firstSector() > origSource.firstSector() )
{
// we were copying from back to front
undoSourceFirstSector = origTarget.firstSector() + origSource.length() - origTarget.sectorsWritten();
undoSourceLastSector = origTarget.firstSector() + origSource.length() - 1;
undoTargetFirstSector = origSource.lastSector() - origTarget.sectorsWritten() + 1;
undoTargetLastSector = origSource.lastSector();
}
CopySourceDevice undoSource( origTarget.device(), undoSourceFirstSector, undoSourceLastSector );
if ( !undoSource.open() )
{
report.line() << tr( "Could not open device %1 to rollback copying." )
.arg( origTarget.device().deviceNode() );
return false;
}
CopyTargetDevice undoTarget( origSource.device(), undoTargetFirstSector, undoTargetLastSector );
if ( !undoTarget.open() )
{
report.line() << tr( "Could not open device %1 to rollback copying." )
.arg( origSource.device().deviceNode() );
return false;
}
return copyBlocks( report, undoTarget, undoSource );
}

View File

@@ -1,76 +0,0 @@
/* === This file is part of Calamares - <http://github.com/calamares> ===
*
* Copyright 2014, Aurélien Gâteau <agateau@kde.org>
*
* Calamares is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* Calamares is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with Calamares. If not, see <http://www.gnu.org/licenses/>.
*/
// This class is heavily based on the MoveFileSystemJob class from KDE Partition
// Manager. Original copyright follow:
/***************************************************************************
* Copyright (C) 2008 by Volker Lanz <vl@fidra.de> *
* *
* This program is free software; you can redistribute it and/or modify *
* it under the terms of the GNU General Public License as published by *
* the Free Software Foundation; either version 2 of the License, or *
* (at your option) any later version. *
* *
* This program is distributed in the hope that it will be useful, *
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
* GNU General Public License for more details. *
* *
* You should have received a copy of the GNU General Public License *
* along with this program; if not, write to the *
* Free Software Foundation, Inc., *
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA *
***************************************************************************/
#ifndef MOVEFILESYSTEMJOB_H
#define MOVEFILESYSTEMJOB_H
#include <jobs/PartitionJob.h>
class CopySourceDevice;
class CopyTargetDevice;
class Device;
class Partition;
class Report;
/**
* This job moves the data of a filesystem from one position on the disk to
* another.
*
* It is used by the ResizePartitionJob.
*/
class MoveFileSystemJob : public PartitionJob
{
Q_OBJECT
public:
MoveFileSystemJob( Device* device, Partition* partition, qint64 oldFirstSector, qint64 newFirstSector, qint64 length );
QString prettyName() const override;
Calamares::JobResult exec() override;
private:
Device* m_device;
qint64 m_oldFirstSector;
qint64 m_newFirstSector;
qint64 m_length;
bool copyBlocks( Report& report, CopyTargetDevice& target, CopySourceDevice& source );
bool rollbackCopyBlocks( Report& report, CopyTargetDevice& origTarget, CopySourceDevice& origSource );
};
#endif /* MOVEFILESYSTEMJOB_H */

View File

@@ -2,6 +2,7 @@
*
* Copyright 2014, Aurélien Gâteau <agateau@kde.org>
* Copyright 2015, Teo Mrnjavac <teo@kde.org>
* Copyright 2017, Andrius Štikonas <andrius@stikonas.eu>
*
* Calamares is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
@@ -17,156 +18,12 @@
* along with Calamares. If not, see <http://www.gnu.org/licenses/>.
*/
// This class is heavily based on the ResizeOperation class from KDE Partition
// Manager. Original copyright follow:
/***************************************************************************
* Copyright (C) 2008,2012 by Volker Lanz <vl@fidra.de> *
* *
* This program is free software; you can redistribute it and/or modify *
* it under the terms of the GNU General Public License as published by *
* the Free Software Foundation; either version 2 of the License, or *
* (at your option) any later version. *
* *
* This program is distributed in the hope that it will be useful, *
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
* GNU General Public License for more details. *
* *
* You should have received a copy of the GNU General Public License *
* along with this program; if not, write to the *
* Free Software Foundation, Inc., *
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA *
***************************************************************************/
#include "jobs/ResizePartitionJob.h"
#include "jobs/CheckFileSystemJob.h"
#include "jobs/MoveFileSystemJob.h"
#include "utils/Logger.h"
// KPMcore
#include <kpmcore/backend/corebackend.h>
#include <kpmcore/backend/corebackendmanager.h>
#include <kpmcore/backend/corebackenddevice.h>
#include <kpmcore/backend/corebackendpartition.h>
#include <kpmcore/backend/corebackendpartitiontable.h>
#include <kpmcore/core/device.h>
#include <kpmcore/core/partition.h>
#include <kpmcore/util/report.h>
// Qt
#include <QScopedPointer>
//- ResizeFileSystemJob --------------------------------------------------------
class ResizeFileSystemJob : public Calamares::Job
{
Q_OBJECT
public:
ResizeFileSystemJob( Device* device, CoreBackendPartitionTable* backendPartitionTable, Partition* partition, qint64 length )
: m_device( device )
, m_backendPartitionTable( backendPartitionTable )
, m_partition( partition )
, m_length( length )
{}
QString prettyName() const override
{
QString path = m_partition->partitionPath();
return tr( "Resize file system on partition %1." ).arg( path );
}
Calamares::JobResult exec() override
{
Report report( nullptr );
FileSystem& fs = m_partition->fileSystem();
FileSystem::CommandSupportType support = m_length < fs.length() ? fs.supportShrink() : fs.supportGrow();
switch ( support )
{
case FileSystem::cmdSupportBackend:
if ( !backendResize( &report ) )
return Calamares::JobResult::error(
QString(),
tr( "Parted failed to resize filesystem." ) + '\n' + report.toText()
);
break;
case FileSystem::cmdSupportFileSystem:
{
qint64 byteLength = m_device->logicalSize() * m_length;
bool ok = fs.resize( report, m_partition->partitionPath(), byteLength );
if ( !ok )
return Calamares::JobResult::error(
QString(),
tr( "Failed to resize filesystem." ) + '\n' + report.toText()
);
break;
}
default:
break;
}
fs.setLastSector( fs.firstSector() + m_length - 1 );
return Calamares::JobResult::ok();
}
private:
Device* m_device;
CoreBackendPartitionTable* m_backendPartitionTable;
Partition* m_partition;
qint64 m_length;
bool backendResize( Report* report )
{
bool ok = m_backendPartitionTable->resizeFileSystem( *report, *m_partition, m_length );
if ( !ok )
return false;
m_backendPartitionTable->commit();
return true;
}
};
//- SetPartGeometryJob ---------------------------------------------------------
class SetPartGeometryJob : public Calamares::Job
{
Q_OBJECT
public:
SetPartGeometryJob( CoreBackendPartitionTable* backendPartitionTable, Partition* partition, qint64 firstSector, qint64 length )
: m_backendPartitionTable( backendPartitionTable )
, m_partition( partition )
, m_firstSector( firstSector )
, m_length( length )
{}
QString prettyName() const override
{
QString path = m_partition->partitionPath();
return tr( "Update geometry of partition %1." ).arg( path );
}
Calamares::JobResult exec() override
{
Report report( nullptr );
qint64 lastSector = m_firstSector + m_length - 1;
bool ok = m_backendPartitionTable->updateGeometry( report, *m_partition, m_firstSector, lastSector );
if ( !ok )
{
return Calamares::JobResult::error(
QString(),
tr( "Failed to change the geometry of the partition." ) + '\n' + report.toText() );
}
m_partition->setFirstSector( m_firstSector );
m_partition->setLastSector( lastSector );
m_backendPartitionTable->commit();
return Calamares::JobResult::ok();
}
private:
CoreBackendPartitionTable* m_backendPartitionTable;
Partition* m_partition;
qint64 m_firstSector;
qint64 m_length;
};
#include <core/device.h>
#include <ops/resizeoperation.h>
#include <util/report.h>
//- ResizePartitionJob ---------------------------------------------------------
ResizePartitionJob::ResizePartitionJob( Device* device, Partition* partition, qint64 firstSector, qint64 lastSector )
@@ -194,7 +51,7 @@ ResizePartitionJob::prettyDescription() const
return tr( "Resize <strong>%2MB</strong> partition <strong>%1</strong> to "
"<strong>%3MB</strong>." )
.arg( partition()->partitionPath() )
.arg( ( m_oldLastSector - m_oldFirstSector ) * partition()->sectorSize() / 1024 / 1024 )
.arg( ( m_oldLastSector - m_oldFirstSector + 1 ) * partition()->sectorSize() / 1024 / 1024 )
.arg( ( m_newLastSector - m_newFirstSector + 1 ) * partition()->sectorSize() / 1024 / 1024 );
}
@@ -205,7 +62,7 @@ ResizePartitionJob::prettyStatusMessage() const
return tr( "Resizing %2MB partition %1 to "
"%3MB." )
.arg( partition()->partitionPath() )
.arg( ( m_oldLastSector - m_oldFirstSector ) * partition()->sectorSize() / 1024 / 1024 )
.arg( ( m_oldLastSector - m_oldFirstSector + 1 ) * partition()->sectorSize() / 1024 / 1024 )
.arg( ( m_newLastSector - m_newFirstSector + 1 ) * partition()->sectorSize() / 1024 / 1024 );
}
@@ -213,64 +70,21 @@ ResizePartitionJob::prettyStatusMessage() const
Calamares::JobResult
ResizePartitionJob::exec()
{
qint64 oldLength = m_oldLastSector - m_oldFirstSector + 1;
qint64 newLength = m_newLastSector - m_newFirstSector + 1;
// Assuming updatePreview() has been called, `partition` uses its new
// position and size. Reset it to the old values: part of the libparted
// backend relies on this (for example:
// LibPartedPartitionTable::updateGeometry())
// The jobs are responsible for updating the partition back when they are
// done.
Report report (nullptr);
// Restore partition sectors that were modified for preview
m_partition->setFirstSector( m_oldFirstSector );
m_partition->setLastSector( m_oldLastSector );
ResizeOperation op(*m_device, *m_partition, m_newFirstSector, m_newLastSector);
op.setStatus(Operation::StatusRunning);
connect(&op, &Operation::progress, [&](int percent) { emit progress(percent / 100.0); } );
CoreBackend* backend = CoreBackendManager::self()->backend();
QScopedPointer<CoreBackendDevice> backendDevice( backend->openDevice( m_device->deviceNode() ) );
if ( !backendDevice.data() )
{
QString errorMessage = tr( "The installer failed to resize partition %1 on disk '%2'." )
.arg( m_partition->partitionPath() )
.arg( m_device->name() );
return Calamares::JobResult::error(
errorMessage,
tr( "Could not open device '%1'." ).arg( m_device->deviceNode() )
);
}
QScopedPointer<CoreBackendPartitionTable> backendPartitionTable( backendDevice->openPartitionTable() );
QString errorMessage = tr( "The installer failed to resize partition %1 on disk '%2'." )
.arg( m_partition->partitionPath() )
.arg( m_device->name() );
if (op.execute(report))
return Calamares::JobResult::ok();
// Create jobs
QList< Calamares::job_ptr > jobs;
jobs << Calamares::job_ptr( new CheckFileSystemJob( partition() ) );
if ( m_partition->roles().has( PartitionRole::Extended ) )
jobs << Calamares::job_ptr( new SetPartGeometryJob( backendPartitionTable.data(), m_partition, m_newFirstSector, newLength ) );
else
{
bool shrink = newLength < oldLength;
bool grow = newLength > oldLength;
bool moveRight = m_newFirstSector > m_oldFirstSector;
bool moveLeft = m_newFirstSector < m_oldFirstSector;
if ( shrink )
{
jobs << Calamares::job_ptr( new ResizeFileSystemJob( m_device, backendPartitionTable.data(), m_partition, newLength ) );
jobs << Calamares::job_ptr( new SetPartGeometryJob( backendPartitionTable.data(), m_partition, m_oldFirstSector, newLength ) );
}
if ( moveRight || moveLeft )
{
// At this point, we need to set the partition's length to either the resized length, if it has already been
// shrunk, or to the original length (it may or may not then later be grown, we don't care here)
const qint64 length = shrink ? newLength : oldLength;
jobs << Calamares::job_ptr( new SetPartGeometryJob( backendPartitionTable.data(), m_partition, m_newFirstSector, length ) );
jobs << Calamares::job_ptr( new MoveFileSystemJob( m_device, m_partition, m_oldFirstSector, m_newFirstSector, length ) );
}
if ( grow )
{
jobs << Calamares::job_ptr( new SetPartGeometryJob( backendPartitionTable.data(), m_partition, m_newFirstSector, newLength ) );
jobs << Calamares::job_ptr( new ResizeFileSystemJob( m_device, backendPartitionTable.data(), m_partition, newLength ) );
}
}
jobs << Calamares::job_ptr( new CheckFileSystemJob( partition() ) );
return execJobList( jobs );
return Calamares::JobResult::error(errorMessage, report.toText());
}
void
@@ -290,31 +104,3 @@ ResizePartitionJob::device() const
{
return m_device;
}
Calamares::JobResult
ResizePartitionJob::execJobList( const QList< Calamares::job_ptr >& jobs )
{
QString errorMessage = tr( "The installer failed to resize partition %1 on disk '%2'." )
.arg( m_partition->partitionPath() )
.arg( m_device->name() );
int nbJobs = jobs.size();
int count = 0;
for ( Calamares::job_ptr job : jobs )
{
cLog() << "- " + job->prettyName();
Calamares::JobResult result = job->exec();
if ( !result )
{
if ( result.message().isEmpty() )
result.setMessage( errorMessage );
return result;
}
++count;
progress( qreal( count ) / nbJobs );
}
return Calamares::JobResult::ok();
}
#include "ResizePartitionJob.moc"

View File

@@ -51,8 +51,6 @@ private:
qint64 m_oldLastSector;
qint64 m_newFirstSector;
qint64 m_newLastSector;
Calamares::JobResult execJobList( const QList< Calamares::job_ptr >& jobs );
};
#endif /* RESIZEPARTITIONJOB_H */

View File

@@ -9,11 +9,9 @@ set( partitionjobtests_SRCS
${PartitionModule_SOURCE_DIR}/core/KPMHelpers.cpp
${PartitionModule_SOURCE_DIR}/core/PartitionInfo.cpp
${PartitionModule_SOURCE_DIR}/core/PartitionIterator.cpp
${PartitionModule_SOURCE_DIR}/jobs/CheckFileSystemJob.cpp
${PartitionModule_SOURCE_DIR}/jobs/CreatePartitionJob.cpp
${PartitionModule_SOURCE_DIR}/jobs/CreatePartitionTableJob.cpp
${PartitionModule_SOURCE_DIR}/jobs/DeletePartitionJob.cpp
${PartitionModule_SOURCE_DIR}/jobs/MoveFileSystemJob.cpp
${PartitionModule_SOURCE_DIR}/jobs/PartitionJob.cpp
${PartitionModule_SOURCE_DIR}/jobs/ResizePartitionJob.cpp
PartitionJobTests.cpp

View File

@@ -0,0 +1,22 @@
find_package(ECM ${ECM_VERSION} REQUIRED NO_MODULE)
find_package( KF5 5.29 REQUIRED CoreAddons Plasma Package )
calamares_add_plugin( plasmalnf
TYPE viewmodule
EXPORT_MACRO PLUGINDLLEXPORT_PRO
SOURCES
PlasmaLnfViewStep.cpp
PlasmaLnfPage.cpp
PlasmaLnfJob.cpp
ThemeWidget.cpp
RESOURCES
page_plasmalnf.qrc
UI
page_plasmalnf.ui
LINK_PRIVATE_LIBRARIES
calamaresui
KF5::Package
KF5::Plasma
SHARED_LIB
)

View File

@@ -0,0 +1,78 @@
/* === This file is part of Calamares - <http://github.com/calamares> ===
*
* Copyright 2017, Adriaan de Groot <groot@kde.org>
*
* Calamares is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* Calamares is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with Calamares. If not, see <http://www.gnu.org/licenses/>.
*/
#include "PlasmaLnfJob.h"
#include "GlobalStorage.h"
#include "JobQueue.h"
#include "utils/CalamaresUtilsSystem.h"
#include "utils/Logger.h"
PlasmaLnfJob::PlasmaLnfJob( const QString& lnfPath, const QString& id )
: m_lnfPath( lnfPath )
, m_id( id )
{
}
PlasmaLnfJob::~PlasmaLnfJob()
{
}
QString
PlasmaLnfJob::prettyName() const
{
return tr( "Plasma Look-and-Feel Job" );
}
QString
PlasmaLnfJob::prettyDescription() const
{
return prettyName();
}
QString PlasmaLnfJob::prettyStatusMessage() const
{
return prettyName();
}
Calamares::JobResult
PlasmaLnfJob::exec()
{
cDebug() << "Plasma Look-and-Feel Job";
auto system = CalamaresUtils::System::instance();
Calamares::GlobalStorage* gs = Calamares::JobQueue::instance()->globalStorage();
QStringList command(
{
"sudo", "-E", "-H", "-u", gs->value( "username" ).toString(),
m_lnfPath, "-platform", "minimal", "--resetLayout", "--apply", m_id
} );
int r = system->targetEnvCall( command );
if ( r )
return Calamares::JobResult::error(
tr( "Could not select KDE Plasma Look-and-Feel package" ),
tr( "Could not select KDE Plasma Look-and-Feel package" ) );
return Calamares::JobResult::ok();
}

View File

@@ -1,6 +1,6 @@
/* === This file is part of Calamares - <http://github.com/calamares> ===
*
* Copyright 2014, Aurélien Gâteau <agateau@kde.org>
* Copyright 2017, Adriaan de Groot <groot@kde.org>
*
* Calamares is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
@@ -16,23 +16,31 @@
* along with Calamares. If not, see <http://www.gnu.org/licenses/>.
*/
#ifndef CHECKFILESYSTEMJOB_H
#define CHECKFILESYSTEMJOB_H
#ifndef PLASMALNFJOB_H
#define PLASMALNFJOB_H
#include <jobs/PartitionJob.h>
#include <QObject>
#include <QVariantMap>
/**
* Runs a file system check on an existing partition.
*/
class CheckFileSystemJob : public PartitionJob
#include <Job.h>
class PlasmaLnfJob : public Calamares::Job
{
Q_OBJECT
public:
CheckFileSystemJob( Partition* partition );
explicit PlasmaLnfJob( const QString& lnfPath, const QString& id );
virtual ~PlasmaLnfJob() override;
QString prettyName() const override;
QString prettyDescription() const override;
QString prettyStatusMessage() const override;
Calamares::JobResult exec() override;
private:
QString m_lnfPath;
QString m_id;
};
#endif /* CHECKFILESYSTEMJOB_H */
#endif // PLASMALNFJOB_H

View File

@@ -0,0 +1,167 @@
/* === This file is part of Calamares - <http://github.com/calamares> ===
*
* Copyright 2017, Adriaan de Groot <groot@kde.org>
*
* Calamares is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* Calamares is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with Calamares. If not, see <http://www.gnu.org/licenses/>.
*/
#include "PlasmaLnfPage.h"
#include "ui_page_plasmalnf.h"
#include "utils/Logger.h"
#include "utils/Retranslator.h"
#include <KPackage/Package>
#include <KPackage/PackageLoader>
ThemeInfo::ThemeInfo( const KPluginMetaData& data )
: id( data.pluginId() )
, name( data.name() )
, description( data.description() )
, widget( nullptr )
{
}
static ThemeInfoList plasma_themes()
{
ThemeInfoList packages;
QList<KPluginMetaData> pkgs = KPackage::PackageLoader::self()->listPackages( "Plasma/LookAndFeel" );
for ( const KPluginMetaData& data : pkgs )
{
if ( data.isValid() && !data.isHidden() && !data.name().isEmpty() )
{
packages << ThemeInfo{ data };
}
}
return packages;
}
PlasmaLnfPage::PlasmaLnfPage( QWidget* parent )
: QWidget( parent )
, ui( new Ui::PlasmaLnfPage )
, m_buttonGroup( nullptr )
{
ui->setupUi( this );
CALAMARES_RETRANSLATE(
{
ui->retranslateUi( this );
ui->generalExplanation->setText( tr( "Please choose a look-and-feel for the KDE Plasma Desktop. You can also skip this step and configure the look-and-feel once the system is installed." ) );
updateThemeNames();
fillUi();
}
)
}
void
PlasmaLnfPage::setLnfPath( const QString& path )
{
m_lnfPath = path;
}
void
PlasmaLnfPage::setEnabledThemes(const ThemeInfoList& themes)
{
m_enabledThemes = themes;
updateThemeNames();
winnowThemes();
fillUi();
}
void
PlasmaLnfPage::setEnabledThemesAll()
{
setEnabledThemes( plasma_themes() );
}
void PlasmaLnfPage::updateThemeNames()
{
auto plasmaThemes = plasma_themes();
for ( auto& enabled_theme : m_enabledThemes )
{
ThemeInfo* t = plasmaThemes.findById( enabled_theme.id );
if ( t != nullptr )
{
enabled_theme.name = t->name;
enabled_theme.description = t->description;
}
}
}
void PlasmaLnfPage::winnowThemes()
{
auto plasmaThemes = plasma_themes();
bool winnowed = true;
int winnow_index = 0;
while ( winnowed )
{
winnowed = false;
winnow_index = 0;
for ( auto& enabled_theme : m_enabledThemes )
{
ThemeInfo* t = plasmaThemes.findById( enabled_theme.id );
if ( t == nullptr )
{
cDebug() << "Removing" << enabled_theme.id;
winnowed = true;
break;
}
++winnow_index;
}
if ( winnowed )
{
m_enabledThemes.removeAt( winnow_index );
}
}
}
void PlasmaLnfPage::fillUi()
{
if ( m_enabledThemes.isEmpty() )
{
return;
}
if ( !m_buttonGroup )
{
m_buttonGroup = new QButtonGroup( this );
m_buttonGroup->setExclusive( true );
}
int c = 1; // After the general explanation
for ( auto& theme : m_enabledThemes )
{
if ( !theme.widget )
{
ThemeWidget* w = new ThemeWidget( theme );
m_buttonGroup->addButton( w->button() );
ui->verticalLayout->insertWidget( c, w );
connect( w, &ThemeWidget::themeSelected, this, &PlasmaLnfPage::plasmaThemeSelected);
theme.widget = w;
}
else
{
theme.widget->updateThemeName( theme );
}
++c;
}
}

View File

@@ -0,0 +1,73 @@
/* === This file is part of Calamares - <http://github.com/calamares> ===
*
* Copyright 2017, Adriaan de Groot <groot@kde.org>
*
* Calamares is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* Calamares is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with Calamares. If not, see <http://www.gnu.org/licenses/>.
*/
#ifndef PLASMALNFPAGE_H
#define PLASMALNFPAGE_H
#include <QButtonGroup>
#include <QList>
#include <QString>
#include <QStringList>
#include <QWidget>
#include "ThemeInfo.h"
#include "ThemeWidget.h"
namespace Ui
{
class PlasmaLnfPage;
}
/** @brief Page for selecting a Plasma Look-and-Feel theme.
*
* You must call setEnabledThemes -- either overload -- once
* to get the selection widgets. Note that calling that with
* an empty list will result in zero (0) selectable themes.
*/
class PlasmaLnfPage : public QWidget
{
Q_OBJECT
public:
explicit PlasmaLnfPage( QWidget* parent = nullptr );
void setLnfPath( const QString& path );
/** @brief enable only the listed themes. */
void setEnabledThemes( const ThemeInfoList& themes );
/** @brief enable all installed plasma themes. */
void setEnabledThemesAll();
signals:
void plasmaThemeSelected( const QString& id );
private:
/** @brief Intersect the list of enabled themes with the installed ones. */
void winnowThemes();
/** @brief Get the translated names for all enabled themes. */
void updateThemeNames();
/** @brief show enabled themes in the UI. */
void fillUi();
Ui::PlasmaLnfPage* ui;
QString m_lnfPath;
ThemeInfoList m_enabledThemes;
QButtonGroup *m_buttonGroup;
QList< ThemeWidget* > m_widgets;
};
#endif //PLASMALNFPAGE_H

View File

@@ -0,0 +1,196 @@
/* === This file is part of Calamares - <http://github.com/calamares> ===
*
* Copyright 2017, Adriaan de Groot <groot@kde.org>
*
* Calamares is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* Calamares is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with Calamares. If not, see <http://www.gnu.org/licenses/>.
*/
#include "PlasmaLnfViewStep.h"
#include "PlasmaLnfJob.h"
#include "PlasmaLnfPage.h"
#include "ThemeInfo.h"
#include "utils/Logger.h"
#include <QProcess>
#include <QVariantMap>
CALAMARES_PLUGIN_FACTORY_DEFINITION( PlasmaLnfViewStepFactory, registerPlugin<PlasmaLnfViewStep>(); )
PlasmaLnfViewStep::PlasmaLnfViewStep( QObject* parent )
: Calamares::ViewStep( parent )
, m_widget( new PlasmaLnfPage )
{
connect( m_widget, &PlasmaLnfPage::plasmaThemeSelected, this, &PlasmaLnfViewStep::themeSelected );
emit nextStatusChanged( false );
}
PlasmaLnfViewStep::~PlasmaLnfViewStep()
{
if ( m_widget && m_widget->parent() == nullptr )
m_widget->deleteLater();
}
QString
PlasmaLnfViewStep::prettyName() const
{
return tr( "Look-and-Feel" );
}
QWidget*
PlasmaLnfViewStep::widget()
{
return m_widget;
}
void
PlasmaLnfViewStep::next()
{
emit done();
}
void
PlasmaLnfViewStep::back()
{}
bool
PlasmaLnfViewStep::isNextEnabled() const
{
return true;
}
bool
PlasmaLnfViewStep::isBackEnabled() const
{
return true;
}
bool
PlasmaLnfViewStep::isAtBeginning() const
{
return true;
}
bool
PlasmaLnfViewStep::isAtEnd() const
{
return true;
}
void PlasmaLnfViewStep::onLeave()
{
}
QList<Calamares::job_ptr>
PlasmaLnfViewStep::jobs() const
{
QList<Calamares::job_ptr> l;
cDebug() << "Creating Plasma LNF jobs ..";
if ( !m_themeId.isEmpty() )
{
if ( !m_lnfPath.isEmpty() )
l.append( Calamares::job_ptr( new PlasmaLnfJob( m_lnfPath, m_themeId ) ) );
else
cDebug() << "WARNING: no lnftool given for plasmalnf module.";
}
return l;
}
void
PlasmaLnfViewStep::setConfigurationMap( const QVariantMap& configurationMap )
{
QString lnfPath;
if ( configurationMap.contains( "lnftool" ) && configurationMap.value( "lnftool" ).type() == QVariant::String )
lnfPath = configurationMap.value( "lnftool" ).toString();
m_lnfPath = lnfPath;
m_widget->setLnfPath( m_lnfPath );
if ( m_lnfPath.isEmpty() )
cDebug() << "WARNING: no lnftool given for plasmalnf module.";
QString liveUser;
if ( configurationMap.contains( "liveuser" ) && configurationMap.value( "liveuser" ).type() == QVariant::String )
liveUser = configurationMap.value( "liveuser" ).toString();
m_liveUser = liveUser;
if ( configurationMap.contains( "themes" ) &&
configurationMap.value( "themes" ).type() == QVariant::List )
{
ThemeInfoList allThemes;
auto themeList = configurationMap.value( "themes" ).toList();
// Create the ThemInfo objects for the listed themes; information
// about the themes from Plasma (e.g. human-readable name and description)
// are filled in by update_names() in PlasmaLnfPage.
for ( const auto& i : themeList )
if ( i.type() == QVariant::Map )
{
auto iv = i.toMap();
allThemes.append( ThemeInfo( iv.value( "theme" ).toString(), iv.value( "image" ).toString() ) );
}
else if ( i.type() == QVariant::String )
allThemes.append( ThemeInfo( i.toString() ) );
if ( allThemes.length() == 1 )
cDebug() << "WARNING: only one theme enabled in plasmalnf";
m_widget->setEnabledThemes( allThemes );
}
else
m_widget->setEnabledThemesAll(); // All of them
}
void
PlasmaLnfViewStep::themeSelected( const QString& id )
{
m_themeId = id;
if ( m_lnfPath.isEmpty() )
{
cDebug() << "WARNING: no lnftool given for plasmalnf module.";
return;
}
QProcess lnftool;
if ( !m_liveUser.isEmpty() )
lnftool.start( "sudo", {"-E", "-H", "-u", m_liveUser, m_lnfPath, "--resetLayout", "--apply", id} );
else
lnftool.start( m_lnfPath, {"--resetLayout", "--apply", id} );
if ( !lnftool.waitForStarted( 1000 ) )
{
cDebug() << "WARNING: could not start look-and-feel" << m_lnfPath;
return;
}
if ( !lnftool.waitForFinished() )
{
cDebug() << "WARNING:" << m_lnfPath << "timed out.";
return;
}
if ( ( lnftool.exitCode() == 0 ) && ( lnftool.exitStatus() == QProcess::NormalExit ) )
cDebug() << "Plasma look-and-feel applied" << id;
else
cDebug() << "WARNING: could not apply look-and-feel" << id;
}

View File

@@ -0,0 +1,71 @@
/* === This file is part of Calamares - <http://github.com/calamares> ===
*
* Copyright 2017, Adriaan de Groot <groot@kde..org>
*
* Calamares is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* Calamares is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with Calamares. If not, see <http://www.gnu.org/licenses/>.
*/
#ifndef PLASMALNFVIEWSTEP_H
#define PLASMALNFVIEWSTEP_H
#include <utils/PluginFactory.h>
#include <viewpages/ViewStep.h>
#include <PluginDllMacro.h>
#include <QObject>
#include <QUrl>
#include <QVariantMap>
class PlasmaLnfPage;
class PLUGINDLLEXPORT PlasmaLnfViewStep : public Calamares::ViewStep
{
Q_OBJECT
public:
explicit PlasmaLnfViewStep( QObject* parent = nullptr );
virtual ~PlasmaLnfViewStep() override;
QString prettyName() const override;
QWidget* widget() override;
void next() override;
void back() override;
bool isNextEnabled() const override;
bool isBackEnabled() const override;
bool isAtBeginning() const override;
bool isAtEnd() const override;
void onLeave() override;
QList<Calamares::job_ptr> jobs() const override;
void setConfigurationMap( const QVariantMap& configurationMap ) override;
public slots:
void themeSelected( const QString& id );
private:
PlasmaLnfPage* m_widget;
QString m_lnfPath;
QString m_themeId;
QString m_liveUser;
};
CALAMARES_PLUGIN_FACTORY_DECLARATION( PlasmaLnfViewStepFactory )
#endif // PLASMALNFVIEWSTEP_H

View File

@@ -0,0 +1,97 @@
/* === This file is part of Calamares - <http://github.com/calamares> ===
*
* Copyright 2017, Adriaan de Groot <groot@kde.org>
*
* Calamares is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* Calamares is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with Calamares. If not, see <http://www.gnu.org/licenses/>.
*/
#ifndef PLASMALNF_THEMEINFO_H
#define PLASMALNF_THEMEINFO_H
#include <QList>
#include <QString>
class KPluginMetaData;
class ThemeWidget;
/** @brief describes a single plasma LnF theme.
*
* A theme description has an id, which is really the name of the desktop
* file (e.g. org.kde.breeze.desktop), a name which is human-readable and
* translated, and an optional image Page, which points to a local screenshot
* of that theme.
*/
struct ThemeInfo
{
QString id;
QString name;
QString description;
QString imagePath;
ThemeWidget* widget;
ThemeInfo()
: widget( nullptr )
{}
explicit ThemeInfo( const QString& _id )
: id( _id )
, widget( nullptr )
{
}
explicit ThemeInfo( const QString& _id, const QString& image )
: id( _id )
, imagePath( image )
, widget( nullptr )
{}
// Defined in PlasmaLnfPage.cpp
explicit ThemeInfo( const KPluginMetaData& );
bool isValid() const { return !id.isEmpty(); }
} ;
class ThemeInfoList : public QList< ThemeInfo >
{
public:
/** @brief Looks for a given @p id in the list of themes, returns nullptr if not found. */
ThemeInfo* findById( const QString& id )
{
for ( ThemeInfo& i : *this )
{
if ( i.id == id )
return &i;
}
return nullptr;
}
/** @brief Looks for a given @p id in the list of themes, returns nullptr if not found. */
const ThemeInfo* findById( const QString& id ) const
{
for ( const ThemeInfo& i : *this )
{
if ( i.id == id )
return &i;
}
return nullptr;
}
/** @brief Checks if a given @p id is in the list of themes. */
bool contains( const QString& id ) const
{
return findById( id ) != nullptr;
}
} ;
#endif

View File

@@ -0,0 +1,85 @@
/* === This file is part of Calamares - <http://github.com/calamares> ===
*
* Copyright 2017, Adriaan de Groot <groot@kde.org>
*
* Calamares is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* Calamares is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with Calamares. If not, see <http://www.gnu.org/licenses/>.
*/
#include "ThemeWidget.h"
#include "ThemeInfo.h"
#include "utils/Logger.h"
#include <QHBoxLayout>
#include <QLabel>
#include <QRadioButton>
ThemeWidget::ThemeWidget(const ThemeInfo& info, QWidget* parent)
: QWidget( parent )
, m_check( new QRadioButton( info.name.isEmpty() ? info.id : info.name, parent ) )
, m_description( new QLabel( info.description, parent ) )
, m_id( info.id )
{
QHBoxLayout* layout = new QHBoxLayout( this );
this->setLayout( layout );
layout->addWidget( m_check, 1 );
constexpr QSize image_size{120, 80};
QPixmap image( info.imagePath );
if ( info.imagePath.isEmpty() )
{
// Image can't possibly be valid
image = QPixmap( ":/view-preview.png" );
}
else if ( image.isNull() )
{
// Not found or not specified, so convert the name into some (horrible, likely)
// color instead.
image = QPixmap( image_size );
uint hash_color = qHash( info.imagePath.isEmpty() ? info.id : info.imagePath );
cDebug() << "Theme image" << info.imagePath << "not found, hash" << hash_color;
image.fill( QColor( QRgb( hash_color ) ) );
}
else
image.scaled( image_size );
QLabel* image_label = new QLabel( this );
image_label->setPixmap( image );
layout->addWidget( image_label, 1 );
layout->addWidget( m_description, 3 );
connect( m_check, &QRadioButton::clicked, this, &ThemeWidget::clicked );
}
void
ThemeWidget::clicked( bool checked )
{
if ( checked )
emit themeSelected( m_id );
}
QAbstractButton*
ThemeWidget::button() const
{
return m_check;
}
void ThemeWidget::updateThemeName(const ThemeInfo& info)
{
m_check->setText( info.name );
m_description->setText( info.description );
}

View File

@@ -0,0 +1,53 @@
/* === This file is part of Calamares - <http://github.com/calamares> ===
*
* Copyright 2017, Adriaan de Groot <groot@kde.org>
*
* Calamares is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* Calamares is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with Calamares. If not, see <http://www.gnu.org/licenses/>.
*/
#ifndef PLASMALNF_THEMEWIDGET_H
#define PLASMALNF_THEMEWIDGET_H
#include <QWidget>
class QAbstractButton;
class QLabel;
class QRadioButton;
struct ThemeInfo;
class ThemeWidget : public QWidget
{
Q_OBJECT
public:
explicit ThemeWidget( const ThemeInfo& info, QWidget* parent = nullptr );
QAbstractButton* button() const;
void updateThemeName( const ThemeInfo& info );
signals:
void themeSelected( const QString& id );
public slots:
void clicked( bool );
private:
QString m_id;
QRadioButton* m_check;
QLabel* m_description;
} ;
#endif

View File

@@ -0,0 +1,5 @@
<RCC>
<qresource>
<file>view-preview.png</file>
</qresource>
</RCC>

View File

@@ -0,0 +1,46 @@
<?xml version="1.0" encoding="UTF-8"?>
<ui version="4.0">
<class>PlasmaLnfPage</class>
<widget class="QWidget" name="PlasmaLnfPage">
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>799</width>
<height>400</height>
</rect>
</property>
<property name="windowTitle">
<string>Form</string>
</property>
<layout class="QVBoxLayout" name="verticalLayout" stretch="0,0">
<item>
<widget class="QLabel" name="generalExplanation">
<property name="text">
<string>Placeholder</string>
</property>
<property name="wordWrap">
<bool>true</bool>
</property>
</widget>
</item>
<item>
<spacer name="verticalSpacer">
<property name="orientation">
<enum>Qt::Vertical</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>20</width>
<height>40</height>
</size>
</property>
</spacer>
</item>
</layout>
</widget>
<resources>
<include location="page_plasmalnf.qrc"/>
</resources>
<connections/>
</ui>

View File

@@ -0,0 +1,29 @@
---
# Full path to the Plasma look-and-feel tool (CLI program
# for querying and applying Plasma themes). If this is not
# set, no LNF setting will happen.
lnftool: "/usr/bin/lookandfeeltool"
# For systems where the user Calamares runs as (usually root,
# via either sudo or pkexec) has a clean environment, set this
# to the originating username; the lnftool will be run through
# "sudo -H -u <liveuser>" instead of directly.
#
# liveuser: "live"
# You can limit the list of Plasma look-and-feel themes by listing ids
# here. If this key is not present, all of the installed themes are listed.
# If the key is present, only installed themes that are *also* included
# in the list are shown (could be none!).
#
# Themes may be listed by id, (e.g. fluffy-bunny, below) or as a theme
# and an image (e.g. breeze) which will be used to show a screenshot.
# Themes with no image get a "missing screenshot" image; if the
# image file is not found, they get a color swatch based on the image name.
themes:
- org.kde.fuzzy-pig.desktop
- theme: org.kde.breeze.desktop
image: "breeze.png"
- theme: org.kde.breezedark.desktop
image: "breeze-dark.png"
- org.kde.fluffy-bunny.desktop

Binary file not shown.

After

Width:  |  Height:  |  Size: 560 B

View File

@@ -0,0 +1,13 @@
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 32 32">
<defs id="defs3051">
<style type="text/css" id="current-color-scheme">
.ColorScheme-Text {
color:#4d4d4d;
}
</style>
</defs>
<path style="fill:currentColor;fill-opacity:1;stroke:none"
d="m4 4v24h24v-24zm1 1h22v22h-22zm6 2a4 4 0 0 0 -4 4 4 4 0 0 0 4 4 4 4 0 0 0 4 -4 4 4 0 0 0 -4 -4m0 1a3 3 0 0 1 3 3 3 3 0 0 1 -3 3 3 3 0 0 1 -3 -3 3 3 0 0 1 3 -3m9.5 6.793l-5 5-2-2-6.5 6.5.707.707 5.793-5.793 2 2 5-5 3.793 3.793.707-.707z"
class="ColorScheme-Text"
/>
</svg>

After

Width:  |  Height:  |  Size: 570 B

66
src/modules/test_conf.cpp Normal file
View File

@@ -0,0 +1,66 @@
/* === This file is part of Calamares - <http://github.com/calamares> ===
*
* Copyright 2017, Adriaan de Groot <groot@kde.org>
*
* Calamares is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* Calamares is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with Calamares. If not, see <http://www.gnu.org/licenses/>.
*/
/**
* This is a test-application that just checks the YAML config-file
* shipped with each module for correctness -- well, for parseability.
*/
#include <iostream>
#include <yaml-cpp/yaml.h>
using std::cerr;
int main(int argc, char** argv)
{
if (argc != 2)
{
cerr << "Usage: test_conf <file.conf>\n";
return 1;
}
try
{
YAML::Node doc = YAML::LoadFile( argv[1] );
if ( doc.IsNull() )
{
// Special case: empty config files are valid,
// but aren't a map. For the example configs,
// this is still an error.
cerr << "WARNING:" << argv[1] << '\n';
cerr << "WARNING: empty YAML\n";
return 1;
}
if ( !doc.IsMap() )
{
cerr << "WARNING:" << argv[1] << '\n';
cerr << "WARNING: not-a-YAML-map\n";
return 1;
}
}
catch ( YAML::Exception& e )
{
cerr << "WARNING:" << argv[1] << '\n';
cerr << "WARNING: YAML parser error " << e.what() << '\n';
return 1;
}
return 0;
}

View File

@@ -1,6 +1,5 @@
find_package(ECM 5.10.0 NO_MODULE)
find_package(ECM ${ECM_VERSION} NO_MODULE)
if( ECM_FOUND )
set(CMAKE_MODULE_PATH ${ECM_MODULE_PATH} ${CMAKE_MODULE_PATH})
include( ECMAddTests )
endif()

View File

@@ -213,12 +213,16 @@ RequirementsChecker::setConfigurationMap( const QVariantMap& configurationMap )
bool ok = false;
m_requiredStorageGB = configurationMap.value( "requiredStorage" ).toDouble( &ok );
if ( !ok )
{
cDebug() << "WARNING: RequirementsChecker entry 'requiredStorage' is invalid.";
m_requiredStorageGB = 3.;
}
Calamares::JobQueue::instance()->globalStorage()->insert( "requiredStorageGB", m_requiredStorageGB );
}
else
{
cDebug() << "WARNING: RequirementsChecker entry 'requiredStorage' is missing.";
m_requiredStorageGB = 3.;
incompleteConfiguration = true;
}
@@ -231,12 +235,14 @@ RequirementsChecker::setConfigurationMap( const QVariantMap& configurationMap )
m_requiredRamGB = configurationMap.value( "requiredRam" ).toDouble( &ok );
if ( !ok )
{
cDebug() << "WARNING: RequirementsChecker entry 'requiredRam' is invalid.";
m_requiredRamGB = 1.;
incompleteConfiguration = true;
}
}
else
{
cDebug() << "WARNING: RequirementsChecker entry 'requiredRam' is missing.";
m_requiredRamGB = 1.;
incompleteConfiguration = true;
}
@@ -248,7 +254,7 @@ RequirementsChecker::setConfigurationMap( const QVariantMap& configurationMap )
if ( m_checkHasInternetUrl.isEmpty() ||
!QUrl( m_checkHasInternetUrl ).isValid() )
{
cDebug() << "Invalid internetCheckUrl in welcome.conf" << m_checkHasInternetUrl
cDebug() << "WARNING: RequirementsChecker entry 'internetCheckUrl' is invalid in welcome.conf" << m_checkHasInternetUrl
<< "reverting to default (http://example.com).";
m_checkHasInternetUrl = "http://example.com";
incompleteConfiguration = true;
@@ -256,8 +262,9 @@ RequirementsChecker::setConfigurationMap( const QVariantMap& configurationMap )
}
else
{
cDebug() << "internetCheckUrl is undefined in welcome.conf, "
cDebug() << "WARNING: RequirementsChecker entry 'internetCheckUrl' is undefined in welcome.conf,"
"reverting to default (http://example.com).";
m_checkHasInternetUrl = "http://example.com";
incompleteConfiguration = true;
}
@@ -269,7 +276,10 @@ RequirementsChecker::setConfigurationMap( const QVariantMap& configurationMap )
m_entriesToCheck.append( configurationMap.value( "check" ).toStringList() );
}
else
{
cDebug() << "WARNING: RequirementsChecker entry 'check' is incomplete.";
incompleteConfiguration = true;
}
if ( configurationMap.contains( "required" ) &&
configurationMap.value( "required" ).type() == QVariant::List )
@@ -278,18 +288,13 @@ RequirementsChecker::setConfigurationMap( const QVariantMap& configurationMap )
m_entriesToRequire.append( configurationMap.value( "required" ).toStringList() );
}
else
{
cDebug() << "WARNING: RequirementsChecker entry 'required' is incomplete.";
incompleteConfiguration = true;
}
if ( incompleteConfiguration )
{
cDebug() << "WARNING: The RequirementsChecker configuration map provided by "
"the welcome module configuration file is incomplete or "
"incorrect.\n"
"Startup will continue for debugging purposes, but one or "
"more checks might not function correctly.\n"
"RequirementsChecker configuration map:\n"
<< configurationMap;
}
cDebug() << "WARNING: RequirementsChecker configuration map:\n" << configurationMap;
}