anaconda.real in RH7.1

A

Allan Adler

I'm trying to reinstall RedHat 7.1 Linux on a PC that was disabled when
I tried to upgrade from RH7.1 to RH9. This is presenting lots of unexpected
difficulties. Apart from wanting to keep the old model T in shape, I'm treating
this as a learning experience. Right now, I'm trying to gain more control
over the installation CD. By that I mean, I intend to modify the installation
script and other aspects of the CD and burn a new installation CD. The
installation script starts off as a shell script named anaconda which
then calls a python script named anaconda.real. The former is pretty easy
to understand, but I don't know anything about python. At the moment, I'm
using the book, "Programming Python", by Mark Lutz, as a reference. The
file anaconda.real is about 526 lines long. I've copied out about an eighth
of it into a notebook and am trying to use the book to make sense of what
I have copied. I'm not finding it very helpful. I don't know whether that
is because the script relies on aspects of python that aren't well explained
in the book or because it relies on aspects of RedHat Linux. I thought I
should ask here first about what seem like purely python issues.

The file anaconda.real is invoked with the line
exec /usr/bin/anaconda.real -T "$@"
I don't know what effect the -T "$@" has.

The file anaconda.real begins:

#!/usr/bin/python
signal.signal(signal.SIGINT,signal.SIG_DFL)

There is nothing about signal or signal.signal or the other signal.*
in the book. The file continues:

# For anaconda in test mode
if (os.path.exists('isys'))
sys.path.append('edd')
sys.path.append('libfdisk')
[lots of lines like that]
else:
sys.path.append('/usr/lib/anaconda')
sys.path.append('/usr/lib/anaconda/textw')
sys.path.append('/usr/lib/anaconda/iw')
sys.path.append('/usr/lib/anaconda/installclasses')

Here I'm guessing that the if never happens and the various /usr/lib/anaconda
directories are appended to the PATH environment variable.

Later on, after importing traceback (which is briefly mentioned in the book),
string, isys, iutil, _ from translate, handleException from exception, it
apparently worries about the environment variable ANACONDAARGS and then
executes

