Skip to content

Commit 42f618c

Browse files
centos 6/7 builds with updated url mangling
1 parent ceeac4c commit 42f618c

5 files changed

+45
-40
lines changed

build_linux_baselines.py

+19-12
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,8 @@ def build_base(packer_var_file, common_vars, packerfile, replace_existing, vmSer
1616
TEMP_DIR="tmp"
1717

1818
vm_name = packer_var_file.strip(".json")
19+
if "-server" in vm_name:
20+
vm_name = vm_name[:vm_name.index("-server")]
1921

2022
temp_path = os.path.join("..", "..", TEMP_DIR, prependString + vm_name)
2123

@@ -109,22 +111,27 @@ def main(argv):
109111

110112
vm_server = serverHelper(esxi_file)
111113

112-
for os_dir in os.listdir("boxcutter"):
113-
common_var_file = os.path.join("linux_vars", os_dir + "_common.json")
114-
with open(os.path.join("", common_var_file)) as common_var_source:
115-
common_vars = json.load(common_var_source)
114+
os.chdir("boxcutter")
116115

117-
os.chdir(os.path.join("boxcutter", os_dir))
118-
packer_file = os_dir + ".json"
116+
for os_dir in os.listdir("."):
117+
if os.path.isdir(os.path.join(".", os_dir)):
118+
common_var_file = os.path.join("..", "linux_vars", os_dir + "_common.json")
119+
with open(os.path.join("", common_var_file)) as common_var_source:
120+
common_vars = json.load(common_var_source)
119121

120-
targets = []
121-
for pattern in common_vars['file_patterns']:
122-
targets.extend(glob.glob(pattern))
122+
os.chdir(os.path.join("", os_dir))
123+
packer_file = os_dir + ".json"
123124

124-
for target in tqdm(targets):
125-
build_base(target, common_vars, packer_file, replace_existing=replace_vms, vmServer=vm_server, prependString=prependString)
125+
targets = []
126+
for pattern in common_vars['file_patterns']:
127+
print pattern
128+
targets.extend(glob.glob(pattern))
126129

127-
os.chdir("../../")
130+
print "\nBuilding " + str(len(targets)) + " " + os_dir.capitalize() + " baselines:"
131+
for target in tqdm(targets):
132+
build_base(target, common_vars, packer_file, replace_existing=replace_vms, vmServer=vm_server, prependString=prependString)
133+
134+
os.chdir("../")
128135

129136
return True
130137

lib/packerMod.py

+17-20
Original file line numberDiff line numberDiff line change
@@ -58,30 +58,27 @@ def update_linux_config(self, template):
5858
})
5959
break
6060

61-
def update_url(self, template): #this could be a lot better, I'll think on it
62-
if 'centos' in template['vm_name']:
63-
url = template['update_url_template'] + template['iso_url'][template['iso_url'].index("centos"):]
64-
else:
65-
version = re.search('(\d\d\.\d\d\.\d)', template['iso_name'])
61+
def update_url(self, template):
62+
63+
base = template['update_url_template']
64+
65+
if "VERSION" in template['update_url_template']: # this essentially just deals with ubuntu url's (or other difficult ones that pop up)
66+
version = re.search('\d\d\.\d\d\.\d', template['iso_name'])
6667
if version:
67-
v = version.group(0)
68-
url = '/'.join([template['update_url_template'], v, template['iso_name']])
68+
base = base[:base.index("VERSION")] + version.group(0)
6969
else:
70-
version = re.search('(\d\d\.\d\d)', template['iso_name'])
71-
if version:
72-
v = version.group(0)
73-
if 'live' in template['iso_name']: # handles more recent releases of ubuntu
74-
url = '/'.join([template['update_url_template'], v, template['iso_name']])
75-
else:
76-
v = v + ".0"
77-
url = '/'.join([template['update_url_template'], v, template['iso_name']])
70+
version = re.search('\d\d.\d\d', template['iso_name'])
71+
if version and 'live' in template['iso_name']:
72+
version = version.group(0)
7873
else:
79-
version = re.search('\d\d', template['vm_name'])
80-
v = version.group(0)
81-
url = '/'.join([template['update_url_template'], version.group(0), "Server/x86_64/iso", template['iso_name']])
82-
74+
version = version.group(0) + ".0"
75+
base = base[:base.index("VERSION")] + version
76+
url = '/'.join([base, template['iso_name']])
77+
else: # this should handle all other os url's
78+
url = '/'.join([base, template['iso_url'][template['iso_url'].index(template['url_base_common'])+len(template['url_base_common']):]])
79+
8380
template.update({
84-
"iso_url": url
81+
"iso_url": url
8582
})
8683

8784

linux_vars/centos_common.json

+4-5
Original file line numberDiff line numberDiff line change
@@ -9,12 +9,11 @@
99
"custom_script": "../../scripts/centos_customs/centos_setup.sh",
1010
"vmware_script": "../../scripts/centos_customs/centos_vmware.sh",
1111
"cleanup_script": "script/cleanup.sh",
12-
"update_url_template": "http://repos-lax.psychz.net/",
12+
"update_url_template": "http://repos-lax.psychz.net/centos",
13+
"url_base_common": "/centos/",
1314
"file_patterns": [
14-
"centos[123456789].json"
15-
],
16-
"boot_command": [
17-
"<up><wait><tab> text ks=hd:fd0:/ks.cfg<enter>"
15+
"centos[1-9].json"
1816
],
17+
"boot_command": "<up><wait><tab> text ks=hd:fd0:/ks.cfg<enter>",
1918
"kickstart": "ks.cfg"
2019
}

linux_vars/fedora_common.json

+3-2
Original file line numberDiff line numberDiff line change
@@ -9,9 +9,10 @@
99
"cleanup_script": "../../scripts/fedora_customs/fedora_cleanup.sh",
1010
"http_directory": "http",
1111
"update_url_template": "https://archives.fedoraproject.org/pub/archive/fedora/linux/releases",
12+
"url_base_common": "/releases/",
1213
"file_patterns": [
13-
"fedora[23456789][0123456789].json",
14-
"fedora[23456789][0123456789]-server.json"
14+
"fedora[1-9][1-9].json",
15+
"fedora[1-9]*-server.json"
1516
],
1617
"boot_command": "<tab> linux text biosdevname=0 ks=hd:fd0:/{{ user `kickstart` }}<enter><enter>"
1718
}

linux_vars/ubuntu_common.json

+2-1
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,8 @@
1010
"minimize_script": "../../scripts/ubuntu_customs/ubuntu_minimize.sh",
1111
"vmware_script": "../../scripts/ubuntu_customs/ubuntu_vmware.sh",
1212
"cleanup_script": "script/cleanup.sh",
13-
"update_url_template": "http://old-releases.ubuntu.com/releases",
13+
"update_url_template": "http://old-releases.ubuntu.com/releases/VERSION",
14+
"url_base_common": ".com/",
1415
"file_patterns": [
1516
"ubuntu1[468]04.json"
1617
]

0 commit comments

Comments
 (0)