chroot to install packages

Himanshu Garg hgarg.india at gmail.com
Thu Nov 14 04:29:55 EST 2013


I have done it but having a problem.

I have written a script

os.chroot("/lxc/test_container/rootfs")
subprocess.call(["apt-key", "add", "/root/package.key"])
subprocess.call(["apt-get", "update"])

os._exit(0)

Now, this script is working properly, entering the chroot jail and adding the apt key, but when the "apt-get update" command runs, it starts but throws me an error:
"E: Unable to change to (unreachable)/lxc/test_container/ - chdir (2: No such file or directory)"

However, when I manually chroot to "/lxc/test_container/rootfs" and run the update command, then it works perfectly with no errors. 

Why the apt-get update command require to go to my "/lxc/test_container" when run in script.



More information about the Python-list mailing list