Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.python > #59356

Re: chroot to install packages

References <510a8652-1097-4327-9dda-56454142cda4@googlegroups.com>
Date 2013-11-14 10:40 +1100
Subject Re: chroot to install packages
From Chris Angelico <rosuav@gmail.com>
Newsgroups comp.lang.python
Message-ID <mailman.2562.1384386029.18130.python-list@python.org> (permalink)

Show all headers | View raw


On Thu, Nov 14, 2013 at 1:31 AM, Himanshu Garg <hgarg.india@gmail.com> wrote:
> I am writing a python script to run chroot command to chroot to a linux distro and then run commands.  How can I do this, as after chrooting, the script runs the commands relative to the outside not inside the chrooted env?

Probably the easiest way to do this is to divide your script into two
pieces: one piece runs inside the chroot, the other doesn't. Then you
have the "outer" script invoke the "inner" script as a separate
process. When the inner process terminates, the outer continues, and
since the outer wasn't chrooted, it's now running commands relative to
the outside.

One convenient way to manage this is to have one script that invokes
itself with arguments. Another way is to have two actually separate
script files. It really depends how much work you're doing in each
half.

ChrisA

Back to comp.lang.python | Previous | NextPrevious in thread | Next in thread | Find similar | Unroll thread


Thread

chroot to install packages Himanshu Garg <hgarg.india@gmail.com> - 2013-11-13 06:31 -0800
  Re: chroot to install packages Chris Angelico <rosuav@gmail.com> - 2013-11-14 10:40 +1100
    Re: chroot to install packages Himanshu Garg <hgarg.india@gmail.com> - 2013-11-13 17:52 -0800
      Re: chroot to install packages Chris Angelico <rosuav@gmail.com> - 2013-11-14 13:00 +1100
      Re: chroot to install packages Steven D'Aprano <steve+comp.lang.python@pearwood.info> - 2013-11-14 02:12 +0000
        Re: chroot to install packages Chris Angelico <rosuav@gmail.com> - 2013-11-14 13:26 +1100
  Re: chroot to install packages Himanshu Garg <hgarg.india@gmail.com> - 2013-11-14 01:29 -0800
    Re: chroot to install packages Chris Angelico <rosuav@gmail.com> - 2013-11-14 20:32 +1100
      Re: chroot to install packages Himanshu Garg <hgarg.india@gmail.com> - 2013-11-14 01:41 -0800

csiph-web