Changeset 755


Ignore:
Timestamp:
Dec 3, 2007 12:43:52 AM (5 years ago)
Author:
jrollins
Message:

debirf: added getopt command line argument parsing, and tweaked
install-kernel plugin a bit.

Location:
trunk/debirf
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • trunk/debirf/debian/changelog

    r747 r755  
    44  * added ability to run make-debirf with fakechroot ('-f' option).  there are problems creating the device tree with this method, though, so it is still underdevelopment. 
    55  * modified debootstrap, plugin run-parts, and debirf_exec to also use fakechroot 
    6   * being root *should* no longer be necessary to make-debirf, therefore make-debirf was moved to /usr/bin/ 
    7   * debirf can now function with stock debian kernels (as of 2.6.22), in rootfs 
     6  * being root *should* no longer be necessary to make-debirf, therefore make-debirf has been moved to /usr/bin/ 
     7  * debirf can now function in rootfs with stock debian kernels (as of 2.6.22) 
    88  * removed /var/lib/debirf 
    99  * removed /etc/debirf in favor of doc/example-profiles 
    1010  * added xkiosk plugin to start X session with browser on startup 
     11  * added xkiosk profile 
     12  * added getopt for command line argument checking 
     13  * added command line arguments to skip some checking/user interaction 
     14  * can now pass kernel package name to make-debirf, instead of just deb, although proper package checking is not fully working 
    1115 
    12  -- Jameson Rollins <jrollins@fifthhorseman.net>  Sun, 02 Dec 2007 12:00:32 -0500 
     16 -- Jameson Rollins <jrollins@fifthhorseman.net>  Mon, 03 Dec 2007 00:40:46 -0500 
    1317 
    1418debirf (0.5) unstable; urgency=low 
  • trunk/debirf/fs/usr/bin/make-debirf

    r747 r755  
    2727    cat <<EOF 
    2828Usage: $CMD [options] profile kernel-image.deb|kernel-package-name 
     29Build a debirf diskless image. 
     30'profile' is a path to a debirf profile directory. 
    2931 
    3032options: 
    31   -f         fakechroot build (other wise requires being root) 
     33  -h|--help          this help message 
     34  -f|--fakechroot    fakechroot build (other wise requires being root) 
     35  -c|--check-vars    check variables before make 
     36  -n|--new           create new root, even if old one exists 
     37  -o|--overwrite     debootstrap on top of old root if it exists 
     38  -s|--skip          skip debootstrap step if old root exists 
    3239EOF 
    3340} 
     
    3946 
    4047create_debootstrap() { 
    41     msg "creating debirf root..." 
    42     # include initramfs-tools because they'll be handy 
    4348    mkdir -p "$DEBIRF_ROOT" 
    4449    if [ "$FAKECHROOT_BUILD" = 'true' ] ; then 
     
    176181### MAIN 
    177182 
    178 #trap umount_proc-sys EXIT 
    179  
    180 if [ "$1" = '-h' -o "$1" = '--help' ] ; then 
     183# option parsing 
     184TEMP=$(getopt --options -hfcnos --longoptions help,fakechroot,check-vars,new,overwrite,skip -n "$CMD" -- "$@") 
     185 
     186if [ $? != 0 ] ; then 
     187    echo "Invalid options." >&2  
    181188    usage 
    182     exit 0 
    183 fi 
    184  
    185 case $# in 
    186     2) 
    187         DEBIRF_PROFILE="$1" 
    188         DEBIRF_KERNEL_PACKAGE="$2" 
    189         ;; 
    190     3) 
    191         if [ "$1" = '-f' ] ; then 
     189    exit 1 
     190fi 
     191 
     192# Note the quotes around `$TEMP': they are essential! 
     193eval set -- "$TEMP" 
     194 
     195while true ; do 
     196    case "$1" in 
     197        -h|--help) 
     198            usage 
     199            exit 0 
     200            ;; 
     201        -f|--fakechroot) 
    192202            echo "Using fakechroot build." 
    193203            FAKECHROOT_BUILD=true 
    194         else 
    195             failure "Improper input arguments." 
    196         fi 
    197         DEBIRF_PROFILE="$2" 
    198         DEBIRF_KERNEL_PACKAGE="$3" 
    199         ;; 
    200     *) 
    201         echo "Improper number of input arguments." 
    202         usage 
    203         exit 1 
    204         ;; 
    205 esac 
     204            shift 1 
     205            ;; 
     206        -c|--check-vars) 
     207            CHECK_VARS=true 
     208            shift 1 
     209            ;; 
     210        -n|--new) 
     211            WRITE_MODE=rewrite 
     212            shift 1 
     213            ;; 
     214        -o|--overwrite) 
     215            WRITE_MODE=overwrite 
     216            shift 1 
     217            ;; 
     218        -s|--skip) 
     219            WRITE_MODE=skip 
     220            shift 1 
     221            ;; 
     222        --) 
     223            shift 
     224            ;; 
     225        *) 
     226            if (( $# < 1 )) ; then 
     227                echo "Improper number of input arguments." 
     228                usage 
     229                exit 1 
     230            fi 
     231            DEBIRF_PROFILE="$1" 
     232            DEBIRF_KERNEL_PACKAGE="$2" 
     233            break 
     234            ;; 
     235    esac 
     236done 
    206237 
    207238# check specified kernel package exists 
     
    263294 
    264295# check variables 
    265 echo "Debirf variables:" 
    266 for var in ${!DEBIRF_*}; do 
    267     if [ $var ] ; then 
    268         export $var 
    269     else 
    270         failure "Variable '$var' not properly set." 
    271     fi 
    272 done 
    273 env | /bin/grep "^DEBIRF_" 
    274 read -p "enter to continue: " OK 
     296if [ "$CHECK_VARS" ] ; then 
     297    echo "Debirf variables:" 
     298    for var in ${!DEBIRF_*}; do 
     299        if [ $var ] ; then 
     300            export $var 
     301        else 
     302            failure "Variable '$var' not properly set." 
     303        fi 
     304    done 
     305    env | /bin/grep "^DEBIRF_" 
     306    read -p "enter to continue: " OK 
     307fi 
    275308 
    276309# create debootstrap root 
    277310if [ -d "$DEBIRF_ROOT" ] ; then 
    278311    echo "Directory $DEBIRF_ROOT already exists." 
    279     echo "Select one of the following:" 
    280     select foo in 'rewrite' 'overwrite' 'skip' 'exit' ; do 
    281         case "$foo" in 
    282             'wipe & rewrite') 
    283                 msg "clearing old debirf root..." 
    284                 rm -rf "$DEBIRF_ROOT" 
    285                 create_debootstrap 
    286                 ;; 
    287             'overwrite') 
    288                 create_debootstrap 
    289                 ;; 
    290             'skip') 
    291                 ;; 
    292             *) 
    293                 failure "aborting." 
    294                 ;; 
    295         esac 
    296         break 
    297     done 
     312    if [ -z "$WRITE_MODE" ] ; then 
     313        echo "Select one of the following:" 
     314        select foo in 'new' 'overwrite' 'skip' 'exit' ; do 
     315            case "$foo" in 
     316                'new') 
     317                    WRITE_MODE=rewrite 
     318                    ;; 
     319                'overwrite') 
     320                    WRITE_MODE=overwrite 
     321                    ;; 
     322                'skip') 
     323                    WRITE_MODE=skip 
     324                    ;; 
     325                *) 
     326                    failure "aborting." 
     327                    ;; 
     328            esac 
     329            break 
     330        done 
     331    fi 
    298332else 
    299     create_debootstrap 
    300 fi 
     333    WRITE_MODE=new 
     334fi 
     335case "$WRITE_MODE" in 
     336    'new') 
     337        msg "creating debirf root..." 
     338        create_debootstrap 
     339        ;; 
     340    'rewrite') 
     341        msg "clearing old debirf root..." 
     342        rm -rf "$DEBIRF_ROOT" 
     343        msg "creating debirf root..." 
     344        create_debootstrap 
     345        ;; 
     346    'overwrite') 
     347        msg "overwriting old debirf root..." 
     348        create_debootstrap 
     349        ;; 
     350    'skip') 
     351        msg "skipping debootstrap..." 
     352        ;; 
     353    *) 
     354        failure "aborting." 
     355        ;; 
     356esac 
    301357 
    302358setup_debirf_info 
  • trunk/debirf/fs/usr/share/debirf/plugins/install-kernel

    r747 r755  
    1 #!/bin/sh 
     1#!/bin/bash 
    22 
    33# debirf plugin: install-kernel 
     
    2626 
    2727install_kernel_apt() { 
    28     debirf_exec apt-get --assume-yes --force-yes -f install "$1" 
     28    debirf_exec apt-get --assume-yes install "$1" 
    2929} 
    3030 
     
    3333    cat >"$DEBIRF_ROOT/etc/kernel-img.conf" <<EOF 
    3434# debirf: default kernel-img options: 
    35 do_symlinks = yes 
     35do_symlinks = no 
    3636do_bootloader = no 
    37 do_initrd = yes 
     37warn_initrd = no 
     38silent_modules = yes 
    3839EOF 
    3940 
Note: See TracChangeset for help on using the changeset viewer.