Skip to main content

Ralsina.Me — Roberto Alsina's website

What I learned about hacking anaconda...

...­Don't hack ana­con­da!

It's pret­ty evil stuff. It "build­s" with di­etlibc (?!) in the Cen­tOS 4 ver­sion.

The lat­est does­n't but it's un­build­able on any­thing oth­er than FC5.

Oh, but that "build­s" is re­al­ly not quite true. It does­n't build at al­l. I don't know how they com­piled it in the first place.

On the oth­er hand, if you switch it to plain glibc, it crash­es (no warn­ing, no er­ror) when run­ning load­er.

And how can you de­bug it? Well, you can't re­al­ly, be­cause there seems to be no way to run ana­con­da un­less you are in­stalling.

Why? Why not cre­ate some way to run it on a test se­tup?

There are no docs I could find on the in­ter­nal­s, there is not even a damn ex­pla­na­tion of what bi­na­ry does what, so I have to track it down the­o­ret­i­cal­ly by mount­ing and ex­am­in­ing the .img files!

Sure, I can prob­a­bly hack it... but why?

Per­son­al­ly, I think it's bet­ter to wait un­til some­one writes a sane in­stall­er. Then again, noone has in 12 years :-(

Dudes, here's what the in­stall­er should do:

  1. Get you in a GUI, or text mod­­e. It does­n't mat­ter.

  2. Par­ti­­tion disks

  3. In­­stall ba­sic sys­tem (about 350M­B, top­s!)

  4. In­­stall boot­load­­er

  5. Boot in­­­to said sys­tem

  6. Con­­fig­ure net­­work

  7. Start pack­­age man­age­­ment tool

Knop­pix al­ready had all the hw au­tode­tect fig­ured years ago. Why are we not us­ing it ev­ery­where?

I am just not the guy who can do it. I don't have the stami­na :-P

Things that should exist.

One of my great­est frus­tra­tions as an ad­e­quate pro­gram­mer is that I think of things I be­lieve should ex­ist, yet I am not able to im­ple­ment them my­self.

To­day I will men­tion one (or two) of them.

There should be a Xen-based dis­tro.

Xen is a very good vir­tu­al­iza­tion pack­age, which gives you mul­ti­ple si­mul­ta­ne­ous vir­tu­al lin­ux in­stal­la­tions with very lit­tle over­head.

Sad­ly, to make it work, right now, you have to get a lin­ux work­ing, then in­stall Xen, then in­stall one or more ex­tra lin­ux­es as xen ma­chines.

Which is not ter­ri­bly hard, but could be done much eas­i­er.

I am think­ing of some­thing like this:

In­stalling Xen-Lin­ux in­stalls a very sim­ple ba­sic set­up as the su­per­vi­sor par­ti­tion, sets up Xen prop­er­ly, and sets you with a sin­gle Xen vir­tu­al ma­chine.

Al­so, in an­oth­er part of the disk, it has a gzipped file with a sim­ple, ba­sic lin­ux set­up which you use as a tem­plate for fur­ther vir­tu­al ma­chine ini­tial­iza­tion­s.

So, when­ev­er you want a new ma­chine, you run a scrip­t, it sets it up, starts it, you get some­thing like first­boot ask­ing you the usu­al net­work/lan­guage/what­ev­er ques­tion­s.

Then, you are dropped in­to a nice pack­age se­lec­tion tool, where you choose what you want in­stalled in this vir­tu­al in­stance.

And that's it.

This would en­cour­age the ad­min­is­tra­tor to al­ways set up his servers as vir­tu­al ma­chi­nes, which ex­cept in cas­es of re­al hard­core per­for­mance re­quire­ments is a good idea (y­ou can im­ple­ment HA as ful­l-im­age fall­back. You can mi­grate to a new box in min­utes!)

I could do most of this. How­ev­er, that leads me to an­oth­er thing that should ex­ist...

A sim­ple in­stall­er

Wait, you may say "Lin­ux in­stall­ers are sim­ple al­ready!!!" and youa re right.

I mean a sim­ple in­stall­er for a guy try­ing to make his own dis­tro!

I ac­tu­al­ly like ana­con­da a lot. But I would like it even bet­ter if I could just get some sort of tool that, giv­en a list of pack­ages, would cre­ate an ana­con­da-based CD with cus­tom­iz­a­ble in­stall script­s.

And that is the piece I am not sure I can im­ple­men­t.

So, if any­one knows of any such thing, I would love to hear about it.

And as a pre­emp­tive mes­sage: No, I don't want to do it with Gen­too, or De­bian, or Ubun­tu, or Suse, or kick­start. I want to cre­ate a RP­M-based, Cen­tOS-based, ana­con­da-based in­stall­er that works just like a reg­u­lar Cen­tOS/RHEL in­stall­er CD.

What I learned moving my blog

  1. PyDS is good enough to let you change how you host your site and keep it just work­ing.

