Search code examples
ubuntudebdebconf

Debconf dialog during .deb installation


I was successfully able to create a .deb installation file for Ubuntu, but I need user input to complete the configuration for the post install script. These questions are dynamic and based on the interfaces a user has on their computer.

Is there a way to prompt the user with questions that have dynamic answers (i.e.- a list of interfaces on their computer) during the install process in Ubuntu Software Center using debconf?


Solution

  • Got it. In the templates file you create a substitution variable and fill it inside the configuration file.

    Templates File:

    Template: pkg/interfaces
    Type: select
    Choices: ${choices}
    Description: .....
    

    Config File:

    declare -a options;
    count=0;
    
    ## Get interfaces from the operating system
    for interface in $(ip link show | awk '/^[0-9]/ {print $2;} ' | sed 's/:$//');
    do
        if [ $interface != "lo" ] && [ $interface != "" ] ;
        then
            options[$count]=$interface;
            count=$((count+1));
        fi
    done
    
    # Set the choices the user has
    db_subst pkg/outface choices $options