#!/usr/bin/env dmm-perform-recipe

module_path:
- local

global_settings:
    name: &name Debian
    version: &version bookworm (bookworm)
    description: &description Live Xfce installer image (bookworm)
    chroot: &chroot /tmp/debmower/disk
    live-media-path: &live-media-path /tmp/debmower/live-media
    squashfs: &squashfs /tmp/debmower/filesystem.squashfs
    architecture: &architecture amd64
    workspace: /tmp/debmower/
    release: &release bookworm


recipe:
    install_debian:
        module: debootstrap
        destination: *chroot
        release: *release
        mirror: http://deb.debian.org/debian
        debootstrapopts: ''
    setup_network:
        module: networking
        chroot: *chroot
        hostname: live
    apt_setup:
        module: aptsetup
        chroot: *chroot
        sources-list: |
            deb http://deb.debian.org/debian bookworm main
        sources-file: /etc/apt/sources.list
        update-sources: True
    setup_bind_mounts:
        module: mountfs
        partitions:
            - dev:
              source: /dev
              mountpoint: /tmp/debmower/disk/dev
              mountopts: ''
              fstype: devtmpfs
            - proc:
              source: /proc
              mountpoint: /tmp/debmower/disk/proc
              mountopts: ''
              fstype: proc
            - sys:
              source: /sys
              mountpoint: /tmp/debmower/disk/sys
              mountopts: ''
              fstype: sysfs
    install_main_meta:
        module: aptpkg
        action: install
        #packages: live-task-xfce
        packages: xfce4 lightdm
        clean_cache: True
        download_only: False
    setup_live_packages:
        module: aptpkg
        action: install
        packages: calamares calamares-settings-debian live-boot live-config-systemd live-tools user-setup live-config live-boot-initramfs-tools grub-common live-task-recommended live-task-localisation grub-common grub-efi-amd64 grub-pc-bin
        clean_cache: True
        download_only: False
    install_linux:
        module: linux
        chroot: *chroot
        package: linux-image-amd64
    download_pool_packages:
        module: aptpkg
        action: install
        packages: grub-efi efibootmgr grub-efi-amd64 grub-efi-amd64-bin grub-pc-bin grub-pc
        clean_cache: False
        download_only: True
    setup_package_pool:
        module: reprepro
        prepend_path: *chroot
        package_path: /var/cache/apt/archives
        architectures: *architecture
        description: *description
        components: main
        live-media-path: *live-media-path
        clean_package_path: True
    clean_apt:
        module: aptsetup
        chroot: *chroot
        sources-list: ''
        sources-file: /etc/apt/sources.list
        update-sources: True
    unmount_filesystems:
        module: umountfs
        mounts:
            - proc:
              mountpoint: /tmp/debmower/disk/proc
            - sys:
              mountpoint: /tmp/debmower/disk/sys
            - dev:
              mountpoint: /tmp/debmower/disk/dev
    make_squashfs:
        module: squashfs
        action: make-squashfs
        blocksize: 262144
        compression-method: zstd
        source: *chroot
        destination: *squashfs
        options: -noappend
    prepare_live_environment:
        module: livedisk
        template_dir: './debian_template'
        update-initramfs: True
    generate_readme:
        module: readme
        template: ./debian_template/README.txt
        destination: *live-media-path
        filename: README.txt
        name: *name
        version: *version
    make_iso_fs:
        module: grub
        action: mkrescue

