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