You are not logged in.

#1 2008-05-31 22:18:29

TigerBenedict
Member
Registered: 2008-03-23
Posts: 9

Lessons Learned

I upgraded some packages a week or two ago, including kernel 2.6.25, mkinitcpio, initscripts, and others. As usual, on reboot my system was entirely unuseable. This time, my rootfs couldn't be found and I was plopped into ramfs, forced to using "echo *" and "cat" to look around.

After hours of scrounging around the forums and wikis, I learned a lot about the bootup sequence of linux machines.  This was fun, but after a while I began to curse Arch Linux. Why does it break every time I upgrade the kernel? I've barely installed anything or even done much with my system yet! Why can't the developers ever do some basic testing before releasing a new critical package? Is this a serious distribution, or some kind of joke??

I usually end up reinstalling the distribution from scratch, and rarely learn anything. I keep coming back to Arch above other distributions because--quite frankly--I like the logo. Blue's my favorite color, and I guess I have a thing for sharp looking triangles. This time, however, I seriously considered moving to another distribution. I began to consider slackware. They have a really sleek looking website.

I gave it a rest for a week or so and then came back. This time, rather than looking at other people's solutions on the forums, I began to perform my own debugging. I even got to try some cool things like peak into the ramfs image and tinker with some of the scripts. Also, I would really like to thank the guy who distributed the entire wiki as a package. I don' t have internet access at home, and also when something like this happens and I can't access the net, this is a real life saver. Especially for someone like me who is fairly new to this level of tinkering.

Anyways, I won't get too much into the details of debugging. Basically, neither the kernel image nor fallback image worked. Downgrading my recent packages didn't work either. Looking at pacman.conf showed some failures during mkinitcpio. Looking closer at the errors showed some strange escape characters in the filenames. E.g.

cp: can't stat /lib/modules/2.6.25-ARCH\033[m ..... something or other.

I was surprised to discover that mkinitcpio itself was a mere shell script, as I was expecting a binary. Tinkering with the script, I discovered that hard coding some of the paths resulted in solving some of the errors. And--upon closer examination--I discovered that grep itself was adding those darn escape characters!

<expletive deleted>. Didn't I recently add a GREP_OPTIONS=--color=always to my bashrc file? The mkinitcpio script was using "grep" to find some paths, and grep was inserting escape characters for colors. Insert foot in mouth for my unjust curses against Arch Linux. It ended up to be my own fault after all.

Anyways, now I have another reason to love Arch Linux beyond the logo (and the package management system). It's a tinkerer's distribution, and that's a lot of fun. And, even though the problem was small, I learned a lot of things by figuring this out.

So, what's the take home lesson (besides don't use GREP_OPTIONS)? If you're going to run a distribution, make sure you have a sexy logo!

----------------------

As a side note, I was trying to think of ways that someone could write a shell script that isn't affected by the user's environmental setup. Figuring out all possible env variables out there is obviously not a solution. Is there a way that the environment could be reset to some useable vanilla state?

Offline

#2 2008-05-31 22:21:16

bender02
Member
From: UK
Registered: 2007-02-04
Posts: 1,328

Re: Lessons Learned

You should file a bug/feature request about mkinitpcio and grep, so that it gets called with --color=never.

EDIT: I forgot to say: well done smile

Last edited by bender02 (2008-05-31 22:21:34)

Offline

#3 2008-05-31 23:30:25

MAC!EK
Member
Registered: 2005-09-27
Posts: 267

Re: Lessons Learned

There's nothing wrong in using colored grep output :>
You can safely use GREP_OPTIONS=--color=auto. Here's an example:

$ echo TEST_TEST| grep --color=auto TEST > /tmp/test_color_auto
$ echo TEST_TEST| grep --color=always TEST > /tmp/test_color_always

$ cat -v /tmp/test_color_auto
TEST_TEST

$ cat -v /tmp/test_color_always
^[[01;31m^[[KTEST^[[m^[[K_^[[01;31m^[[KTEST^[[m^[[K

As bender02 said, file a bug report smile

Offline

#4 2008-06-01 11:34:04

Procyon
Member
Registered: 2008-05-07
Posts: 1,819

Re: Lessons Learned

--color=auto won't work if you pipe it to less though, will it?

I use an alias for --color=always among other things.

Offline

#5 2008-06-01 11:45:37

dolby
Member
From: 1992
Registered: 2006-08-08
Posts: 1,581

Re: Lessons Learned

one of the reasons i chose zsh as my default shell is that aliasing grep in bash to use color breaks a lot of things


There shouldn't be any reason to learn more editor types than emacs or vi -- mg (1)
[You learn that sarcasm does not often work well in international forums.  That is why we avoid it. -- ewaller (arch linux forum moderator)

Offline

#6 2008-06-01 11:47:09

MAC!EK
Member
Registered: 2005-09-27
Posts: 267

Re: Lessons Learned

No it won't work.

That's the difference, option auto doesn't use color when output of grep is going to next pipe ( '|' ) or is redirected to file ( '>' ).

Offline

#7 2008-06-01 12:44:22

Allan
Pacman
From: Brisbane, AU
Registered: 2007-06-09
Posts: 11,402
Website

Re: Lessons Learned

I'll add another file a bug report as I haven't seen one about this yet...

Anyway, I think this is a lesson in actually looking at your pacman output.  There is often useful information in it which will stop you from having problems.  The number of people who got caught out by not dealing with the /etc/profile.pacnew file and then having "missing" man pages was amazing.

Offline

#8 2008-06-02 00:47:31

TigerBenedict
Member
Registered: 2008-03-23
Posts: 9

Re: Lessons Learned

Thanks for the tips. I always wondered what the auto option was for.

Well, I'm not sure if this is really a bug. I'm sure there are a lot more scripts out there beyond mkinitcpio that use grep without checking GREP_OPTIONS. And, adding color isn't the only possibility where things could get screwed up. If I added -r to my grep options, or -i, other things could possibly be affected. And, who knows what other environment variables in all the other gnu tools  might have similar caveats?

That's why I was wondering if there was a "best practice" technique for shell script programmers--something that would reset the entire environment to a useable vanilla state, rather than trying to guess what values might mess the script up. Perhaps one could merely unset the entire environment (and restore it at the end), except for certain necessesities such as PATH? What would be the dangers of doing something like that?

Last edited by TigerBenedict (2008-06-02 00:49:29)

Offline

#9 2008-06-05 09:08:38

aantipop
Member
Registered: 2008-02-15
Posts: 46

Re: Lessons Learned

do you think, i have a similar problem here: http://bbs.archlinux.org/viewtopic.php?pid=376939 ?
but i didnt mess with grep-colors..


rainbow networks - we bring colour to your gibs

Offline

#10 2008-06-05 14:20:23

mmmasterluke
Member
Registered: 2007-12-07
Posts: 49

Re: Lessons Learned

That's interesting. The logo made me try Arch too. The one before the current one though. It wasn't as sharp but there was still something to it.

Last edited by mmmasterluke (2008-06-05 14:21:28)

Offline

#11 2008-06-06 09:01:22

JeremyTheWicked
Member
From: Poland
Registered: 2008-05-23
Posts: 193

Re: Lessons Learned

Haha. For me it was the logo, either. I found Arch by "accident" on Distrowatch.

As for the lessons learned: I've learned more about Linux in 2 weeks of using Arch than I have learned in 2 years of using Ubuntu (most of my knowledge originated back in the days of Debian).


arch(3) adj amused because you think you understand something better than other people ;P

Offline

Board footer

Powered by FluxBB