[merge] sync with upstream

This commit is contained in:
Philip Müller 2018-06-29 08:25:08 +02:00
commit 62e065c52f
32 changed files with 672 additions and 238 deletions

View File

@ -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 <foo>-<implementation>.
# 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 <foo>, set USE_<foo> to the
# name of the implementation. If USE_<foo> 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_<foo> 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" )

View File

@ -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()

View File

@ -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()

93
ci/RELEASE.sh Normal file
View File

@ -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 <<EOF
# Next steps for this release:
git push --tags
gpg -s -u $KEY_ID --detach --armor $TAR_FILE # Sign the tarball
# Upload tarball $TAR_FILE and the signature $TAR_FILE.asc
# Announce via https://github.com/calamares/calamares/releases/new
# SHA256: $SHA256
EOF
exit 0

View File

@ -50,7 +50,7 @@
<message>
<location filename="../src/libcalamaresui/viewpages/BlankViewStep.cpp" line="69"/>
<source>Blank Page</source>
<translation type="unfinished"/>
<translation>Pusta strona</translation>
</message>
</context>
<context>
@ -192,17 +192,17 @@
<message>
<location filename="../src/libcalamaresui/ViewManager.cpp" line="179"/>
<source>Calamares Initialization Failed</source>
<translation type="unfinished"/>
<translation>Błąd inicjacji programu Calamares</translation>
</message>
<message>
<location filename="../src/libcalamaresui/ViewManager.cpp" line="180"/>
<source>%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.</source>
<translation type="unfinished"/>
<translation>%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ę.</translation>
</message>
<message>
<location filename="../src/libcalamaresui/ViewManager.cpp" line="185"/>
<source>&lt;br/&gt;The following modules could not be loaded:</source>
<translation type="unfinished"/>
<translation>&lt;br/&gt;Następujące moduły nie mogły zostać wczytane:</translation>
</message>
<message>
<location filename="../src/libcalamaresui/ViewManager.cpp" line="277"/>
@ -1663,7 +1663,7 @@ Instalator zostanie zamknięty i wszystkie zmiany zostaną utracone.</translatio
<message>
<location filename="../src/modules/partition/gui/PartitionPage.ui" line="107"/>
<source>Cre&amp;ate</source>
<translation type="unfinished"/>
<translation>Ut_wórz</translation>
</message>
<message>
<location filename="../src/modules/partition/gui/PartitionPage.ui" line="114"/>

View File

@ -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

View File

@ -212,7 +212,7 @@ Settings::customModuleInstances() const
}
QList< QPair< ModuleAction, QStringList > >
Settings::ModuleSequence
Settings::modulesSequence() const
{
return m_modulesSequence;

View File

@ -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;

View File

@ -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();
}

View File

@ -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;

View File

@ -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;
}
}

View File

@ -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;

View File

@ -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_<foo> variables by looking for subdirectories
# with a <foo>-<implementation> 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} )

View File

@ -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)"

View File

@ -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.

View File

@ -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"
- "not much"

View File

@ -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"
- "not much"

View File

@ -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:

View File

@ -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

View File

@ -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"

View File

@ -1,2 +1,3 @@
# Run mkinitcpio(8) with the given preset value
---
kernel: linux312

View File

@ -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

View File

@ -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

View File

@ -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

View File

@ -0,0 +1,106 @@
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
#
# === This file is part of Calamares - <https://github.com/calamares> ===
#
# Copyright 2016, Artoo <artoo@manjaro.org>
# Copyright 2017, Philip Müller <philm@manjaro.org>
# Copyright 2018, Artoo <artoo@artixlinux.org>
# Copyright 2018, 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/>.
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()

View File

@ -0,0 +1,5 @@
---
type: "job"
name: "services-openrc"
interface: "python"
script: "main.py"

View File

@ -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: []

View File

@ -0,0 +1,97 @@
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
#
# === This file is part of Calamares - <https://github.com/calamares> ===
#
# Copyright 2014, Philip Müller <philm@manjaro.org>
# Copyright 2014, Teo Mrnjavac <teo@kde.org>
# Copyright 2017, Alf Gaida <agaida@siduction.org>
# Copyright 2018, 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/>.
import libcalamares
def systemctl(targets, command, suffix):
"""
For each entry in @p targets, run "systemctl <command> <thing>",
where <thing> 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

View File

@ -1,6 +1,6 @@
---
type: "job"
name: "services"
name: "services-systemd"
interface: "python"
requires: []
script: "main.py"

View File

@ -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 <name>.service
# services:
# - name: "NetworkManager"
# mandatory: true
# - name: "cups"
# mandatory: false
#
# # Enables <name>.target
# targets:
# - name: "graphical"
# mandatory: true
#
# # Disables <name>.service
# disable:
# - name: "pacman-init"
# mandatory: false
#
# # Disables <name>.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: []

View File

@ -1,126 +0,0 @@
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
#
# === This file is part of Calamares - <https://github.com/calamares> ===
#
# Copyright 2014-2016, Philip Müller <philm@manjaro.org>
# Copyright 2014, Teo Mrnjavac <teo@kde.org>
# Copyright 2016, Artoo <artoo@manjaro.org>
# Copyright 2017, Alf Gaida <agaida@siduction.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/>.
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

View File

@ -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: []