cloud-init/add-variable-to-forbid-tmp-dir.patch

65 lines
1.9 KiB
Diff
Raw Normal View History

2020-07-31 15:06:51 +08:00
From 224da46b2331b582577b86c3eb707f67d57800fb Mon Sep 17 00:00:00 2001
From: chengquan <chengquan3@huawei.com>
Date: Thu, 8 Aug 2019 16:15:31 +0800
Subject: [PATCH] cloud-init: add variable to forbid tmp dir
reason: add variable to forbid temporary directory
Signed-off-by: chengquan <chengquan3@huawei.com>
---
setup.py | 14 +++++++++++---
1 file changed, 11 insertions(+), 3 deletions(-)
2020-07-31 15:06:51 +08:00
2020-11-04 10:20:14 +08:00
diff --git a/setup.py b/setup.py
2023-07-12 15:58:59 +08:00
index 55b929a..34fb29b 100644
2020-11-04 10:20:14 +08:00
--- a/setup.py
+++ b/setup.py
2023-07-12 15:58:59 +08:00
@@ -90,6 +90,8 @@ def read_requires():
2020-11-04 10:20:14 +08:00
deps = subprocess.check_output(cmd)
return deps.decode("utf-8").splitlines()
2023-07-12 15:58:59 +08:00
2020-07-31 15:06:51 +08:00
+# add variable to forbid tmp dir
+num = 0
2023-07-12 15:58:59 +08:00
2020-07-31 15:06:51 +08:00
def render_tmpl(template, mode=None):
"""render template into a tmpdir under same dir as setup.py
2023-07-12 15:58:59 +08:00
@@ -110,7 +112,10 @@ def render_tmpl(template, mode=None):
2020-07-31 15:06:51 +08:00
return template
2023-07-12 15:58:59 +08:00
2020-07-31 15:06:51 +08:00
topdir = os.path.dirname(sys.argv[0])
- tmpd = tempfile.mkdtemp(dir=topdir, prefix=RENDERED_TMPD_PREFIX)
+ global num
+ os.mkdir(topdir + str(num))
+ tmpd = os.path.abspath(topdir + str(num))
+ num = num + 1
atexit.register(shutil.rmtree, tmpd)
bname = os.path.basename(template).rstrip(tmpl_ext)
fpath = os.path.join(tmpd, bname)
2023-07-12 15:58:59 +08:00
@@ -136,6 +141,9 @@ def render_tmpl(template, mode=None):
2020-07-31 15:06:51 +08:00
# return path relative to setup.py
return os.path.join(os.path.basename(tmpd), bname)
2023-07-12 15:58:59 +08:00
2020-07-31 15:06:51 +08:00
+def sort_files(file_list):
+ file_list.sort()
+ return file_list
2023-07-12 15:58:59 +08:00
2020-07-31 15:06:51 +08:00
# User can set the variant for template rendering
if "--distro" in sys.argv:
2023-07-12 15:58:59 +08:00
@@ -153,11 +161,11 @@ INITSYS_FILES = {
"systemd": [
render_tmpl(f)
for f in (
- glob("systemd/*.tmpl")
+ sort_files((glob('systemd/*.tmpl')
+ glob("systemd/*.service")
+ glob("systemd/*.socket")
+ glob("systemd/*.target")
- )
+ )))
if (is_f(f) and not is_generator(f))
],
"systemd.generators": [
2023-07-12 15:58:59 +08:00
--
2.27.0