19 Commits

Author SHA1 Message Date
Adriaan de Groot
ff3391f67b Docs: add release announcement 2021-05-10 13:50:13 +02:00
Adriaan de Groot
b60b21b680 CMake: bump version 2021-05-10 13:45:31 +02:00
Adriaan de Groot
8a533d22be [mobile] Consistent initialization-expressions in declaration of Config 2021-05-11 11:49:06 +02:00
Adriaan de Groot
6f32c18ef9 Merge pull request #14 from ollieparanoid/non-numeric-pass
[mobile] support non-numeric passwords
2021-05-11 11:42:01 +02:00
Oliver Smith
f36f21c55c mobile.qml: refactor navNextFeature()
Make it more readable as for-loop.
2021-05-09 19:01:09 +02:00
Oliver Smith
bcacab531f [mobile] navNextFeature: fix skipping > 1 feature
Fix the condition in the while loop, so that it can actually continue
with the "continue" keyword. Without this patch, having the sshd
feature disabled would result in the fsType feature getting displayed,
even if it was disabled.
2021-05-02 17:54:18 +02:00
Oliver Smith
85586293c8 [mobile] tweak invalid chars msg/related comments
Change "cannot be typed in at boot time" to "can possibly not be typed
in after installation" and explain that the same check is now used for
the user password too.
2021-05-02 17:54:17 +02:00
Oliver Smith
e71eb01feb [mobile] add option userPasswordNumeric
Related: https://gitlab.com/postmarketOS/postmarketos-ondev/-/issues/46
2021-05-02 17:54:15 +02:00
Oliver Smith
3eb3e9c98d [mobile] rename default_pin -> user_pass
Prepare to add a config option to allow non-numeric passwords, by giving
the existing default_pin screen the more generic name user_pass.
Adjust the title of the screen too.

"default" in the file name was referring to configuring the default
user's PIN/password as opposed to the SSH user. However, I think
replacing it with "user" makes it more intuitive.
2021-05-02 17:54:13 +02:00
Oliver Smith
2bf5706f73 [mobile] add option builtinVirtualKeyboard
Allow to always hide the built-in qtvirtualkeyboard to support using a
different keyboard.

Related: https://gitlab.com/postmarketOS/postmarketos-ondev/-/issues/47
2021-05-02 17:54:05 +02:00
Adriaan de Groot
76885c7fe1 [mobile] Don't need to list headers as source 2021-04-06 12:00:21 +02:00
Adriaan de Groot
fad0575e4d Merge pull request #13 from ollieparanoid/readme-update
Docs: README: update mobile description
2021-04-03 00:01:12 +02:00
Adriaan de Groot
550f7d40ef CMake: collect and report the skipped modules
Use the newly-added methods for reporting skipped modules.
This requires a post-3.2.39 Calamares, which the CMakeLists.txt
does not yet enforce.
2021-03-23 01:50:59 +01:00
Adriaan de Groot
6c07d39374 [os-freebsd] Remove superfluous linking
For external modules, calamares_add_plugin() does the right thing,
and links to Calamares::calamares; don't use the internal name
from the Calamares repository, and don't link redundantly
to it anyway.
2021-03-22 14:09:28 +01:00
Adriaan de Groot
4285ccebd7 [os-freebsd] Until there's a config file, mark it explicitly without 2021-03-22 13:38:39 +01:00
Adriaan de Groot
320d67a5ba CMake: bail out on broken CMake folders
On a developer's system, the CMake configuration from the **build**
can be found in cache, and that means that <srcdir>/build/CalamaresConfig.cmake
is read instead of an installed version; that doesn't work, so
bail out early (after a half-dozen errors from CalamaresConfig internals).
2021-03-22 13:04:08 +01:00
Adriaan de Groot
6a80ce6dab Add os-* modules to the build
Document SKIP_MODULES and USE_os, although they don't **work**
yet; this should be the same machinery as in the core repo.
2021-03-22 12:33:54 +01:00
Adriaan de Groot
33678a6a16 Import os-* modules from the main repo
The os-* branch was started to add some os-specific modules
to the main Calamares repo. Now that calamares-extensions
has its own release cycle and a reason-to-be beyond examples,
those modules are more suitable here than in the main repo.

