From 6e69a63a4cabf3f34cc6a36e19bcfac5a09d3af4 Mon Sep 17 00:00:00 2001 From: Nulo Date: Sat, 18 Jun 2022 12:09:50 -0300 Subject: [PATCH] alpine: Usar comillas para todo y limpiar --- alpine.lua | 31 +++++++++++++++---------------- 1 file changed, 15 insertions(+), 16 deletions(-) diff --git a/alpine.lua b/alpine.lua index 64c885a..56a834d 100644 --- a/alpine.lua +++ b/alpine.lua @@ -5,39 +5,35 @@ local t = require("utils/templater") -- Returns nil when no failure, otherwise apk's status code function alpine.init_rootfs(path, alpine_base_version, alpine_version) - local status = os.execute(t("sudo rm -rf {{path}} && mkdir -p {{path}}", {path = path})) + local status = os.execute(t("sudo rm -rf '{{path}}' && mkdir -p '{{path}}'", {path = path})) if not (status == 0) then return status end local url = t("https://dl-cdn.alpinelinux.org/alpine/v{{base_version}}/releases/x86_64/alpine-minirootfs-{{version}}-x86_64.tar.gz", { base_version = alpine_base_version, version = alpine_version }) - local status = os.execute(t("cd {{path}} && wget --no-verbose -O- {{url}} | tar zx", { path = path, url = url })) + local status = os.execute(t("cd '{{path}}' && wget --no-verbose -O- '{{url}}' | tar zx", { path = path, url = url })) if not (status == 0) then return status end end function alpine.move_boot(path) - local status = os.execute(t("sudo rm -rf {{path}}/../boot && sudo mv {{path}}/boot {{path}}/../ && sudo mkdir {{path}}/boot", { + local status = os.execute(t("sudo rm -rf '{{path}}/../boot' && sudo mv '{{path}}/boot' '{{path}}/../' && sudo mkdir '{{path}}/boot'", { path = path, })) if not (status == 0) then return status end end function alpine.make_squashfs(path, output_path) - local status = os.execute(t("sudo mksquashfs {{path}} {{output_path}} -comp zstd -Xcompression-level 3 -noappend -quiet && sudo chown $(id -u):$(id -g) {{output_path}}", { + local status = os.execute(t("sudo mksquashfs '{{path}}' '{{output_path}}' -comp zstd -Xcompression-level 3 -noappend -quiet && sudo chown $(id -u):$(id -g) '{{output_path}}'", { path = path, output_path = output_path, })) if not (status == 0) then return status end - -- status = os.execute(t("qemu-img convert {{output_path}} {{output_path}}.qcow2 -O qcow2", { - -- output_path = output_path, - -- })) - -- if not (status == 0) then return status end end function alpine.mkdir(rootfs_path, path) local real_path = rootfs_path..path - local cmd = t("mkdir -p {{real_path}}", { + local cmd = t("mkdir -p '{{real_path}}'", { real_path = real_path, }) @@ -59,7 +55,7 @@ end function alpine.write_file(rootfs_path, path, content) local real_path = rootfs_path..path - local cmd = t("mkdir -p {{real_dirname}} && test -f {{real_path}} || exit 0 && sudo chown $(id -u) {{real_path}}", { + local cmd = t("mkdir -p '{{real_dirname}}' && test -f '{{real_path}}' || exit 0 && sudo chown $(id -u) '{{real_path}}'", { real_path = real_path, real_dirname = utils.dirname(real_path), }) @@ -78,7 +74,7 @@ end function alpine.symlink(rootfs_path, path, target) local real_path = rootfs_path..path - local cmd = t("mkdir -p {{real_dirname}} && ln -s {{target}} {{real_path}}", { + local cmd = t("mkdir -p '{{real_dirname}}' && ln -s '{{target}}' '{{real_path}}'", { real_path = real_path, target = target, real_dirname = utils.dirname(real_path), @@ -92,7 +88,7 @@ end function alpine.chmod(rootfs_path, path, perms) local real_path = rootfs_path..path - local cmd = t("chmod {{perms}} {{real_path}}", { + local cmd = t("chmod '{{perms}}' '{{real_path}}'", { real_path = real_path, perms = perms, }) @@ -114,17 +110,20 @@ function alpine.make_world(rootfs_path, packages) utils.join_table(packages, "\n")) if err then return err end - local status = os.execute("sudo apk upgrade --clean-protected --root "..rootfs_path) + local params = { rootfs_path = rootfs_path } + + local status = os.execute(t("sudo apk upgrade --clean-protected --root '{{rootfs_path}}'", + params)) if not (status == 0) then return status end - local status = os.execute(t("rm {{rootfs_path}}/etc/apk/cache", - { rootfs_path = rootfs_path })) + local status = os.execute(t("rm '{{rootfs_path}}/etc/apk/cache'", + params)) if not (status == 0) then return status end end -- Returns nil when no failure, otherwise status code function alpine.set_password(rootfs_path, user, password) - local status = os.execute(t("echo '{{password}}\n{{password}}' | sudo chroot {{rootfs_path}} passwd {{user}}", { + local status = os.execute(t("echo '{{password}}\n{{password}}' | sudo chroot '{{rootfs_path}}' passwd '{{user}}'", { password = password, rootfs_path = rootfs_path, user = user,