This commit is contained in:
lapatatadouce
2025-07-15 22:54:17 +02:00
parent 588d901ca7
commit ba86c1be05
7 changed files with 128 additions and 158 deletions

120
README.md
View File

@@ -1,90 +1,102 @@
# UDIB
UDIB is the Unattended Debian Installation Builder.
It provides a handy commandline utility for injecting files into Debian installation ISOs.
Using UDIB, you can preseed an ISO by injecting a preseed file.
Preseeded ISOs allow fully automated Debian installations on bare metal (or anywhere else).
UDIB est l'outil de construction d'installation Debian non assistée.
Il fournit un utilitaire en ligne de commande pratique pour injecter des fichiers dans les ISOs d'installation Debian.
En utilisant UDIB, vous pouvez préconfigurer un ISO en injectant un fichier de préconfiguration.
Les ISOs préconfigurés permettent des installations Debian entièrement automatisées sur du matériel nu (ou n'importe où ailleurs).
## Quick Start Guide
**Note:** Ce projet est un fork de [YunoHost/custom-debian-iso](https://github.com/YunoHost/custom-debian-iso) qui est lui-même un fork de [ulinja/udib](https://github.com/ulinja/udib).
This short guide explains how to build a Debian ISO with a customized and automated installation:
## Guide de démarrage rapide
1. make sure you have all the [required software](#build-machine) installed
2. clone this repo and `cd` into your local copy
3. (optional) create and activate a virtual environment: `python3 -m venv .venv && . .venv/bin/activate`
4. install the required python packages: `pip install -r requirements.txt`
5. all the Debian ISOs are available in <https://cdimage.debian.org/mirror/cdimage/archive/>
5. create the custom ISOs: `./udib.py inject -i debian-11.10.0-amd64-netinst.iso`
6. boot from the `-modified.iso` on your target machine (or in a VM)
Ce guide court explique comment construire un ISO Debian avec une installation personnalisée et automatisée :
Depending on how many answers you provided in the preseed file, the installation may require some manual interaction.
Preseed files are very powerful, and if you need more customization you can have a deeper look into [how they work](#whats-preseeding).
You can also use UDIB to get the full preseed example file: `./udib.py get preseed-file-full` and use that as a starting point.
Be sure to have a look at the [usage reference](#detailed-usage-guide) for a closer look at UDIB itself.
1. assurez-vous d'avoir tous les [logiciels requis](#machine-de-construction) installés
2. clonez ce dépôt et `cd` dans votre copie locale
3. (optionnel) créez et activez un environnement virtuel : `python3 -m venv .venv && . .venv/bin/activate`
4. installez les packages python requis : `pip install -r requirements.txt`
5. tous les ISOs Debian sont disponibles dans <https://cdimage.debian.org/mirror/cdimage/archive/>
5. créez les ISOs personnalisés : `./udib.py inject -i debian-11.10.0-amd64-netinst.iso`
6. démarrez à partir de l'ISO `-modified.iso` sur votre machine cible (ou dans une VM)
## What's preseeding?
Selon le nombre de réponses que vous avez fournies dans le fichier de préconfiguration, l'installation peut nécessiter une certaine interaction manuelle.
Les fichiers de préconfiguration sont très puissants, et si vous avez besoin de plus de personnalisation, vous pouvez regarder plus en détail [comment ils fonctionnent](#quest-ce-que-la-préconfiguration).
Vous pouvez également utiliser UDIB pour obtenir le fichier d'exemple de préconfiguration complet : `./udib.py get preseed-file-full` et l'utiliser comme point de départ.
Assurez-vous de jeter un œil à la [référence d'utilisation](#guide-dutilisation-détaillé) pour un regard plus approfondi sur UDIB lui-même.
A preseed file is a text file which provides the Debian installer with previously set (preseeded) answers during the installation process.
Preseeding a Debian ISO allows you to heavily reduce the amount of user interaction required during an installation, or even fully automate it.
The preseed file is written by you and then injected into the installation image.
When you start the installation, any answers you have provided to the debian installer as part of your preseed file are automatically applied during the installation.
If you want to know more, you can have a look at Debian's [official guide](https://www.debian.org/releases/stable/amd64/apb.en.html) or at the Debian wiki's [quick overview](https://wiki.debian.org/DebianInstaller/Preseed), both of which explain preseeding much better than I can.
## Qu'est-ce que la préconfiguration ?
## How does UDIB work?
Un fichier de préconfiguration est un fichier texte qui fournit à l'installateur Debian des réponses préalablement définies (préconfigurées) pendant le processus d'installation.
La préconfiguration d'un ISO Debian vous permet de réduire considérablement la quantité d'interaction utilisateur requise pendant une installation, ou même de l'automatiser entièrement.
Le fichier de préconfiguration est écrit par vous puis injecté dans l'image d'installation.
Quand vous démarrez l'installation, toutes les réponses que vous avez fournies à l'installateur debian dans le cadre de votre fichier de préconfiguration sont automatiquement appliquées pendant l'installation.
Si vous voulez en savoir plus, vous pouvez regarder le [guide officiel](https://www.debian.org/releases/stable/amd64/apb.en.html) de Debian ou l'[aperçu rapide](https://wiki.debian.org/DebianInstaller/Preseed) du wiki Debian, qui expliquent tous deux la préconfiguration bien mieux que je ne peux le faire.
UDIB's main purpose is the injection files into existing Debian installation ISOs.
In a nutshell, it does this by extracting the ISO, adding the files to the ISO's initrd, and repacking the ISO again.
You could do all of this manually of course by following the [basic](https://wiki.debian.org/DebianInstaller/Preseed/EditIso#Adding_a_Preseed_File_to_the_Initrd) and [advanced](https://wiki.debian.org/RepackBootableISO) guides for ISO repacking on the Debian wiki, but UDIB does all of this for you.
## Comment fonctionne UDIB ?
# Dependencies
Le but principal d'UDIB est l'injection de fichiers dans les ISOs d'installation Debian existants.
En résumé, il fait cela en extrayant l'ISO, en ajoutant les fichiers à l'initrd de l'ISO, et en repackageant l'ISO à nouveau.
Vous pourriez faire tout cela manuellement bien sûr en suivant les guides [basique](https://wiki.debian.org/DebianInstaller/Preseed/EditIso#Adding_a_Preseed_File_to_the_Initrd) et [avancé](https://wiki.debian.org/RepackBootableISO) pour le repackaging d'ISO sur le wiki Debian, mais UDIB fait tout cela pour vous.
Using UDIB to create ISOs requires the following software:
# Dépendances
L'utilisation d'UDIB pour créer des ISOs nécessite les logiciels suivants :
- GNU/Linux
- `python3` *(3.10.4 known to work)*
- [required python packages](./requirements.txt) can be installed in a virtual environment
- `xorriso` *(1.5.4 known to work)*
- `python3` *(3.10.4 connu pour fonctionner)*
- [packages python requis](./requirements.txt) peuvent être installés dans un environnement virtuel
- `xorriso` *(1.5.4 connu pour fonctionner)*
- **Debian (bullseye):** [xorriso](https://packages.debian.org/bullseye/xorriso)
- **Arch Linux:** [extra/libisoburn](extra/libisoburn)
- GNU `gpg`
- preinstalled on most distributions
- préinstallé sur la plupart des distributions
- GNU `cpio`
- preinstalled on most distributions
- préinstallé sur la plupart des distributions
- GNU `sha512sum`
- preinstalled on most distributions
- préinstallé sur la plupart des distributions
Internet access is (obviously) required if you want to fetch any files using UDIB.
Un accès Internet est (évidemment) requis si vous voulez récupérer des fichiers en utilisant UDIB.
# Detailed usage guide
# Guide d'utilisation détaillé
You can view help at the commandline using `./udib.py --help` for general options and `./udib.py COMMAND --help` for help with a specific subcommand.
Vous pouvez voir l'aide en ligne de commande en utilisant `./udib.py --help` pour les options générales et `./udib.py COMMAND --help` pour l'aide avec une sous-commande spécifique.
The name and destination of files produced by `udib.py` can be specified with the `--output-file` option.
Alternatively, you can use the `--output-dir` option to specify the directory where produced files will be saved, without having to name them explicitly (default names will be used).
Le nom et la destination des fichiers produits par `udib.py` peuvent être spécifiés avec l'option `--output-file`.
Alternativement, vous pouvez utiliser l'option `--output-dir` pour spécifier le répertoire où les fichiers produits seront sauvegardés, sans avoir à les nommer explicitement (les noms par défaut seront utilisés).
## Retrieving example preseed files or vanilla ISOs
## Récupération d'exemples de fichiers de préconfiguration ou d'ISOs vanille
As a starting point for creating your own preseeded ISO, you can retrieve one of Debian's example preseed files or an unmodified Debian ISO using UDIB:
Comme point de départ pour créer votre propre ISO préconfiguré, vous pouvez récupérer un des fichiers d'exemple de préconfiguration de Debian ou un ISO Debian non modifié en utilisant UDIB :
```
udib.py [--output-file FILE | --output-dir DIR] get WHAT
```
`WHAT` must be a specific string and can be either one of:
`WHAT` doit être une chaîne spécifique et peut être soit :
- `preseed-file-basic` to download Debian's basic example preseed file (sufficient in most cases)
- `preseed-file-full` to download Debian's full example preseed file (has a LOT of customization options)
- `iso` to download the latest, unmodified Debian stable x86-64 netinst ISO
- `preseed-file-basic` pour télécharger le fichier d'exemple de préconfiguration basique de Debian (suffisant dans la plupart des cas)
- `preseed-file-full` pour télécharger le fichier d'exemple de préconfiguration complet de Debian (a BEAUCOUP d'options de personnalisation)
- `iso` pour télécharger le dernier ISO netinst Debian stable x86-64 non modifié
## Injecting files into an ISO
## Injection de fichiers dans un ISO
To inject existing files into an ISO, you can run the following command:
Pour injecter des fichiers existants dans un ISO, vous pouvez exécuter la commande suivante :
```
udib.py [--output-file FILE | --output-dir DIR] inject [--image-file IMAGEFILE] FILE [FILE ...]
```bash
python udib.py --output-file skylanix.iso inject --image-file debian-12.11.0-amd64-netinst.iso
```
where `FILE` is the path to the file you want to inject.
Injected files are added at the root of the installer's filesystem and can be accessed there during the installation.
**NOTE:** the installer will not recognize a preseed file unless it's filename is `preseed.cfg` exactly.
If you don't specify an `--image-file`, UDIB will download the latest Debian x86-64 netinst ISO and inject your `FILE`s into it.
Le script injecte automatiquement tous les fichiers présents dans le dossier `files_to_inject/` :
- Configuration GRUB personnalisée (`boot/grub/grub.cfg` et thème)
- Configuration isolinux (`isolinux/menu.cfg` et `splash.png`)
- Logo personnalisé (`logo.png`)
- Fichier de préconfiguration (`preseeds/default.preseed`)
**Exemple complet :**
```bash
# Créer un ISO personnalisé "skylanix.iso" à partir de l'ISO Debian standard
python udib.py --output-file skylanix.iso inject --image-file debian-12.11.0-amd64-netinst.iso
```
**NOTE:** l'installateur ne reconnaîtra pas un fichier de préconfiguration sauf si son nom de fichier est exactement `preseed.cfg`.
Si vous ne spécifiez pas d'`--image-file`, UDIB téléchargera le dernier ISO netinst Debian x86-64 et injectera vos fichiers dedans.

View File

@@ -1,6 +1,7 @@
"""A collection of general utilities, not specific to any module."""
from crypt import crypt, METHOD_SHA512
import hashlib
import secrets
from getpass import getpass
from os import remove, rename
from pathlib import Path
@@ -36,8 +37,13 @@ def hash_user_password(printer=None):
p.failure("Passwords did not match")
return
# Generate a salt and create SHA-512 hash
salt = secrets.token_hex(16)
password_hash = hashlib.sha512((salt + password).encode()).hexdigest()
full_hash = f"$6${salt}${password_hash}"
p.info("Password hash:")
p.info(crypt(password, METHOD_SHA512))
p.info(full_hash)
def assert_system_dependencies_installed():
"""Checks whether all system dependencies required by udib are installed.

Binary file not shown.

Before

Width:  |  Height:  |  Size: 6.4 KiB

After

Width:  |  Height:  |  Size: 76 KiB

View File

@@ -1,7 +1,7 @@
menu hshift 11
menu width 57
menu title YunoHost installation
menu title skylanix installation
menu background splash.png
menu color title * #FFFFFFFF *

BIN
files_to_inject/isolinux/splash.png Normal file → Executable file

Binary file not shown.

Before

Width:  |  Height:  |  Size: 7.1 KiB

After

Width:  |  Height:  |  Size: 68 KiB

BIN
files_to_inject/logo.png Normal file → Executable file

Binary file not shown.

Before

Width:  |  Height:  |  Size: 11 KiB

After

Width:  |  Height:  |  Size: 64 KiB

154
files_to_inject/preseeds/default.preseed Normal file → Executable file
View File

@@ -1,116 +1,68 @@
### Network configuration
# Configuration de la langue et de la localisation
d-i debian-installer/locale string fr_CH.UTF-8
d-i preseed/early_command string debconf-set-selections /tmp/preseed.cfg
# Configuration du clavier
d-i keyboard-configuration/modelcode string pc105
d-i keyboard-configuration/variantcode string fr
# Configuration réseau (choix automatique de la première interface active)
d-i netcfg/choose_interface select auto
d-i netcfg/dhcp_failed note
d-i netcfg/dhcp_options select Configure network manually
d-i netcfg/disable_dhcp boolean false
d-i netcfg/get_hostname string yunohost
d-i netcfg/get_domain string yunohost.org
d-i netcfg/get_hostname string skylanix
d-i netcfg/get_hostname seen false
d-i netcfg/get_domain string unassigned-domain
### Mirror settings
d-i mirror/country string manual
d-i mirror/http/hostname string ftp.debian.org
d-i mirror/http/directory string /debian
d-i mirror/http/proxy string
# Désactivation du compte root
d-i passwd/root-login boolean false
### Localization
# Partitionnement manuel (sans partitionnement automatique)
d-i partman-auto/method string
d-i partman-auto/choose_recipe select
d-i partman-partitioning/confirm_write_new_label boolean false
d-i partman/confirm boolean false
d-i partman/confirm_nooverwrite boolean false
d-i tzdata/Areas select Europe
d-i localechooser/continentlist select Europe
d-i time/zone string Europe/Paris
d-i time/zone seen false
# Configuration de l'horloge système
d-i clock-setup/utc boolean true
d-i time/zone string Europe/Zurich
d-i time/zone seen false
d-i clock-setup/ntp boolean true
d-i clock-setup/ntp-server string 0.fr.pool.ntp.org
d-i clock-setup/ntp seen false
### Partitioning
d-i partman-auto/method string lvm
d-i partman-lvm/device_remove_lvm boolean true
d-i partman-md/device_remove_md boolean true
d-i partman-auto/choose_recipe select atomic
# "atomic" corresponds to:
# https://salsa.debian.org/installer-team/partman-auto/-/blob/162/recipes/atomic
# https://salsa.debian.org/installer-team/partman-auto/-/blob/162/recipes-amd64-efi/atomic
d-i partman-lvm/device_remove_lvm_span boolean true
d-i partman-auto/purge_lvm_from_device boolean true
d-i partman-auto-lvm/new_vg_name string system
d-i partman-lvm/confirm boolean true
d-i partman-auto-lvm/guided_size string max
d-i partman/confirm_write_new_label boolean true
# These lines are commented to keep displaying the partitioning info and ask confirmation
# because it's deemed to brutal to savagely format the disk without asking confirmation here
#d-i partman/choose_partition select finish
#d-i partman/confirm boolean true
d-i partman/confirm_nooverwrite boolean true
d-i partman-lvm/confirm_nooverwrite boolean true
### Account setup
d-i passwd/root-password-crypted password $1$6xBdkGvE$8nLCNRxwABespdFJniEiX0
d-i passwd/make-user boolean false
### Base system installation
d-i apt-setup/non-free boolean false
d-i apt-setup/contrib boolean true
d-i apt-setup/services-select multiselect security, updates
d-i apt-setup/security_host string security.debian.org
d-i apt-setup/local0/repository string \
http://repo.yunohost.org/debian/ __DIST__ stable __TESTING__
d-i apt-setup/local0/key string http://repo.yunohost.org/keys/yunohost___DIST__.asc
d-i apt-setup/local0/comment string YunoHost repository
#d-i debian-installer/allow_unauthenticated string true
# Skip "scan another CD/DVD"
# https://unix.stackexchange.com/a/409237
apt-cdrom-setup apt-setup/cdrom/set-next boolean false
# Configuration APT : ne pas utiliser en priorité le CD-ROM comme source
d-i apt-setup/cdrom/set-first boolean false
d-i apt-setup/cdrom/set-next boolean false
d-i apt-setup/cdrom/set-failed boolean false
### Package selection
tasksel tasksel/first multiselect standard, ssh-server
# Keep postfix in here, otherwise exim4 might get installed and create a weird
# conflict...
d-i pkgsel/include string postfix yunohost yunohost-admin
d-i pkgsel/upgrade select none
# Activation des dépôts non-free
d-i apt-setup/non-free boolean true
### Deactivate poll on popular packages
popularity-contest popularity-contest/participate boolean false
debconf debconf/frontend select Noninteractive
# Sélection des tâches à installer
tasksel tasksel/first multiselect minimal
### Boot loader installation
# Paquets additionnels à installer
d-i pkgsel/include string \
kde-plasma-desktop \
vim \
wget \
curl \
git \
htop \
network-manager \
spice-vdagent
# Ajout du dépôt XanMod et installation du kernel
d-i preseed/late_command string \
in-target mkdir -p /etc/apt/keyrings ; \
in-target wget -qO /etc/apt/keyrings/xanmod-archive-keyring.gpg https://dl.xanmod.org/archive.key ; \
in-target sh -c "echo 'deb [signed-by=/etc/apt/keyrings/xanmod-archive-keyring.gpg] http://deb.xanmod.org trixie main' > /etc/apt/sources.list.d/xanmod.list" ; \
in-target apt-get update ; \
in-target apt-get install -y linux-xanmod-x64v3
# Installation de GRUB
d-i grub-installer/only_debian boolean true
d-i grub-installer/with_other_os boolean true
d-i grub-installer/bootdev string default
### Finishing up the installation
# Demander à l'utilisateur de choisir où installer GRUB
d-i grub-installer/bootdev seen false
# Message indiquant que le redémarrage est en cours
d-i finish-install/reboot_in_progress note
d-i cdrom-detect/eject boolean true
d-i debian-installer/exit/reboot boolean true
### YunoHost Debconf (same than in yunohost/install_script)
slapd slapd/password1 password yunohost
slapd slapd/password2 password yunohost
slapd slapd/domain string yunohost.org
slapd shared/organization string yunohost.org
slapd slapd/allow_ldap_v2 boolean false
slapd slapd/invalid_config boolean true
slapd slapd/backend select MDB
postfix postfix/main_mailer_type select Internet Site
postfix postfix/mailname string /etc/mailname
mysql-server-5.5 mysql-server/root_password password yunohost
mysql-server-5.5 mysql-server/root_password_again password yunohost
mariadb-server-10.0 mysql-server/root_password password yunohost
mariadb-server-10.0 mysql-server/root_password_again password yunohost
nslcd nslcd/ldap-bindpw password
nslc nslcd/ldap-starttls boolean false
nslcd nslcd/ldap-reqcert select
nslcd nslcd/ldap-uris string ldap://localhost/
nslcd nslcd/ldap-binddn string
nslcd nslcd/ldap-base string dc=yunohost,dc=org
libnss-ldapd libnss-ldapd/nsswitch multiselect group, passwd, shadow
postsrsd postsrsd/domain string yunohost.org
### Avoid circular dependencies error
d-i preseed/early_command string apt-install debhelper || true