Both modules are stubs; development did not get very far.
2021-03-22 12:02:19 +01:00
Oliver Smith
2c91dc4664 Docs: README: update mobile description 2021-02-23 21:13:01 +01:00
15 changed files with 344 additions and 54 deletions

17
CHANGES
View File

@@ -6,8 +6,19 @@ This is the changelog for Calamares-Extensions. For each release, the major
changes and contributors are listed. Note that Calamares-Extensions does not changes and contributors are listed. Note that Calamares-Extensions does not
have a historical changelog -- this log starts with version 1.0.0. have a historical changelog -- this log starts with version 1.0.0.
# 1.1.2 (2021-05-14)
# 1.1.1 (2021-02-23) # This release contains contributions from (alphabetically by first name):
- Oliver Smith
Changes and new modules in this release:
- New *os-* modules are intended for OS-specific work. They don't
do anything concrete yet, though.
- The *mobile* module has new features thanks to Oliver, with
keyboard selection (numeric / alpha) for PIN / password entry among them.
# 1.1.1 (2021-02-23)
This release contains contributions from (alphabetically by first name): This release contains contributions from (alphabetically by first name):
- Oliver Smith - Oliver Smith
@@ -22,7 +33,7 @@ Changes and new modules in this release:
- *mobile* wait screen has been re-worded. - *mobile* wait screen has been re-worded.
# 1.1.0 (2021-01-04) # # 1.1.0 (2021-01-04)
This release contains contributions from (alphabetically by first name): This release contains contributions from (alphabetically by first name):
- Oliver Smith - Oliver Smith
@@ -32,7 +43,7 @@ Changes and new modules in this release:
- *mobile* module SSH daemon can be disabled - *mobile* module SSH daemon can be disabled
# 1.0.0 (2020-12-05) # # 1.0.0 (2020-12-05)
This release contains contributions from (alphabetically by first name): This release contains contributions from (alphabetically by first name):
- Oliver Smith - Oliver Smith

View File

@@ -24,13 +24,32 @@
# distro can use an unmodified (upstream) Calamares package and a local # distro can use an unmodified (upstream) Calamares package and a local
# customisation package in tandem. # customisation package in tandem.
# #
# Besides being an example repository, it is also a collection of modules
# and branding that is usable in its own right.
#
### CONFIGURING
#
# By default, all the branding examples and all the modules are built.
# This can be influenced through:
# SKIP_MODULES : a space or semicolon-separated list of directory names
# under src/modules that should not be built.
# USE_* : fills in SKIP_MODULES for modules called *-<something>
# In this repository, there is just one "group" to which USE_* applies:
# USE_os : operating-system-specific modules.
cmake_minimum_required(VERSION 3.3 FATAL_ERROR) cmake_minimum_required(VERSION 3.3 FATAL_ERROR)
project(calamares-extensions project(calamares-extensions
VERSION 1.1.1 VERSION 1.1.2
LANGUAGES CXX LANGUAGES CXX
) )
find_package(Calamares 3.2.26 REQUIRED) # On developer's machine, the user package registry breaks
# consumers by loading the developer's config from a build
# directory (which doesn't have the rest of the config
# installed inside it).
find_package(Calamares 3.2.26 REQUIRED NO_CMAKE_PACKAGE_REGISTRY)
if (NOT TARGET Calamares::calamares OR NOT TARGET Calamares::calamaresui)
message(FATAL_ERROR "Calamares found with missing CMake targets")
endif()
find_package(YAMLCPP REQUIRED) # Needed to untangle some dependencies before Calamares 3.2.36 find_package(YAMLCPP REQUIRED) # Needed to untangle some dependencies before Calamares 3.2.36
@@ -76,16 +95,18 @@ calamares_add_branding_subdirectory( branding/kaos_branding NAME kaos )
# #
# Add one of more modules, either C++ or Python. # Add one of more modules, either C++ or Python.
# #
set(SKIPPED_MODULES "") set(LIST_SKIPPED_MODULES "")
calamares_add_module_subdirectory( modules/filekeeper ) # C++ job calamares_add_module_subdirectory( modules/filekeeper LIST_SKIPPED_MODULES ) # C++ job
calamares_add_module_subdirectory( modules/freebsddisk ) # C++ viewmodule calamares_add_module_subdirectory( modules/freebsddisk LIST_SKIPPED_MODULES ) # C++ viewmodule
calamares_add_module_subdirectory( modules/mobile ) calamares_add_module_subdirectory( modules/mobile LIST_SKIPPED_MODULES )
calamares_add_module_subdirectory( modules/slowpython ) # Python job calamares_add_module_subdirectory( modules/os-freebsd LIST_SKIPPED_MODULES )
calamares_add_module_subdirectory( modules/os-nixos LIST_SKIPPED_MODULES )
calamares_add_module_subdirectory( modules/slowpython LIST_SKIPPED_MODULES ) # Python job
# If modules cannot be built, they usually call a macro # If modules cannot be built, they usually call a macro
# which builds a list of explanations; show that list. # which builds a list of explanations; show that list.
calamares_explain_skipped_modules( ${SKIPPED_MODULES} ) calamares_explain_skipped_modules( ${LIST_SKIPPED_MODULES} )
### RELEASE SUPPORT ### RELEASE SUPPORT
# #

