From 1499a3026d5eb091d922681298767199f1fd64e6 Mon Sep 17 00:00:00 2001 From: Augustin Cavalier Date: Tue, 19 Oct 2021 16:40:53 -0400 Subject: [PATCH] tools/hardlink_packages: Trigger an error if there are duplicate package entries. This would have caught a user error on my part in the last build-packages update. --- src/tools/hardlink_packages.py | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/src/tools/hardlink_packages.py b/src/tools/hardlink_packages.py index 125287b389..701b618b95 100755 --- a/src/tools/hardlink_packages.py +++ b/src/tools/hardlink_packages.py @@ -46,7 +46,7 @@ for filename in os.listdir(args_src): pattern = re.compile("^[a-z0-9]") newFileForJam = [] packageFiles = [] -filesNotFound = False +errorsOccurred = False with open(args_jamf) as f: for line in f: pkg = line.strip() @@ -75,14 +75,16 @@ with open(args_jamf) as f: if (greatestVersion == None): print("not found: " + pkg) newFileForJam.append(line) - filesNotFound = True + errorsOccurred = True continue else: # found it, so hardlink it if not (os.path.exists(args_dst_packages + greatestVersion)): os.link(args_src + greatestVersion, args_dst_packages + greatestVersion) - if ('packages/' + greatestVersion) not in packageFiles: - packageFiles.append('packages/' + greatestVersion) + if ('packages/' + greatestVersion) in packageFiles: + print("error: duplicated package: " + pkgname) + errorsOccurred = True + packageFiles.append('packages/' + greatestVersion) # also hardlink the source package, if one exists srcpkg = greatestVersion.replace("-" + args_arch + ".hpkg", "-source.hpkg").replace('-', '_source-', 1) @@ -93,7 +95,7 @@ with open(args_jamf) as f: packageFiles.append('packages/' + srcpkg) newFileForJam.append("\t" + greatestVersion[:greatestVersion.rfind('-')] + "\n"); -if filesNotFound: +if errorsOccurred: sys.exit(1) finalizedNewFile = "".join(newFileForJam).encode('UTF-8')