TurnKey Linux Virtual Appliance Library

di-live.d component and d-i main-menu

ericbouer's picture


Short story:Let's say I have the following 2 lines in my di-live.d script

echo "hello"

di-live fails on that because its trying to get the output of that script into the d-i menu.

throwing the following exception:

File "/usr/lib/python2.5/site-packages/debconf.py", line 96, in command
    raise DebconfError(status, data)
debconf.DebconfError: (20, 'Unsupported command "hello" (full line was "hello") received from confmodule.')

How can I bypass this without modifying di-live.py?

Long story:

I'm working on a patch that has to get some user input during the installation.

I already have a ncurses based interface that uses good old "dialog" and I'm trying to run it from a component I've created in dl-live.d. however, since dl-live runs everything in this folder as a menu component I'm getting an error. I don't want to touch that ncurses interface nor the di-live.py or d-i.

Many thanks and keep up the great work.

Alon Swartz's picture

A little info on di-live

There are basically 2 ways to extend di-live, either with live-installer scripts or with full fledged di-live components.

live-installer scripts:
Live installer scripts live in /usr/lib/live-installer.d and will be executed inside the /target chroot. They do not support user interaction, and will be executed on firstboot when running live (for example: regeneration of ssh keys).

di-live components:
As you already know, they live in /usr/lib/di-live.d . They are executed outside of the /target chroot (ie. in the live system), so you need to take care of chrooting (di-live makes this easy, see below).

Note that di-live leverages debconf for user interaction, you cannot use ncurses/dialog without hacking di-live/d-i to pieces. Under normal circumstances, for debconf to interact with the user you would be required to create a template and have it installed together with your package. This can become tedious especially for adhoc scripts, so di-live provides simple methods to get around this.

So, for example, if you would like to get input from the user and use it to do something in the /target chroot, you would do something like this:
import sys
import common

TARGET = "/target"
def main():
    if not common.target_mounted(TARGET):
        sys.exit(10) # return to menu

    db = common.Debconf()
    foo = db.get_input('Enter value for foo', 'default foo value')
    bar = db.get_password('Enter password')

    chroot = common.Chroot(TARGET)
    chroot.system('foobar-config --silent %s %s' % (foo, bar))

if __name__ == "__main__":
See common.py for more info.

Note: Your scripts must NOT print to stdout or stderr, as this will cause issues with debconf. Rather, if an error occured, you should write to /var/log/di-live.log and exit with errorcode 10 (tells d-i to backup a step).

I hope the above helps...
beric's picture

very helpful ! thanks. I

very helpful ! thanks.

I guess a solution is to running dialog  by creating another service and run it before the di-live.


Alon Swartz's picture

Not sure if I would go down that road...

Why can't you use debconf? Take a look at the The Debconf Programmer's Tutorial.

Post new comment

The content of this field is kept private and will not be shown publicly. If you have a Gravatar account, used to display your avatar.
  • Web page addresses and e-mail addresses turn into links automatically.
  • Allowed HTML tags: <a> <p> <span> <div> <h1> <h2> <h3> <h4> <h5> <h6> <img> <map> <area> <hr> <br> <br /> <ul> <ol> <li> <dl> <dt> <dd> <table> <tr> <td> <em> <b> <u> <i> <strong> <font> <del> <ins> <sub> <sup> <quote> <blockquote> <pre> <address> <code> <cite> <strike> <caption>

More information about formatting options

Leave this field empty. It's part of a security mechanism.
(Dear spammers: moderators are notified of all new posts. Spam is deleted immediately)