Browse Source

New snapshot: 3.2.2v3.2.2-1

master
Alf Gaida 2 years ago
parent
commit
f5a293cd28
100 changed files with 16099 additions and 12 deletions
  1. 6
    0
      .gitattributes
  2. 26
    0
      .github/ISSUE_TEMPLATE/bug_report.md
  3. 17
    0
      .github/ISSUE_TEMPLATE/feature_request.md
  4. 50
    6
      .gitignore
  5. 0
    0
      .gitmodules
  6. 1
    1
      .travis.yml
  7. 24
    0
      AUTHORS
  8. 125
    0
      CHANGES
  9. 539
    0
      CMakeLists.txt
  10. 69
    0
      CMakeModules/BoostPython3.cmake
  11. 32
    0
      CMakeModules/CMakeColors.cmake
  12. 23
    0
      CMakeModules/CMakeDateStamp.cmake
  13. 45
    0
      CMakeModules/CMakeVersionSource.cmake
  14. 151
    0
      CMakeModules/CalamaresAddBrandingSubdirectory.cmake
  15. 143
    0
      CMakeModules/CalamaresAddLibrary.cmake
  16. 147
    0
      CMakeModules/CalamaresAddModuleSubdirectory.cmake
  17. 160
    0
      CMakeModules/CalamaresAddPlugin.cmake
  18. 177
    0
      CMakeModules/CalamaresAddTranslations.cmake
  19. 34
    0
      CMakeModules/FindCrypt.cmake
  20. 57
    0
      CMakeModules/FindLIBPARTED.cmake
  21. 37
    0
      CMakeModules/FindLibPWQuality.cmake
  22. 177
    0
      CMakeModules/FindPythonQt.cmake
  23. 50
    0
      CMakeModules/FindYAMLCPP.cmake
  24. 17
    0
      CMakeModules/IncludeKPMCore.cmake
  25. 4
    0
      CalamaresBuildTreeSettings.cmake.in
  26. 32
    0
      CalamaresConfig.cmake.in
  27. 12
    0
      CalamaresConfigVersion.cmake.in
  28. 29
    0
      CalamaresUse.cmake.in
  29. 2
    0
      Dockerfile
  30. 674
    0
      LICENSE
  31. 49
    0
      LICENSES/BSD3-SameGame
  32. 383
    0
      LICENSES/GPLv2+-libpwquality
  33. 16
    0
      LICENSES/GPLv3+-ImageRegistry
  34. 18
    0
      LICENSES/GPLv3+-QJsonModel
  35. 83
    0
      LICENSES/LGPLv2.1-Presentation
  36. 22
    0
      LICENSES/LGPLv2.1-Presentation-Exception
  37. 209
    0
      LICENSES/LGPLv3-Breeze
  38. 21
    0
      LICENSES/MIT-QtWaitingSpinner
  39. 44
    0
      README.md
  40. 178
    0
      calamares.desktop
  41. 15
    0
      calamares.desktop.in
  42. 201
    0
      ci/HACKING.md
  43. 78
    0
      ci/RELEASE.md
  44. 93
    0
      ci/RELEASE.sh
  45. 13
    0
      ci/astylerc
  46. 19
    0
      ci/buildall.sh
  47. 6
    0
      ci/calamaresstyle
  48. 6
    0
      ci/coverity-model.c
  49. 4
    0
      ci/cppcheck.sh
  50. 12
    0
      ci/travis-config.sh
  51. 36
    0
      ci/travis-continuous.sh
  52. 34
    0
      ci/travis-coverity.sh
  53. 21
    0
      ci/travis.sh
  54. 106
    0
      ci/txpull.sh
  55. 80
    0
      ci/txpush.sh
  56. 21
    0
      cmake_uninstall.cmake.in
  57. 22
    0
      com.github.calamares.calamares.policy
  58. 11
    0
      data/example-root/README.md
  59. 2
    0
      data/example-root/etc/bash.bashrc
  60. 1
    0
      data/example-root/etc/group
  61. 1
    0
      data/example-root/etc/issue
  62. 486
    0
      data/example-root/etc/locale.gen
  63. 2
    0
      data/example-root/etc/profile
  64. 0
    0
      data/example-root/etc/sudoers.d/10-installer
  65. 0
    0
      data/example-root/usr/share/zoneinfo/.dummy
  66. BIN
      data/example-root/usr/share/zoneinfo/America/New_York
  67. BIN
      data/example-root/usr/share/zoneinfo/UTC
  68. BIN
      data/example-root/usr/share/zoneinfo/Zulu
  69. 0
    0
      data/example-root/var/lib/dbus/.dummy
  70. 0
    0
      data/example-root/var/lib/initramfs-tools
  71. 1
    0
      data/example-root/xbin/linux-version
  72. 1
    0
      data/example-root/xbin/useradd
  73. 111
    0
      data/images/boot-environment.svg
  74. 110
    0
      data/images/bugs.svg
  75. BIN
      data/images/fail.svgz
  76. 157
    0
      data/images/help.svg
  77. BIN
      data/images/information.svgz
  78. BIN
      data/images/no.svgz
  79. 407
    0
      data/images/partition-alongside.svg
  80. 289
    0
      data/images/partition-disk.svg
  81. 360
    0
      data/images/partition-erase-auto.svg
  82. 333
    0
      data/images/partition-manual.svg
  83. 324
    0
      data/images/partition-partition.svg
  84. 401
    0
      data/images/partition-replace-os.svg
  85. 112
    0
      data/images/partition-table.svg
  86. 99
    0
      data/images/release.svg
  87. BIN
      data/images/squid.png
  88. 318
    0
      data/images/squid.svg
  89. 18
    0
      data/images/state-error.svg
  90. 18
    0
      data/images/state-ok.svg
  91. 18
    0
      data/images/state-warning.svg
  92. BIN
      data/images/yes.svgz
  93. 4
    4
      debian/changelog
  94. 1
    0
      debian/files
  95. 8
    1
      debian/repository.spec
  96. 24
    0
      lang/CMakeLists.txt
  97. 2611
    0
      lang/calamares_ar.ts
  98. 2611
    0
      lang/calamares_ast.ts
  99. 2610
    0
      lang/calamares_be.ts
  100. 0
    0
      lang/calamares_bg.ts

+ 6
- 0
.gitattributes View File