View File

@@ -172,9 +172,13 @@ phase).
- [mobile](modules/mobile/CMakeLists.txt) is a QML **view** that - [mobile](modules/mobile/CMakeLists.txt) is a QML **view** that
takes over a number of other view steps. It is specific to takes over a number of other view steps. It is specific to
mobile phone use, possibly specific to PostmarketOS. It does mobile phone use, and as of writing used by
a number of "welcome to your new phone" things, e.g. [postmarketOS](https://postmarketos.org) and
with PostmarketOS installed on a PinePhone. [Mobian](https://mobian-project.org/). Among other things, it
allows to set up full disk encryption and to configure the
default user's password. Read the
[on-device installer](https://wiki.postmarketos.org/wiki/On-device_installer)
article for more information.
### CMake Preparation ### CMake Preparation

View File

@@ -6,13 +6,9 @@ calamares_add_plugin( mobile
EXPORT_MACRO PLUGINDLLEXPORT_PRO EXPORT_MACRO PLUGINDLLEXPORT_PRO
SOURCES SOURCES
Config.cpp Config.cpp
Config.h
MobileQmlViewStep.cpp MobileQmlViewStep.cpp
MobileQmlViewStep.h
PartitionJob.cpp PartitionJob.cpp
PartitionJob.h
UsersJob.cpp UsersJob.cpp
UsersJob.h
RESOURCES RESOURCES
mobile.qrc mobile.qrc
SHARED_LIB SHARED_LIB

View File

@@ -25,6 +25,9 @@ Config::setConfigurationMap( const QVariantMap& cfgMap )
m_userInterface = getString( cfgMap, "userInterface", "(unknown)" ); m_userInterface = getString( cfgMap, "userInterface", "(unknown)" );
m_version = getString( cfgMap, "version", "(unknown)" ); m_version = getString( cfgMap, "version", "(unknown)" );
m_username = getString( cfgMap, "username", "user" ); m_username = getString( cfgMap, "username", "user" );
m_userPasswordNumeric = getBool( cfgMap, "userPasswordNumeric", true );
m_builtinVirtualKeyboard = getBool( cfgMap, "builtinVirtualKeyboard", true );
m_featureSshd = getBool( cfgMap, "featureSshd", true ); m_featureSshd = getBool( cfgMap, "featureSshd", true );
m_featureFsType = getBool( cfgMap, "featureFsType", false ); m_featureFsType = getBool( cfgMap, "featureFsType", false );

View File

@@ -10,6 +10,9 @@
class Config : public QObject class Config : public QObject
{ {
Q_OBJECT Q_OBJECT
/* installer UI */
Q_PROPERTY( bool builtinVirtualKeyboard READ builtinVirtualKeyboard CONSTANT FINAL )
/* welcome */ /* welcome */
Q_PROPERTY( QString osName READ osName CONSTANT FINAL ) Q_PROPERTY( QString osName READ osName CONSTANT FINAL )
Q_PROPERTY( QString arch READ arch CONSTANT FINAL ) Q_PROPERTY( QString arch READ arch CONSTANT FINAL )
@@ -20,6 +23,7 @@ class Config : public QObject
/* default user */ /* default user */
Q_PROPERTY( QString username READ username CONSTANT FINAL ) Q_PROPERTY( QString username READ username CONSTANT FINAL )
Q_PROPERTY( QString userPassword READ userPassword WRITE setUserPassword NOTIFY userPasswordChanged ) Q_PROPERTY( QString userPassword READ userPassword WRITE setUserPassword NOTIFY userPasswordChanged )
Q_PROPERTY( bool userPasswordNumeric READ userPasswordNumeric CONSTANT FINAL )
/* ssh server + credentials */ /* ssh server + credentials */
Q_PROPERTY( bool featureSshd READ featureSshd CONSTANT FINAL ) Q_PROPERTY( bool featureSshd READ featureSshd CONSTANT FINAL )
@@ -58,6 +62,9 @@ public:
void setConfigurationMap( const QVariantMap& ); void setConfigurationMap( const QVariantMap& );
Calamares::JobList createJobs(); Calamares::JobList createJobs();
/* installer UI */
bool builtinVirtualKeyboard() { return m_builtinVirtualKeyboard; }
/* welcome */ /* welcome */
QString osName() const { return m_osName; } QString osName() const { return m_osName; }
QString arch() const { return m_arch; } QString arch() const { return m_arch; }
@@ -69,6 +76,7 @@ public:
QString username() const { return m_username; } QString username() const { return m_username; }
QString userPassword() const { return m_userPassword; } QString userPassword() const { return m_userPassword; }
void setUserPassword( const QString& userPassword ); void setUserPassword( const QString& userPassword );
bool userPasswordNumeric() const { return m_userPasswordNumeric; }
/* ssh server + credetials */ /* ssh server + credetials */
bool featureSshd() { return m_featureSshd; } bool featureSshd() { return m_featureSshd; }
@@ -117,6 +125,9 @@ public:
QString cmdSshdUseradd() const { return m_cmdSshdUseradd; } QString cmdSshdUseradd() const { return m_cmdSshdUseradd; }
private: private:
/* installer UI */
bool m_builtinVirtualKeyboard;
/* welcome */ /* welcome */
QString m_osName; QString m_osName;
QString m_arch; QString m_arch;
@@ -127,23 +138,24 @@ private:
/* default user */ /* default user */
QString m_username; QString m_username;
QString m_userPassword; QString m_userPassword;
bool m_userPasswordNumeric;
/* ssh server + credetials */ /* ssh server + credentials */
bool m_featureSshd; bool m_featureSshd = false;
QString m_sshdUsername; QString m_sshdUsername;
QString m_sshdPassword; QString m_sshdPassword;
bool m_isSshEnabled; bool m_isSshEnabled = false;
/* full disk encryption */ /* full disk encryption */
QString m_fdePassword = ""; QString m_fdePassword;
bool m_isFdeEnabled = false; bool m_isFdeEnabled = false;
/* filesystem selection */ /* filesystem selection */
bool m_featureFsType; bool m_featureFsType = false;
QString m_defaultFs; QString m_defaultFs;
QString m_fsType; QString m_fsType;
// Index of the currently selected filesystem in UI. // Index of the currently selected filesystem in UI.
int m_fsIndex; int m_fsIndex = -1;
QStringList m_fsList; QStringList m_fsList;
/* partition job */ /* partition job */

View File

@@ -11,6 +11,10 @@
## User Interface name (e.g. Plasma Mobile) ## User Interface name (e.g. Plasma Mobile)
# userInterface: "(unknown)" # userInterface: "(unknown)"
## User Interface assumes that the password is numeric (as of writing, this is
## the case with Plasma Mobile and Phosh)
# userPasswordNumeric: true
## OS version ## OS version
# version: "(unknown)" # version: "(unknown)"
@@ -64,6 +68,10 @@
## this gets used without asking the user. ## this gets used without asking the user.
# defaultFs: ext4 # defaultFs: ext4
## Start Qt's virtual keyboard within the mobile module. Disable if you bring
## your own virtual keyboard (e.g. svkbd).
# builtinVirtualKeyboard: true
####### #######
### Commands running in the installer OS ### Commands running in the installer OS
####### #######

View File

@@ -19,7 +19,7 @@ Page
"welcome": null, /* titlebar disabled */ "welcome": null, /* titlebar disabled */
"install_target": "Installation target", "install_target": "Installation target",
"install_target_confirm": "Warning", "install_target_confirm": "Warning",
"default_pin": "Lockscreen PIN", "user_pass": "User password",
"ssh_confirm": "SSH server", "ssh_confirm": "SSH server",
"ssh_credentials": "SSH credentials", "ssh_credentials": "SSH credentials",
"fs_selection": "Root filesystem", "fs_selection": "Root filesystem",
@@ -33,8 +33,8 @@ Page
"screens": ["welcome"]}, "screens": ["welcome"]},
{"name": "installTarget", {"name": "installTarget",
"screens": ["install_target", "install_target_confirm"]}, "screens": ["install_target", "install_target_confirm"]},
{"name": "userPin", {"name": "userPassword",
"screens": ["default_pin"]}, "screens": ["user_pass"]},
{"name": "sshd", {"name": "sshd",
"screens": ["ssh_confirm", "ssh_credentials"]}, "screens": ["ssh_confirm", "ssh_credentials"]},
{"name": "fsType", {"name": "fsType",
@@ -46,7 +46,7 @@ Page
] ]
property var featureIdByScreen: (function() { property var featureIdByScreen: (function() {
/* Put "features" above into an index of screen name -> feature id: /* Put "features" above into an index of screen name -> feature id:
* featureIdByScreen = {"welcome": 0, "default_pin": 1, ...} */ * featureIdByScreen = {"welcome": 0, "user_pass": 1, ...} */
var ret = {}; var ret = {};
for (var i=0; i<features.length; i++) { for (var i=0; i<features.length; i++) {
for (var j=0; j<features[i]["screens"].length; j++) { for (var j=0; j<features[i]["screens"].length; j++) {
@@ -55,8 +55,8 @@ Page
} }
return ret; return ret;
}()) }())
/* Only allow characters, that can be typed in with the initramfs on-screen keyboard /* Only allow characters, that can be typed in with osk-sdl
* (osk-sdl: see src/keyboard.cpp). FIXME: make configurable, but keep this as default? */ * (src/keyboard.cpp). Details in big comment in validatePassword(). */
property var allowed_chars: property var allowed_chars:
/* layer 0 */ "abcdefghijklmnopqrstuvwxyz" + /* layer 0 */ "abcdefghijklmnopqrstuvwxyz" +
/* layer 1 */ "ABCDEFGHIJKLMNOPQRSTUVWXYZ" + /* layer 1 */ "ABCDEFGHIJKLMNOPQRSTUVWXYZ" +
@@ -142,6 +142,7 @@ Page
InputPanel { InputPanel {
id: inputPanel id: inputPanel
y: Qt.inputMethod.visible ? parent.height - inputPanel.height : parent.height y: Qt.inputMethod.visible ? parent.height - inputPanel.height : parent.height
visible: config.builtinVirtualKeyboard
anchors.left: parent.left anchors.left: parent.left
anchors.right: parent.right anchors.right: parent.right
} }
@@ -183,10 +184,10 @@ Page
timer.start(); timer.start();
} }
function navNextFeature() { function navNextFeature() {
var id = featureIdByScreen[screen] + 1; var id;
/* Skip disabled features */ /* Skip disabled features */
do { for (id = featureIdByScreen[screen] + 1; id < features.length; id++) {
/* First letter uppercase */ /* First letter uppercase */
var name = features[id]["name"]; var name = features[id]["name"];
var nameUp = name.charAt(0).toUpperCase() + name.slice(1); var nameUp = name.charAt(0).toUpperCase() + name.slice(1);
@@ -195,7 +196,6 @@ Page
var configOption = "feature" + nameUp; var configOption = "feature" + nameUp;
if (config[configOption] === false) { if (config[configOption] === false) {
console.log("Skipping feature (disabled in config): " + name); console.log("Skipping feature (disabled in config): " + name);
id += 1;
continue; continue;
} }
@@ -204,10 +204,11 @@ Page
if (eval("typeof " + funcName) === "function" if (eval("typeof " + funcName) === "function"
&& eval(funcName + "()")) { && eval(funcName + "()")) {
console.log("Skipping feature (skip function): " + name); console.log("Skipping feature (skip function): " + name);
id += 1;
continue; continue;
} }
} while(false);
break;
}
console.log("Navigating to feature: " + features[id]["name"]); console.log("Navigating to feature: " + features[id]["name"]);
return navTo(features[id]["screens"][0]); return navTo(features[id]["screens"][0]);
@@ -252,7 +253,7 @@ Page
return true; return true;
} }
/* Input validation: user-screens (default_pin, ssh_credentials) */ /* Input validation: user-screens (user_pass, ssh_credentials) */
function validatePin(userPin, userPinRepeat, errorText) { function validatePin(userPin, userPinRepeat, errorText) {
var pin = userPin.text; var pin = userPin.text;
var repeat = userPinRepeat.text; var repeat = userPinRepeat.text;
@@ -388,11 +389,21 @@ Page
if (pass == "") if (pass == "")
return validationFailure(errorText); return validationFailure(errorText);
/* This function gets called for the FDE password and for the user
* password. As of writing, all distributions shipping the mobile
* module are using osk-sdl to type in the FDE password after the
* installation, and another keyboard after booting up, to type in the
* user password. The osk-sdl password has the same keys as
* squeekboard's default layout, and other keyboards should be able to
* type these characters in as well. For now, verify that the password
* only contains characters that can be typed in by osk-sdl. If you
* need this to be more sophisticated, feel free to submit patches to
* make this more configurable. */
if (!check_chars(pass)) if (!check_chars(pass))
return validationFailure(errorText, return validationFailure(errorText,
"The password must only contain" + "The password must only contain" +
" these characters, others cannot be" + " these characters, others can possibly" +
" typed in at boot time:\n" + " not be typed in after installation:\n" +
"\n" + "\n" +
allowed_chars_multiline()); allowed_chars_multiline());

View File

@@ -7,7 +7,7 @@
<file>install_target.qml</file> <!-- install from external to internal? --> <file>install_target.qml</file> <!-- install from external to internal? -->
<file>install_target_confirm.qml</file> <!-- overwrite internal storage? --> <file>install_target_confirm.qml</file> <!-- overwrite internal storage? -->
<file>default_pin.qml</file> <!-- default user: pin --> <file>user_pass.qml</file> <!-- default user: password -->
<file>ssh_confirm.qml</file> <!-- sshd: enable or not? --> <file>ssh_confirm.qml</file> <!-- sshd: enable or not? -->
<file>ssh_credentials.qml</file> <!-- sshd user: username, password --> <file>ssh_credentials.qml</file> <!-- sshd user: username, password -->
<file>fs_selection.qml</file> <!-- filesystem selection --> <file>fs_selection.qml</file> <!-- filesystem selection -->

View File

@@ -12,6 +12,17 @@ import QtQuick.Window 2.3
import QtQuick.VirtualKeyboard 2.1 import QtQuick.VirtualKeyboard 2.1
Item { Item {
property var placeholder: (config.userPasswordNumeric
? "PIN"
: "Password")
property var hints: (config.userPasswordNumeric
? Qt.ImhDigitsOnly
: Qt.ImhPreferLowercase)
property var validateFunc: (config.userPasswordNumeric
? validatePin
: validatePassword);
anchors.left: parent.left anchors.left: parent.left
anchors.top: parent.top anchors.top: parent.top
anchors.right: parent.right anchors.right: parent.right
@@ -25,23 +36,31 @@ Item {
anchors.topMargin: 30 anchors.topMargin: 30
wrapMode: Text.WordWrap wrapMode: Text.WordWrap
text: "Set the numeric password of your user. The lockscreen will" + text: (function() {
" ask for this PIN. This is <i>not</i> the PIN of your SIM" + if (config.userPasswordNumeric) {
" card. Make sure to remember it." return "Set the numeric password of your user. The" +
" lockscreen will ask for this PIN. This is" +
" <i>not</i> the PIN of your SIM card. Make sure to" +
" remember it.";
} else {
return "Set the password of your user. The lockscreen will" +
" ask for this password. Make sure to remember it.";
}
}())
width: 500 width: 500
} }
TextField { TextField {
id: userPin id: userPass
anchors.top: description.bottom anchors.top: description.bottom
placeholderText: qsTr("PIN") placeholderText: qsTr(placeholder)
echoMode: TextInput.Password echoMode: TextInput.Password
onTextChanged: validatePin(userPin, userPinRepeat, errorText) onTextChanged: validateFunc(userPass, userPassRepeat, errorText)
text: config.userPassword text: config.userPassword
/* Let the virtual keyboard change to digits only */ /* Let the virtual keyboard change to digits only */
inputMethodHints: Qt.ImhDigitsOnly inputMethodHints: hints
onActiveFocusChanged: { onActiveFocusChanged: {
if(activeFocus) { if(activeFocus) {
Qt.inputMethod.update(Qt.ImQueryInput) Qt.inputMethod.update(Qt.ImQueryInput)
@@ -54,12 +73,12 @@ Item {
} }
TextField { TextField {
id: userPinRepeat id: userPassRepeat
anchors.top: userPin.bottom anchors.top: userPass.bottom
placeholderText: qsTr("PIN (repeat)") placeholderText: qsTr(placeholder + " (repeat)")
inputMethodHints: Qt.ImhDigitsOnly inputMethodHints: hints
echoMode: TextInput.Password echoMode: TextInput.Password
onTextChanged: validatePin(userPin, userPinRepeat, errorText) onTextChanged: validateFunc(userPass, userPassRepeat, errorText)
text: config.userPassword text: config.userPassword
anchors.horizontalCenter: parent.horizontalCenter anchors.horizontalCenter: parent.horizontalCenter
@@ -68,7 +87,7 @@ Item {
} }
Text { Text {
anchors.top: userPinRepeat.bottom anchors.top: userPassRepeat.bottom
id: errorText id: errorText
visible: false visible: false
wrapMode: Text.WordWrap wrapMode: Text.WordWrap
@@ -86,8 +105,8 @@ Item {
text: qsTr("Continue") text: qsTr("Continue")
onClicked: { onClicked: {
if (validatePin(userPin, userPinRepeat, errorText)) { if (validateFunc(userPass, userPassRepeat, errorText)) {
config.userPassword = userPin.text; config.userPassword = userPass.text;
navNext(); navNext();
} }
} }

View File

@@ -0,0 +1,20 @@
# The OS-FreeBSD module does "all the things" in a FreeBSD installation.
# Since the other modules -- users, fstab, grub, pretty much all of them
# -- are Linux-specific, it doesn't make much sense to fork each of them
# or provide alternatives, so instead we have one module that completes
# a FreeBSD installation based on the GlobalStorage values set by
# Calamares viewmodules.
#
# SPDX-FileCopyrightText: 2019 Adriaan de Groot <groot@kde.org>
# SPDX-License-Identifier: GPL-3.0-or-later
# License-Filename: LICENSE
#
calamares_add_plugin( os-freebsd
TYPE job
EXPORT_MACRO PLUGINDLLEXPORT_PRO
SOURCES
FreeBSDJob.cpp
SHARED_LIB
NO_CONFIG
)

View File

@@ -0,0 +1,58 @@
/* === This file is part of Calamares - <https://github.com/calamares> ===
*
* SPDX-FileCopyrightText: 2019 Adriaan de Groot <groot@kde.org>
* SPDX-License-Identifier: GPL-3.0-or-later
* License-Filename: LICENSE
*/
#include "FreeBSDJob.h"
#include "CalamaresVersion.h"
#include "GlobalStorage.h"
#include "JobQueue.h"
#include "utils/Logger.h"
#include <QDateTime>
#include <QProcess>
#include <QThread>
FreeBSDJob::FreeBSDJob( QObject* parent )
: Calamares::CppJob( parent )
{
}
FreeBSDJob::~FreeBSDJob() {}
QString
FreeBSDJob::prettyName() const
{
return tr( "FreeBSD Installation Job" );
}
Calamares::JobResult
FreeBSDJob::exec()
{
emit progress( 0.1 );
cDebug() << "[FREEBSD]";
Calamares::JobQueue::instance()->globalStorage()->debugDump();
emit progress( 0.5 );
QThread::sleep( 3 );
emit progress( 1.0 );
return Calamares::JobResult::ok();
}
void
FreeBSDJob::setConfigurationMap( const QVariantMap& configurationMap )
{
// TODO: actually fetch something from that configuration
m_configurationMap = configurationMap;
}
CALAMARES_PLUGIN_FACTORY_DEFINITION( FreeBSDJobFactory, registerPlugin< FreeBSDJob >(); )

View File

@@ -0,0 +1,39 @@
/* === This file is part of Calamares - <https://github.com/calamares> ===
*
* SPDX-FileCopyrightText: 2019 Adriaan de Groot <groot@kde.org>
* SPDX-License-Identifier: GPL-3.0-or-later
* License-Filename: LICENSE
*/
#ifndef FREEBSDJOB_H
#define FREEBSDJOB_H
#include "CppJob.h"
#include "DllMacro.h"
#include "utils/PluginFactory.h"
#include <QObject>
#include <QVariantMap>
class PLUGINDLLEXPORT FreeBSDJob : public Calamares::CppJob
{
Q_OBJECT
public:
explicit FreeBSDJob( QObject* parent = nullptr );
virtual ~FreeBSDJob() override;
QString prettyName() const override;
Calamares::JobResult exec() override;
void setConfigurationMap( const QVariantMap& configurationMap ) override;
private:
QVariantMap m_configurationMap;
};
CALAMARES_PLUGIN_FACTORY_DECLARATION( FreeBSDJobFactory )
#endif // FREEBSDJOB_H

83
modules/os-nixos/main.py Normal file
View File

@@ -0,0 +1,83 @@
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
#
# === This file is part of Calamares - <https://github.com/calamares> ===
#
# 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/>.
#
# SPDX-FileCopyrightText: 2019 Adriaan de Groot <groot@kde.org>
# SPDX-License-Identifier: GPL-3.0-or-later
# License-Filename: LICENSE
#
"""
=== NixOS Configuration
NixOS has its own "do all the things" configuration file which
declaratively handles what things need to be done in the target
system, and it has an existing tool to "execute" that declarative
specification. This module takes configuration values set by
Calamares viewmodules (e.g. the users module) and puts
them into the configuration file in the target system,
and then runs the necessary NixOS specific tools.
"""
import libcalamares
import os
from time import gmtime, strftime, sleep
import gettext
_ = gettext.translation("calamares-python",
localedir=libcalamares.utils.gettext_path(),
languages=libcalamares.utils.gettext_languages(),
fallback=True).gettext
def pretty_name():
return _("NixOS Configuration.")
def run():
"""NixOS Configuration."""
libcalamares.utils.debug("LocaleDir=" +
str(libcalamares.utils.gettext_path()))
libcalamares.utils.debug("Languages=" +
str(libcalamares.utils.gettext_languages()))
# TODO: probably want to use the job configuration
# with a key "stage" to distinguish generate-config
# from execute-config; maybe it wants an "all" as well
# to do both.
accumulator = "*** Job configuration\n"
accumulator += str(libcalamares.job.configuration)
libcalamares.utils.debug(accumulator)
accumulator = "*** GlobalStorage configuration\n"
accumulator += "count: " + str(libcalamares.globalstorage.count()) + "\n"
accumulator += "keys: {}\n".format(str(libcalamares.globalstorage.keys()))
libcalamares.utils.debug(accumulator)
libcalamares.utils.debug("Run NixOS tools.")
libcalamares.job.setprogress( 0.1 )
sleep(1)
libcalamares.job.setprogress( 0.5 )
sleep(1)
libcalamares.job.setprogress( 1.0 )
sleep(3)
# To indicate an error, return a tuple of:
# (message, detailed-error-message)
return None

View File

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