summaryrefslogtreecommitdiffstats
path: root/meta/classes-global
diff options
context:
space:
mode:
authorAlexander Kanavin <alex.kanavin@gmail.com>2024-01-29 19:06:29 +0100
committerRichard Purdie <richard.purdie@linuxfoundation.org>2024-02-02 11:06:17 +0000
commit4584746c1acaea848d1ee0329cefa2a51b5049a7 (patch)
tree4f9d0fefe501314cd06c46cc14af9d71d4a1c10a /meta/classes-global
parent43f9098a69593dfcc1797b5d6552ddd86cffd262 (diff)
downloadpoky-4584746c1acaea848d1ee0329cefa2a51b5049a7.tar.gz
classes/package_rpm: correctly escape percent characters
This many characters doesn't work with rpm 4.19 packaging (as shown by nodejs recipes), and per documentation a single escape is enough: https://github.com/rpm-software-management/rpm/blob/rpm-4.19.x/docs/manual/spec.md#shell-globbing It also should be done in a function, and just before writing out the corrected filename to .spec, not earlier where the path may still be needed for file operations (such as gettings file attributes). (From OE-Core rev: 6d9fe2623c37e405a80acf71633f7291ecdde533) Signed-off-by: Alexander Kanavin <alex@linutronix.de> Signed-off-by: Alexandre Belloni <alexandre.belloni@bootlin.com> Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
Diffstat (limited to 'meta/classes-global')
-rw-r--r--meta/classes-global/package_rpm.bbclass16
1 files changed, 8 insertions, 8 deletions
diff --git a/meta/classes-global/package_rpm.bbclass b/meta/classes-global/package_rpm.bbclass
index e0f4de42a1..819ee50278 100644
--- a/meta/classes-global/package_rpm.bbclass
+++ b/meta/classes-global/package_rpm.bbclass
@@ -216,10 +216,12 @@ python write_specfile () {
216 raise e 216 raise e
217 return "%attr({:o},{},{}) ".format(mode, owner, group) 217 return "%attr({:o},{},{}) ".format(mode, owner, group)
218 218
219 def escape_chars(p):
220 return p.replace("%", "%%")
221
219 path = rootpath.replace(walkpath, "") 222 path = rootpath.replace(walkpath, "")
220 if path.endswith("DEBIAN") or path.endswith("CONTROL"): 223 if path.endswith("DEBIAN") or path.endswith("CONTROL"):
221 continue 224 continue
222 path = path.replace("%", "%%%%%%%%")
223 225
224 # Treat all symlinks to directories as normal files. 226 # Treat all symlinks to directories as normal files.
225 # os.walk() lists them as directories. 227 # os.walk() lists them as directories.
@@ -238,29 +240,27 @@ python write_specfile () {
238 for dir in dirs: 240 for dir in dirs:
239 if dir == "CONTROL" or dir == "DEBIAN": 241 if dir == "CONTROL" or dir == "DEBIAN":
240 continue 242 continue
241 dir = dir.replace("%", "%%%%%%%%")
242 p = path + '/' + dir 243 p = path + '/' + dir
243 # All packages own the directories their files are in... 244 # All packages own the directories their files are in...
244 target.append(get_attr(dir) + '%dir "' + p + '"') 245 target.append(get_attr(dir) + '%dir "' + escape_chars(p) + '"')
245 else: 246 else:
246 # packages own only empty directories or explict directory. 247 # packages own only empty directories or explict directory.
247 # This will prevent the overlapping of security permission. 248 # This will prevent the overlapping of security permission.
248 attr = get_attr(path) 249 attr = get_attr(path)
249 if path and not files and not dirs: 250 if path and not files and not dirs:
250 target.append(attr + '%dir "' + path + '"') 251 target.append(attr + '%dir "' + escape_chars(path) + '"')
251 elif path and path in dirfiles: 252 elif path and path in dirfiles:
252 target.append(attr + '%dir "' + path + '"') 253 target.append(attr + '%dir "' + escape_chars(path) + '"')
253 254
254 for file in files: 255 for file in files:
255 if file == "CONTROL" or file == "DEBIAN": 256 if file == "CONTROL" or file == "DEBIAN":
256 continue 257 continue
257 file = file.replace("%", "%%%%%%%%")
258 attr = get_attr(file) 258 attr = get_attr(file)
259 p = path + '/' + file 259 p = path + '/' + file
260 if conffiles.count(p): 260 if conffiles.count(p):
261 target.append(attr + '%config "' + p + '"') 261 target.append(attr + '%config "' + escape_chars(p) + '"')
262 else: 262 else:
263 target.append(attr + '"' + p + '"') 263 target.append(attr + '"' + escape_chars(p) + '"')
264 264
265 # Prevent the prerm/postrm scripts from being run during an upgrade 265 # Prevent the prerm/postrm scripts from being run during an upgrade
266 def wrap_uninstall(scriptvar): 266 def wrap_uninstall(scriptvar):