File: livedisk.py

package info (click to toggle)
python3-dmm 0.1.3-2
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 540 kB
  • sloc: python: 441; makefile: 2
file content (45 lines) | stat: -rw-r--r-- 1,274 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
"""
livedisk functions for for dmm.
"""

import pathlib
import os
from shutil import copyfile

def init():
    """
    Initialization for livedisk module
    """


def recipe_run(config, globalconf):
    """
    Perform actions for livedisk module
    """
    # Create working directory for live media
    path = pathlib.Path(globalconf['live-media-path'] + "/live")
    path.mkdir(parents=True, exist_ok=True)

    # copy squashfs, kernel and initramfs into livedir
    print("Current working directory is " + os.getcwd())
    squashfs = globalconf['squashfs']
    kernel = globalconf['chroot'] +  "/boot/vmlinuz*"
    initrd = globalconf['chroot'] + "/boot/initrd*"
    livepath = globalconf['live-media-path'] + "/live/"
    os.system("cp %s %s" % (squashfs, livepath + "/filesystem.squashfs"))
    os.system("cp %s %s" % (kernel, livepath + "/vmlinuz"))
    os.system("cp %s %s" % (initrd, livepath + "/initrd.gz"))

    # Copy template directory to live media
    teamplate_dir = config['template_dir']
    os.system("cp -r %s/ %s" % (config['template_dir'] + "/*", globalconf['live-media-path']))

    # Update initramfs
    if config['update-initramfs']:
        os.system("chroot %s update-initramfs -u" % globalconf['chroot'])

    # TODO: create md5sums



init()