@@ -0,0 +1,6 @@
.tx/* export-ignore
hacking/* export-ignore
HACKING.md export-ignore
.editorconfig export-ignore
src/modules/testmodule.py export-ignore
src/modules/globalStorage.yaml export-ignore

+ 26
- 0
.github/ISSUE_TEMPLATE/bug_report.md View File

@@ -0,0 +1,26 @@
---
name: Bug report
about: Create a report to help us improve

---

> Hi! Thank you for helping improve Calamares. If you are seeing a problem in installing a specific distribution, you should **probably** report the problem in the distribution's bug tracker, first. That helps filter out issues with packaging, mis-configuration, etc. that Calamares has no control over. If you are a distribution packager or maintainer, this page is for you.

**Describe the bug**
A clear and concise description of what the bug is. Please include 32/64 bit machine details, EFI/BIOS details, and disk setup.

**To Reproduce**
Steps to reproduce the behavior:
1. Go to '...'
2. Click on '....'
3. Scroll down to '....'
4. See error

**Expected behavior**
A clear and concise description of what you expected to happen.

**Screenshots and Logs**
If applicable, add screenshots to help explain your problem. Calamares has an installation log (usually `~/.cache/calamares/session.log`), please check it for confidential information and attach it if possible.

**Additional context**
Add any other context about the problem here.

+ 17
- 0
.github/ISSUE_TEMPLATE/feature_request.md View File

@@ -0,0 +1,17 @@
---
name: Feature request
about: Suggest an idea for this project

---

**Is your feature request related to a problem? Please describe.**
A clear and concise description of what the problem is. Ex. I'm always frustrated when [...]

**Describe the solution you'd like**
A clear and concise description of what you want to happen.

**Describe alternatives you've considered**
A clear and concise description of any alternative solutions or features you've considered.

**Additional context**
Add any other context or screenshots about the feature request here.

+ 50
- 6
.gitignore View File

@@ -1,8 +1,52 @@
debian/files
debian/*.substvars
# C++ objects and libs

debian/.debhelper/
debian/calamares/
debian/debhelper-build-stamp
*.slo
*.lo
*.o
*.a
*.la
*.lai
*.so
*.dll
*.dylib

obj-x86_64-linux-gnu/
# Python

__pycache__

# Qt-es

/.qmake.cache
/.qmake.stash
*.pro.user
*.pro.user.*
*.moc
*.qmlc
moc_*.cpp
qrc_*.cpp
ui_*.h
Makefile*
*-build-*
*-build
/build

# QtCreator

*.autosave
qtcreator-build
CMakeLists.txt.user

# KDevelop
*.kdev4

# PyCharm
.idea

# Visual Studio Code
.vscode

# Backup files
*~

# Kate
*.kate-swp

+ 0
- 0
.gitmodules View File


+ 1
- 1
.travis.yml View File

@@ -16,5 +16,5 @@ install:
- docker build -t calamares .

script:
- docker run -v $PWD:/src --tmpfs /build:rw,size=81920k -e SRCDIR=/src -e BUILDDIR=/build calamares "/src/ci/travis.sh"
- docker run -v $PWD:/src --tmpfs /build:rw,size=65536k -e SRCDIR=/src -e BUILDDIR=/build calamares "/src/ci/travis.sh"


+ 24
- 0
AUTHORS View File

@@ -0,0 +1,24 @@
# MAINTAINER

Teo Mrnjavac <teo@kde.org> (maintainer -2017)
Adriaan de Groot <groot@kde.org> (maintainer 2017-)

# CONTRIBUTORS

Alf Gaida
Allen Welkie
Andrius Štikonas
Bernhard Landauer
Bezzy1999
bill-auger
crispg72
demmm
Gabriel Craciunescu
Kai Dohmen
Kevin Kofler
Kyle Robertze
Lisa Vitolo
n3rdopolis
Philip Müller
Ramon Buldó
Rohan Garg

+ 125
- 0
CHANGES View File

@@ -0,0 +1,125 @@
This is the changelog for Calamares. For each release, the major changes and
contributors are listed. Note that Calamares does not have a historical
changelog -- this log starts with version 3.2.0. The release notes on the
website will have to do for older versions.

= 3.2.2 (2018-09-04) =

This release contains contributions from (alphabetically by first name):
- Andrius Štikonas
- artoo@cromnix.org
- Caio Carvalho
- Harald Sitter
- Philip Müller
- Simon Quigley
- Walter Lapchynski

== Core ==

* Example configurations are **no longer installed** by default.
The default setting for *INSTALL_CONFIG* has changed. Distributions
are strongly encouraged to write their own configuration files and
not rely on the example configuration files. Example configurations
may change unpredictably.
* It is now possible to express module dependencies through the
*requiredModules* key in `module.desc`. All of the required modules
for a given module must occur in the sequence **before** the module
requiring them. None of the core modules use this facility.
* The search paths for QML files, branding descriptors and module
descriptors have been revamped and now self-document in the log.
* A new `ci/RELEASE.sh` script has been added to streamline releases;
it is not guaranteed to work anywhere in particular though.

== Modules ==

* When multiple modules are mutually exclusive, or don't make sense
to enable concurrectly, a new `USE_<foo>` framework has been added
to CMake to simplify the selection of modules. This is in addition
to the existing `SKIP_MODULES` mechanism.
* Various off-by-one-sector errors in the automatic partitioning
mode have been corrected. In addition, swap space is calculated
a little more conservatively.
* A new module has been added to the core which can configure openrc
services. To make services configuration consistent:
- The *services* module has been **renamed** *services-systemd*,
- The openrc module is named *services-openrc*,
- At CMake time, it is possible to select all of the services modules,
or one specific one, by setting the *USE_services* CMake variable.
By default, all of the modules are built and installed.
* The systemd-services module can now disable targets and mask both
targets and services (which will allow you to break the system with
a bad configuration). The configuration is a little more flexible
because a service (or target) name can be used on its own with
sensible defaults.
* The displaymanager module has been entirely revamped. A long-standing
bug which ignored the settings for default desktop has been fixed
(thanks to Walter Lapchynski). Translations have been added to the
error messages. Each DM now has an implementation class for doing
all the configuration steps it needs. This groups the code needed for
a specific DM (and presumably, per-distro) in one place.
Distro's are **strongly advised** to re-test their DM configuration
and installation with the revamped code.

**3.2.1** (2018-06-25)

This release contains contributions from (alphabetically by first name):
- Bill Auguer
- Gabriel Craciunescu
- Phil Mueller
- Raul Rodrigo Segura

== Core ==

* Qt 5.7 is now the minimum required Qt version. Because KPMCore
(a fairly fundamental dependency) requires Qt 5.7, Calamares
has followed suit.
* New testing application `loadmodule` for loading and running a
single Calamares module.
* New translations Belarussian and Korean.
* Jobs can now be *emergency jobs* which run even after a failure.
* Improved debugging when modules fail to load.
* Bad configuration files will now cause the user-interface of
Calamares to display an error message, rather than silently
ignoring some configuration errors. This will certainly cause
problems for distributions with sloppy configurations.

== Modules ==

* New module preservefiles, keeps (log) files around after install;
this duplicates functionality with the unmount module, but unmount
is very late, rather limited, and fragile.
* Interactiveterminal module now disables itself if build requirements
are not met, rather than blocking the build.
* Fixes in the timezone map data make the southern hemisphere more
usable and put Reykjavik in its place.
* The packages module can now update the target system if explicitly
told to do so.
* More paths and executables are configurable in the bootloader module.
* Distributions are advised to review the `users.conf` setup **again**,
as some changes in version 3.2.0 caused regressions downstream.
* Distributions are advised to review their `locale.gen` files
**again**. Previous changes were too restrictive, matching only
the specific format Chakra Linux uses. Calamares now preserves
all the comment-lines in the file and writes enabled locales
at the end, with a descriptive comment.

**3.2.0** (2018-05-17)

This release contains contributions from (alphabetically by first name):
- Alf Gaida
- AlmAck
- Caio Carvalho
- Frede H

== Modules ==

* UI annoyances in the partitioning module were fixed; the
mount-point selector is now more obvious when no mount-point
has been chosen, and the mount-point and flags are preserved
when (re)editing partitions.
* The handling of `@@ROOT@@` substitution in shellprocesses was
backwards; this has been fixed (the substitution is made when
running in the **host**).
* The user shell is no longer hard-coded to `/bin/bash`,
but follows the default setting for useradd(8), e.g.
those set in `/etc/default/useradd`.

+ 539
- 0
CMakeLists.txt View File

@@ -0,0 +1,539 @@
# === 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-License-Identifier: GPL-3.0+
# License-Filename: LICENSE
#
###
#
# Generally, this CMakeLists.txt will find all the dependencies for Calamares
# and complain appropriately. See below (later in this file) for CMake-level
# options. There are some "secret" options as well:
#
# SKIP_MODULES : a space or semicolon-separated list of directory names
# under src/modules that should not be built.
#
# 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 )

cmake_minimum_required( VERSION 3.2 )


### OPTIONS
#
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
#
set( CALAMARES_ORGANIZATION_NAME "Calamares" )
set( CALAMARES_ORGANIZATION_DOMAIN "github.com/calamares" )
set( CALAMARES_APPLICATION_NAME "Calamares" )
set( CALAMARES_DESCRIPTION_SUMMARY
"The distribution-independent installer framework" )

set( CALAMARES_VERSION_MAJOR 3 )
set( CALAMARES_VERSION_MINOR 2 )
set( CALAMARES_VERSION_PATCH 2 )
set( CALAMARES_VERSION_RC 0 )

### Transifex (languages) info
#
# complete = 100% translated,
# good = nearly complete (use own judgement, right now >= 75%)
# ok = incomplete (more than 25% untranslated),
# bad = 0% translated, placeholder in tx; these are not included.
#
# Language en (source language) is added later. It isn't listed in
# Transifex either. Get the list of languages and their status
# from https://transifex.com/calamares/calamares/ .
#
# When adding a new language, take care that it is properly loaded
# by the translation framework. Languages with alternate scripts
# (sr@latin in particular) may need special handling in CalamaresUtils.cpp.
#
# TODO: drop the es_ES translation from Transifex
# TODO: move eo (Esperanto) to _ok once Qt can actually create a
# locale for it.
#
# NOTE: when updating the list from Transifex, copy these four lines
# and prefix each variable name with "p", so that the automatic
# checks for new languages and misspelled ones are done (that is,
# copy these four lines to four backup lines, add "p", and then update
# the original four lines with the current translations).
set( _tx_complete ca zh_TW hr cs_CZ da et fr id it_IT lt pl pt_PT es_MX tr_TR )
set( _tx_good sq de pt_BR zh_CN ja ro es sk )
set( _tx_ok hu ru he nl bg uk ast is ko ar sv el gl en_GB
th fi_FI hi eu nb sr sl sr@latin mr es_PR kn kk be )
set( _tx_bad fr_CH gu lo fa ur uz eo )


### Required versions
#
# See DEPENDENCIES section below.
set( QT_VERSION 5.7.0 )
set( YAMLCPP_VERSION 0.5.1 )
set( ECM_VERSION 5.18 )
set( PYTHONLIBS_VERSION 3.3 )
set( BOOSTPYTHON_VERSION 1.55.0 )


### CMAKE SETUP
#
set( CMAKE_MODULE_PATH "${CMAKE_SOURCE_DIR}/CMakeModules" )

# CMake 3.9, 3.10 compatibility
if( POLICY CMP0071 )
cmake_policy( SET CMP0071 NEW )
endif()
if(NOT CMAKE_VERSION VERSION_LESS "3.10.0")
list(APPEND CMAKE_AUTOMOC_MACRO_NAMES
"K_PLUGIN_FACTORY_WITH_JSON"
"K_EXPORT_PLASMA_DATAENGINE_WITH_JSON"
"K_EXPORT_PLASMA_RUNNER"
)
endif()


### C++ SETUP
#
set( CMAKE_CXX_STANDARD 14 )
set( CMAKE_CXX_STANDARD_REQUIRED ON )
set( CMAKE_C_STANDARD 99 )
set( CMAKE_C_STANDARD_REQUIRED ON )

set( CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Wall" )
if( CMAKE_CXX_COMPILER_ID MATCHES "Clang" )
message( STATUS "Found Clang ${CMAKE_CXX_COMPILER_VERSION}, setting up Clang-specific compiler flags." )
set( CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Wall" )
set( CMAKE_C_FLAGS_DEBUG "-g" )
set( CMAKE_C_FLAGS_MINSIZEREL "-Os -DNDEBUG" )
set( CMAKE_C_FLAGS_RELEASE "-O4 -DNDEBUG" )
set( CMAKE_C_FLAGS_RELWITHDEBINFO "-O2 -g" )

# Clang warnings: doing *everything* is counter-productive, since it warns
# about things which we can't fix (e.g. C++98 incompatibilities, but
# Calamares is C++14).
foreach( CLANG_WARNINGS
-Weverything
-Wno-c++98-compat
-Wno-c++98-compat-pedantic
-Wno-padded
-Wno-undefined-reinterpret-cast
-Wno-global-constructors
-Wno-exit-time-destructors
-Wno-missing-prototypes
-Wno-documentation-unknown-command
)
string( APPEND CMAKE_CXX_FLAGS " ${CLANG_WARNINGS}" )
endforeach()

# Third-party code where we don't care so much about compiler warnings
# (because it's uncomfortable to patch) get different flags; use
# mark_thirdparty_code( <file> [<file>...] )
# to switch off warnings for those sources.
set( SUPPRESS_3RDPARTY_WARNINGS "-Wno-everything" )
set( SUPPRESS_BOOST_WARNINGS " -Wno-zero-as-null-pointer-constant -Wno-disabled-macro-expansion" )

set( CMAKE_CXX_FLAGS_DEBUG "-g" )
set( CMAKE_CXX_FLAGS_MINSIZEREL "-Os -DNDEBUG" )
set( CMAKE_CXX_FLAGS_RELEASE "-O4 -DNDEBUG" )
set( CMAKE_CXX_FLAGS_RELWITHDEBINFO "-O2 -g" )

set( CMAKE_TOOLCHAIN_PREFIX "llvm-" )

set( CMAKE_SHARED_LINKER_FLAGS "-Wl,--no-undefined" )
else()
set( CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wl,--no-undefined" )
set( CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wl,--fatal-warnings -Wnon-virtual-dtor -Woverloaded-virtual -Werror=return-type" )

set( SUPPRESS_3RDPARTY_WARNINGS "" )
set( SUPPRESS_BOOST_WARNINGS "" )
endif()

# Use mark_thirdparty_code() to reduce warnings from the compiler
# on code that we're not going to fix. Call this with a list of files.
macro(mark_thirdparty_code)
set_source_files_properties( ${ARGV}
PROPERTIES
COMPILE_FLAGS "${SUPPRESS_3RDPARTY_WARNINGS}"
COMPILE_DEFINITIONS "THIRDPARTY"
)
endmacro()

if( CMAKE_COMPILER_IS_GNUCXX )
if( CMAKE_CXX_COMPILER_VERSION VERSION_GREATER 4.9 OR
CMAKE_CXX_COMPILER_VERSION VERSION_EQUAL 4.9 )
message( STATUS "Found GNU g++ ${CMAKE_CXX_COMPILER_VERSION}, enabling colorized error messages." )
set( CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fdiagnostics-color=auto" )
endif()
endif()

include( FeatureSummary )
include( CMakeColors )


### DEPENDENCIES
#
find_package( Qt5 ${QT_VERSION} CONFIG REQUIRED Core Gui Widgets LinguistTools Svg Quick QuickWidgets )
find_package( YAMLCPP ${YAMLCPP_VERSION} REQUIRED )
if( INSTALL_POLKIT )
find_package( PolkitQt5-1 REQUIRED )
else()
# Find it anyway, for dependencies-reporting
find_package( PolkitQt5-1 )
endif()
set_package_properties(
PolkitQt5-1 PROPERTIES
DESCRIPTION "Qt5 support for Polkit"
URL "https://cgit.kde.org/polkit-qt-1.git"
PURPOSE "PolkitQt5-1 helps with installing Polkit configuration"
)

# Find ECM once, and add it to the module search path; Calamares
# modules that need ECM can do
# find_package(ECM ${ECM_VERSION} REQUIRED NO_MODULE),
# no need to mess with the module path after.
find_package(ECM ${ECM_VERSION} NO_MODULE)
if( ECM_FOUND )
set(CMAKE_MODULE_PATH ${ECM_MODULE_PATH} ${CMAKE_MODULE_PATH})
endif()

find_package( KF5 COMPONENTS CoreAddons Crash )
if( NOT KF5Crash_FOUND )
set( WITH_KF5Crash OFF )
endif()

if( BUILD_TESTING )
enable_testing()
endif ()

find_package( PythonLibs ${PYTHONLIBS_VERSION} )
set_package_properties(
PythonLibs PROPERTIES
DESCRIPTION "C interface libraries for the Python 3 interpreter."
URL "http://python.org"
PURPOSE "Python 3 is used for Python job modules."
)

if ( PYTHONLIBS_FOUND )
include( BoostPython3 )
find_boost_python3( ${BOOSTPYTHON_VERSION} ${PYTHONLIBS_VERSION_STRING} CALAMARES_BOOST_PYTHON3_FOUND )
set_package_properties(
Boost PROPERTIES
PURPOSE "Boost.Python is used for Python job modules."
)

find_package( PythonQt )
set_package_properties( PythonQt PROPERTIES
DESCRIPTION "A Python embedding solution for Qt applications."
URL "http://pythonqt.sourceforge.net"
PURPOSE "PythonQt is used for Python view modules."
)
endif()

if( NOT PYTHONLIBS_FOUND OR NOT CALAMARES_BOOST_PYTHON3_FOUND )
message(STATUS "Disabling Boost::Python modules")
set( WITH_PYTHON OFF )
endif()
if( NOT PYTHONLIBS_FOUND OR NOT PYTHONQT_FOUND )
message(STATUS "Disabling PythonQt modules")
set( WITH_PYTHONQT OFF )
endif()

### Transifex Translation status
#
# Construct language lists for use. If there are p_tx* variables,
# then run an extra cmake-time check for consistency of the old
# (p_tx*) and new (_tx*) lists.
#
set( prev_tx ${p_tx_complete} ${p_tx_good} ${p_tx_ok} ${p_tx_bad} )
set( curr_tx ${_tx_complete} ${_tx_good} ${_tx_ok} ${_tx_bad} )
if ( prev_tx )
# Gone in new list
foreach( l ${prev_tx} )
list( FIND curr_tx ${l} p_l )
if( p_l EQUAL -1 )
message(WARNING "Language ${l} was present in previous translations and is now absent.")
endif()
endforeach()

# New in list
foreach( l ${curr_tx} )
list( FIND prev_tx ${l} p_l )
if( p_l EQUAL -1 )
message(WARNING "Language ${l} is new.")
endif()
set( p_l "lang/calamares_${l}.ts" )
if( NOT EXISTS ${CMAKE_CURRENT_SOURCE_DIR}/${p_l} )
message(WARNING "Language ${l} has no .ts file yet.")
endif()
endforeach()

unset( p_l )
unset( l )
endif()
unset( prev_tx )
unset( curr_tx )

set( CALAMARES_TRANSLATION_LANGUAGES en ${_tx_complete} ${_tx_good} ${_tx_ok} )
list( SORT CALAMARES_TRANSLATION_LANGUAGES )

add_subdirectory( lang ) # i18n tools


### Example Distro
#
# For testing purposes Calamares includes a very, very, limited sample
# distro called "Generic". The root filesystem of "Generic" lives in
# data/example-root and can be squashed up as part of the build, so
# that a pure-upstream run of ./calamares -d from the build directory
# (with all the default settings and configurations) can actually
# do an complete example run.
#
# Some binaries from the build host (e.g. /bin and /lib) are also
# squashed into the example filesystem.
#
# To build the example distro (for use by the default, example,
# unsquashfs module), build the target 'example-distro', eg.:
#
# make example-distro
#
find_program( mksquashfs_PROGRAM mksquashfs )
if( mksquashfs_PROGRAM )
set( mksquashfs_FOUND ON )
set( src_fs ${CMAKE_SOURCE_DIR}/data/example-root/ )
set( dst_fs ${CMAKE_BINARY_DIR}/example.sqfs )
if( EXISTS ${src_fs} )
# based on the build host. If /lib64 exists, assume it is needed.
# Collect directories needed for a minimal binary distro,
# Note that the last path component is added to the root, so
# if you add /usr/sbin here, it will be put into /sbin_1.
# Add such paths to /etc/profile under ${src_fs}.
set( candidate_fs /sbin /bin /lib /lib64 )
set( host_fs "" )
foreach( c_fs ${candidate_fs} )
if( EXISTS ${c_fs} )
list( APPEND host_fs ${c_fs} )
endif()
endforeach()
add_custom_command(
OUTPUT ${dst_fs}
COMMAND ${mksquashfs_PROGRAM} ${src_fs} ${dst_fs} -all-root
COMMAND ${mksquashfs_PROGRAM} ${host_fs} ${dst_fs} -all-root
)
add_custom_target(example-distro DEPENDS ${dst_fs})
endif()
else()
set( mksquashfs_FOUND OFF )
endif()
# Doesn't list mksquashfs as an optional dep, though, because it
# hasn't been sent through the find_package() scheme.
#
# "http://tldp.org/HOWTO/SquashFS-HOWTO/creatingandusing.html"
add_feature_info( ExampleDistro ${mksquashfs_FOUND} "Create example-distro target.")


### CALAMARES PROPER
#
set( CALAMARES_VERSION ${CALAMARES_VERSION_MAJOR}.${CALAMARES_VERSION_MINOR}.${CALAMARES_VERSION_PATCH} )
set( CALAMARES_VERSION_SHORT "${CALAMARES_VERSION}" )
if( CALAMARES_VERSION_RC )
set( CALAMARES_VERSION ${CALAMARES_VERSION}rc${CALAMARES_VERSION_RC} )
endif()

# additional info for non-release builds
if( NOT BUILD_RELEASE AND EXISTS "${CMAKE_CURRENT_SOURCE_DIR}/.git/" )
include( CMakeDateStamp )
set( CALAMARES_VERSION_DATE "${CMAKE_DATESTAMP_YEAR}${CMAKE_DATESTAMP_MONTH}${CMAKE_DATESTAMP_DAY}" )
if( CALAMARES_VERSION_DATE GREATER 0 )
set( CALAMARES_VERSION ${CALAMARES_VERSION}.${CALAMARES_VERSION_DATE} )
endif()

include( CMakeVersionSource )
if( CMAKE_VERSION_SOURCE )
set( CALAMARES_VERSION ${CALAMARES_VERSION}-${CMAKE_VERSION_SOURCE} )
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" )

# set paths
set( CMAKE_RUNTIME_OUTPUT_DIRECTORY "${CMAKE_BINARY_DIR}" )
set( CMAKE_LIBRARY_OUTPUT_DIRECTORY "${CMAKE_BINARY_DIR}" )
set( CMAKE_ARCHIVE_OUTPUT_DIRECTORY "${CMAKE_BINARY_DIR}" )

# Better default installation paths: GNUInstallDirs defines
# CMAKE_INSTALL_FULL_SYSCONFDIR to be CMAKE_INSTALL_PREFIX/etc by default
# but we really want /etc
if( NOT DEFINED CMAKE_INSTALL_SYSCONFDIR )
set( CMAKE_INSTALL_SYSCONFDIR "/etc" )
endif()

# make predefined install dirs available everywhere
include( GNUInstallDirs )

# make uninstall support
configure_file(
"${CMAKE_CURRENT_SOURCE_DIR}/cmake_uninstall.cmake.in"
"${CMAKE_CURRENT_BINARY_DIR}/cmake_uninstall.cmake"
IMMEDIATE @ONLY
)

# Early configure these files as we need them later on
set( CALAMARES_CMAKE_DIR "${CMAKE_SOURCE_DIR}/CMakeModules" )
set( CALAMARES_LIBRARIES calamares )

add_subdirectory( src )

add_feature_info(Python ${WITH_PYTHON} "Python job modules")
add_feature_info(PythonQt ${WITH_PYTHONQT} "Python view modules")
add_feature_info(Config ${INSTALL_CONFIG} "Install Calamares configuration")
add_feature_info(KCrash ${WITH_KF5Crash} "Crash dumps via KCrash")

# Add all targets to the build-tree export set
set( CMAKE_INSTALL_CMAKEDIR "${CMAKE_INSTALL_LIBDIR}/cmake/Calamares" CACHE PATH "Installation directory for CMake files" )
set( CMAKE_INSTALL_FULL_CMAKEDIR "${CMAKE_INSTALL_PREFIX}/${CMAKE_INSTALL_CMAKEDIR}" )
export( TARGETS calamares
FILE "${PROJECT_BINARY_DIR}/CalamaresLibraryDepends.cmake" )

# Export the package for use from the build-tree
# (this registers the build-tree with a global CMake-registry)
export( PACKAGE Calamares )

# Create a CalamaresBuildTreeSettings.cmake file for the use from the build tree
configure_file( CalamaresBuildTreeSettings.cmake.in "${PROJECT_BINARY_DIR}/CalamaresBuildTreeSettings.cmake" @ONLY )

# Create the CalamaresConfig.cmake and CalamaresConfigVersion files
file( RELATIVE_PATH CONF_REL_INCLUDE_DIR "${CMAKE_INSTALL_FULL_CMAKEDIR}" "${CMAKE_INSTALL_FULL_INCLUDEDIR}" )

configure_file( CalamaresConfig.cmake.in "${PROJECT_BINARY_DIR}/CalamaresConfig.cmake" @ONLY )
configure_file( CalamaresConfigVersion.cmake.in "${PROJECT_BINARY_DIR}/CalamaresConfigVersion.cmake" @ONLY )
configure_file( CalamaresUse.cmake.in "${PROJECT_BINARY_DIR}/CalamaresUse.cmake" @ONLY )

# Install the cmake files
install(
FILES
"${PROJECT_BINARY_DIR}/CalamaresConfig.cmake"
"${PROJECT_BINARY_DIR}/CalamaresConfigVersion.cmake"
"${PROJECT_BINARY_DIR}/CalamaresUse.cmake"
"CMakeModules/CalamaresAddPlugin.cmake"
"CMakeModules/CalamaresAddModuleSubdirectory.cmake"
"CMakeModules/CalamaresAddLibrary.cmake"
"CMakeModules/CalamaresAddBrandingSubdirectory.cmake"
"CMakeModules/CalamaresAddTranslations.cmake"
"CMakeModules/CMakeColors.cmake"
DESTINATION
"${CMAKE_INSTALL_CMAKEDIR}"
)

# Install the export set for use with the install-tree
install(
EXPORT
CalamaresLibraryDepends
DESTINATION
"${CMAKE_INSTALL_CMAKEDIR}"
)

if( INSTALL_CONFIG )
install(
FILES
settings.conf
DESTINATION
share/calamares
)
endif()

if( INSTALL_POLKIT )
install(
FILES
com.github.calamares.calamares.policy
DESTINATION
"${POLKITQT-1_POLICY_FILES_INSTALL_DIR}"
)
endif()

install(
FILES
calamares.desktop
DESTINATION
${CMAKE_INSTALL_DATADIR}/applications
)

install(
FILES
man/calamares.8
DESTINATION
${CMAKE_INSTALL_MANDIR}/man8/
)

# uninstall target
configure_file(
"${CMAKE_CURRENT_SOURCE_DIR}/cmake_uninstall.cmake.in"
"${CMAKE_CURRENT_BINARY_DIR}/cmake_uninstall.cmake"
IMMEDIATE @ONLY
)

add_custom_target( uninstall
COMMAND ${CMAKE_COMMAND} -P ${CMAKE_CURRENT_BINARY_DIR}/cmake_uninstall.cmake
)

### CMAKE SUMMARY REPORT
#
feature_summary(WHAT ALL)

get_directory_property( SKIPPED_MODULES
DIRECTORY src/modules
DEFINITION LIST_SKIPPED_MODULES
)
calamares_explain_skipped_modules( ${SKIPPED_MODULES} )

+ 69
- 0
CMakeModules/BoostPython3.cmake View File

@@ -0,0 +1,69 @@
# On Ubuntu 14.04, the libboost-python1.54-dev package comes with one library
# for each Python version:
# libboost_python-py27.so
# libboost_python-py33.so
# libboost_python-py34.so
#
# Boost upstream however installs Boost.Python3 libboost_python3.so, which is
# what FindBoost.cmake is looking for. It looks for a library named
# "libboost_${component}.so".
#
# On Gentoo instead, the >=dev-libs/boost-1.54 package provides boost library
# with a name like:
# libboost_python-2.7.so
# libboost_python-3.3.so
# libboost_python-3.4.so
# depending on what python's targets you selected during install
#
# find_boost_python3() tries to find the package with different component
# names. By default it tries "python3", "python-py$suffix" and
# "python-$dotsuffix", where suffix is based on the `python_version` argument.
# One can supply a custom component name by setting the
# `CALAMARES_BOOST_PYTHON3_COMPONENT` variable at CMake time.
set( CALAMARES_BOOST_PYTHON3_COMPONENT python3 CACHE STRING
"Name of the Boost.Python component. If Boost.Python is installed as
libboost_python-foo.so then this variable should be set to 'python-foo'."
)

include(FindPackageHandleStandardArgs)

macro( _find_boost_python3_int boost_version componentname found_var )
foreach( _fbp_name ${CALAMARES_BOOST_PYTHON3_COMPONENT} ${componentname} )
find_package( Boost ${boost_version} QUIET COMPONENTS ${_fbp_name} )
string( TOUPPER ${_fbp_name} _fbp_uc_name )
if( Boost_${_fbp_uc_name}_FOUND )
set( ${found_var} ${_fbp_uc_name} )
break()
endif()
endforeach()
endmacro()

macro( find_boost_python3 boost_version python_version found_var )
set( ${found_var} OFF )
set( _fbp_found OFF )

# turns "3.4.123abc" into "34"
string( REGEX REPLACE "([0-9]+)\\.([0-9]+)\\..*" "\\1\\2" _fbp_python_short_version ${python_version} )
_find_boost_python3_int( ${boost_version} python-py${_fbp_python_short_version} _fbp_found )

if (NOT _fbp_found)
# The following loop changes the searched name for Gentoo based distributions
# turns "3.4.123abc" into "3.4"
string( REGEX REPLACE "([0-9]+)\\.([0-9]+)\\..*" "\\1.\\2" _fbp_python_short_version ${python_version} )
_find_boost_python3_int( ${boost_version} python-${_fbp_python_short_version} _fbp_found )
endif()

set( ${found_var} ${_fbp_found} )

# This is superfluous, but allows proper reporting in the features list
if ( _fbp_found )
find_package( Boost ${boost_version} COMPONENTS ${_fbp_found} )
else()
find_package( Boost ${boost_version} COMPONENTS Python )
endif()
set_package_properties(
Boost PROPERTIES
DESCRIPTION "A C++ library which enables seamless interoperability between C++ and Python 3."
URL "http://www.boost.org"
)
endmacro()

+ 32
- 0
CMakeModules/CMakeColors.cmake View File

@@ -0,0 +1,32 @@
if(NOT WIN32)
set(_use_color ON)
if("0" STREQUAL "$ENV{CLICOLOR}")
set(_use_color OFF)
endif()
if("0" STREQUAL "$ENV{CLICOLOR_FORCE}")
set(_use_color OFF)
endif()
if(NOT CMAKE_COLOR_MAKEFILE)
set(_use_color OFF)
endif()

if(_use_color)
string(ASCII 27 Esc)
set(ColorReset "${Esc}[m")
set(ColorBold "${Esc}[1m")
set(Red "${Esc}[31m")
set(Green "${Esc}[32m")
set(Yellow "${Esc}[33m")
set(Blue "${Esc}[34m")
set(Magenta "${Esc}[35m")
set(Cyan "${Esc}[36m")
set(White "${Esc}[37m")
set(BoldRed "${Esc}[1;31m")
set(BoldGreen "${Esc}[1;32m")
set(BoldYellow "${Esc}[1;33m")
set(BoldBlue "${Esc}[1;34m")
set(BoldMagenta "${Esc}[1;35m")
set(BoldCyan "${Esc}[1;36m")
set(BoldWhite "${Esc}[1;37m")
endif()
endif()

+ 23
- 0
CMakeModules/CMakeDateStamp.cmake View File

@@ -0,0 +1,23 @@
find_program(DATE_EXECUTABLE NAMES date)
mark_as_advanced(DATE_EXECUTABLE)

if(DATE_EXECUTABLE)
execute_process(
COMMAND ${DATE_EXECUTABLE} +%Y
OUTPUT_VARIABLE CMAKE_DATESTAMP_YEAR
OUTPUT_STRIP_TRAILING_WHITESPACE
WORKING_DIRECTORY ${CMAKE_SOURCE_DIR}
)
execute_process(
COMMAND ${DATE_EXECUTABLE} +%m
OUTPUT_VARIABLE CMAKE_DATESTAMP_MONTH
OUTPUT_STRIP_TRAILING_WHITESPACE
WORKING_DIRECTORY ${CMAKE_SOURCE_DIR}
)
execute_process(
COMMAND ${DATE_EXECUTABLE} +%d
OUTPUT_VARIABLE CMAKE_DATESTAMP_DAY
OUTPUT_STRIP_TRAILING_WHITESPACE
WORKING_DIRECTORY ${CMAKE_SOURCE_DIR}
)
endif()

+ 45
- 0
CMakeModules/CMakeVersionSource.cmake View File

@@ -0,0 +1,45 @@
# Try to identify the current development source version.
set(CMAKE_VERSION_SOURCE "")
if(EXISTS ${CMAKE_SOURCE_DIR}/.git/HEAD)
find_program(GIT_EXECUTABLE NAMES git git.cmd)
mark_as_advanced(GIT_EXECUTABLE)
if(GIT_EXECUTABLE)
execute_process(
COMMAND ${GIT_EXECUTABLE} rev-parse --verify -q --short=7 HEAD
OUTPUT_VARIABLE head
OUTPUT_STRIP_TRAILING_WHITESPACE
WORKING_DIRECTORY ${CMAKE_SOURCE_DIR}
)
if(head)
set(branch "")
execute_process(
COMMAND ${GIT_EXECUTABLE} name-rev HEAD
OUTPUT_VARIABLE branch
OUTPUT_STRIP_TRAILING_WHITESPACE
WORKING_DIRECTORY ${CMAKE_SOURCE_DIR}
)
string(REGEX REPLACE "HEAD " "" branch "${branch}")
set(CMAKE_VERSION_SOURCE "git-${branch}-${head}")
execute_process(
COMMAND ${GIT_EXECUTABLE} update-index -q --refresh
WORKING_DIRECTORY ${CMAKE_SOURCE_DIR}
)
execute_process(
COMMAND ${GIT_EXECUTABLE} diff-index --name-only HEAD --
OUTPUT_VARIABLE dirty
OUTPUT_STRIP_TRAILING_WHITESPACE
WORKING_DIRECTORY ${CMAKE_SOURCE_DIR}
)
if(dirty)
set(CMAKE_VERSION_SOURCE "${CMAKE_VERSION_SOURCE}-dirty")
endif()
endif()
endif()
elseif(EXISTS ${CMAKE_SOURCE_DIR}/CVS/Repository)
file(READ ${CMAKE_SOURCE_DIR}/CVS/Repository repo)
set(branch "")
if("${repo}" MATCHES "\\.git/")
string(REGEX REPLACE ".*\\.git/([^\r\n]*).*" "-\\1" branch "${repo}")
endif()
set(CMAKE_VERSION_SOURCE "cvs${branch}")
endif()

+ 151
- 0
CMakeModules/CalamaresAddBrandingSubdirectory.cmake View File

@@ -0,0 +1,151 @@
# === 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-License-Identifier: GPL-3.0+
# License-Filename: LICENSE
#
###
#
# Support macros for creating Calamares branding components.
#
# Calamares branding components have two parts:
# - a branding.desc file that tells Calamares how to describe the product
# (e.g. strings like "Generic GNU/Linux") and the name of a QML file
# (the "slideshow") that is displayed during installation.
# - the QML files themselves, plus supporting images etc.
#
# Branding components can be created inside the Calamares source tree
# (there is one example the `default/` branding, which is also connected
# to the default configuration shipped with Calamares), but they can be
# built outside of, and largely independently of, Calamares by using
# these CMake macros.
#
# See the calamares-examples repository for more examples.
#
include( CMakeParseArguments)

include( CMakeColors )

# Usage calamares_add_branding( <name> [DIRECTORY <dir>] [SUBDIRECTORIES <dir> ...])
#
# Adds a branding component to the build:
# - the component's top-level files are copied into the build-dir;
# CMakeLists.txt is excluded from the glob.
# - the component's top-level files are installed into the component branding dir
#
# The branding component lives in <dir> if given, otherwise the
# current source directory. The branding component is installed
# with the given <name>, which is usually the name of the
# directory containing the component, and which must match the
# *componentName* in `branding.desc`.
#
# If SUBDIRECTORIES are given, then those are copied (each one level deep)
# to the installation location as well, preserving the subdirectory name.
function( calamares_add_branding NAME )
cmake_parse_arguments( _CABT "" "DIRECTORY" "SUBDIRECTORIES" ${ARGN} )
if (NOT _CABT_DIRECTORY)
set(_CABT_DIRECTORY ".")
endif()

set( SUBDIRECTORY ${_CABT_DIRECTORY} )
set( _brand_dir ${_CABT_DIRECTORY} )

set( BRANDING_DIR share/calamares/branding )
set( BRANDING_COMPONENT_DESTINATION ${BRANDING_DIR}/${NAME} )

foreach( _subdir "" ${_CABT_SUBDIRECTORIES} )
file( GLOB BRANDING_COMPONENT_FILES RELATIVE ${CMAKE_CURRENT_SOURCE_DIR}/${_brand_dir} "${_brand_dir}/${_subdir}/*" )
foreach( BRANDING_COMPONENT_FILE ${BRANDING_COMPONENT_FILES} )
set( _subpath ${_brand_dir}/${BRANDING_COMPONENT_FILE} )
if( NOT IS_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/${_subpath} )
configure_file( ${_subpath} ${_subpath} COPYONLY )

install( FILES ${CMAKE_CURRENT_BINARY_DIR}/${_subpath}
DESTINATION ${BRANDING_COMPONENT_DESTINATION}/${_subdir}/ )
endif()
endforeach()
endforeach()

message( "-- ${BoldYellow}Found ${CALAMARES_APPLICATION_NAME} branding component: ${BoldRed}${NAME}${ColorReset}" )
if( NOT CMAKE_BUILD_TYPE STREQUAL "Release" )
message( " ${Green}TYPE:${ColorReset} branding component" )
message( " ${Green}BRANDING_COMPONENT_DESTINATION:${ColorReset} ${BRANDING_COMPONENT_DESTINATION}" )
endif()
endfunction()

# Usage calamares_add_branding_translations( <name> [DIRECTORY <dir>])
#
# Adds the translations for a branding component to the build:
# - the component's lang/ directory is scanned for .ts files
# - the component's translations are installed into the component branding dir
#
# Translation files must be called calamares-<name>_<lang>.ts . Optionally
# the lang/ dir is found in the given <dir> instead of the current source
# directory.
function( calamares_add_branding_translations NAME )
cmake_parse_arguments( _CABT "" "DIRECTORY" "" ${ARGN} )
if (NOT _CABT_DIRECTORY)
set(_CABT_DIRECTORY ".")
endif()

set( SUBDIRECTORY ${_CABT_DIRECTORY} )
set( _brand_dir ${_CABT_DIRECTORY} )

set( BRANDING_DIR share/calamares/branding )
set( BRANDING_COMPONENT_DESTINATION ${BRANDING_DIR}/${NAME} )

file( GLOB BRANDING_TRANSLATION_FILES RELATIVE ${CMAKE_CURRENT_SOURCE_DIR} "${SUBDIRECTORY}/lang/calamares-${NAME}_*.ts" )
if ( BRANDING_TRANSLATION_FILES )
qt5_add_translation( QM_FILES ${BRANDING_TRANSLATION_FILES} )
add_custom_target( branding-translation-${NAME} ALL DEPENDS ${QM_FILES} )
install( FILES ${QM_FILES} DESTINATION ${BRANDING_COMPONENT_DESTINATION}/lang/ )
list( LENGTH BRANDING_TRANSLATION_FILES _branding_count )
message( " ${Green}BRANDING_TRANSLATIONS:${ColorReset} ${_branding_count} language(s)" )
endif()
endfunction()

# Usage calamares_add_branding_subdirectory( <dir> [NAME <name>] [SUBDIRECTORIES <dir> ...])
#
# Adds a branding component from a subdirectory:
# - if there is a CMakeLists.txt, use that (that CMakeLists.txt should
# call suitable calamares_add_branding() and other macros to install
# the branding component).
# - otherwise assume a "standard" setup with top-level files and a lang/
# subdirectory for translations.
#
# If NAME is given, this is used instead of <dir> as the name of
# the branding component. This is needed if <dir> is more than
# one level deep, or to rename a component as it gets installed.
#
# If SUBDIRECTORIES are given, they are relative to <dir>, and are
# copied (one level deep) to the install location as well.
function( calamares_add_branding_subdirectory SUBDIRECTORY )
cmake_parse_arguments( _CABS "" "NAME" "SUBDIRECTORIES" ${ARGN} )
if (NOT _CABS_NAME)
set(_CABS_NAME "${SUBDIRECTORY}")
endif()

if( EXISTS "${CMAKE_CURRENT_SOURCE_DIR}/${SUBDIRECTORY}/CMakeLists.txt" )
add_subdirectory( ${SUBDIRECTORY} )
elseif( EXISTS "${CMAKE_CURRENT_SOURCE_DIR}/${SUBDIRECTORY}/branding.desc" )
calamares_add_branding( ${_CABS_NAME} DIRECTORY ${SUBDIRECTORY} SUBDIRECTORIES ${_CABS_SUBDIRECTORIES} )
if( IS_DIRECTORY "${CMAKE_CURRENT_SOURCE_DIR}/${SUBDIRECTORY}/lang" )
calamares_add_branding_translations( ${_CABS_NAME} DIRECTORY ${SUBDIRECTORY} )
endif()
else()
message( "-- ${BoldYellow}Warning:${ColorReset} tried to add branding component subdirectory ${BoldRed}${SUBDIRECTORY}${ColorReset} which has no branding.desc." )
endif()
message( "" )
endfunction()

+ 143
- 0
CMakeModules/CalamaresAddLibrary.cmake View File

@@ -0,0 +1,143 @@
# === 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-License-Identifier: GPL-3.0+
# License-Filename: LICENSE
#
###
#
# Support functions for building plugins.

include( CMakeParseArguments )

function(calamares_add_library)
# parse arguments (name needs to be saved before passing ARGN into the macro)
set(NAME ${ARGV0})
set(options NO_INSTALL NO_VERSION)
set(oneValueArgs NAME TYPE EXPORT_MACRO TARGET TARGET_TYPE EXPORT VERSION SOVERSION INSTALL_BINDIR RESOURCES)
set(multiValueArgs SOURCES UI LINK_LIBRARIES LINK_PRIVATE_LIBRARIES COMPILE_DEFINITIONS QT5_MODULES)
cmake_parse_arguments(LIBRARY "${options}" "${oneValueArgs}" "${multiValueArgs}" ${ARGN})
set(LIBRARY_NAME ${NAME})


# message("*** Arguments for ${LIBRARY_NAME}")
# message("Sources: ${LIBRARY_SOURCES}")
# message("Link libraries: ${LIBRARY_LINK_LIBRARIES}")
# message("UI: ${LIBRARY_UI}")
# message("TARGET_TYPE: ${LIBRARY_TARGET_TYPE}")
# message("EXPORT_MACRO: ${LIBRARY_EXPORT_MACRO}")
# message("NO_INSTALL: ${LIBRARY_NO_INSTALL}")

set(target ${LIBRARY_NAME})

# qt stuff
include_directories(${CMAKE_CURRENT_LIST_DIR})
include_directories(${CMAKE_CURRENT_BINARY_DIR})

if(LIBRARY_UI)
qt5_wrap_ui(LIBRARY_UI_SOURCES ${LIBRARY_UI})
list(APPEND LIBRARY_SOURCES ${LIBRARY_UI_SOURCES})
endif()

# add resources from current dir
if(EXISTS "${CMAKE_CURRENT_LIST_DIR}/${LIBRARY_RESOURCES}")
qt5_add_resources(LIBRARY_RC_SOURCES "${LIBRARY_RESOURCES}")
list(APPEND LIBRARY_SOURCES ${LIBRARY_RC_SOURCES})
unset(LIBRARY_RC_SOURCES)
endif()

# add target
if(LIBRARY_TARGET_TYPE STREQUAL "STATIC")
add_library(${target} STATIC ${LIBRARY_SOURCES})
elseif(LIBRARY_TARGET_TYPE STREQUAL "MODULE")
add_library(${target} MODULE ${LIBRARY_SOURCES})
else() # default
add_library(${target} SHARED ${LIBRARY_SOURCES})
endif()

# definitions - can this be moved into set_target_properties below?
add_definitions(${QT_DEFINITIONS})
set_target_properties(${target} PROPERTIES AUTOMOC TRUE)

if(LIBRARY_EXPORT_MACRO)
set_target_properties(${target} PROPERTIES COMPILE_DEFINITIONS ${LIBRARY_EXPORT_MACRO})
endif()

if(LIBRARY_COMPILE_DEFINITIONS)
# Dear CMake, i hate you! Sincerely, domme
# At least in CMake 2.8.8, you CANNOT set more than one COMPILE_DEFINITIONS value
# only takes the first one if called multiple times or bails out with wrong number of arguments
# when passing in a list, thus i redefine the export macro here in hope it won't mess up other targets
add_definitions( "-D${LIBRARY_EXPORT_MACRO}" )

set_target_properties(${target} PROPERTIES COMPILE_DEFINITIONS ${LIBRARY_COMPILE_DEFINITIONS})
endif()

# add link targets
target_link_libraries(${target}
LINK_PUBLIC ${CALAMARES_LIBRARIES}
Qt5::Core
Qt5::Gui
Qt5::Widgets
${LIBRARY_QT5_MODULES}
)
if(LIBRARY_LINK_LIBRARIES)
target_link_libraries(${target} LINK_PUBLIC ${LIBRARY_LINK_LIBRARIES})
endif()
if(LIBRARY_LINK_PRIVATE_LIBRARIES)
target_link_libraries(${target} LINK_PRIVATE ${LIBRARY_LINK_PRIVATE_LIBRARIES})
endif()

# add soversion
if(NOT LIBRARY_NO_VERSION)
set_target_properties(${target} PROPERTIES VERSION ${LIBRARY_VERSION})

if(NOT LIBRARY_SOVERSION)
set(LIBRARY_SOVERSION ${LIBRARY_VERSION})
endif()

set_target_properties(${target} PROPERTIES SOVERSION ${LIBRARY_SOVERSION})
endif()


if(NOT LIBRARY_INSTALL_BINDIR)
set(LIBRARY_INSTALL_BINDIR "${CMAKE_INSTALL_BINDIR}")
set(LIBRARY_INSTALL_LIBDIR "${CMAKE_INSTALL_LIBDIR}")
else()
set(LIBRARY_INSTALL_LIBDIR "${LIBRARY_INSTALL_BINDIR}")
endif()

#message("INSTALL_BINDIR: ${LIBRARY_INSTALL_BINDIR}")
#message("INSTALL_LIBDIR: ${LIBRARY_INSTALL_LIBDIR}")

# make installation optional, maybe useful for dummy plugins one day
if(NOT LIBRARY_NO_INSTALL)
include(GNUInstallDirs)
if(NOT LIBRARY_EXPORT)
install( TARGETS ${target}
RUNTIME DESTINATION ${LIBRARY_INSTALL_BINDIR}
LIBRARY DESTINATION ${LIBRARY_INSTALL_LIBDIR}
ARCHIVE DESTINATION ${LIBRARY_INSTALL_LIBDIR}
)
else()
install( TARGETS ${target}
EXPORT ${LIBRARY_EXPORT}
RUNTIME DESTINATION ${LIBRARY_INSTALL_BINDIR}
LIBRARY DESTINATION ${LIBRARY_INSTALL_LIBDIR}
ARCHIVE DESTINATION ${LIBRARY_INSTALL_LIBDIR}
)
endif()
endif()
endfunction()

+ 147
- 0
CMakeModules/CalamaresAddModuleSubdirectory.cmake View File

@@ -0,0 +1,147 @@
# === 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-License-Identifier: GPL-3.0+
# License-Filename: LICENSE
#
###
#
# Function and support code for adding a Calamares module (either a Qt / C++ plugin,
# or a Python module, or whatever) to the build.
#
include( CalamaresAddTranslations )

set( MODULE_DATA_DESTINATION share/calamares/modules )

# Convenience function to indicate that a module has been skipped
# (optionally also why). Call this in the module's CMakeLists.txt
macro( calamares_skip_module )
set( SKIPPED_MODULES ${SKIPPED_MODULES} ${ARGV} PARENT_SCOPE )
endmacro()

function( calamares_explain_skipped_modules )
if ( ARGN )
message( "${ColorReset}-- Skipped modules:" )
foreach( SUBDIRECTORY ${ARGN} )
message( "${ColorReset}-- Skipped ${BoldRed}${SUBDIRECTORY}${ColorReset}." )
endforeach()
message( "" )
endif()
endfunction()

function( calamares_add_module_subdirectory )
set( SUBDIRECTORY ${ARGV0} )

set( SKIPPED_MODULES )
set( MODULE_CONFIG_FILES "" )

set( _mod_dir "${CMAKE_CURRENT_SOURCE_DIR}/${SUBDIRECTORY}" )
# If this subdirectory has a CMakeLists.txt, we add_subdirectory it...
if( EXISTS "${_mod_dir}/CMakeLists.txt" )
add_subdirectory( ${SUBDIRECTORY} )
file( GLOB MODULE_CONFIG_FILES RELATIVE ${_mod_dir} "${SUBDIRECTORY}/*.conf" )
# Module has indicated it should be skipped, show that in
# the calling CMakeLists (which is src/modules/CMakeLists.txt normally).
if ( SKIPPED_MODULES )
set( SKIPPED_MODULES ${SKIPPED_MODULES} PARENT_SCOPE )
set( MODULE_CONFIG_FILES "" )
endif()
# ...otherwise, we look for a module.desc.
elseif( EXISTS "${_mod_dir}/module.desc" )
set( MODULES_DIR ${CMAKE_INSTALL_LIBDIR}/calamares/modules )
set( MODULE_DESTINATION ${MODULES_DIR}/${SUBDIRECTORY} )

# Read module.desc, check that the interface type is supported.
file(STRINGS "${_mod_dir}/module.desc" MODULE_INTERFACE REGEX "^interface")
if ( MODULE_INTERFACE MATCHES "pythonqt" )
set( _mod_enabled ${WITH_PYTHONQT} )
set( _mod_reason "No PythonQt support" )
elseif ( MODULE_INTERFACE MATCHES "python" )
set( _mod_enabled ${WITH_PYTHON} )
set( _mod_reason "No Python support" )
else()
set( _mod_enabled ON )
set( _mod_reason "" )
endif()

if ( _mod_enabled )
# We glob all the files inside the subdirectory, and we make sure they are
# synced with the bindir structure and installed.
file( GLOB MODULE_FILES RELATIVE ${_mod_dir} "${SUBDIRECTORY}/*" )
foreach( MODULE_FILE ${MODULE_FILES} )
if( NOT IS_DIRECTORY ${_mod_dir}/${MODULE_FILE} )
configure_file( ${SUBDIRECTORY}/${MODULE_FILE} ${SUBDIRECTORY}/${MODULE_FILE} COPYONLY )

get_filename_component( FLEXT ${MODULE_FILE} EXT )
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}
DESTINATION ${MODULE_DESTINATION} )
endif()
endif()
endforeach()

message( "-- ${BoldYellow}Found ${CALAMARES_APPLICATION_NAME} module: ${BoldRed}${SUBDIRECTORY}${ColorReset}" )
if( NOT CMAKE_BUILD_TYPE STREQUAL "Release" )
message( " ${Green}TYPE:${ColorReset} jobmodule" )
message( " ${Green}MODULE_DESTINATION:${ColorReset} ${MODULE_DESTINATION}" )
if( MODULE_CONFIG_FILES )
if ( INSTALL_CONFIG )
set( _destination "${MODULE_DATA_DESTINATION}" )
else()
set( _destination "[Build directory only]" )
endif()
message( " ${Green}CONFIGURATION_FILES:${ColorReset} ${MODULE_CONFIG_FILES} => ${_destination}" )
endif()
message( "" )
endif()
# We copy over the lang directory, if any
if( IS_DIRECTORY "${CMAKE_CURRENT_SOURCE_DIR}/${SUBDIRECTORY}/lang" )
install_calamares_gettext_translations(
${SUBDIRECTORY}
SOURCE_DIR "${CMAKE_CURRENT_SOURCE_DIR}/${SUBDIRECTORY}/lang"
FILENAME ${SUBDIRECTORY}.mo
RENAME calamares-${SUBDIRECTORY}.mo
)
endif()
else()
# Module disabled due to missing dependencies / unsupported interface
set( SKIPPED_MODULES "${SUBDIRECTORY} (${_mod_reason})" PARENT_SCOPE )
endif()
else()
message( "-- ${BoldYellow}Warning:${ColorReset} tried to add module subdirectory ${BoldRed}${SUBDIRECTORY}${ColorReset} which has no CMakeLists.txt or module.desc." )
message( "" )
endif()

# Check any config files for basic correctness
if ( BUILD_TESTING AND MODULE_CONFIG_FILES )
set( _count 0 )
foreach( _config_file ${MODULE_CONFIG_FILES} )
set( _count_str "-${_count}" )
if ( _count EQUAL 0 )
set( _count_str "" )
endif()
add_test(
NAME config-${SUBDIRECTORY}${_count_str}
COMMAND test_conf ${CMAKE_CURRENT_BINARY_DIR}/${SUBDIRECTORY}/${_config_file} )
math( EXPR _count "${_count} + 1" )
endforeach()
endif()
endfunction()

+ 160
- 0
CMakeModules/CalamaresAddPlugin.cmake View File

@@ -0,0 +1,160 @@
# === 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-License-Identifier: GPL-3.0+
# License-Filename: LICENSE
#
###
#
# Convenience function for creating a C++ (qtplugin) module for Calamares.
# This function provides cmake-time feedback about the plugin, adds
# targets for compilation and boilerplate information, and creates
# a module.desc with standard values if none is provided (which only
# happens for very unusual plugins).
#
# Usage:
#
# calamares_add_plugin(
# module-name
# TYPE <view|job>
# EXPORT_MACRO macro-name
# SOURCES source-file...
# UI ui-file...
# LINK_LIBRARIES lib...
# LINK_PRIVATE_LIBRARIES lib...
# COMPILE_DEFINITIONS def...
# RESOURCES resource-file
# [NO_INSTALL]
# [SHARED_LIB]
# [EMERGENCY]
# )

include( CMakeParseArguments )
include( CalamaresAddLibrary )
include( CMakeColors )

function( calamares_add_plugin )
# parse arguments ( name needs to be saved before passing ARGN into the macro )
set( NAME ${ARGV0} )
set( options NO_INSTALL SHARED_LIB EMERGENCY )
set( oneValueArgs NAME TYPE EXPORT_MACRO RESOURCES )
set( multiValueArgs SOURCES UI LINK_LIBRARIES LINK_PRIVATE_LIBRARIES COMPILE_DEFINITIONS )
cmake_parse_arguments( PLUGIN "${options}" "${oneValueArgs}" "${multiValueArgs}" ${ARGN} )
set( PLUGIN_NAME ${NAME} )
set( PLUGIN_DESTINATION ${CMAKE_INSTALL_LIBDIR}/calamares/modules/${PLUGIN_NAME} )
set( PLUGIN_DESC_FILE module.desc )
file( GLOB PLUGIN_CONFIG_FILES RELATIVE ${CMAKE_CURRENT_SOURCE_DIR} "*.conf" )
set( PLUGIN_DATA_DESTINATION share/calamares/modules )
set( CMAKE_RUNTIME_OUTPUT_DIRECTORY "${CMAKE_CURRENT_BINARY_DIR}" )
set( CMAKE_LIBRARY_OUTPUT_DIRECTORY "${CMAKE_CURRENT_BINARY_DIR}" )
set( CMAKE_ARCHIVE_OUTPUT_DIRECTORY "${CMAKE_CURRENT_BINARY_DIR}" )

message( "-- ${BoldYellow}Found ${CALAMARES_APPLICATION_NAME} module: ${BoldRed}${PLUGIN_NAME}${ColorReset}" )
if( NOT CMAKE_BUILD_TYPE STREQUAL "Release" )
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}PLUGIN_DESTINATION:${ColorReset} ${PLUGIN_DESTINATION}" )
if( PLUGIN_CONFIG_FILES )
set( _destination "(unknown)" )
if ( INSTALL_CONFIG AND NOT PLUGIN_NO_INSTALL )
set( _destination "${PLUGIN_DATA_DESTINATION}" )
elseif( NOT PLUGIN_NO_INSTALL )
# Not INSTALL_CONFIG
set( _destination "[Build directory only]" )
else()
set( _destination "[Skipping installation]" )
endif()
message( " ${Green}CONFIGURATION_FILES:${ColorReset} ${PLUGIN_CONFIG_FILES} => ${_destination}" )
endif()
if( PLUGIN_RESOURCES )
message( " ${Green}RESOURCES:${ColorReset} ${PLUGIN_RESOURCES}" )
endif()
message( "" )
endif()
# create target name once for convenience
set( target "calamares_${PLUGIN_TYPE}_${PLUGIN_NAME}" )

# determine target type
if( NOT ${PLUGIN_SHARED_LIB} )
set( target_type "MODULE" )
else()
set( target_type "SHARED" )
endif()

set( calamares_add_library_args
"${target}"
"EXPORT_MACRO" "${PLUGIN_EXPORT_MACRO}"
"TARGET_TYPE" "${target_type}"
"SOURCES" "${PLUGIN_SOURCES}"
)

if( PLUGIN_UI )
list( APPEND calamares_add_library_args "UI" "${PLUGIN_UI}" )
endif()

if( PLUGIN_LINK_LIBRARIES )
list( APPEND calamares_add_library_args "LINK_LIBRARIES" "${PLUGIN_LINK_LIBRARIES}" )
endif()

if( PLUGIN_LINK_PRIVATE_LIBRARIES )
list( APPEND calamares_add_library_args "LINK_PRIVATE_LIBRARIES" "${PLUGIN_LINK_PRIVATE_LIBRARIES}" )
endif()

if( PLUGIN_COMPILE_DEFINITIONS )
list( APPEND calamares_add_library_args "COMPILE_DEFINITIONS" ${PLUGIN_COMPILE_DEFINITIONS} )
endif()

if ( PLUGIN_NO_INSTALL )
list( APPEND calamares_add_library_args "NO_INSTALL" )
endif()

list( APPEND calamares_add_library_args
"NO_VERSION"
"INSTALL_BINDIR" "${PLUGIN_DESTINATION}"
)

if( PLUGIN_RESOURCES )
list( APPEND calamares_add_library_args "RESOURCES" "${PLUGIN_RESOURCES}" )
endif()

calamares_add_library( ${calamares_add_library_args} )

if ( EXISTS ${CMAKE_CURRENT_SOURCE_DIR}/${PLUGIN_DESC_FILE} )
configure_file( ${PLUGIN_DESC_FILE} ${PLUGIN_DESC_FILE} COPYONLY )
else()
set( _file ${CMAKE_CURRENT_BINARY_DIR}/${PLUGIN_DESC_FILE} )
set( _type ${PLUGIN_TYPE} )
file( WRITE ${_file} "# AUTO-GENERATED metadata file\n# Syntax is YAML 1.2\n---\n" )
file( APPEND ${_file} "type: \"${_type}\"\nname: \"${PLUGIN_NAME}\"\ninterface: \"qtplugin\"\nload: \"lib${target}.so\"\n" )
if ( PLUGIN_EMERGENCY )
file( APPEND ${_file} "emergency: true\n" )
endif()
endif()

if ( NOT PLUGIN_NO_INSTALL )
install( FILES ${CMAKE_CURRENT_BINARY_DIR}/${PLUGIN_DESC_FILE}
DESTINATION ${PLUGIN_DESTINATION} )

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

+ 177
- 0
CMakeModules/CalamaresAddTranslations.cmake View File

@@ -0,0 +1,177 @@
# === 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-License-Identifier: GPL-3.0+
# License-Filename: LICENSE
#
###
#
# This file has not yet been documented for use outside of Calamares itself.

include( CMakeParseArguments )

if( NOT _rcc_version_support_checked )
set( _rcc_version_support_checked TRUE )

# Extract the executable name
get_property( _rcc_executable
TARGET ${Qt5Core_RCC_EXECUTABLE}
PROPERTY IMPORTED_LOCATION
)
if( NOT _rcc_executable )
# Weird, probably now uses Qt5::rcc which is wrong too
set( _rcc_executable ${Qt5Core_RCC_EXECUTABLE} )
endif()

# Try an empty RCC file with explicit format-version
execute_process(
COMMAND echo "<RCC version='1.0'></RCC>"
COMMAND ${Qt5Core_RCC_EXECUTABLE} --format-version 1 --list -
RESULT_VARIABLE _rcc_version_rv
ERROR_VARIABLE _rcc_version_dump
)
if ( _rcc_version_rv EQUAL 0 )
# Supported: force to the reproducible version
set( _rcc_version_support --format-version 1 )
else()
# Older Qt versions (5.7, 5.8) don't support setting the
# rcc format-version, so won't be reproducible if they
# default to version 2.
set( _rcc_version_support "" )
endif()
unset( _rcc_version_rv )
unset( _rcc_version_dump )
endif()


# Internal macro for adding the C++ / Qt translations to the
# build and install tree. Should be called only once, from
# src/calamares/CMakeLists.txt.
macro(add_calamares_translations language)
list( APPEND CALAMARES_LANGUAGES ${ARGV} )

set( calamares_i18n_qrc_content "<!DOCTYPE RCC><RCC version=\"1.0\">\n" )

# calamares and qt language files
set( calamares_i18n_qrc_content "${calamares_i18n_qrc_content}<qresource prefix=\"/lang\">\n" )
foreach( lang ${CALAMARES_LANGUAGES} )
set( calamares_i18n_qrc_content "${calamares_i18n_qrc_content}<file>calamares_${lang}.qm</file>\n" )
list( APPEND TS_FILES "${CMAKE_SOURCE_DIR}/lang/calamares_${lang}.ts" )
endforeach()

set( calamares_i18n_qrc_content "${calamares_i18n_qrc_content}</qresource>\n" )
set( calamares_i18n_qrc_content "${calamares_i18n_qrc_content}</RCC>\n" )

file( WRITE ${CMAKE_BINARY_DIR}/lang/calamares_i18n.qrc "${calamares_i18n_qrc_content}" )

qt5_add_translation(QM_FILES ${TS_FILES})

## HACK HACK HACK - around rcc limitations to allow out of source-tree building
set( trans_file calamares_i18n )
set( trans_srcfile ${CMAKE_BINARY_DIR}/lang/${trans_file}.qrc )
set( trans_infile ${CMAKE_CURRENT_BINARY_DIR}/${trans_file}.qrc )
set( trans_outfile ${CMAKE_CURRENT_BINARY_DIR}/qrc_${trans_file}.cxx )

# Copy the QRC file to the output directory
add_custom_command(
OUTPUT ${trans_infile}
COMMAND ${CMAKE_COMMAND} -E copy ${trans_srcfile} ${trans_infile}
MAIN_DEPENDENCY ${trans_srcfile}
)

# Run the resource compiler (rcc_options should already be set)
add_custom_command(
OUTPUT ${trans_outfile}
COMMAND "${Qt5Core_RCC_EXECUTABLE}"
ARGS ${rcc_options} ${_rcc_version_support} -name ${trans_file} -o ${trans_outfile} ${trans_infile}
MAIN_DEPENDENCY ${trans_infile}
DEPENDS ${QM_FILES}
)
endmacro()

# Internal macro for Python translations
#
# Translations of the Python modules that don't have their own
# lang/ subdirectories -- these are collected in top-level
# lang/python/<lang>/LC_MESSAGES/python.mo
macro(add_calamares_python_translations language)
set( CALAMARES_LANGUAGES "" )
list( APPEND CALAMARES_LANGUAGES ${ARGV} )

install_calamares_gettext_translations( python
SOURCE_DIR ${CMAKE_SOURCE_DIR}/lang/python
FILENAME python.mo
RENAME calamares-python.mo
)
endmacro()

# Installs a directory containing language-code-labeled subdirectories with
# gettext data into the appropriate system directory. Allows renaming the
# .mo files during install to avoid namespace clashes.
#
# install_calamares_gettext_translations(
# NAME <name of module, for human use>
# SOURCE_DIR path/to/lang
# FILENAME <name of file.mo>
# [RENAME <new-name of.mo>]
# )
#
# For all of the (global) translation languages enabled for Calamares,
# try installing $SOURCE_DIR/$lang/LC_MESSAGES/<filename>.mo into the
# system gettext data directory (e.g. share/locale/), possibly renaming
# filename.mo to renamed.mo in the process.
function( install_calamares_gettext_translations )
# parse arguments ( name needs to be saved before passing ARGN into the macro )
set( NAME ${ARGV0} )
set( oneValueArgs NAME SOURCE_DIR FILENAME RENAME )
cmake_parse_arguments( TRANSLATION "${options}" "${oneValueArgs}" "${multiValueArgs}" ${ARGN} )

if( NOT TRANSLATION_NAME )
set( TRANSLATION_NAME ${NAME} )
endif()
if( NOT TRANSLATION_FILENAME )
set( TRANSLATION_FILENAME "${TRANSLATION_NAME}.mo" )
endif()
if( NOT TRANSLATION_RENAME )
set( TRANSLATION_RENAME "${TRANSLATION_FILENAME}" )
endif()

message(STATUS "Installing gettext translations for ${TRANSLATION_NAME}")
message(STATUS " Installing ${TRANSLATION_FILENAME} from ${TRANSLATION_SOURCE_DIR}")

set( TRANSLATION_NAME "${NAME}" )
set( INSTALLED_TRANSLATIONS "" )
foreach( lang ${CALAMARES_TRANSLATION_LANGUAGES} ) # Global
set( lang_mo "${TRANSLATION_SOURCE_DIR}/${lang}/LC_MESSAGES/${TRANSLATION_FILENAME}" )
if( lang STREQUAL "en" )
message( STATUS " Skipping ${TRANSLATION_NAME} translations for en_US" )
else( EXISTS ${lang_mo} )
list( APPEND INSTALLED_LANGUAGES "${lang}" )
install(
FILES ${lang_mo}
DESTINATION ${CMAKE_INSTALL_LOCALEDIR}/${lang}/LC_MESSAGES/
RENAME ${TRANSLATION_RENAME}
)
# TODO: make translations available in build dir too, for
# translation when running calamares -d from builddir.
set(_build_lc ${CMAKE_BINARY_DIR}/lang/${lang}/LC_MESSAGES/)
file(COPY ${lang_mo} DESTINATION ${_build_lc})
if (NOT TRANSLATION_FILENAME STREQUAL TRANSLATION_RENAME)
file(RENAME ${_build_lc}${TRANSLATION_FILENAME} ${_build_lc}${TRANSLATION_RENAME})
endif()

endif()
endforeach()
endfunction()

+ 34
- 0
CMakeModules/FindCrypt.cmake View File

@@ -0,0 +1,34 @@
# - Find libcrypt
# Find the libcrypt includes and the libcrypt libraries
# This module defines
# LIBCRYPT_INCLUDE_DIR, root crypt include dir. Include crypt with crypt.h
# LIBCRYPT_LIBRARY, the path to libcrypt
# LIBCRYPT_FOUND, whether libcrypt was found

if( CMAKE_SYSTEM MATCHES "FreeBSD" )
# FreeBSD has crypt(3) declared in unistd.h, which lives in
# libc; the libcrypt found here is not used.
find_path( CRYPT_INCLUDE_DIR NAMES unistd.h )
add_definitions( -DNO_CRYPT_H )
else()
find_path( CRYPT_INCLUDE_DIR
NAMES crypt.h
HINTS
${CMAKE_INSTALL_INCLUDEDIR}
NO_CACHE
)
endif()

find_library( CRYPT_LIBRARIES
NAMES crypt
HINTS
${CMAKE_INSTALL_LIBDIR}
)

include( FindPackageHandleStandardArgs )
find_package_handle_standard_args(
Crypt
REQUIRED_VARS CRYPT_LIBRARIES CRYPT_INCLUDE_DIR
)

mark_as_advanced( CRYPT_INCLUDE_DIR CRYPT_LIBRARIES )

+ 57
- 0
CMakeModules/FindLIBPARTED.cmake View File

@@ -0,0 +1,57 @@
# Copyright (C) 2008,2010,2011 by Volker Lanz <vl@fidra.de>
#
# Redistribution and use in source and binary forms, with or without
# modification, are permitted provided that the following conditions
# are met:
#
# 1. Redistributions of source code must retain the above copyright
# notice, this list of conditions and the following disclaimer.
# 2. Redistributions in binary form must reproduce the above copyright
# notice, this list of conditions and the following disclaimer in the
# documentation and/or other materials provided with the distribution.
#
# THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
# IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
# OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
# IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
# INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
# NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
# DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
# THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
# THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.

include(CheckCSourceCompiles)
include(CheckFunctionExists)

if (LIBPARTED_INCLUDE_DIR AND LIBPARTED_LIBRARY)
# Already in cache, be silent
set(LIBPARTED_FIND_QUIETLY TRUE)
endif (LIBPARTED_INCLUDE_DIR AND LIBPARTED_LIBRARY)


FIND_PATH(LIBPARTED_INCLUDE_DIR parted.h PATH_SUFFIXES parted )

FIND_LIBRARY(LIBPARTED_LIBRARY NAMES parted)
FIND_LIBRARY(LIBPARTED_FS_RESIZE_LIBRARY NAMES parted-fs-resize)

INCLUDE(FindPackageHandleStandardArgs)
FIND_PACKAGE_HANDLE_STANDARD_ARGS(LIBPARTED DEFAULT_MSG LIBPARTED_LIBRARY LIBPARTED_INCLUDE_DIR)

if (LIBPARTED_FS_RESIZE_LIBRARY)
set(LIBPARTED_LIBS ${LIBPARTED_LIBRARY} ${LIBPARTED_FS_RESIZE_LIBRARY})
else (LIBPARTED_FS_RESIZE_LIBRARY)
set(LIBPARTED_LIBS ${LIBPARTED_LIBRARY})
endif (LIBPARTED_FS_RESIZE_LIBRARY)

# KDE adds -ansi to the C make flags, parted headers use GNU extensions, so
# undo that
unset(CMAKE_C_FLAGS)

set(CMAKE_REQUIRED_INCLUDES ${LIBPARTED_INCLUDE_DIR})
set(CMAKE_REQUIRED_LIBRARIES ${LIBPARTED_LIBS})

CHECK_FUNCTION_EXISTS("ped_file_system_clobber" LIBPARTED_FILESYSTEM_SUPPORT) # parted < 3.0
CHECK_FUNCTION_EXISTS("ped_file_system_resize" LIBPARTED_FS_RESIZE_LIBRARY_SUPPORT) # parted != 3.0

MARK_AS_ADVANCED(LIBPARTED_LIBRARY LIBPARTED_INCLUDE_DIR LIBPARTED_FILESYSTEM_SUPPORT LIBPARTED_FS_RESIZE_LIBRARY LIBPARTED_FS_RESIZE_LIBRARY_SUPPORT)

+ 37
- 0
CMakeModules/FindLibPWQuality.cmake View File

@@ -0,0 +1,37 @@
# Locate libpwquality
# https://github.com/libpwquality/libpwquality
#
# This module defines
# LibPWQuality_FOUND
# LibPWQuality_LIBRARIES, where to find the library
# LibPWQuality_INCLUDE_DIRS, where to find pwquality.h
#
include(FindPkgConfig)
include(FindPackageHandleStandardArgs)

pkg_search_module(pc_pwquality QUIET pwquality)

find_path(LibPWQuality_INCLUDE_DIR
NAMES pwquality.h
PATHS ${pc_pwquality_INCLUDE_DIRS}
)
find_library(LibPWQuality_LIBRARY
NAMES pwquality
PATHS ${pc_pwquality_LIBRARY_DIRS}
)
if(pc_pwquality_FOUND)
set(LibPWQuality_LIBRARIES ${LibPWQuality_LIBRARY})
set(LibPWQuality_INCLUDE_DIRS ${LibPWQuality_INCLUDE_DIR} ${pc_pwquality_INCLUDE_DIRS})
endif()

find_package_handle_standard_args(LibPWQuality DEFAULT_MSG
LibPWQuality_INCLUDE_DIRS
LibPWQuality_LIBRARIES
)
mark_as_advanced(LibPWQuality_INCLUDE_DIRS LibPWQuality_LIBRARIES)

set_package_properties(
LibPWQuality PROPERTIES
DESCRIPTION "Password quality checking library"
URL "https://github.com/libpwquality/libpwquality"
)

+ 177
- 0
CMakeModules/FindPythonQt.cmake View File

@@ -0,0 +1,177 @@
# Find PythonQt
#
# Sets PYTHONQT_FOUND, PYTHONQT_INCLUDE_DIR, PYTHONQT_LIBRARY, PYTHONQT_LIBRARIES
#
# Also sets PYTHONQT_INCLUDE_DIRS to add whatever directories
# that are needed for extensions.
#

# Python is required
find_package(PythonLibs)
if(NOT PYTHONLIBS_FOUND)
message(FATAL_ERROR "error: Python is required to build PythonQt")
endif()

# Cut X.Y[.Z] down to just X.Y
string(REGEX REPLACE
"^([0-9][0-9]*)\.([0-9][0-9]*)"
"\\1.\\2@"
_PYTHONLIBS_MAJMIN
${PYTHONLIBS_VERSION_STRING}
)
string(REGEX REPLACE
"@.*"
""
PYTHONLIBS_MAJMIN
${_PYTHONLIBS_MAJMIN}
)

if(NOT EXISTS "${PYTHONQT_INSTALL_DIR}")
find_path(PYTHONQT_INSTALL_DIR
NAMES
include/PythonQt/PythonQt.h
include/PythonQt5/PythonQt.h
DOC "Directory where PythonQt was installed.")
endif()

# XXX Since PythonQt 3.0 is not yet cmakeified, depending
# on how PythonQt is built, headers will not always be
# installed in "include/PythonQt". That is why "src"
# is added as an option. See [1] for more details.
# [1] https://github.com/commontk/CTK/pull/538#issuecomment-86106367
find_path(PYTHONQT_INCLUDE_DIR PythonQt.h
PATHS
"${PYTHONQT_INSTALL_DIR}/include/PythonQt"
"${PYTHONQT_INSTALL_DIR}/include/PythonQt5"
"${PYTHONQT_INSTALL_DIR}/src"
DOC "Path to the PythonQt include directory")
find_path(PYTHONQT_ALL_INCLUDE_DIR PythonQt_QtAll.h
PATHS
"${PYTHONQT_INCLUDE_DIR}"
"${PYTHONQT_INSTALL_DIR}"
PATH_SUFFIXES
"extensions/PythonQt_QtAll"
"src"
DOC "Path to the PythonQt 'all' header")

if ( NOT PythonQt_FIND_QUIETLY )
message( STATUS "Searching for PythonQt (PythonLibs ${PYTHONLIBS_MAJMIN}) .." )
if ( PYTHONQT_INCLUDE_DIR )
message( STATUS " .. found include ${PYTHONQT_INCLUDE_DIR}" )
message( STATUS " .. found all include ${PYTHONQT_ALL_INCLUDE_DIR}" )
endif()
endif()

# Minimum v3.1 is needed
find_library(PYTHONQT_LIBRARY_RELEASE
NAMES
PythonQt-Qt5-Python${PYTHONLIBS_MAJMIN}
PythonQt-Qt5-Python3
PythonQt
PATHS "${PYTHONQT_INSTALL_DIR}/lib"
DOC "The PythonQt library."
)
find_library(PYTHONQT_LIBRARY_DEBUG
NAMES
PythonQt-Qt5-Python${PYTHONLIBS_MAJMIN}JMIN${CTK_CMAKE_DEBUG_POSTFIX}
PythonQt-Qt5-Python${PYTHONLIBS_MAJMIN}${CMAKE_DEBUG_POSTFIX}
PythonQt-Qt5-Python${PYTHONLIBS_MAJMIN}
PythonQt-Qt5-Python3${CTK_CMAKE_DEBUG_POSTFIX}
PythonQt-Qt5-Python3${CMAKE_DEBUG_POSTFIX}
PythonQt-Qt5-Python3
PythonQt${CTK_CMAKE_DEBUG_POSTFIX}
PythonQt${CMAKE_DEBUG_POSTFIX}
PythonQt
PATHS "${PYTHONQT_INSTALL_DIR}/lib"
DOC "The PythonQt library (debug build)."
)
find_library(PYTHONQT_QTALL_LIBRARY_RELEASE
NAMES
PythonQt_QtAll-Qt5-Python${PYTHONLIBS_MAJMIN}
PythonQt_QtAll-Qt5-Python3
PythonQt_QtAll
PATHS "${PYTHONQT_INSTALL_DIR}/lib"
DOC "Full Qt bindings for the PythonQt library."
)
find_library(PYTHONQT_QTALL_LIBRARY_DEBUG
NAMES
PythonQt_QtAll-Qt5-Python${PYTHONLIBS_MAJMIN}${CTK_CMAKE_DEBUG_POSTFIX}
PythonQt_QtAll-Qt5-Python${PYTHONLIBS_MAJMIN}${CMAKE_DEBUG_POSTFIX}
PythonQt_QtAll-Qt5-Python${PYTHONLIBS_MAJMIN}
PythonQt_QtAll-Qt5-Python3${CTK_CMAKE_DEBUG_POSTFIX}
PythonQt_QtAll-Qt5-Python3${CMAKE_DEBUG_POSTFIX}
PythonQt_QtAll-Qt5-Python3
PythonQt_QtAll${CTK_CMAKE_DEBUG_POSTFIX}
PythonQt_QtAll${CMAKE_DEBUG_POSTFIX}
PythonQt_QtAll
PATHS "${PYTHONQT_INSTALL_DIR}/lib"
DOC "Full Qt bindings for the PythonQt library (debug build)."
)

set(PYTHONQT_LIBRARY)
if(PYTHONQT_LIBRARY_RELEASE)
list(APPEND PYTHONQT_LIBRARY optimized ${PYTHONQT_LIBRARY_RELEASE})
endif()
if(PYTHONQT_LIBRARY_DEBUG)
list(APPEND PYTHONQT_LIBRARY debug ${PYTHONQT_LIBRARY_DEBUG})
endif()

set(PYTHONQT_QTALL_LIBRARY)
if(PYTHONQT_QTALL_LIBRARY_RELEASE)
list(APPEND PYTHONQT_QTALL_LIBRARY optimized ${PYTHONQT_QTALL_LIBRARY_RELEASE})
endif()