Ignore:
Timestamp:
May 2, 2007 7:13:57 PM (6 years ago)
Author:
jrollins
Message:

debirf: made changes for profile structure. For some reason I'm not happy with
how it's working out, though. Something doesn't feel right. It may just be me,
though.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/debirf/fs/usr/sbin/make-debirf

    r473 r475  
    1616CMD=$(basename $0) 
    1717 
    18 DEBIRF_CONF=${DEBIRF_CONF:-"/etc/debirf/debirf.conf"} 
    19 [ -f "$DEBIRF_CONF" ] && source "$DEBIRF_CONF" 
    20  
    21 ### defaults 
    22 # debirf label 
    23 DEBIRF_LABEL=${DEBIRF_LABEL:-"debirf"} 
    24 # where to build the debirf 
    25 DEBIRF_PATH=${DEBIRF_PATH:-"/var/lib/debirf"} 
    26 # the debirf root, used by plugins 
    27 DEBIRF_ROOT=${DEBIRF_ROOT:-"$DEBIRF_PATH/root"} 
    28 # the plugins directory 
    29 DEBIRF_PLUGINS=${DEBIRF_PLUGINS:-"/usr/share/debirf/plugins"} 
    30 # debirf boot method 
    31 DEBIRF_METHOD=${DEBIRF_METHOD:-"stupid_simple"} 
    32 # Debian mirror 
    33 DEBIRF_MIRROR=${DEBIRF_MIRROR:-"http://mirrors.kernel.org/debian"} 
    34 # what distribution should debirf be built from? 
    35 DEBIRF_DISTRO=${DEBIRF_DISTRO:-"lenny"} 
    36  
    37 DEBIRF_COMMON="/usr/share/debirf/common" 
    38  
    39 DEBIRF_INFO_TARGET="${DEBIRF_ROOT}/etc/debirf/debirf.info" 
    40  
    41 # set locale default 
    42 export LC_CTYPE="C" 
    43 export LANGUAGE="C" 
    44 export LANG="C" 
     18DEBIRF_COMMON=${DEBIRF_COMMON:-"/usr/share/debirf/common"} 
     19source "$DEBIRF_COMMON" 
    4520 
    4621############################################################### 
     
    4823 
    4924usage() { 
    50 cat <<EOF 
    51 Usage: $CMD kernel-image.deb 
    52  
    53 Create a debirf initramfs. 
    54  
    55 'man make-debirf' for more information. 
     25    cat <<EOF 
     26Usage: $CMD profile kernel-image.deb 
     27       $CMD kernel-image.deb 
    5628EOF 
     29} 
     30 
     31failure() { 
     32    echo "$1" >&2 
     33    exit ${2:-'1'} 
    5734} 
    5835 
     
    12097# umount sys, proc 
    12198umount_proc-sys() { 
     99    [ "$DEBIRF_ROOT" ] || exit 
    122100    if mount | grep -q "$DEBIRF_ROOT/proc" ; then 
    123101        msg "umounting proc..." 
     
    135113trap umount_proc-sys EXIT 
    136114 
    137 # check specified kernel package exists, and determine kernel name 
    138 DEBIRF_KERNEL_PACKAGE="$1" 
     115if [ "$1" = '-h' -o "$1" = '--help' ] ; then 
     116    usage 
     117    exit 0 
     118fi 
     119 
     120case $# in 
     121    1) 
     122        DEBIRF_KERNEL_PACKAGE="$1" 
     123        ;; 
     124    2) 
     125        DEBIRF_PROFILE="$1" 
     126        DEBIRF_KERNEL_PACKAGE="$2" 
     127        ;; 
     128    *) 
     129        echo "Improper number of input arguments." 
     130        usage 
     131        exit 1 
     132        ;; 
     133esac 
     134 
     135# check specified kernel package exists 
    139136if [ ! -f "$DEBIRF_KERNEL_PACKAGE" ] ; then 
    140     echo "Specified kernel package $DEBIRF_KERNEL_PACKAGE not found." 
    141     echo 
    142     usage 
    143     exit 1 
    144 fi 
    145  
    146 # check for common functions 
    147 [ -f "$DEBIRF_COMMON" ] || failure "debirf function file $DEBIRF_COMMON not found." 
    148 source "$DEBIRF_COMMON" 
    149  
    150 # check plugin directory exists 
    151 if [ ! -d "$DEBIRF_PLUGINS" ] ; then 
    152     read -p "Plugin directory $DEBIRF_PLUGINS not found.  Continue? [y|N]: " -n 1 OK ; [ -z $OK ] || echo 
     137    failure "Specified kernel package '$DEBIRF_KERNEL_PACKAGE' not found." 
     138fi 
     139 
     140# check for debirf profile 
     141if [ -z "$DEBIRF_PROFILE" ] ; then 
     142    echo "Profile not specified." 
     143    read -p "Use default profile ('$DEBIRF_PROFILE_DEFAULT')? [Y|n]: " OK 
     144    if [ -z "$OK" -o "${OK/y/Y}" = 'Y' ] ; then 
     145        DEBIRF_PROFILE="$DEBIRF_PROFILE_DEFAULT" 
     146    fi 
     147fi 
     148if [ "$DEBIRF_PROFILE" ] ; then 
     149    if [ ! -d "$DEBIRF_PROFILE" ] ; then 
     150        if [ ! -d "$DEBIRF_PROFILED/$DEBIRF_PROFILE" ] ; then 
     151            failure "Profile '$DEBIRF_PROFILE' not found." 
     152        else 
     153            DEBIRF_PROFILE="$DEBIRF_PROFILED/$DEBIRF_PROFILE" 
     154        fi 
     155    fi 
     156    echo "Using profile '$DEBIRF_PROFILE'." 
     157    DEBIRF_CONF="$DEBIRF_PROFILE/debirf.conf" 
     158    DEBIRF_PLUGINS="$DEBIRF_PROFILE/plugins.d" 
     159fi 
     160 
     161# find debirf.conf 
     162if [ "$DEBIRF_CONF" ] ; then 
     163    if [ -f "$DEBIRF_CONF" ] ; then 
     164        source "$DEBIRF_CONF" 
     165    else 
     166        failure "Config file '$DEBIRF_CONF' not found." 
     167    fi 
     168fi 
     169 
     170# find plugin directory 
     171if [ "$DEBIRF_PLUGINS" ] ; then 
     172    if [ ! -d "$DEBIRF_PLUGINS" ] ; then 
     173        failure "Plugin directory '$DEBIRF_PLUGINS' not found." 
     174    fi 
     175else 
     176    echo "Plugin directory file not specified." 
     177    read -p "Continue without plugins? [y|N]: " OK 
    153178    if [ "${OK/y/Y}" != 'Y' ] ; then 
    154179        failure "aborting." 
     
    156181fi 
    157182 
     183# echo 
     184# for var in ${!DEBIRF_*}; do 
     185#     export $var 
     186# done 
     187# env | /bin/grep "^DEBIRF_" 
     188# exit 
     189 
    158190# create debootstrap root 
    159191if [ -d "$DEBIRF_ROOT" ] ; then 
    160     echo "Directory $DEBIRF_ROOT already exists.  Select one of the following:" 
     192    echo "Directory $DEBIRF_ROOT already exists." 
     193    echo "Select one of the following:" 
    161194    select foo in 'rewrite' 'overwrite' 'skip' 'exit' ; do 
    162195        case "$foo" in 
     
    179212fi 
    180213 
    181 # if [ -d "$DEBIRF_ROOT" ] ; then 
    182 #     read -p "Directory $DEBIRF_ROOT already exists.  write over? [y|N]: " -n 1 OK ; [ -z $OK ] || echo 
    183 #     if [ "${OK/y/Y}" = 'Y' ] ; then 
    184 #       msg "installing new root..." 
    185 #       create_debootstrap 
    186 #     fi 
    187 # else 
    188 #     msg "installing root..." 
    189 #     create_debootstrap 
    190 # fi 
    191  
    192214setup_debirf_info 
    193215 
    194 mount_proc-sys 
    195  
    196 # update apt 
    197 debirf_exec apt-get update 
    198  
    199 # install plugins 
    200 msg "installing plugins..." 
    201 run_plugins 
    202  
    203 umount_proc-sys 
     216if [ "$DEBIRF_PLUGINS" ] ; then 
     217    mount_proc-sys 
     218     
     219    # update apt 
     220    debirf_exec apt-get update 
     221     
     222    # install plugins 
     223    msg "installing plugins..." 
     224    run_plugins 
     225 
     226    umount_proc-sys 
     227fi 
    204228 
    205229# clear mtab 
     
    212236KERNAVAIL=$(ls -1 "$DEBIRF_ROOT/lib/modules" | head -n1) 
    213237DEBIRF_INITRD="${DEBIRF_LABEL}_${DEBIRF_DISTRO}_${KERNAVAIL}.cgz" 
    214 create_initrd_${DEBIRF_METHOD} "$DEBIRF_PATH/$DEBIRF_INITRD" 
     238create_initrd_${DEBIRF_METHOD} "$DEBIRF_BUILDD/$DEBIRF_INITRD" 
    215239 
    216240# final output 
    217 DEBIRF_KERNEL=$(ls "$DEBIRF_PATH" | grep "vmlinu" | grep "$KERNAVAIL") 
     241DEBIRF_KERNEL=$(ls "$DEBIRF_BUILDD" | grep "vmlinu" | grep "$KERNAVAIL") 
    218242msg "debirf initrd created." 
    219 if [ "$DEBIRF_PATH/$DEBIRF_KERNEL" ] ; then 
    220     msg "kernel: $DEBIRF_PATH/$DEBIRF_KERNEL" 
    221 fi 
    222 msg "initrd: $DEBIRF_PATH/$DEBIRF_INITRD" 
     243if [ "$DEBIRF_BUILDD/$DEBIRF_KERNEL" ] ; then 
     244    msg "kernel: $DEBIRF_BUILDD/$DEBIRF_KERNEL" 
     245fi 
     246msg "initrd: $DEBIRF_BUILDD/$DEBIRF_INITRD" 
Note: See TracChangeset for help on using the changeset viewer.