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.
This commit is contained in:
parent
f0a567c451
commit
1499a3026d
@ -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')
|
||||
|
Loading…
Reference in New Issue
Block a user