I switched from pyc­s.net (thanks for all the good work!) to a stat­ic site host­ed at my IS­P.

Since PyDS sim­ply gen­er­ates a whole lot of stat­ic HTM­L, this worked pret­ty good!

I gen­er­ate the site, and then up­load us­ing lft­p. No fuss, again, it just work­s.

  1. Stat­ic host­ing suck­­s.

On pyc­s.net I had re­fer­rer logs, stat­s, com­ments. The stat­ic tem­plate from PyDS does­n't have any of that, of course.

  1. You can work around the suck­­age.

No com­ments? Haloscan can host them for you.

No stat­s? stat­counter can do them for you.

No spam-free mail web­for­m? I haven't looked yet, but I bet it ex­ists some­place :-)

  1. You learn stuff.

I now un­der­stand how PyD­S's macros/tem­plates/nugget­s/u­pload­ings work. I thought I did. Now I do.

For ex­am­ple, I like com­ments for longer ar­ti­cles. Be­fore, I added the links by hand. Now I just hacked the tem­plates and it's done au­to­mat­i­cal­ly. I could have saved a few hours of my life if I had both­ered to learn it.

  1. Switch­ing your URL suck­­s.

Since noone knows where the hell my page is. Luck­i­ly soon clee will switch me at plan­etkde.org and things will start to flow again.

  1. De­pend­ing on free host­ing's tech sup­­port is not a good idea.

I love pyc­s.net. I loved how it worked. Un­til it stopped work­ing.

I have no right to whine, though, so I of­fered to help (got no re­sponse yet). Then I moved out.

Since mov­ing is an­noy­ing, I will prob­a­bly not be go­ing back, even if I start lov­ing it again :-(

I am get­ting and re­post­ing all the com­ments, but then gain haloscan has a 4-­month lim­it on the com­ments, so I will have to im­ple­ment some sort of com­men­t-archiv­ing and clos­ing mech­a­nis­m.

BPython Lives!!!

In Jan­uary, I sug­gest­ed it would be triv­ial to write a pre­proces­sor that would ac­cept a ver­sion of python which de­lim­it­ed blocks with braces in­stead of in­den­ta­tion.

Ok, al­most, I sug­gest­ed #{ and #} as de­lim­iter­s.

Well, I had a few min­utes free to­day, and here it is, a func­tion­al BPython->Python com­pil­er, so to speak.

Here's the kind of im­put it takes (no­tice how it's not in­dent­ed at al­l:

def factorial(n):
#{
if n==1:
#{
return 1
#}
else:
#{
return n*factorial(n-1)
#}
#}

for x in range(1,10):
#{
print x,"!=",factorial(x)
#}

And it pro­duces this (I am not hap­py with the in­dent­ing of the com­ments, but who cares):

def factorial(n):
  #{
  if n==1:
    #{
    return 1
  #}
  else:
    #{
    return n*factorial(n-1)
  #}
#}

for x in range(1,10):
  #{
  print x,"!=",factorial(x)
#}

As you can see, this is both a le­gal Python and a le­gal BPython pro­gram ;-)

It has some prob­lem­s, like not work­ing when you use a line like this:

#{ x=1

But hey, it is python with braces.

Here's the code. I pre­dict­ed 30 lines. It's 34. And it's 99% a ripoff of Ka Ping Yee's re­gur­gi­tate.py which you can find all around the we­b.

#!/usr/bin/env python
import tokenize, sys
program = []
lastrow, lastcol = 1, 0
lastline = ''
indlevel=0
def rebuild(type, token, (startrow, startcol), (endrow, endcol), line):
    global lastrow, lastcol, lastline, program,indlevel
    if type==52 and token.startswith ("#{"):
            type=5
            indlevel+=1
    if type==52 and token.startswith ("#}"):
            type=6
            indlevel-=1
    line="  "*indlevel+line.lstrip()
    startcol+=indlevel*2
    endcol+=indlevel*2
    # Deal with the bits between tokens.
    if lastrow == startrow == endrow:            # ordinary token
        program.append(line[lastcol:startcol])
    elif lastrow != startrow:                    # backslash continuation
        program.append(lastline[lastcol:] + line[:startcol])
    elif startrow != endrow:                     # multi-line string
        program.append(lastline[lastcol:startcol])
    # Append the token itself.
    program.append(token)
    # Save some information for the next time around.
    if token and token[-1] == '\n':
        lastrow, lastcol = endrow+1, 0           # start on next line
    else:
        lastrow, lastcol = endrow, endcol        # remember last position
    lastline = line                              # remember last line
tokenize.tokenize(sys.stdin.readline, rebuild)
for piece in program: sys.stdout.write(piece)

So, all of you who dis­like python be­cause of the lack of braces and the sig­nif­i­cant whites­pace:

BPython has no sig­nif­i­cant whites­pace, and braces are manda­to­ry.

En­joy cod­ing!