Bug 475541 - Wrong parsing of %%post section from kickstarts.
Wrong parsing of %%post section from kickstarts.
Product: Fedora
Classification: Fedora
Component: anaconda (Show other bugs)
All Linux
low Severity medium
: ---
: ---
Assigned To: Anaconda Maintenance Team
Fedora Extras Quality Assurance
Depends On:
  Show dependency treegraph
Reported: 2008-12-09 11:28 EST by Vadim Grinco
Modified: 2009-06-18 14:15 EDT (History)
2 users (show)

See Also:
Fixed In Version:
Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of:
Last Closed: 2009-06-18 14:15:04 EDT
Type: ---
Regression: ---
Mount Type: ---
Documentation: ---
Verified Versions:
Category: ---
oVirt Team: ---
RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: ---

Attachments (Terms of Use)
ks.cfg (11.70 KB, text/plain)
2008-12-09 11:31 EST, Vadim Grinco
no flags Details

  None (edit)
Description Vadim Grinco 2008-12-09 11:28:58 EST
Description of problem:

Anaconda doesn't parse %%post section correctly in ks.cfg.

How reproducible:
Kick F10 from nfs://bigpapi.bos.redhat.com/vol/engineering/redhat/released/F-10/GOLD/Fedora/x86_64/os with the ks.cfg attached or run `test_lab_machine.py -r -S rhts.redhat.com -t /distribution/inventory -u jgrando@redhat.com -a x86_64 -m dell-pe1950-01.rhts.bos.redhat.com -f Fedora10` if you have rhts-scheduler-workflows installed.

Actual results:

15:02:25 ERROR   : Error code 127 encountered running the kickstart script at line 253

Expected results:

Successful execution of the script.

Additional info:

Tested on dell-pe1950-01.rhts.bos.redhat.com. Works with F10 distribution from http://mirror.englab.brq.redhat.com/fedora/10/Fedora/x86_64/os/
Comment 1 Vadim Grinco 2008-12-09 11:30:02 EST
Created attachment 326348 [details]
Comment 2 Vadim Grinco 2008-12-09 11:31:18 EST
Created attachment 326349 [details]
Comment 3 Chris Lumens 2008-12-10 11:41:10 EST
If I run ksvalidator on the script and do a little poking around in pdb, I find that the script in question is:

(Pdb) handler.scripts[1].lineno
(Pdb) handler.scripts[1].script
'/bin/cp /etc/resolv.conf /mnt/sysimage/etc/resolv.conf\n\n'

I don't see how there could be a parse error here, unless subprocess really doesn't like things to end with a newline.  The error message you're seeing usually happens when there was an error running the script itself.  For instance:  is there even a /etc/resolv.conf file to copy?  What makes you think there's a parse error here?
Comment 4 Vadim Grinco 2008-12-10 12:09:48 EST

When I asked jgranado he didn't say anything about line 253 in the post scripts, and I assumed that the error below means line 253 in ks.cfg itself.

From anaconda.log:
15:02:25 INFO    : Running kickstart %%post script(s)
15:02:25 ERROR   : Error code 127 encountered running the kickstart script at line 253
15:02:47 INFO    : All kickstart %%post script(s) have been run

From ks.cfg:
   251	cat << __EOT__ > /etc/yum.repos.d/rhts-tests.repo
   252	[rhts-noarch]
   253	name=Fedora10 - \$basearch - rhts development
   254	baseurl=http://rhts.redhat.com/rpms/development/noarch/noarch
   255	enabled=1
   256	gpgcheck=0
   257	__EOT__

I tried to run the same test on two diferrent lab controllers, on the same hardware (ks.cfg is the same, except  rhts specific variables and distro location) and it failed to install F10 from `nfs --server=bigpapi.bos.redhat.com --dir=/vol/engineering/redhat/released/F-10/GOLD/Fedora/x86_64/os` but succeeded from `nfs --server=filer-eng.brq.redhat.com --dir=/vol/mirrors/engineering/fedora/10/Fedora/x86_64/os`

vfalico had a similar issue.
Comment 5 Veaceslav Falico 2008-12-10 12:22:57 EST
Error 127 means that the _program_ does not exist. 

[vfalico@dhcp-lab-150 tests]$ /bin/cp /etc/resolv.conf ~/; echo $?
[vfalico@dhcp-lab-150 tests]$ /bin/cp /etc/resolv.conf1 ~/; echo $?
/bin/cp: cannot stat `/etc/resolv.conf1': No such file or directory
[vfalico@dhcp-lab-150 tests]$ /bin/cp1 /etc/resolv.conf ~/; echo $?
bash: /bin/cp1: No such file or directory
[vfalico@dhcp-lab-150 tests]$ 

In F10 the ks %post script is executed in chroot'ed environment, from python, so I think it's somewhat regarding the chroot. I have similar bugs in sumo other distributions. If I'll find anything, I'll write here...
Comment 6 Chris Lumens 2008-12-10 13:01:32 EST
When I download the attachment and open it in vim, line 253 is this:

%post --nochroot

Since this is the only nochroot script in the kickstart file, I'm willing to believe that we're not handling this right.  I haven't tested it recently, but I also haven't made any changes here.  It's certainly worth investigating.  I could set up a test real quick, or you could add something to your %post script to show the contents of /.  This would tell us whether --nochroot was working or not:

%post --nochroot
ls / > /tmp/LS

Then it's just a matter of if LS ends up in /tmp/LS or /mnt/sysimage/tmp/LS.
Comment 7 Vadim Grinco 2008-12-10 13:57:20 EST

You're right. I forgot that nl doesn't number empty lines by default. 

Will do that and update you.


Note You need to log in before you can comment on or make changes to this bug.