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


Groups > comp.lang.python > #59356

Re: chroot to install packages

Path csiph.com!v102.xanadu-bbs.net!xanadu-bbs.net!feeder.erje.net!eu.feeder.erje.net!feeds.phibee-telecom.net!newsfeed.xs4all.nl!newsfeed4.news.xs4all.nl!xs4all!newsgate.cistron.nl!newsgate.news.xs4all.nl!post.news.xs4all.nl!not-for-mail
Return-Path <rosuav@gmail.com>
X-Original-To python-list@python.org
Delivered-To python-list@mail.python.org
X-Spam-Status OK 0.037
X-Spam-Evidence '*H*': 0.93; '*S*': 0.00; 'runs': 0.10; 'python': 0.11; 'from:addr:rosuav': 0.16; 'from:name:chris angelico': 0.16; 'garg': 0.16; 'half.': 0.16; 'invokes': 0.16; 'subject:install': 0.16; 'files.': 0.16; 'wrote:': 0.18; 'thu,': 0.19; 'command': 0.22; 'separate': 0.22; 'convenient': 0.24; 'script': 0.25; 'header:In-Reply-To:1': 0.27; 'am,': 0.29; 'relative': 0.30; 'message-id:@mail.gmail.com': 0.30; 'invoke': 0.31; 'piece': 0.31; 'probably': 0.32; 'run': 0.32; 'another': 0.32; 'linux': 0.33; 'running': 0.33; 'received:google.com': 0.35; 'really': 0.36; '14,': 0.36; 'doing': 0.36; 'two': 0.37; 'depends': 0.38; 'easiest': 0.38; 'nov': 0.38; 'to:addr:python-list': 0.38; 'itself': 0.39; 'to:addr:python.org': 0.39; 'how': 0.40; 'commands': 0.60; "you're": 0.61; 'commands.': 0.84; 'divide': 0.84; '2013': 0.98
DKIM-Signature v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:in-reply-to:references:date:message-id:subject:from:to :content-type; bh=CkOkk1BQc6b1K16/KZFILp1quWSplfu0Rvhl9Lt21a4=; b=XyiRDvr0vr2g6sUlfwnOM99SmlA1xfCI1MErk6s+IF2EskTXSuZHE1HNrhSIUp6QEo oE3GIwnGJrlxQU8EH0OqoZXAaylbTVEzJlE9QTz8HsDgNPUUVQt1h2Bsljkpc6s2Z4Tb tIiQ/ZBmotML8oYEeACMVejeSyMXkE1cDA2hPnEeriyoQIA0R6H9vb+Aciw1lKF3lpC3 Jzq2vx0mfjCDBNoLBOfBYQHIQQnMIqv/jL4/9FF9U+yrHCvPnzVsrjOLkVNAf8vRX1fc fLAyV8gHhwrz6pbOo7nQUnc2xcb9/0l1hjVxIuC1M3ZOQ6xp92Gwxo+dExJbIcf8ReZj Ye6w==
MIME-Version 1.0
X-Received by 10.68.164.98 with SMTP id yp2mr235715pbb.184.1384386020167; Wed, 13 Nov 2013 15:40:20 -0800 (PST)
In-Reply-To <510a8652-1097-4327-9dda-56454142cda4@googlegroups.com>
References <510a8652-1097-4327-9dda-56454142cda4@googlegroups.com>
Date Thu, 14 Nov 2013 10:40:20 +1100
Subject Re: chroot to install packages
From Chris Angelico <rosuav@gmail.com>
To python-list@python.org
Content-Type text/plain; charset=ISO-8859-1
X-BeenThere python-list@python.org
X-Mailman-Version 2.1.15
Precedence list
List-Id General discussion list for the Python programming language <python-list.python.org>
List-Unsubscribe <https://mail.python.org/mailman/options/python-list>, <mailto:python-list-request@python.org?subject=unsubscribe>
List-Archive <http://mail.python.org/pipermail/python-list/>
List-Post <mailto:python-list@python.org>
List-Help <mailto:python-list-request@python.org?subject=help>
List-Subscribe <https://mail.python.org/mailman/listinfo/python-list>, <mailto:python-list-request@python.org?subject=subscribe>
Newsgroups comp.lang.python
Message-ID <mailman.2562.1384386029.18130.python-list@python.org> (permalink)
Lines 16
NNTP-Posting-Host 2001:888:2000:d::a6
X-Trace 1384386029 news.xs4all.nl 15936 [2001:888:2000:d::a6]:43014
X-Complaints-To abuse@xs4all.nl
Xref csiph.com comp.lang.python:59356

Show key headers only | 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