From 3b240e46f789cd12ff8d7a30febeffea6c21e16c Mon Sep 17 00:00:00 2001 From: Steffen Pankratz Date: Fri, 26 Jul 2019 23:45:24 +0200 Subject: [PATCH] fix deprecation warnings in regular expressions (!1804) From https://docs.python.org/3/library/re.html "Backslashes are not handled in any special way in a string literal prefixed with 'r'." Signed-off-by: Steffen Pankratz --- pmb/config/init.py | 2 +- pmb/install/_install.py | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/pmb/config/init.py b/pmb/config/init.py index e3e92be1..278b0503 100644 --- a/pmb/config/init.py +++ b/pmb/config/init.py @@ -357,7 +357,7 @@ def frontend(args): " or \"none\"") extra = pmb.helpers.cli.ask(args, "Extra packages", None, args.extra_packages, - validation_regex="^([-.+\w]+)(,[-.+\w]+)*$") + validation_regex=r"^([-.+\w]+)(,[-.+\w]+)*$") cfg["pmbootstrap"]["extra_packages"] = extra # Configure timezone info diff --git a/pmb/install/_install.py b/pmb/install/_install.py index cb8dbf0c..a4a022db 100644 --- a/pmb/install/_install.py +++ b/pmb/install/_install.py @@ -170,7 +170,7 @@ def configure_apk(args): pmb.helpers.run.root(args, ["cp", key, rootfs + "/etc/apk/keys/"]) # Disable pmbootstrap repository - pmb.helpers.run.root(args, ["sed", "-i", "/\/mnt\/pmbootstrap-packages/d", + pmb.helpers.run.root(args, ["sed", "-i", r"/\/mnt\/pmbootstrap-packages/d", rootfs + "/etc/apk/repositories"]) pmb.helpers.run.user(args, ["cat", rootfs + "/etc/apk/repositories"]) @@ -281,7 +281,7 @@ def setup_hostname(args): suffix = "rootfs_" + args.device pmb.chroot.root(args, ["sh", "-c", "echo " + shlex.quote(hostname) + " > /etc/hostname"], suffix) - regex = ("s/^127\.0\.0\.1.*/127.0.0.1\t" + re.escape(hostname) + + regex = (r"s/^127\.0\.0\.1.*/127.0.0.1\t" + re.escape(hostname) + " localhost.localdomain localhost/") pmb.chroot.root(args, ["sed", "-i", "-e", regex, "/etc/hosts"], suffix)