src/tools: hardlink_packages: Autodetect arch from jam remote repository file
Change-Id: Iccbcdb3105bf7762259493b9852446a3c83fbd2f
This commit is contained in:
parent
6a379485c5
commit
2439b2b9dc
@ -10,12 +10,21 @@
|
||||
import sys, os, subprocess, re, hashlib
|
||||
from pkg_resources import parse_version
|
||||
|
||||
if len(sys.argv) != 5:
|
||||
print("usage: hardlink_packages.py [arch] [jam RemotePackageRepository file] "
|
||||
# Detect architecture from provided jam remote package repo file
|
||||
def probe_architecture(jamf):
|
||||
text = ""
|
||||
with open(jamf) as f:
|
||||
for readline in f:
|
||||
line_strip = readline.strip()
|
||||
text += line_strip
|
||||
return text.split(":")[1].strip()
|
||||
|
||||
if len(sys.argv) != 4:
|
||||
print("usage: hardlink_packages.py [jam RemotePackageRepository file] "
|
||||
+ "[prebuilt packages directory] [destination root directory]")
|
||||
print("note that the [jam RemotePackageRepository file] will be modified.")
|
||||
print("note that [target directory] is assumed to have a 'packages' subdirectory, "
|
||||
+ " and a repo.info.template file (using $ARCH$)")
|
||||
print(" note that the [jam RemotePackageRepository file] will be modified.")
|
||||
print(" note that [target directory] is assumed to have a 'packages' subdirectory, "
|
||||
+ "and a repo.info.template file (using $ARCH$)")
|
||||
sys.exit(1)
|
||||
|
||||
if subprocess.run(['package_repo'], None, None, None,
|
||||
@ -23,10 +32,12 @@ if subprocess.run(['package_repo'], None, None, None,
|
||||
print("package_repo command does not seem to exist.")
|
||||
sys.exit(1)
|
||||
|
||||
args_arch = sys.argv[1]
|
||||
args_jamf = sys.argv[2]
|
||||
args_src = sys.argv[3]
|
||||
args_dst = sys.argv[4]
|
||||
args_jamf = sys.argv[1]
|
||||
args_src = sys.argv[2]
|
||||
args_dst = sys.argv[3]
|
||||
arch = probe_architecture(args_jamf)
|
||||
|
||||
print("Detected Architecture: " + arch)
|
||||
|
||||
if not args_dst.endswith('/'):
|
||||
args_dst = args_dst + '/'
|
||||
@ -37,7 +48,7 @@ args_dst_packages = args_dst + 'packages/'
|
||||
|
||||
packageVersions = []
|
||||
for filename in os.listdir(args_src):
|
||||
if (not (filename.endswith("-" + args_arch + ".hpkg")) and
|
||||
if (not (filename.endswith("-" + arch + ".hpkg")) and
|
||||
not (filename.endswith("-any.hpkg"))):
|
||||
continue
|
||||
packageVersions.append(filename)
|
||||
@ -83,7 +94,7 @@ with open(args_jamf) as f:
|
||||
if ('packages/' + greatestVersion) not in packageFiles:
|
||||
packageFiles.append('packages/' + greatestVersion)
|
||||
# also hardlink the source package, if one exists
|
||||
srcpkg = greatestVersion.replace("-" + args_arch + ".hpkg",
|
||||
srcpkg = greatestVersion.replace("-" + arch + ".hpkg",
|
||||
"-source.hpkg").replace('-', '_source-', 1)
|
||||
if os.path.exists(args_src + srcpkg):
|
||||
if not os.path.exists(args_dst_packages + srcpkg):
|
||||
@ -112,7 +123,7 @@ os.symlink('../packages', repodir + 'packages')
|
||||
with open(args_dst + 'repo.info.template', 'r') as ritf:
|
||||
repoInfoTemplate = ritf.read()
|
||||
|
||||
repoInfoTemplate = repoInfoTemplate.replace("$ARCH$", args_arch)
|
||||
repoInfoTemplate = repoInfoTemplate.replace("$ARCH$", arch)
|
||||
with open(repodir + 'repo.info', 'w') as rinf:
|
||||
rinf.write(repoInfoTemplate)
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user