try:
(args, extra) = isys.getopt(theargs, 'GTRxtdr:fm:',
['gui','text','reconfig','xmode','test','debug','nofallback',
'method=','rootpath=',...

Anyway, in a nutshell, whenever I see anything specific in the file
anaconda.real, it isn't mentioned in the book and I don't know how to
get more information about it and I don't know how python gets its information
about it.

What do I need to read?
 
P

pruebauno

Allan said:
I'm using the book, "Programming Python", by Mark Lutz, as a reference.

No offence to Mark Lutz or O'Reilly but I consider "Programming Python"
one of the worst books I have read (in my case an old first edition).
It overwhelms the beginning programmer ("Learning Python" is probably
better for that), it bores the experienced programmer to death with
introductory details and does not work as a reference book. It is a
nice survey of application areas for python, but the book lacks a clear
goal, purpose and a problem it tries to address. It needs more focus.
It needs to be marketed correctly also. I believe too many people new
to python buy that book and get discouraged about Python, O'Reilly and
programming when they should buy something else instead.

That said what you probably want is "Python in a Nutshell" by O'Reilly
which is a good reference book it has a concise introduction of Python
in the beginning and after that, documentation for the most usefull
libraries out there.

Personally I use the online documentation a lot:

If I know the the name of the module
(for example it starts with sys.zz) I use:
http://www.python.org/doc/2.4.1/modindex.html

If I know what I want but not the name I use:
http://www.python.org/doc/2.4.1/lib/lib.html
 
M

Michael Hoffman

A

Allan Adler

Allan Adler said:
I'm trying to reinstall RedHat 7.1 Linux on a PC that was disabled when
I tried to upgrade from RH7.1 [....]
The file anaconda.real is invoked with the line
exec /usr/bin/anaconda.real -T "$@"
I don't know what effect the -T "$@" has.

Tiny progress on this: in a shell script, "$@" apparently lets you refer
to the output of a previous command. I don't know what output would be
relevant, since the last few lines of the shell script anaconda that
invokes anaconda.real are:

cd /usr/sbin
uncpio < sbin.cgz
rm sbin.cgz
cd /lib
uncpio < libs.cgz
rm libs.cgz
cd /
exec /usr/bin/anaconda.real -T "$@"

As for exec itself, the command line
exec -T
leads to a complaint that -T is an illegal option for exec, while
python -T
leads to a usage statement that doesn't list -T among the options for python.
So, I still don't understand the statement that is used to call the python
script anaconda.real.

I also tried to execute in interactive session some of the commands in the
file anaconda.real. E.g. the first command signal.signal(SIGINT,SIG_DFL)

Python 1.5.2 (#1, Mar 3 2001, 01:35:43)
[GCC 2.96 20000731 (Red Hat Linux 7.1 2 on linux-i386
Copyright 1991-1995 Stichting Mathematisch Centrum, AmsterdamTraceback (innermost last):
Traceback (innermost last):
Traceback (innermost last):
File "<stdin>", line 1, in ?
ImportError: No module named SIGINT

On the other hand, while looking at Kernighan and Pike, "The Unix programming
environment" (1984), I fortuitously ran across a discussion of signals and
interrupts on p.225, including the example

#include <signal.h>
signal(SIGINT,SIG_DFL)

which restores default action for process termination. The resemblance to the
first command in anaconda.real is so close that I think the intention in
both must be the same. What is the right way to get python to do this?

The file anaconda.real doesn't explicitly execute
import signal
but it still somehow knows what signal means (my example session above shows
that it stops complaining about not knowing what signal means after I import
signal). Presumably there is some way of invoking python that causes signal
and other stuff to be imported automatically. What is it?
 
S

Steve Holden

Allan said:
I'm trying to reinstall RedHat 7.1 Linux on a PC that was disabled when
I tried to upgrade from RH7.1 [....]
The file anaconda.real is invoked with the line
exec /usr/bin/anaconda.real -T "$@"
I don't know what effect the -T "$@" has.


Tiny progress on this: in a shell script, "$@" apparently lets you refer
to the output of a previous command. I don't know what output would be
relevant, since the last few lines of the shell script anaconda that
invokes anaconda.real are:

cd /usr/sbin
uncpio < sbin.cgz
rm sbin.cgz
cd /lib
uncpio < libs.cgz
rm libs.cgz
cd /
exec /usr/bin/anaconda.real -T "$@"
$@ doesn't refer to the output of a previous command. It refers to a
list of quoted arguments of the script it's a part of. It's supposed,
IIRC, to be equivalent to

exec /usr/bin/anaconda.real -T "$1" "$2" "$2" ...

as opposed to $*, which would be equivalent to

exec /usr/bin/anaconda.real -T $1 $2 $3 ...
As for exec itself, the command line
exec -T
leads to a complaint that -T is an illegal option for exec, while
python -T
leads to a usage statement that doesn't list -T among the options for python.
So, I still don't understand the statement that is used to call the python
script anaconda.real.
What's supposed to happen is that anaconda.real is supposed to be
processed by the Python interpreter. You will probably find a "shebang"
line at the start of anaconda.real that reads something like

#!/usr/bin/python1.5.2

The -T argument is, I suspect, intended for anaconda.real - you could
check the source and verify that it looks at sys.argv.
I also tried to execute in interactive session some of the commands in the
file anaconda.real. E.g. the first command signal.signal(SIGINT,SIG_DFL)

Python 1.5.2 (#1, Mar 3 2001, 01:35:43)
[GCC 2.96 20000731 (Red Hat Linux 7.1 2 on linux-i386
Copyright 1991-1995 Stichting Mathematisch Centrum, Amsterdam

Traceback (innermost last):

Traceback (innermost last):

Traceback (innermost last):
File "<stdin>", line 1, in ?
ImportError: No module named SIGINT

On the other hand, while looking at Kernighan and Pike, "The Unix programming
environment" (1984), I fortuitously ran across a discussion of signals and
interrupts on p.225, including the example

#include <signal.h>
signal(SIGINT,SIG_DFL)

which restores default action for process termination. The resemblance to the
first command in anaconda.real is so close that I think the intention in
both must be the same. What is the right way to get python to do this?
SIGINT is defined in the signal module so you probably want

signal.signal(signal.SIGINT, signal.SIG_DFL)
The file anaconda.real doesn't explicitly execute
import signal
but it still somehow knows what signal means (my example session above shows
that it stops complaining about not knowing what signal means after I import
signal). Presumably there is some way of invoking python that causes signal
and other stuff to be imported automatically. What is it?

On that one you have me stumped. It's possible it imports some other
module that plays with the namespace in a magical way.

regards
Steve
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,768
Messages
2,569,574
Members
45,048
Latest member
verona

Latest Threads

Top