22 lines
652 B
Python
22 lines
652 B
Python
import logging, os, tempfile
|
|
import os.path as path
|
|
|
|
|
|
def make_chroot(configdir):
|
|
# Create directories
|
|
basedir = tempfile.mkdtemp()
|
|
rootdir = path.join(basedir, "root")
|
|
logging.info(f"created temporary directory in {basedir}")
|
|
|
|
# Initialize base-devel packages
|
|
pacman = path.join(configdir, "pacman.conf")
|
|
makepkg = path.join(configdir, "makepkg.conf")
|
|
r = os.popen(f"mkarchroot -C {pacman} -M {makepkg} {rootdir} base-devel")
|
|
logging.debug(r.read())
|
|
|
|
# Make sure everything is up-to-date
|
|
r = os.popen(f"arch-nspawn {rootdir} pacman -Syu")
|
|
logging.debug(r.read())
|
|
|
|
logging.info("chroot initialized")
|