Change-Id: I33dc7968ec9738c1a96f26bdb73f396db79049d9
Reviewed-on: http://photon-jenkins.eng.vmware.com:8082/3463
Reviewed-by: Anish Swaminathan <anishs@vmware.com>
Tested-by: Anish Swaminathan <anishs@vmware.com>
... | ... |
@@ -100,6 +100,7 @@ if __name__ == '__main__': |
100 | 100 |
parser.add_option("-i", "--image-name", dest="image_name") |
101 | 101 |
parser.add_option("-t", "--tools-bin-path", dest="tools_bin_path") |
102 | 102 |
parser.add_option("-b", "--build-scripts-path", dest="build_scripts_path") |
103 |
+ parser.add_option("-s", "--src-root", dest="src_root") |
|
103 | 104 |
|
104 | 105 |
(options, args) = parser.parse_args() |
105 | 106 |
utils = Utils() |
... | ... |
@@ -216,13 +217,15 @@ if __name__ == '__main__': |
216 | 216 |
tgzout.add(raw_image, arcname=os.path.basename(raw_image)) |
217 | 217 |
tgzout.close() |
218 | 218 |
elif config['artifacttype'] == 'vhd': |
219 |
- vhdname = img_path + '/photon-' + options.image_name + '-' + photon_release_ver + '-' + photon_build_num + '.vhd' |
|
219 |
+ relrawpath = os.path.relpath(raw_image, options.src_root) |
|
220 |
+ vhdname = os.path.dirname(relrawpath) + '/photon-' + options.image_name + '-' + photon_release_ver + '-' + photon_build_num + '.vhd' |
|
220 | 221 |
print "Converting raw disk to vhd ..." |
221 |
- info_output=utils.runshellcommand("docker run -v /:/mnt:rw anishs/qemu-img info -f raw --output json {}".format('/mnt' + raw_image)) |
|
222 |
+ info_output=utils.runshellcommand("docker run -v {}:/mnt:rw anishs/qemu-img info -f raw --output json {}".format(options.src_root, '/mnt/' + relrawpath)) |
|
222 | 223 |
mbsize = 1024 * 1024 |
223 |
- mbroundedsize = (int(json.loads(info_output)["virtual-size"])/mbsize + 1) * mbsize |
|
224 |
- utils.runshellcommand("docker run -v /:/mnt:rw anishs/qemu-img resize -f raw {} {}".format('/mnt' + raw_image, mbroundedsize)) |
|
225 |
- utils.runshellcommand("docker run -v /:/mnt:rw anishs/qemu-img convert {} -O vpc -o subformat=fixed {}".format('/mnt' + raw_image, '/mnt' + vhdname)) |
|
224 |
+ #qemu-img adds an extra 512 bytes to the raw image |
|
225 |
+ mbroundedsize = ((int(json.loads(info_output)["virtual-size"])/mbsize + 1) * mbsize) - 512 |
|
226 |
+ utils.runshellcommand("docker run -v {}:/mnt:rw anishs/qemu-img resize -f raw {} {}".format(options.src_root, '/mnt/' + relrawpath, mbroundedsize)) |
|
227 |
+ utils.runshellcommand("docker run -v {}:/mnt:rw anishs/qemu-img convert {} -O vpc -o subformat=fixed,force_size {}".format(options.src_root, '/mnt/' + relrawpath, '/mnt/' + vhdname)) |
|
226 | 228 |
elif config['artifacttype'] == 'ova': |
227 | 229 |
create_ova_image(raw_image, options.tools_bin_path, options.build_scripts_path + '/' + options.image_name, config) |
228 | 230 |
if 'customartifacts' in config: |