install: fix crash if /etc/skel is missing (MR 2001)

Create an empty home dir if /etc/skel does not exist in the target
rootfs. Due to changes in packaging, this can happen now, previously
/etc/skel would always have existed.
This commit is contained in:
Oliver Smith 2020-12-07 08:56:41 +01:00
parent 799f4b925b
commit 2401423e2b
No known key found for this signature in database
GPG Key ID: 5AE7F5513E0885CB
1 changed files with 4 additions and 1 deletions

View File

@ -178,7 +178,10 @@ def create_home_from_skel(args):
rootfs = args.work + "/chroot_native/mnt/install"
homedir = rootfs + "/home/" + args.user
pmb.helpers.run.root(args, ["mkdir", rootfs + "/home"])
pmb.helpers.run.root(args, ["cp", "-a", rootfs + "/etc/skel", homedir])
if os.path.exists(f"{rootfs}/etc/skel"):
pmb.helpers.run.root(args, ["cp", "-a", f"{rootfs}/etc/skel", homedir])
else:
pmb.helpers.run.root(args, ["mkdir", homedir])
pmb.helpers.run.root(args, ["chown", "-R", "10000", homedir])