How to make your own distro in 3 not-so simple steps
What I know after one day of hacking around anaconda, the CentOS/Fedora/RHEL installer...
What I know after one day of hacking around anaconda, the CentOS/Fedora/RHEL installer...
One of my greatest frustrations as an adequate programmer is that I think of things I believe should exist, yet I am not able to implement them myself.
Today I will mention one (or two) of them.
There should be a Xen-based distro.
Xen is a very good virtualization package, which gives you multiple simultaneous virtual linux installations with very little overhead.
Sadly, to make it work, right now, you have to get a linux working, then install Xen, then install one or more extra linuxes as xen machines.
Which is not terribly hard, but could be done much easier.
I am thinking of something like this:
Installing Xen-Linux installs a very simple basic setup as the supervisor partition, sets up Xen properly, and sets you with a single Xen virtual machine.
Also, in another part of the disk, it has a gzipped file with a simple, basic linux setup which you use as a template for further virtual machine initializations.
So, whenever you want a new machine, you run a script, it sets it up, starts it, you get something like firstboot asking you the usual network/language/whatever questions.
Then, you are dropped into a nice package selection tool, where you choose what you want installed in this virtual instance.
And that's it.
This would encourage the administrator to always set up his servers as virtual machines, which except in cases of real hardcore performance requirements is a good idea (you can implement HA as full-image fallback. You can migrate to a new box in minutes!)
I could do most of this. However, that leads me to another thing that should exist...
A simple installer
Wait, you may say "Linux installers are simple already!!!" and youa re right.
I mean a simple installer for a guy trying to make his own distro!
I actually like anaconda a lot. But I would like it even better if I could just get some sort of tool that, given a list of packages, would create an anaconda-based CD with customizable install scripts.
And that is the piece I am not sure I can implement.
So, if anyone knows of any such thing, I would love to hear about it.
And as a preemptive message: No, I don't want to do it with Gentoo, or Debian, or Ubuntu, or Suse, or kickstart. I want to create a RPM-based, CentOS-based, anaconda-based installer that works just like a regular CentOS/RHEL installer CD.
PyDS is good enough to let you change how you host your site and keep it just working.
I switched from pycs.net (thanks for all the good work!) to a static site hosted at my ISP.
Since PyDS simply generates a whole lot of static HTML, this worked pretty good!
I generate the site, and then upload using lftp. No fuss, again, it just works.
Static hosting sucks.
On pycs.net I had referrer logs, stats, comments. The static template from PyDS doesn't have any of that, of course.
You can work around the suckage.
No comments? Haloscan can host them for you.
No stats? statcounter can do them for you.
No spam-free mail webform? I haven't looked yet, but I bet it exists someplace :-)
You learn stuff.
I now understand how PyDS's macros/templates/nuggets/uploadings work. I thought I did. Now I do.
For example, I like comments for longer articles. Before, I added the links by hand. Now I just hacked the templates and it's done automatically. I could have saved a few hours of my life if I had bothered to learn it.
Switching your URL sucks.
Since noone knows where the hell my page is. Luckily soon clee will switch me at planetkde.org and things will start to flow again.
Depending on free hosting's tech support is not a good idea.
I love pycs.net. I loved how it worked. Until it stopped working.
I have no right to whine, though, so I offered to help (got no response yet). Then I moved out.
Since moving is annoying, I will probably not be going back, even if I start loving it again :-(
I am getting and reposting all the comments, but then gain haloscan has a 4-month limit on the comments, so I will have to implement some sort of comment-archiving and closing mechanism.
In January, I suggested it would be trivial to write a preprocessor that would accept a version of python which delimited blocks with braces instead of indentation.
Ok, almost, I suggested #{ and #} as delimiters.
Well, I had a few minutes free today, and here it is, a functional BPython->Python compiler, so to speak.
Here's the kind of imput it takes (notice how it's not indented at all:
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 produces this (I am not happy with the indenting of the comments, 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 legal Python and a legal BPython program ;-)
It has some problems, like not working when you use a line like this:
#{ x=1
But hey, it is python with braces.
Here's the code. I predicted 30 lines. It's 34. And it's 99% a ripoff of Ka Ping Yee's regurgitate.py which you can find all around the web.
#!/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 dislike python because of the lack of braces and the significant whitespace:
BPython has no significant whitespace, and braces are mandatory.
Enjoy coding!
A new story in the "Fighting Spam with Qmail" series, after an over two year hiatus.
This one is about RBLs, qmail and a great tool called qmail-spp.