From 76a4edb61271550af9b7266d7e6470dccd1bb44b Mon Sep 17 00:00:00 2001
From: valentin <valentinb@fsmpi.rwth-aachen.de>
Date: Sat, 8 Oct 2022 20:30:07 +0200
Subject: [PATCH] new calamares module: fix mirrorlist and activate NTP

* correction in packages: missing LaTeX package in live system
* added xorg-xinput to packages
* new calamares module postcfglip:
    * overwrite mirrorlist if not connected
      to the internet (otherwise mirrorlist is randomly generated).
    * activate NTP (time synchronization)
This configuration is untested!
---
 assemble_image.sh       |  1 +
 calamares-settings.conf |  1 +
 packages                |  3 +-
 postcfglip/main.py      | 86 +++++++++++++++++++++++++++++++++++++++++
 postcfglip/module.desc  |  6 +++
 5 files changed, 96 insertions(+), 1 deletion(-)
 create mode 100644 postcfglip/main.py
 create mode 100644 postcfglip/module.desc

diff --git a/assemble_image.sh b/assemble_image.sh
index a17b8d9..ef2320e 100755
--- a/assemble_image.sh
+++ b/assemble_image.sh
@@ -165,6 +165,7 @@ cp -f calamares-settings.conf /var/lib/manjaro-tools/buildiso/lip/x86_64/livefs/
 cp "calamares.desktop" "$LIVE/usr/share/applications/calamares.desktop"
 
 rsync --recursive makedoku /var/lib/manjaro-tools/buildiso/lip/x86_64/livefs/usr/lib/calamares/modules
+rsync --recursive postcfglip /var/lib/manjaro-tools/buildiso/lip/x86_64/livefs/usr/lib/calamares/modules
 
 set +e # buildiso returns a 1 on partial builds
 buildiso -p lip -zc -k linux515 # and then build the iso
diff --git a/calamares-settings.conf b/calamares-settings.conf
index 0f205da..9aba086 100644
--- a/calamares-settings.conf
+++ b/calamares-settings.conf
@@ -53,6 +53,7 @@ sequence:
     - exec:
         - packages
         - makedoku
+        - postcfglip
         - umount
     - show:
         - finished
diff --git a/packages b/packages
index 27961f2..11952f8 100644
--- a/packages
+++ b/packages
@@ -66,12 +66,13 @@
 LD   |efivar|
 LD   |vim|
  c   |neovim|neovim: Editor, Alternative zu vim
+LD   |xorg-xinput|
 LD   |htop|
 LD   |git|
 LD   |gparted|
 
 #texlive
-L    |texlive-core texlive-bin|minimale LaTeX Installation
+L    |texlive-core texlive-bin texlive-latexextra|minimale LaTeX Installation
  C   |texlive-bibtexextra texlive-latexextra texlive-fontsextra psutils texlive-pstricks texlive-science texlive-pictures tex-gyre-fonts texlive-publishers texlive-core texlive-bin texinfo|LaTeX mit vielen Paketen für wissenschaftliche Arbeiten
  c   |texlive-music texlive-games t1utils texlive-formatsextra texinfo texlive-humanities|Zusätzliche Fonts und Pakete für LaTeX
 
diff --git a/postcfglip/main.py b/postcfglip/main.py
new file mode 100644
index 0000000..3456bc7
--- /dev/null
+++ b/postcfglip/main.py
@@ -0,0 +1,86 @@
+#!/usr/bin/env python3
+# -*- coding: utf-8 -*-
+#
+# === This file is part of Calamares - <https://calamares.io> ===
+#
+#   SPDX-FileCopyrightText: 2014 Teo Mrnjavac <teo@kde.org>
+#   SPDX-FileCopyrightText: 2017 Alf Gaida <agaida@siduction.org>
+#   SPDX-FileCopyrightText: 2017 Adriaan de Groot <groot@kde.org>
+#   SPDX-License-Identifier: GPL-3.0-or-later
+#
+#   Calamares is Free Software: see the License-Identifier above.
+#
+
+"""
+=== Example Python jobmodule.
+
+A Python jobmodule is a Python program which imports libcalamares and
+has a function run() as entry point. run() must return None if everything
+went well, or a tuple (str,str) with an error message and description
+if something went wrong.
+"""
+
+DEFAULT_MIRRORLIST = """## Manjaro Linux custom mirrorlist
+## Configuration from Linux Install Party in Aachen
+## Generated on 2022-10-08 20:17
+##
+## Please use 'pacman-mirrors -f [NUMBER] [NUMBER]' to modify mirrorlist
+## (Use 0 for all mirrors)
+##
+
+## Country : Germany
+Server = https://ftp.halifax.rwth-aachen.de/manjaro/stable/$repo/$arch
+
+## Country : Germany
+Server = https://mirror.netcologne.de/manjaro/stable/$repo/$arch
+
+## Country : Germany
+Server = https://mirror.moson.org/manjaro/stable/$repo/$arch
+
+## Country : Germany
+Server = https://mirror.23m.com/manjaro/stable/$repo/$arch
+
+## Country : Netherlands
+Server = http://ftp.snt.utwente.nl/pub/linux/manjaro/stable/$repo/$arch
+
+## Country : Belgium
+Server = http://ftp.belnet.be/mirrors/manjaro/repos/stable/$repo/$arch
+
+## Country : Netherlands
+Server = https://manjaro.mirrors.lavatech.top/stable/$repo/$arch
+
+## Country : Netherlands
+Server = https://mirror.koddos.net/manjaro/stable/$repo/$arch
+
+## Country : Germany
+Server = https://mirror.tarnkappe.info/manjaro/stable/$repo/$arch
+
+## Country : Belgium
+Server = https://mirror.futureweb.be/manjaro/stable/$repo/$arch
+
+## Country : Germany
+Server = https://mirror.alpix.eu/manjaro/stable/$repo/$arch
+
+## Country : Netherlands
+Server = https://ftp.nluug.nl/pub/os/Linux/distr/manjaro/stable/$repo/$arch
+
+## Country : Germany
+Server = https://ftp.gwdg.de/pub/linux/manjaro/stable/$repo/$arch
+
+## Country : Germany
+Server = https://mirror.informatik.tu-freiberg.de/manjaro/stable/$repo/$arch
+"""
+
+from os.path import join
+from libcalamares import globalstorage
+from libcalamares.utils import target_env_call
+
+def run():
+    """Custom postinstall configuration"""
+    root = globalstorage.value("rootMountPoint")
+    mirrorlist_path = join(root, "etc/pacman.d/mirrorlist")
+    if not globalstorage.value("hasInternet"):
+        with open(mirrorlist_path, "w") as file:
+            file.write(DEFAULT_MIRRORLIST)
+    target_env_call(["timedatectl", "set-ntp", "1"])
+    return None
diff --git a/postcfglip/module.desc b/postcfglip/module.desc
new file mode 100644
index 0000000..cb18248
--- /dev/null
+++ b/postcfglip/module.desc
@@ -0,0 +1,6 @@
+type:       "job"
+name:       "postcfglip"
+interface:  "python"
+script:     "main.py"
+
+# vim: filetype=yaml
-- 
GitLab