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:
@@ -46,7 +46,7 @@ for filename in os.listdir(args_src):
|
|||||||
pattern = re.compile("^[a-z0-9]")
|
pattern = re.compile("^[a-z0-9]")
|
||||||
newFileForJam = []
|
newFileForJam = []
|
||||||
packageFiles = []
|
packageFiles = []
|
||||||
filesNotFound = False
|
errorsOccurred = False
|
||||||
with open(args_jamf) as f:
|
with open(args_jamf) as f:
|
||||||
for line in f:
|
for line in f:
|
||||||
pkg = line.strip()
|
pkg = line.strip()
|
||||||
@@ -75,14 +75,16 @@ with open(args_jamf) as f:
|
|||||||
if (greatestVersion == None):
|
if (greatestVersion == None):
|
||||||
print("not found: " + pkg)
|
print("not found: " + pkg)
|
||||||
newFileForJam.append(line)
|
newFileForJam.append(line)
|
||||||
filesNotFound = True
|
errorsOccurred = True
|
||||||
continue
|
continue
|
||||||
else:
|
else:
|
||||||
# found it, so hardlink it
|
# found it, so hardlink it
|
||||||
if not (os.path.exists(args_dst_packages + greatestVersion)):
|
if not (os.path.exists(args_dst_packages + greatestVersion)):
|
||||||
os.link(args_src + greatestVersion, args_dst_packages + greatestVersion)
|
os.link(args_src + greatestVersion, args_dst_packages + greatestVersion)
|
||||||
if ('packages/' + greatestVersion) not in packageFiles:
|
if ('packages/' + greatestVersion) in packageFiles:
|
||||||
packageFiles.append('packages/' + greatestVersion)
|
print("error: duplicated package: " + pkgname)
|
||||||
|
errorsOccurred = True
|
||||||
|
packageFiles.append('packages/' + greatestVersion)
|
||||||
# also hardlink the source package, if one exists
|
# also hardlink the source package, if one exists
|
||||||
srcpkg = greatestVersion.replace("-" + args_arch + ".hpkg",
|
srcpkg = greatestVersion.replace("-" + args_arch + ".hpkg",
|
||||||
"-source.hpkg").replace('-', '_source-', 1)
|
"-source.hpkg").replace('-', '_source-', 1)
|
||||||
@@ -93,7 +95,7 @@ with open(args_jamf) as f:
|
|||||||
packageFiles.append('packages/' + srcpkg)
|
packageFiles.append('packages/' + srcpkg)
|
||||||
newFileForJam.append("\t" + greatestVersion[:greatestVersion.rfind('-')] + "\n");
|
newFileForJam.append("\t" + greatestVersion[:greatestVersion.rfind('-')] + "\n");
|
||||||
|
|
||||||
if filesNotFound:
|
if errorsOccurred:
|
||||||
sys.exit(1)
|
sys.exit(1)
|
||||||
|
|
||||||
finalizedNewFile = "".join(newFileForJam).encode('UTF-8')
|
finalizedNewFile = "".join(newFileForJam).encode('UTF-8')
|
||||||
|
|||||||
Reference in New Issue
Block a user