82abba92fd5722d7083da2dc665f99c0f687fcd7
[invirt/packages/invirt-autoinstaller.git] / files / usr / sbin / sipb-xen-make-iso
1 #!/usr/bin/env python
2
3 import sys
4 import os
5 import shutil
6 import tempfile
7 from subprocess import call
8
9 def make_debian_cd(basetree, passhash):
10   old_preseed = file(os.path.join(basetree, 'preseed.cfg'))
11   tmptree = tempfile.mkdtemp('', 'auto-install.', '/tmp')
12   cdtree = os.path.join(tmptree, 'cdrom')
13   shutil.copytree(os.path.join(basetree, 'cdrom'), cdtree, symlinks=True)
14   new_preseed = file(os.path.join(cdtree, 'preseed.cfg'), 'w')
15   new_preseed.write(old_preseed.read())
16   new_preseed.write('d-i passwd/root-password-crypted password '+passhash+'\n')
17   new_preseed.close()
18   output_iso = os.path.join(tmptree, 'install.iso')
19   call('''mkisofs -r -V "SIPB-Xen_Custom_Install_CD" -cache-inodes -J -l
20            -b isolinux/isolinux.bin -c isolinux/boot.cat
21            -no-emul-boot -boot-load-size 4 -boot-info-table'''.split()
22        + ['-o', output_iso, cdtree])
23   return output_iso
24
25 if __name__ == '__main__':
26   print make_debian_cd(*sys.argv[1:])