From d59ac74f3a48efded86929a34c9e1852e9bb8d04 Mon Sep 17 00:00:00 2001 From: Jarrod Johnson Date: Mon, 15 Nov 2021 11:34:34 -0500 Subject: [PATCH] Support relative path on < include For pkglist and syncfile, detect relative path and interpret relative to the file that does the include. --- confluent_server/confluent/syncfiles.py | 7 ++++++- imgutil/imgutil | 5 +++++ 2 files changed, 11 insertions(+), 1 deletion(-) diff --git a/confluent_server/confluent/syncfiles.py b/confluent_server/confluent/syncfiles.py index f2071fa2..70558a57 100644 --- a/confluent_server/confluent/syncfiles.py +++ b/confluent_server/confluent/syncfiles.py @@ -47,7 +47,12 @@ def get_entries(filename): if ent in ('APPENDONCE:', 'MERGE:', 'REPLACE:'): secname = ent if ent[0] == '<': - for subent in get_entries(ent[1:]): + subfilename = ent[1:] + if subfilename[-1] == '>': + subfilename = subfilename[:-1] + if subfilename[0] != '/': + subfilename = os.path.join(os.path.dirname(filename), subfilename) + for subent in get_entries(subfilename): yield subent yield secname else: diff --git a/imgutil/imgutil b/imgutil/imgutil index a944cc1e..416266ad 100644 --- a/imgutil/imgutil +++ b/imgutil/imgutil @@ -424,6 +424,11 @@ class OsHandler(object): if not pkg: continue if pkg[0] == '<': # Include from specified file + subfilename = pkg[1:] + if subfilename[-1] == '>': + subfilename = subfilename[:-1] + if subfilename[0] != '/': + subfilename = os.path.join(os.path.dirname(pkglistfile), subfilename) retpkgs.extend(self.list_packages(pkg[1:])) else: retpkgs.append(pkg)