Adding your own module to anaconda.

I am interested in anaconda so I wrote really simple "Hello World" module in the anaconda stage2 for my studying. That module doesn't do any important job. It only shows "Hello World" onto the screen. However, it was easier than as I expected :D

This is a diffstat's output . As you can see it's really small diff. One of the reason is I didn't touch text.py and kickstart.py. so I added two files, and modified three files.

[masami@moon]~% diffstat ana.diff 
 dispatch.py          |    1 +
 gui.py               |    1 +
 helloworld.py        |   41 +++++++++++++++++++++++++++++++++++++++++
 installclass.py      |    1 +
 iw/helloworld_gui.py |   50 ++++++++++++++++++++++++++++++++++++++++++++++++++
 5 files changed, 94 insertions(+)

dispatch.py, gui.py and installclass.py were added just one line to add my module to install steps. This module appears next to Welcome screen because I set my module next to "welcome" in dispatch.py.
btw, I use f14-branch.

This is a diff output.

diff --git a/pyanaconda/dispatch.py b/pyanaconda/dispatch.py
index 39aa2d9..fe69f07 100644
--- a/pyanaconda/dispatch.py
+++ b/pyanaconda/dispatch.py
@@ -67,6 +67,7 @@ log = logging.getLogger("anaconda")
 # gets passed in when we call the function.
 installSteps = [
     ("welcome", ),
+    ("helloworld", ),
     ("language", ),
     ("keyboard", ),
     ("betanag", betaNagScreen, ),
diff --git a/pyanaconda/gui.py b/pyanaconda/gui.py
index dc8cf0e..2cd9f75 100755
--- a/pyanaconda/gui.py
+++ b/pyanaconda/gui.py
@@ -62,6 +62,7 @@ class StayOnScreen(Exception):
 mainWindow = None
 
 stepToClass = {
+    "helloworld" : ("helloworld_gui", "HelloWorldWindow"),
     "language" : ("language_gui", "LanguageWindow"),
     "keyboard" : ("kbd_gui", "KeyboardWindow"),
     "welcome" : ("welcome_gui", "WelcomeWindow"),
diff --git a/pyanaconda/helloworld.py b/pyanaconda/helloworld.py
new file mode 100644
index 0000000..15adb82
--- /dev/null
+++ b/pyanaconda/helloworld.py
@@ -0,0 +1,41 @@
+#
+# helloworld.py: Test program for learning anaconda.
+#
+# Copyright (C) 2010, Masami Ichikawa <masami@fedoraproject.org>
+# All rights reserved.
+#
+# This program is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 2 of the License, or
+# (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program.  If not, see <http://www.gnu.org/licenses/>.
+#
+
+import os
+import string
+import locale
+
+import gettext
+from simpleconfig import SimpleConfigFile
+
+import logging
+log = logging.getLogger("anaconda")
+
+class HelloWorld(object):
+
+    def __init__ (self, display_mode = 'g'):
+        pass
+
+    def write(self, instPath):
+        pass
+
+    def writeKS(self, f):
+        pass
+
diff --git a/pyanaconda/installclass.py b/pyanaconda/installclass.py
index 3c6a579..8ce40a9 100644
--- a/pyanaconda/installclass.py
+++ b/pyanaconda/installclass.py
@@ -76,6 +76,7 @@ class BaseInstallClass(object):
     def setSteps(self, anaconda):
         dispatch = anaconda.dispatch
        dispatch.setStepList(
+                 "helloworld",
                 "language",
                 "keyboard",
                 "welcome",
diff --git a/pyanaconda/iw/helloworld_gui.py b/pyanaconda/iw/helloworld_gui.py
new file mode 100644
index 0000000..fd92ced
--- /dev/null
+++ b/pyanaconda/iw/helloworld_gui.py
@@ -0,0 +1,50 @@
+#
+# helloworld_gui.py: hello world screen.
+# This is a sample program for learning anaconda.
+#
+# Copyright (C) 2010, Masami Ichikawa <masami@fedoraproject.org>.  All rights reserved.
+#
+# This program is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 2 of the License, or
+# (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program.  If not, see <http://www.gnu.org/licenses/>.
+#
+
+import gtk
+from pyanaconda import gui
+import sys
+from iw_gui import *
+
+from pyanaconda.constants import *
+import gettext
+_ = lambda x: gettext.ldgettext("anaconda", x)
+
+class HelloWorldWindow (InstallWindow):
+
+    windowTitle = "" #N_("HelloWorld")
+
+    def __init__ (self, ics):
+        InstallWindow.__init__ (self, ics)
+        ics.setGrabNext (1)
+        self.anaconda = None
+
+    # HelloWorldWindow tag="helo"
+    def getScreen (self, anaconda):
+        self.anaconda = anaconda
+
+        box = gtk.VBox (False, 10)
+        label = gtk.Label (_("Hello World"))
+        box.pack_start(label, False)
+
+        return box
+
+    def getNext (self):
+        pass

When you write source code(s), you need to build anaconda rpm package or create an updates.img to enable your module. so I choose creating an updates.img because it seems easier than building rpm and an iso.
Creating an updates.img is easy. You need to move /path/to/anaconda then do "make updates". Actually, I did "./autogen.sh" and "./configure" then "make updates".

You can see files which you added/modified are in the image.

[masami@moon]~/tmp/test% gunzip -dc ../../anaconda/updates.img | cpio -id
142 blocks
[masami@moon]~/tmp/test% ls -R
.:
.  ..  pyanaconda

./pyanaconda:
.  ..  dispatch.py  gui.py  helloworld.py  installclass.py  iw

./pyanaconda/iw:
.  ..  helloworld_gui.py
[masami@moon]~/tmp/test% 
||
Finally, you can test your module. I modified f14-branch, so I use F14's DVD iso to test.
>||
qemu-kvm -boot d -cdrom Fedora-14-x86_64-DVD.iso -hda hda.img -m 768

At first, you need to add updates.img's URL in boot option.

Anaconda automatically configure network, and downloads updates.img. When Welcome message is appeared, push NEXT button, then Hello World module is shown:)