diff --git a/CMakeLists.txt b/CMakeLists.txt index 5eed360f8..183bc93f3 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -28,6 +28,9 @@ # Example usage: # # cmake . -DSKIP_MODULES="partition luksbootkeycfg" +# +# One special target is "show-version", which can be built +# to obtain the version number from here. project( calamares C CXX ) @@ -36,13 +39,30 @@ cmake_minimum_required( VERSION 3.2 ) ### OPTIONS # -option( INSTALL_CONFIG "Install configuration files" ON ) +option( INSTALL_CONFIG "Install configuration files" OFF ) option( INSTALL_POLKIT "Install Polkit configuration" ON ) option( BUILD_TESTING "Build the testing tree." ON ) option( WITH_PYTHON "Enable Python modules API (requires Boost.Python)." ON ) option( WITH_PYTHONQT "Enable next generation Python modules API (experimental, requires PythonQt)." ON ) option( WITH_KF5Crash "Enable crash reporting with KCrash." ON ) +### USE_* +# +# By convention, when there are multiple modules that implement similar +# functionality, and it only makes sense to have **at most one** of them +# enabled at any time, those modules are named -. +# For example, services-systemd and services-openrc. +# +# Setting up SKIP_MODULES to ignore "the ones you don't want" can be +# annoying and error-prone (e.g. if a new module shows up). The USE_* +# modules provide a way to do automatic selection. To pick exactly +# one of the implementations from group , set USE_ to the +# name of the implementation. If USE_ is unset, or empty, then +# all the implementations are enabled (this just means they are +# **available** to `settings.conf`, not that they are used). +# +# Currently, no USE_ variables exist. +set( USE_services "" CACHE STRING "Select the services module to use" ) ### Calamares application info # @@ -54,9 +74,8 @@ set( CALAMARES_DESCRIPTION_SUMMARY set( CALAMARES_VERSION_MAJOR 3 ) set( CALAMARES_VERSION_MINOR 2 ) -set( CALAMARES_VERSION_PATCH 1 ) -set( CALAMARES_VERSION_RC 0 ) - +set( CALAMARES_VERSION_PATCH 2 ) +set( CALAMARES_VERSION_RC 1 ) ### Transifex (languages) info # @@ -377,6 +396,15 @@ if( NOT BUILD_RELEASE AND EXISTS "${CMAKE_CURRENT_SOURCE_DIR}/.git/" ) endif() endif() +# Special target for not-RC (e.g. might-be-release) builds. +# This is used by the release script to get the version. +if ( CALAMARES_VERSION_RC EQUAL 0 ) + add_custom_target(show-version + ${CMAKE_COMMAND} -E echo CALAMARES_VERSION=${CALAMARES_VERSION_SHORT} + USES_TERMINAL + ) +endif() + # enforce using constBegin, constEnd for const-iterators add_definitions( "-DQT_STRICT_ITERATORS" ) diff --git a/CMakeModules/CalamaresAddModuleSubdirectory.cmake b/CMakeModules/CalamaresAddModuleSubdirectory.cmake index af26f5a74..0b417bdf3 100644 --- a/CMakeModules/CalamaresAddModuleSubdirectory.cmake +++ b/CMakeModules/CalamaresAddModuleSubdirectory.cmake @@ -85,9 +85,11 @@ function( calamares_add_module_subdirectory ) configure_file( ${SUBDIRECTORY}/${MODULE_FILE} ${SUBDIRECTORY}/${MODULE_FILE} COPYONLY ) get_filename_component( FLEXT ${MODULE_FILE} EXT ) - if( "${FLEXT}" STREQUAL ".conf" AND INSTALL_CONFIG) - install( FILES ${CMAKE_CURRENT_BINARY_DIR}/${SUBDIRECTORY}/${MODULE_FILE} - DESTINATION ${MODULE_DATA_DESTINATION} ) + if( "${FLEXT}" STREQUAL ".conf" ) + if( INSTALL_CONFIG ) + install( FILES ${CMAKE_CURRENT_BINARY_DIR}/${SUBDIRECTORY}/${MODULE_FILE} + DESTINATION ${MODULE_DATA_DESTINATION} ) + endif() list( APPEND MODULE_CONFIG_FILES ${MODULE_FILE} ) else() install( FILES ${CMAKE_CURRENT_BINARY_DIR}/${SUBDIRECTORY}/${MODULE_FILE} @@ -102,10 +104,11 @@ function( calamares_add_module_subdirectory ) message( " ${Green}MODULE_DESTINATION:${ColorReset} ${MODULE_DESTINATION}" ) if( MODULE_CONFIG_FILES ) if ( INSTALL_CONFIG ) - message( " ${Green}CONFIGURATION_FILES:${ColorReset} ${MODULE_CONFIG_FILES} => ${MODULE_DATA_DESTINATION}" ) + set( _destination "${MODULE_DATA_DESTINATION}" ) else() - message( " ${Green}CONFIGURATION_FILES:${ColorReset} ${MODULE_CONFIG_FILES} => [Skipping installation]" ) + set( _destination "[Build directory only]" ) endif() + message( " ${Green}CONFIGURATION_FILES:${ColorReset} ${MODULE_CONFIG_FILES} => ${_destination}" ) endif() message( "" ) endif() diff --git a/CMakeModules/CalamaresAddPlugin.cmake b/CMakeModules/CalamaresAddPlugin.cmake index d2f878381..1bf20e4ca 100644 --- a/CMakeModules/CalamaresAddPlugin.cmake +++ b/CMakeModules/CalamaresAddPlugin.cmake @@ -66,17 +66,18 @@ function( calamares_add_plugin ) message( " ${Green}TYPE:${ColorReset} ${PLUGIN_TYPE}" ) message( " ${Green}LINK_LIBRARIES:${ColorReset} ${PLUGIN_LINK_LIBRARIES}" ) message( " ${Green}LINK_PRIVATE_LIBRARIES:${ColorReset} ${PLUGIN_LINK_PRIVATE_LIBRARIES}" ) -# message( " ${Green}SOURCES:${ColorReset} ${PLUGIN_SOURCES}" ) -# message( " ${Green}UI:${ColorReset} ${PLUGIN_UI}" ) -# message( " ${Green}EXPORT_MACRO:${ColorReset} ${PLUGIN_EXPORT_MACRO}" ) -# message( " ${Green}NO_INSTALL:${ColorReset} ${PLUGIN_NO_INSTALL}" ) message( " ${Green}PLUGIN_DESTINATION:${ColorReset} ${PLUGIN_DESTINATION}" ) if( PLUGIN_CONFIG_FILES ) + set( _destination "(unknown)" ) if ( INSTALL_CONFIG AND NOT PLUGIN_NO_INSTALL ) - message( " ${Green}CONFIGURATION_FILES:${ColorReset} ${PLUGIN_CONFIG_FILES} => ${PLUGIN_DATA_DESTINATION}" ) + set( _destination "${PLUGIN_DATA_DESTINATION}" ) + elseif( NOT PLUGIN_NO_INSTALL ) + # Not INSTALL_CONFIG + set( _destination "[Build directory only]" ) else() - message( " ${Green}CONFIGURATION_FILES:${ColorReset} ${PLUGIN_CONFIG_FILES} => [Skipping installation]" ) + set( _destination "[Skipping installation]" ) endif() + message( " ${Green}CONFIGURATION_FILES:${ColorReset} ${PLUGIN_CONFIG_FILES} => ${_destination}" ) endif() if( PLUGIN_RESOURCES ) message( " ${Green}RESOURCES:${ColorReset} ${PLUGIN_RESOURCES}" ) @@ -147,12 +148,13 @@ function( calamares_add_plugin ) install( FILES ${CMAKE_CURRENT_BINARY_DIR}/${PLUGIN_DESC_FILE} DESTINATION ${PLUGIN_DESTINATION} ) - if ( INSTALL_CONFIG ) - foreach( PLUGIN_CONFIG_FILE ${PLUGIN_CONFIG_FILES} ) - configure_file( ${PLUGIN_CONFIG_FILE} ${PLUGIN_CONFIG_FILE} COPYONLY ) - install( FILES ${CMAKE_CURRENT_BINARY_DIR}/${PLUGIN_CONFIG_FILE} - DESTINATION ${PLUGIN_DATA_DESTINATION} ) - endforeach() - endif() + foreach( PLUGIN_CONFIG_FILE ${PLUGIN_CONFIG_FILES} ) + configure_file( ${PLUGIN_CONFIG_FILE} ${PLUGIN_CONFIG_FILE} COPYONLY ) + if ( INSTALL_CONFIG ) + install( + FILES ${CMAKE_CURRENT_BINARY_DIR}/${PLUGIN_CONFIG_FILE} + DESTINATION ${PLUGIN_DATA_DESTINATION} ) + endif() + endforeach() endif() endfunction() diff --git a/ci/RELEASE.sh b/ci/RELEASE.sh new file mode 100644 index 000000000..142d6b0c0 --- /dev/null +++ b/ci/RELEASE.sh @@ -0,0 +1,93 @@ +#! /bin/sh +# +# Release script for Calamares +# +# This attempts to perform the different steps of the RELEASE.md +# document automatically. It's not tested on other machines or +# setups other than [ade]'s development VM. +# +# Assumes that the version in CMakeLists.txt has been bumped, +# and that a release of that version is desired. +# +# None of the "update stuff" is done by this script; in preparation +# for the release, you should have already done: +# - updating the version +# - pulling translations +# - updating the language list +# - switching to the right branch + +test -d .git || { echo "Not at top-level." ; exit 1 ; } +test -d src/modules || { echo "No src/modules." ; exit 1 ; } + +which cmake > /dev/null 2>&1 || { echo "No cmake(1) available." ; exit 1 ; } + +### Build with default compiler +# +# +BUILDDIR=$(mktemp -d --suffix=-build --tmpdir=.) +rm -rf "$BUILDDIR" +mkdir "$BUILDDIR" || { echo "Could not create build directory." ; exit 1 ; } +( cd "$BUILDDIR" && cmake .. && make -j4 ) || { echo "Could not perform test-build." ; exit 1 ; } +( cd "$BUILDDIR" && make test ) || { echo "Tests failed." ; exit 1 ; } + +### Build with clang +# +# +if which clang++ > /dev/null 2>&1 ; then + # Do build again with clang + rm -rf "$BUILDDIR" + mkdir "$BUILDDIR" || { echo "Could not create build directory." ; exit 1 ; } + ( cd "$BUILDDIR" && CC=clang CXX=clang++ cmake .. && make -j4 ) || { echo "Could not perform test-build." ; exit 1 ; } + ( cd "$BUILDDIR" && make test ) || { echo "Tests failed." ; exit 1 ; } +fi + +### Get version number for this release +# +# +V=$( cd "$BUILDDIR" && make show-version | grep ^CALAMARES_VERSION | sed s/^[A-Z_]*=// ) +test -n "$V" || { echo "Could not obtain version." ; exit 1 ; } + +### Create signed tag +# +# This is the signing key ID associated with the GitHub account adriaandegroot, +# which is used to create all "verified" tags in the Calamares repo. +KEY_ID="128F00873E05AF1D" +git tag -u "$KEY_ID" -m "Release v$V" "v$V" || { echo "Could not sign tag v$V." ; exit 1 ; } + +### Create the tarball +# +# +TAR_V="calamares-$V" +TAR_FILE="$TAR_V.tar.gz" +git archive -o "$TAR_FILE" --prefix "$TAR_V/" "v$V" || { echo "Could not create tarball." ; exit 1 ; } +test -f "$TAR_FILE" || { echo "Tarball was not created." ; exit 1 ; } +SHA256=$(sha256sum "$TAR_FILE" | cut -d" " -f1) + +### Build the tarball +# +# +D=$(date +%Y%m%d-%H%M%S) +TMPDIR=$(mktemp -d --suffix="-calamares-$D") +test -d "$TMPDIR" || { echo "Could not create tarball-build directory." ; exit 1 ; } +tar xzf "$TAR_FILE" -C "$TMPDIR" || { echo "Could not unpack tarball." ; exit 1 ; } +test -d "$TMPDIR/$TAR_V" || { echo "Tarball did not contain source directory." ; exit 1 ; } +( cd "$TMPDIR/$TAR_V" && cmake . && make -j4 && make test ) || { echo "Tarball build failed." ; exit 1 ; } + +### Cleanup +# +rm -rf "$BUILDDIR" # From test-builds +rm -rf "$TMPDIR" # From tarball + +### Print subsequent instructions +# +# +cat < Blank Page - + Pusta strona @@ -192,17 +192,17 @@ Calamares Initialization Failed - + Błąd inicjacji programu Calamares %1 can not be installed. Calamares was unable to load all of the configured modules. This is a problem with the way Calamares is being used by the distribution. - + %1 nie może zostać zainstalowany. Calamares nie mógł wczytać wszystkich skonfigurowanych modułów. Jest to problem ze sposobem, w jaki Calamares jest używany przez dystrybucję. <br/>The following modules could not be loaded: - + <br/>Następujące moduły nie mogły zostać wczytane: @@ -1663,7 +1663,7 @@ Instalator zostanie zamknięty i wszystkie zmiany zostaną utracone. Cre&ate - + Ut_wórz diff --git a/settings.conf b/settings.conf index d49ab96c8..f20992db1 100644 --- a/settings.conf +++ b/settings.conf @@ -70,39 +70,39 @@ modules-search: [ local ] # # YAML: list of lists of strings. sequence: - - show: - - welcome - - locale - - keyboard - - partition - - users - - summary - - exec: - - partition - - mount - - unpackfs - - machineid - - fstab - - locale - - keyboard - - localecfg - - luksopenswaphookcfg - - luksbootkeyfile - - plymouthcfg - - initcpiocfg - - initcpio - - users - - displaymanager - - mhwdcfg - - networkcfg - - hwclock - - services - - grubcfg - - bootloader - - postcfg - - umount - - show: - - finished +- show: + - welcome + - locale + - keyboard + - partition + - users + - summary +- exec: + - partition + - mount + - unpackfs + - machineid + - fstab + - locale + - keyboard + - localecfg + - luksopenswaphookcfg + - luksbootkeyfile + - plymouthcfg + - initcpiocfg + - initcpio + - users + - displaymanager + - mhwdcfg + - networkcfg + - hwclock + - services-systemd + - grubcfg + - bootloader + - postcfg + - umount +- show: + - finished # A branding component is a directory, either in SHARE/calamares/branding or # in /etc/calamares/branding (the latter takes precedence). The directory must diff --git a/src/libcalamares/Settings.cpp b/src/libcalamares/Settings.cpp index 1fdfc6daa..8fd4eeac3 100644 --- a/src/libcalamares/Settings.cpp +++ b/src/libcalamares/Settings.cpp @@ -212,7 +212,7 @@ Settings::customModuleInstances() const } -QList< QPair< ModuleAction, QStringList > > +Settings::ModuleSequence Settings::modulesSequence() const { return m_modulesSequence; diff --git a/src/libcalamares/Settings.h b/src/libcalamares/Settings.h index 2330f5747..4da65f710 100644 --- a/src/libcalamares/Settings.h +++ b/src/libcalamares/Settings.h @@ -47,7 +47,8 @@ public: using InstanceDescriptionList = QList< InstanceDescription >; InstanceDescriptionList customModuleInstances() const; - QList< QPair< ModuleAction, QStringList > > modulesSequence() const; + using ModuleSequence = QList< QPair< ModuleAction, QStringList > >; + ModuleSequence modulesSequence() const; QString brandingComponentName() const; @@ -63,7 +64,7 @@ private: QStringList m_modulesSearchPaths; InstanceDescriptionList m_customModuleInstances; - QList< QPair< ModuleAction, QStringList > > m_modulesSequence; + ModuleSequence m_modulesSequence; QString m_brandingComponentName; diff --git a/src/libcalamaresui/modulesystem/Module.cpp b/src/libcalamaresui/modulesystem/Module.cpp index c820b98b3..ed1cb33ea 100644 --- a/src/libcalamaresui/modulesystem/Module.cpp +++ b/src/libcalamaresui/modulesystem/Module.cpp @@ -224,13 +224,6 @@ Module::instanceKey() const } -QStringList -Module::requiredModules() const -{ - return m_requiredModules; -} - - QString Module::location() const { @@ -286,7 +279,6 @@ void Module::initFrom( const QVariantMap& moduleDescriptor ) { m_name = moduleDescriptor.value( "name" ).toString(); - if ( moduleDescriptor.contains( EMERGENCY ) ) m_maybe_emergency = moduleDescriptor[ EMERGENCY ].toBool(); } diff --git a/src/libcalamaresui/modulesystem/Module.h b/src/libcalamaresui/modulesystem/Module.h index 18c2e4cbe..f89c9eedb 100644 --- a/src/libcalamaresui/modulesystem/Module.h +++ b/src/libcalamaresui/modulesystem/Module.h @@ -106,13 +106,6 @@ public: */ virtual QString instanceKey() const final; - /** - * @brief requiredModules a list of names of modules required by this one. - * @return the list of names. - * The module dependencies system is currently incomplete and unused. - */ - virtual QStringList requiredModules() const; - /** * @brief location returns the full path of this module's directory. * @return the path. @@ -198,7 +191,6 @@ private: void loadConfigurationFile( const QString& configFileName ); //throws YAML::Exception QString m_name; - QStringList m_requiredModules; QString m_directory; QString m_instanceId; diff --git a/src/libcalamaresui/modulesystem/ModuleManager.cpp b/src/libcalamaresui/modulesystem/ModuleManager.cpp index ed1e52f9f..86d97d2db 100644 --- a/src/libcalamaresui/modulesystem/ModuleManager.cpp +++ b/src/libcalamaresui/modulesystem/ModuleManager.cpp @@ -126,7 +126,6 @@ ModuleManager::doInit() } // At this point m_availableModules is filled with whatever was found in the // search paths. - checkDependencies(); emit initDone(); } @@ -176,11 +175,11 @@ ModuleManager::loadModules() { QTimer::singleShot( 0, this, [ this ]() { - QStringList failedModules; + QStringList failedModules = checkDependencies(); Settings::InstanceDescriptionList customInstances = Settings::instance()->customModuleInstances(); - const auto modulesSequence = Settings::instance()->modulesSequence(); + const auto modulesSequence = failedModules.isEmpty() ? Settings::instance()->modulesSequence() : Settings::ModuleSequence(); for ( const auto& modulePhase : modulesSequence ) { ModuleAction currentAction = modulePhase.first; @@ -262,6 +261,14 @@ ModuleManager::loadModules() failedModules.append( instanceKey ); continue; } + + if ( !checkDependencies( *thisModule ) ) + { + // Error message is already printed + failedModules.append( instanceKey ); + continue; + } + // If it's a ViewModule, it also appends the ViewStep to the ViewManager. thisModule->loadSelf(); m_loadedModulesByInstanceKey.insert( instanceKey, thisModule ); @@ -301,24 +308,29 @@ ModuleManager::loadModules() } -void +QStringList ModuleManager::checkDependencies() { + QStringList failed; + // This goes through the map of available modules, and deletes those whose // dependencies are not met, if any. - bool somethingWasRemovedBecauseOfUnmetDependencies = false; forever { + bool somethingWasRemovedBecauseOfUnmetDependencies = false; for ( auto it = m_availableDescriptorsByModuleName.begin(); it != m_availableDescriptorsByModuleName.end(); ++it ) { foreach ( const QString& depName, - ( *it ).value( "requiredModules" ).toStringList() ) + it->value( "requiredModules" ).toStringList() ) { if ( !m_availableDescriptorsByModuleName.contains( depName ) ) { + QString moduleName = it->value( "name" ).toString(); somethingWasRemovedBecauseOfUnmetDependencies = true; m_availableDescriptorsByModuleName.erase( it ); + failed << moduleName; + cWarning() << "Module" << moduleName << "has unknown requirement" << depName; break; } } @@ -328,7 +340,33 @@ ModuleManager::checkDependencies() if ( !somethingWasRemovedBecauseOfUnmetDependencies ) break; } + + return failed; } +bool +ModuleManager::checkDependencies( const Module& m ) +{ + bool allRequirementsFound = true; + QStringList requiredModules = m_availableDescriptorsByModuleName[ m.name() ].value( "requiredModules" ).toStringList(); + + for ( const QString& required : requiredModules ) + { + bool requirementFound = false; + for( const Module* v : m_loadedModulesByInstanceKey ) + if ( required == v->name() ) + { + requirementFound = true; + break; + } + if ( !requirementFound ) + { + cError() << "Module" << m.name() << "requires" << required << "before it in sequence."; + allRequirementsFound = false; + } + } + + return allRequirementsFound; +} } diff --git a/src/libcalamaresui/modulesystem/ModuleManager.h b/src/libcalamaresui/modulesystem/ModuleManager.h index eff09b321..a0edc2528 100644 --- a/src/libcalamaresui/modulesystem/ModuleManager.h +++ b/src/libcalamaresui/modulesystem/ModuleManager.h @@ -90,7 +90,25 @@ private slots: void doInit(); private: - void checkDependencies(); + /** + * Check in a general sense whether the dependencies between + * modules are valid. Returns a list of module names that + * do **not** have their requirements met. + * + * Returns an empty list on success. + * + * Also modifies m_availableDescriptorsByModuleName to remove + * all the entries that fail. + */ + QStringList checkDependencies(); + + /** + * Check for this specific module if its required modules have + * already been loaded (i.e. are in sequence before it). + * + * Returns true if the requirements are met. + */ + bool checkDependencies( const Module& ); QMap< QString, QVariantMap > m_availableDescriptorsByModuleName; QMap< QString, QString > m_moduleDirectoriesByModuleName; diff --git a/src/modules/CMakeLists.txt b/src/modules/CMakeLists.txt index 514d6b4f6..0a8d1db70 100644 --- a/src/modules/CMakeLists.txt +++ b/src/modules/CMakeLists.txt @@ -15,13 +15,34 @@ string( REPLACE " " ";" SKIP_LIST "${SKIP_MODULES}" ) file( GLOB SUBDIRECTORIES RELATIVE ${CMAKE_CURRENT_SOURCE_DIR} "*" ) list( SORT SUBDIRECTORIES ) +set( _use_categories "" ) +set( _found_categories "" ) + foreach( SUBDIRECTORY ${SUBDIRECTORIES} ) list( FIND SKIP_LIST ${SUBDIRECTORY} DO_SKIP ) + set( _skip_reason "user request" ) + # Handle the USE_ variables by looking for subdirectories + # with a - kind of name. + if( SUBDIRECTORY MATCHES "^[a-zA-Z0-9_]+-" ) + string( REGEX REPLACE "^[^-]+-" "" _implementation ${SUBDIRECTORY} ) + string( REGEX REPLACE "-.*" "" _category ${SUBDIRECTORY} ) + if( USE_${_category} ) + list( APPEND _use_categories ${_category} ) + if( "${_implementation}" STREQUAL "${USE_${_category}}" ) + list( APPEND _found_categories ${_category} ) + else() + list( APPEND SKIP_LIST ${SUBDIRECTORY} ) + set( _skip_reason "USE_${_category}=${USE_${_category}}" ) + set( DO_SKIP 1 ) + endif() + endif() + endif() + if( NOT DO_SKIP EQUAL -1 ) message( "${ColorReset}-- Skipping module ${BoldRed}${SUBDIRECTORY}${ColorReset}." ) message( "" ) - list( APPEND LIST_SKIPPED_MODULES "${SUBDIRECTORY} (user request)" ) + list( APPEND LIST_SKIPPED_MODULES "${SUBDIRECTORY} (${_skip_reason})" ) elseif( ( IS_DIRECTORY "${CMAKE_CURRENT_SOURCE_DIR}/${SUBDIRECTORY}" ) AND ( DO_SKIP EQUAL -1 ) ) set( SKIPPED_MODULES ) @@ -36,5 +57,12 @@ endforeach() # both before and after the feature summary. calamares_explain_skipped_modules( ${LIST_SKIPPED_MODULES} ) +foreach( _category ${_use_categories} ) + list( FIND _found_categories ${_category} _found ) + if ( _found EQUAL -1 ) + message( FATAL_ERROR "USE_${_category} is set to ${USE_${_category}} and no module matches." ) + endif() +endforeach() + include( CalamaresAddTranslations ) add_calamares_python_translations( ${CALAMARES_TRANSLATION_LANGUAGES} ) diff --git a/src/modules/bootloader/bootloader.conf b/src/modules/bootloader/bootloader.conf index f5fcf19c8..51337de9d 100644 --- a/src/modules/bootloader/bootloader.conf +++ b/src/modules/bootloader/bootloader.conf @@ -12,8 +12,10 @@ kernel: "_ALL_kver_" img: "_default_image_" fallback: "_fallback_image_" timeout: "10" + # Optionally set the menu entry name and kernel name to use in systemd-boot. # If not specified here, these settings will be taken from branding.desc. +# # bootloaderEntryName: "Manjaro" kernelLine: ", with _manjaro_kernel_" fallbackKernelLine: ", with _manjaro_kernel_ (fallback initramfs)" diff --git a/src/modules/displaymanager/displaymanager.conf b/src/modules/displaymanager/displaymanager.conf index 1c30ed637..8f8e9c704 100644 --- a/src/modules/displaymanager/displaymanager.conf +++ b/src/modules/displaymanager/displaymanager.conf @@ -1,3 +1,5 @@ +# Configure one or more display managers (e.g. SDDM) +# with a "best effort" approach. --- #The DM module attempts to set up all the DMs found in this list, in that precise order. #It also sets up autologin, if the feature is enabled in globalstorage. diff --git a/src/modules/dummycpp/dummycpp.conf b/src/modules/dummycpp/dummycpp.conf index c90b6f3b9..1f2e1daee 100644 --- a/src/modules/dummycpp/dummycpp.conf +++ b/src/modules/dummycpp/dummycpp.conf @@ -1,3 +1,6 @@ +# This is a dummy (example) module for C++ Jobs. +# +# The code is the documentation for the configuration file. --- syntax: "YAML map of anything" example: @@ -15,4 +18,4 @@ a_list_of_maps: - "another element" - name: "another item" contents: - - "not much" \ No newline at end of file + - "not much" diff --git a/src/modules/dummypython/dummypython.conf b/src/modules/dummypython/dummypython.conf index fc985089a..c700120e7 100644 --- a/src/modules/dummypython/dummypython.conf +++ b/src/modules/dummypython/dummypython.conf @@ -1,3 +1,6 @@ +# This is a dummy (example) module for a Python Job Module. +# +# The code is the documentation for the configuration file. --- syntax: "YAML map of anything" example: @@ -15,4 +18,4 @@ a_list_of_maps: - "another element" - name: "another item" contents: - - "not much" \ No newline at end of file + - "not much" diff --git a/src/modules/dummypythonqt/dummypythonqt.conf b/src/modules/dummypythonqt/dummypythonqt.conf index f60e778e1..5bc64abfa 100644 --- a/src/modules/dummypythonqt/dummypythonqt.conf +++ b/src/modules/dummypythonqt/dummypythonqt.conf @@ -1,3 +1,6 @@ +# This is a dummy (example) module for PythonQt. +# +# The code is the documentation for the configuration file. --- syntax: "YAML map of anything" example: diff --git a/src/modules/fstab/fstab.conf b/src/modules/fstab/fstab.conf index c3dbfc309..11adff2ed 100644 --- a/src/modules/fstab/fstab.conf +++ b/src/modules/fstab/fstab.conf @@ -1,13 +1,28 @@ +# Creates /etc/fstab and /etc/crypttab in the target system. +# Also creates mount points for all the filesystems. +# +# When creating fstab entries for a filesystem, this module +# uses the options for the filesystem type to write to the +# options field of the file. --- +# Mount options to use for all filesystems. If a specific filesystem +# is listed here, use those options, otherwise use the *default* +# options from this mapping. mountOptions: default: defaults,noatime btrfs: defaults,noatime,space_cache,autodefrag + +# If a filesystem is on an SSD, add the following options. If a specific +# filesystem is listed here, use those options, otherwise no additional +# options are set (i.e. there is no *default* like in *mountOptions*). ssdExtraMountOptions: ext4: discard jfs: discard xfs: discard swap: discard btrfs: discard,compress=lzo + +# Additional options added to each line in /etc/crypttab crypttabOptions: luks # For Debian and Debian-based distributions, change the above line to: # crypttabOptions: luks,keyscript=/bin/cat diff --git a/src/modules/grubcfg/grubcfg.conf b/src/modules/grubcfg/grubcfg.conf index 608c9b2b4..b354ec35a 100644 --- a/src/modules/grubcfg/grubcfg.conf +++ b/src/modules/grubcfg/grubcfg.conf @@ -1,10 +1,22 @@ +# Write lines to /etc/default/grub (in the target system) based +# on calculated values and the values set in the *defaults* key +# in this configuration file. +# +# Calculated values are: +# - GRUB_DISTRIBUTOR, branding module, *bootloaderEntryName* +# - GRUB_ENABLE_CRYPTODISK, based on the presence of filesystems +# that use LUKS +# - GRUB_CMDLINE_LINUX_DEFAULT, adding LUKS setup and plymouth +# support to the kernel. + --- # If set to true, always creates /etc/default/grub from scratch even if the file # already existed. If set to false, edits the existing file instead. overwrite: false + # Default entries to write to /etc/default/grub if it does not exist yet or if -# we are overwriting it. Note that in addition, GRUB_CMDLINE_LINUX_DEFAULT and -# GRUB_DISTRIBUTOR will always be written, with automatically detected values. +# we are overwriting it. +# defaults: GRUB_TIMEOUT: 5 GRUB_DEFAULT: "saved" diff --git a/src/modules/initcpio/initcpio.conf b/src/modules/initcpio/initcpio.conf index 21f5704cc..466a8785d 100644 --- a/src/modules/initcpio/initcpio.conf +++ b/src/modules/initcpio/initcpio.conf @@ -1,2 +1,3 @@ +# Run mkinitcpio(8) with the given preset value --- kernel: linux312 diff --git a/src/modules/luksopenswaphookcfg/luksopenswaphookcfg.conf b/src/modules/luksopenswaphookcfg/luksopenswaphookcfg.conf index 886867f8d..f5610cd7c 100644 --- a/src/modules/luksopenswaphookcfg/luksopenswaphookcfg.conf +++ b/src/modules/luksopenswaphookcfg/luksopenswaphookcfg.conf @@ -1,2 +1,4 @@ +# Writes an openswap configuration with LUKS settings to the given path --- +# Path of the configuration file to write (in the target system) configFilePath: /etc/openswap.conf diff --git a/src/modules/mount/mount.conf b/src/modules/mount/mount.conf index d8f8fb8cc..bb28eed66 100644 --- a/src/modules/mount/mount.conf +++ b/src/modules/mount/mount.conf @@ -1,4 +1,18 @@ +# Mount filesystems in the target (generally, before treating the +# target as a usable chroot / "live" system). Filesystems are +# automatically mounted from the partitioning module. Filesystems +# listed here are **extra**. The filesystems listed in *extraMounts* +# are mounted in all target systems. The filesystems listed in +# *extraMountsEfi* are mounted in the target system **only** if +# the host machine uses UEFI. --- +# Extra filesystems to mount. The key's value is a list of entries; each +# entry has four keys: +# - device The device node to mount +# - fs The filesystem type to use +# - mountPoint Where to mount the filesystem +# - options (optional) Extra options to pass to mount(8) +# extraMounts: - device: proc fs: proc diff --git a/src/modules/removeuser/removeuser.conf b/src/modules/removeuser/removeuser.conf index a59961ec5..dab4b2526 100644 --- a/src/modules/removeuser/removeuser.conf +++ b/src/modules/removeuser/removeuser.conf @@ -1,2 +1,6 @@ +# Removes a single user (with userdel) from the system. +# This is typically used in OEM setups or if the live user +# spills into the target system. --- +# Username in the target system to be removed. username: live diff --git a/src/modules/services-openrc/main.py b/src/modules/services-openrc/main.py new file mode 100644 index 000000000..c3e14b481 --- /dev/null +++ b/src/modules/services-openrc/main.py @@ -0,0 +1,106 @@ +#!/usr/bin/env python3 +# -*- coding: utf-8 -*- +# +# === This file is part of Calamares - === +# +# Copyright 2016, Artoo +# Copyright 2017, Philip Müller +# Copyright 2018, Artoo +# Copyright 2018, Adriaan de Groot +# +# 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 . + +import libcalamares + +from libcalamares.utils import target_env_call, warning +from os.path import exists, join + + +class OpenrcController: + """ + This is the openrc service controller. + All of its state comes from global storage and the job + configuration at initialization time. + """ + + def __init__(self): + self.root = libcalamares.globalstorage.value('rootMountPoint') + + # Translate the entries in the config to the actions passed to rc-config + self.services = dict() + self.services["add"] = libcalamares.job.configuration.get('services', []) + self.services["del"] = libcalamares.job.configuration.get('disable', []) + + self.initdDir = libcalamares.job.configuration['initdDir'] + self.runlevelsDir = libcalamares.job.configuration['runlevelsDir'] + + def update(self, state): + """ + Call rc-update for each service listed + in services for the given @p state. rc-update + is called with @p state as the command as well. + """ + + for svc in self.services.get(state, []): + if isinstance(svc, str): + name = svc + runlevel = "default" + mandatory = False + else: + name = svc["name"] + runlevel = svc.get("runlevel", "default") + mandatory = svc.get("mandatory", False) + + service_path = self.root + self.initdDir + "/" + name + runlevel_path = self.root + self.runlevelsDir + "/" + runlevel + + if exists(service_path): + if exists(runlevel_path): + ec = target_env_call(["rc-update", state, name, runlevel]) + if ec != 0: + if mandatory: + return ("Cannot {} service {} to {}".format(state, name, runlevel), + "rc-update {} call in chroot returned error code {}".format(state, ec) + ) + else: + warning("Could not {} service {} in {}, error {!s}".format(state, name, runlevel, ec)) + else: + if mandatory: + return ("Target runlevel {} does not exist for {}.".format(runlevel, name), + "No {} found.".format(runlevel_path)) + else: + warning("Target runlevel {} does not exist for {}.".format(runlevel, name)) + else: + if mandatory: + return ("Target service {} does not exist.".format(name), + "No {} found.".format(service_path)) + else: + warning("Target service {} does not exist in {}.".format(name, self.initdDir)) + + + def run(self): + """Run the controller + """ + + for state in ("add", "del"): + r = self.update(state) + if r is not None: + return r + +def run(): + """ + Setup services + """ + + return OpenrcController().run() diff --git a/src/modules/services-openrc/module.desc b/src/modules/services-openrc/module.desc new file mode 100644 index 000000000..4b0b51614 --- /dev/null +++ b/src/modules/services-openrc/module.desc @@ -0,0 +1,5 @@ +--- +type: "job" +name: "services-openrc" +interface: "python" +script: "main.py" diff --git a/src/modules/services-openrc/services-openrc.conf b/src/modules/services-openrc/services-openrc.conf new file mode 100644 index 000000000..b8255b21a --- /dev/null +++ b/src/modules/services-openrc/services-openrc.conf @@ -0,0 +1,46 @@ +# openrc services module to modify service runlevels via rc-update in the chroot +# +# Services can be added (to any runlevel, or multiple runlevels) or deleted. +# Handle del with care and only use it if absolutely necessary. +# +# if a service is listed in the conf but is not present/detected on the target system, +# or a runlevel does not exist, it will be ignored and skipped; a warning is logged. +# +--- +# initdDir: holds the openrc service directory location +initdDir: /etc/init.d + +# runlevelsDir: holds the runlevels directory location +runlevelsDir: /etc/runlevels + +# services: a list of entries to **enable** +# disable: a list of entries to **disable** +# +# Each entry has three fields: +# - name: the service name +# - (optional) runlevel: can hold any runlevel present on the target +# system; if no runlevel is provided, "default" is assumed. +# - (optional) mandatory: if set to true, a failure to modify +# the service will result in installation failure, rather than just +# a warning. The default is false. +# +# an entry may also be a single string, which is interpreted +# as the name field (runlevel "default" is assumed then, and not-mandatory). +# +# # Example services and disable settings: +# # - add foo1 to default, but it must succeed +# # - add foo2 to nonetwork +# # - remove foo3 from default +# # - remove foo4 from default +# services: +# - name: foo1 +# mandatory: true +# - name: foo2 +# runlevel: nonetwork +# disable: +# - name: foo3 +# runlevel: default +# - foo4 +services: [] +disable: [] + diff --git a/src/modules/services-systemd/main.py b/src/modules/services-systemd/main.py new file mode 100644 index 000000000..09263b9f0 --- /dev/null +++ b/src/modules/services-systemd/main.py @@ -0,0 +1,97 @@ +#!/usr/bin/env python3 +# -*- coding: utf-8 -*- +# +# === This file is part of Calamares - === +# +# Copyright 2014, Philip Müller +# Copyright 2014, Teo Mrnjavac +# Copyright 2017, Alf Gaida +# Copyright 2018, Adriaan de Groot +# +# 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 . + +import libcalamares + + +def systemctl(targets, command, suffix): + """ + For each entry in @p targets, run "systemctl ", + where is the entry's name plus the given @p suffix. + (No dot is added between name and suffix; suffix may be empty) + + Returns a failure message, or None if this was successful. + Services that are not mandatory have their failures suppressed + silently. + """ + for svc in targets: + if isinstance(svc, str): + name = svc + mandatory = False + else: + name = svc["name"] + mandatory = svc.get("mandatory", False) + + ec = libcalamares.utils.target_env_call( + ['systemctl', command, "{}{}".format(name, suffix)] + ) + + if ec != 0: + if mandatory: + return ("Cannot {} systemd {} {}".format(command, suffix, name), + "systemctl {} call in chroot returned error code {}".format(command, ec) + ) + else: + libcalamares.utils.warning( + "Cannot {} systemd {} {}".format(command, suffix, name) + ) + libcalamares.utils.warning( + "systemctl {} call in chroot returned error code {}".format(command, ec) + ) + return None + + +def run(): + """ + Setup systemd services + """ + cfg = libcalamares.job.configuration + + # note that the "systemctl enable" and "systemctl disable" commands used + # here will work in a chroot; in fact, they are the only systemctl commands + # that support that, see: + # http://0pointer.de/blog/projects/changing-roots.html + + r = systemctl(cfg.get("services", []), "enable", ".service") + if r is not None: + return r + + r = systemctl(cfg.get("targets", []), "enable", ".target") + if r is not None: + return r + + r = systemctl(cfg.get("disable", []), "disable", ".service") + if r is not None: + return r + + r = systemctl(cfg.get("disable-targets", []), "disable", ".target") + if r is not None: + return r + + r = systemctl(cfg.get("mask", []), "mask", "") + if r is not None: + return r + + + # This could have just been return r + return None diff --git a/src/modules/services/module.desc b/src/modules/services-systemd/module.desc similarity index 72% rename from src/modules/services/module.desc rename to src/modules/services-systemd/module.desc index eff1dcc63..4a72b658b 100644 --- a/src/modules/services/module.desc +++ b/src/modules/services-systemd/module.desc @@ -1,6 +1,6 @@ --- type: "job" -name: "services" +name: "services-systemd" interface: "python" requires: [] script: "main.py" diff --git a/src/modules/services-systemd/services-systemd.conf b/src/modules/services-systemd/services-systemd.conf new file mode 100644 index 000000000..6ff1409bf --- /dev/null +++ b/src/modules/services-systemd/services-systemd.conf @@ -0,0 +1,70 @@ +# Systemd services manipulation. +# +# This module can enable services and targets for systemd +# (if packaging doesn't already do that). It can calso +# disable services (but not targets). +# +# First, services are enabled; then targets; then services +# are disabled -- this order of operations is fixed. +--- + +# There are three configuration keys for this module: +# *services*, *targets* and *disable*. The value of each +# key is a list of entries. Each entry has two keys: +# - *name* is the (string) name of the service or target that is being +# changed. Use quotes. Don't include ".target" or ".service" +# in the name. +# - *mandatory* is a boolean option, which states whether the change +# must be done successfully. If systemd reports an error while changing +# a mandatory entry, the installation will fail. When mandatory is false, +# errors for that entry (service or target) are ignored. If mandatory +# is not specified, the default is false. +# +# An entry may also be given as a single string, which is then +# interpreted as the name of the service. In this case, mandatory +# is also set to the default of false. +# +# Use [] to express an empty list. + +# # This example enables NetworkManager (and fails if it can't), +# # disables cups (and ignores failure). Then it enables the +# # graphical target (e.g. so that SDDM runs for login), and +# # finally disables pacman-init (an ArchLinux-only service). +# # +# # Enables .service +# services: +# - name: "NetworkManager" +# mandatory: true +# - name: "cups" +# mandatory: false +# +# # Enables .target +# targets: +# - name: "graphical" +# mandatory: true +# +# # Disables .service +# disable: +# - name: "pacman-init" +# mandatory: false +# +# # Disables .target +# # .. this shows how to use just the name +# disable-targets: +# - graphical +# +# # Masks (stronger version of disable). This section +# # is unusual because you **must** include the suffix +# # (e.g. ".service") as part of the name, so, e.g. to mask +# # NetworkManager (rather than just disable it) you must +# # specify "NetworkManager.service" as name. +# mask: +# - name: "NetworkManager.service" +# - mandatory: true + +# By default, no changes are made. +services: [] +targets: [] +disable: [] +disable-targets: [] +mask: [] diff --git a/src/modules/services/main.py b/src/modules/services/main.py deleted file mode 100644 index 89f7577e5..000000000 --- a/src/modules/services/main.py +++ /dev/null @@ -1,126 +0,0 @@ -#!/usr/bin/env python3 -# -*- coding: utf-8 -*- -# -# === This file is part of Calamares - === -# -# Copyright 2014-2016, Philip Müller -# Copyright 2014, Teo Mrnjavac -# Copyright 2016, Artoo -# Copyright 2017, Alf Gaida -# -# 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 . - -import libcalamares -from os.path import join, exists - - -def run(): - """ - Setup systemd services - """ - services = libcalamares.job.configuration['services'] - targets = libcalamares.job.configuration['targets'] - disable = libcalamares.job.configuration['disable'] - rootmnt = libcalamares.globalstorage.value("rootMountPoint") - - # note that the "systemctl enable" and "systemctl disable" commands used - # here will work in a chroot; in fact, they are the only systemctl commands - # that support that, see: - # http://0pointer.de/blog/projects/changing-roots.html - - # enable services - for svc in services: - ec = libcalamares.utils.target_env_call( - ['systemctl', 'enable', '{}.service'.format(svc['name'])] - ) - - if ec != 0: - if svc['mandatory']: - return ("Cannot enable systemd service {}".format(svc['name']), - "systemctl enable call in chroot returned error code " - "{}".format(ec) - ) - else: - libcalamares.utils.debug( - "Cannot enable systemd service {}".format(svc['name']) - ) - libcalamares.utils.debug( - "systemctl enable call in chroot returned error code " - "{}".format(ec) - ) - - # enable targets - for tgt in targets: - ec = libcalamares.utils.target_env_call( - ['systemctl', 'enable', '{}.target'.format(tgt['name'])] - ) - - if ec != 0: - if tgt['mandatory']: - return ("Cannot enable systemd target {}".format(tgt['name']), - "systemctl enable call in chroot returned error code " - "{}".format(ec) - ) - else: - libcalamares.utils.debug( - "Cannot enable systemd target {}".format(tgt['name']) - ) - libcalamares.utils.debug( - "systemctl enable call in chroot returned error code " - "{}".format(ec) - ) - - for dbl in disable: - ec = libcalamares.utils.target_env_call( - ['systemctl', 'disable', '{}.service'.format(dbl['name'])] - ) - - if ec != 0: - if dbl['mandatory']: - return ("Cannot disable systemd service" - "{}".format(dbl['name']), - "systemctl disable call in chroot returned error code " - "{}".format(ec)) - else: - libcalamares.utils.debug( - "Cannot disable systemd service {}".format(dbl['name']) - ) - libcalamares.utils.debug( - "systemctl disable call in chroot returned error code " - "{}".format(ec) - ) - - if libcalamares.globalstorage.contains("displayManagers"): - for dm in libcalamares.globalstorage.value("displayManagers"): - if not exists(join( - rootmnt, "etc/systemd/system/display-manager.service" - )): - ec = libcalamares.utils.target_env_call( - ['systemctl', 'enable', '{}.service'.format(dm)] - ) - - if ec != 0: - return "Cannot enable systemd service {}".format(dm), \ - "systemctl enable call in chroot returned error " \ - "code {}".format(ec) - else: - libcalamares.utils.debug( - "Cannot enable systemd service {}".format(dm) - ) - libcalamares.utils.debug( - "systemctl enable call in chroot returned error code " - "{}".format(ec) - ) - - return None diff --git a/src/modules/services/services.conf b/src/modules/services/services.conf deleted file mode 100644 index ebc8f9bd9..000000000 --- a/src/modules/services/services.conf +++ /dev/null @@ -1,20 +0,0 @@ ---- -#systemd services and targets are enabled in this precise order - -services: - - name: "NetworkManager" #name of the service file - mandatory: false #true=> if enabling fails the installer errors out and quits - #false=>if enabling fails print warning to console and continue - - name: "org.cups.cupsd" - mandatory: false - -targets: - - name: "graphical" - mandatory: true - -disable: - - name: "pacman-init" - mandatory: false - -# Example to express an empty list: -# disable: []