def chroot(path_to_install): path = Dir(path_to_install) os.system('mount -t proc proc {}\n'.format(path.full('/proc'))) os.system('mount --rbind /sys {}\n'.format(path.full('/sys'))) os.system('mount --rbind /dev {}\n'.format(path.full('/dev'))) os.chroot(path_to_install) os.system('source /etc/profile') os.system('export PS1="(chroot) $PS1"')
def unpack_stage3(path_to_install): path_to_stage3 = '/tmp/stage3-amd64-latest.tar.bz2' cmd = 'tar xvjpf ' + path_to_stage3 print_log('chdir ' + path_to_install) os.chdir(path_to_install) print_log('cleaning ... ') print_log('[rm -rf *]') os.system('rm -rf *') print_log('done') print_log('installing ... ') status, msg = subprocess.getstatusoutput(cmd) print_log(msg) print_log('status ' + str(status)) path = Dir(path_to_install) print_log('cp /etc/resolv.conf ' + path.full('etc/resolv.conf')) shutil.copy2('/etc/resolv.conf', path.full('etc/resolv.conf'))