Magellan Linux

Diff of /tags/grubby-8_15/new-kernel-pkg

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

trunk/mkinitrd-magellan/grubby/new-kernel-pkg revision 1305 by niro, Fri May 27 17:31:15 2011 UTC trunk/grubby/new-kernel-pkg revision 1691 by niro, Fri Feb 17 23:10:15 2012 UTC
# Line 40  else Line 40  else
40  fi  fi
41    
42  [ -f /etc/conf.d/grubby ] && . /etc/conf.d/grubby  [ -f /etc/conf.d/grubby ] && . /etc/conf.d/grubby
43    [ -f /etc/conf.d/grubby-uboot ] && . /etc/conf.d/grubby-uboot
44    
45  cfgGrub=""  cfgGrub=""
46  cfgLilo=""  cfgLilo=""
47    cfguBoot=""
48  runLilo=""  runLilo=""
49  grubConfig=""  grubConfig=""
50    
# Line 77  then Line 79  then
79   lilo=/sbin/zipl   lilo=/sbin/zipl
80   runLilo="yes"   runLilo="yes"
81   isx86=""   isx86=""
82    elif [[ ${ARCH} = armv7l ]]
83    then
84     liloConfig=""
85     bootPrefix=/boot
86     ubootDir=${UBOOT_DIR:-"/boot/uboot"}
87     ubootScript=$ubootDir/${UBOOT_SCR:-"boot.scr"}
88     ubootKList=${UBOOT_KLIST:-"klist.txt"}
89     ubootDevice=/dev/${UBOOT_DEVICE:-"mmcblk0p1"}
90     ubootDefaultImage=${UBOOT_UIMAGE:-"uImage"}
91     ubootDefaultInitrd=${UBOOT_UINITRD:-"uInitrd"}
92     mounted=""
93     liloFlag=""
94     isx86=""
95  else  else
96   # this leaves i?86 and x86_64   # this leaves i?86 and x86_64
97   liloConfig=/etc/lilo.conf   liloConfig=/etc/lilo.conf
# Line 89  fi Line 104  fi
104  mode=""  mode=""
105  version=""  version=""
106  initrd=""  initrd=""
107    dracut=""
108    dracuthostonly=""
109  initrdfile=""  initrdfile=""
110  moddep=""  moddep=""
111  verbose=""  verbose=""
# Line 96  makedefault="" Line 113  makedefault=""
113  package=""  package=""
114  mbkernel=""  mbkernel=""
115  mbargs=""  mbargs=""
116    adddracutargs=""
117    addplymouthinitrd=""
118    
119  usage()  usage()
120  {  {
121   echo "Usage: $(basename $0) [-v] [--mkinitrd] [--rminitrd]" >&2   echo "Usage: $(basename $0) [-v] [--mkinitrd] [--rminitrd] [--dracut]" >&2
122   echo "       [--initrdfile=<initrd-image>] [--depmod] [--rmmoddep]" >&2   echo "       [--initrdfile=<initrd-image>] [--depmod] [--rmmoddep]" >&2
123   echo "       [--kernel-args=<args>] [--remove-args=<args>]" >&2   echo "       [--kernel-args=<args>] [--remove-args=<args>]" >&2
124   echo "       [--banner=<banner>] [--multiboot=multiboot]" >&2   echo "       [--banner=<banner>] [--multiboot=multiboot]" >&2
125   echo "       [--mbargs=mbargs] [--make-default]" >&2   echo "       [--mbargs=mbargs] [--make-default] [--add-dracut-args]" >&2
126     echo "       [--add-plymouth-initrd]" >&2
127     echo "       [--host-only]" >&2
128   echo "       <--install | --remove | --update> <kernel-version>" >&2   echo "       <--install | --remove | --update> <kernel-version>" >&2
129   echo "       (ex: $(basename $0) --mkinitrd --depmod --install 2.4.7-2)" >&2   echo "       (ex: $(basename $0) --mkinitrd --depmod --install 2.4.7-2)" >&2
130   exit 1   exit 1
# Line 111  usage() Line 132  usage()
132    
133  run_grub2()  run_grub2()
134  {  {
135   if [ -d /boot/grub2 -a -x /sbin/grub2-mkconfig ]   if [ -d /boot/grub -a -x /sbin/grub-mkconfig ]
136   then   then
137   cp /boot/grub2/grub.cfg /boot/grub2/grub.cfg.old   cp /boot/grub/grub.cfg /boot/grub/grub.cfg.old
138   /sbin/grub2-mkconfig -o /boot/grub2/grub.cfg   /sbin/grub-mkconfig -o /boot/grub/grub.cfg
139   fi   fi
140  }  }
141    
# Line 132  install() Line 153  install()
153   then   then
154   [[ -n ${verbose} ]] && echo "found ${initrdfile} and using it with grubby"   [[ -n ${verbose} ]] && echo "found ${initrdfile} and using it with grubby"
155   INITRD="--initrd ${initrdfile}"   INITRD="--initrd ${initrdfile}"
156    
157     if [[ -n ${addplymouthinitrd} ]]
158     then
159     INITRD="${INITRD} --extra-initrd ${bootPrefix}/initrd-plymouth.img"
160     fi
161   fi   fi
162    
163   # FIXME: is this a good heuristic to find out if we're on iSeries?   # FIXME: is this a good heuristic to find out if we're on iSeries?
# Line 247  remove() Line 273  remove()
273   else   else
274   [[ -n ${verbose} ]] && echo "${liloConfig} does not exist, not running grubby"   [[ -n ${verbose} ]] && echo "${liloConfig} does not exist, not running grubby"
275   fi   fi
276    
277     if [[ -n ${cfguBoot} ]]
278     then
279     [[ -n ${verbose} ]] && echo "removing ${version} from ${ubootDir}..."
280    
281     if [ -f ${ubootDir}/${ubootKList} ]
282     then
283     tmpKList=$(mktemp ${ubootDir}/${ubootKList}.XXXX)
284     curversion=$(tail -n1 ${ubootDir}/${ubootKList})
285     sed "/${version}/d" ${ubootDir}/${ubootKList} > ${tmpKList}
286     newversion=$(tail -n1 ${tmpKList})
287     if [ -f ${ubootDir}/uImage-${newversion} ] && [ -f ${ubootDir}/uInitrd-${newversion} ]
288     then
289     if [[ ${curversion} != ${newversion} ]]
290     then
291     cp -fp ${ubootDir}/uImage-${newversion} ${ubootDir}/${ubootDefaultImage}
292     if [ $? -ne 0 ]
293     then
294     [[ -n ${verbose} ]] && echo "copy uImage-${newversion} error, default kernel not replaced!" && exit
295     fi
296     cp -fp ${ubootDir}/uInitrd-${newversion} ${ubootDir}/${ubootDefaultInitrd}
297     if [ $? -ne 0 ]
298     then
299     [[ -n ${verbose} ]] && echo "copy uInitrd-${newversion} error, default Initrd not replaced!" && exit
300     fi
301     fi
302    
303     [[ -n ${verbose} ]] && echo "removing uImage-${version}"
304     if [ -f ${ubootDir}/uImage-${version} ]
305     then
306     rm -f ${ubootDir}/uImage-${version}
307     else
308     [[ -n ${verbose} ]] && echo "uImage-${version} did not exist!"
309     fi
310    
311     [[ -n ${verbose} ]] && echo "removing uInitrd-${version}"
312     if [ -f ${ubootDir}/uInitrd-${version} ]
313     then
314     rm -f ${ubootDir}/uInitrd-${version}
315     else
316     [[ -n ${verbose} ]] && echo "uInitrd-${version} did not exist!"
317     fi
318    
319     mv ${tmpKList} ${ubootDir}/${ubootKList}
320     else
321     [[ -n ${verbose} ]] && echo "uImage ${newversion} does not exist!"
322     [ -f ${tmpKList} ] && rm -f ${tmpKList}
323     fi
324     else
325     [[ -n ${verbose} ]] && echo "No previous kernel version. uBoot images not removed!"
326     fi
327     else
328     [[ -n ${verbose} ]] && echo "${ubootScript} does not exist, not modifying ${ubootDir}"
329     fi
330  }  }
331    
332  update()  update()
# Line 262  update() Line 342  update()
342   then   then
343   [[ -n ${verbose} ]] && echo "found ${initrdfile} and using it with grubby"   [[ -n ${verbose} ]] && echo "found ${initrdfile} and using it with grubby"
344   INITRD="--initrd ${initrdfile}"   INITRD="--initrd ${initrdfile}"
345    
346     if [[ -n ${addplymouthinitrd} ]]
347     then
348     INITRD="${INITRD} --extra-initrd ${bootPrefix}/initrd-plymouth.img"
349     fi
350   fi   fi
351    
352   # Run grub2's configuration update in parallel, if it is installed   # Run grub2's configuration update in parallel, if it is installed
# Line 300  update() Line 385  update()
385   else   else
386   [[ -n ${verbose} ]] && echo "${liloConfig} does not exist, not running grubby"   [[ -n ${verbose} ]] && echo "${liloConfig} does not exist, not running grubby"
387   fi   fi
388    
389     if [[ -n ${cfguBoot} ]]
390     then
391     [[ -n ${verbose} ]] && echo "adding $version to ${ubootDir}..."
392    
393     [[ -n ${verbose} ]] && echo "creating uImage-${version}"
394     mkimage -A arm -O linux -T kernel -C none -a 0x80008000 -e 0x80008000 \
395     -n ${version} -d ${bootPrefix}/${kernelName}-${version} ${ubootDir}/uImage-${version}
396    
397     [[ -n ${verbose} ]] && echo "creating uInitrd-${version}"
398     mkimage -A arm -O linux -T ramdisk -C none -a 0 -e 0 \
399     -n initramfs -d ${initrdfile} ${ubootDir}/uInitrd-${version}
400    
401     if [ -f ${ubootDir}/uImage-${version} ] && [ -f ${ubootDir}/uInitrd-${version} ]
402     then
403     cp -fp ${ubootDir}/uImage-${version} ${ubootDir}/${ubootDefaultImage}
404     if [ $? -ne 0 ]
405     then
406     [[ -n ${verbose} ]] && echo "copy uImage-${version} error, kernel not installed!" && exit
407     fi
408     cp -fp ${ubootDir}/uInitrd-${version} ${ubootDir}/${ubootDefaultInitrd}
409     if [ $? -ne 0 ]
410     then
411     [[ -n ${verbose} ]] && echo "copy uInitrd-${version} error, kernel not installed!" && exit
412     fi
413     echo ${version} >> ${ubootDir}/${ubootKList}
414     else
415     [[ -n ${verbose} ]] && echo "cannot make ${version} the default"
416     fi
417     else
418     [[ -n ${verbose} ]] && echo "${ubootScript} does not exist, not setting up ${ubootDir}"
419     fi
420  }  }
421    
422  mkinitrd()  mkinitrd()
423  {  {
424     if [[ -n ${dracut} ]]
425     then
426     tool="/sbin/dracut ${dracuthostonly} -f ${initrdfile} ${version}"
427     else
428     tool="/sbin/mkinitrd --allow-missing -f ${initrdfile} ${version}"
429     fi
430   [[ -n ${verbose} ]] && echo "creating initrd ${initrdfile} using ${version}"   [[ -n ${verbose} ]] && echo "creating initrd ${initrdfile} using ${version}"
431   /sbin/mkinitrd --allow-missing -f ${initrdfile} ${version}   ${tool}
432   rc=$?   rc=$?
433   if [ ${rc} != 0 ]   if [ ${rc} != 0 ]
434   then   then
# Line 344  do Line 467  do
467   initrd="remove"   initrd="remove"
468   ;;   ;;
469    
470     --dracut)
471     dracut=--dracut
472     ;;
473    
474     --host-only)
475     dracuthostonly=-H
476     ;;
477    
478   --initrdfile*)   --initrdfile*)
479   if echo $1 | grep '=' >/dev/null   if echo $1 | grep '=' >/dev/null
480   then   then
# Line 427  do Line 558  do
558   fi   fi
559   ;;   ;;
560    
561     --add-dracut-args)
562     adddracutargs=--add-dracut-args
563     ;;
564    
565     --add-plymouth-initrd)
566     addplymouthinitrd=--add-plymouth-initrd
567     ;;
568    
569   -v)   -v)
570   verbose=-v   verbose=-v
571   ;;   ;;
# Line 478  fi Line 617  fi
617  if [[ -z ${initrdfile} ]]  if [[ -z ${initrdfile} ]]
618  then  then
619   INITRD_NAME_PREFIX="initrd"   INITRD_NAME_PREFIX="initrd"
620     if [[ -n ${dracut} ]]
621     then
622     INITRD_NAME_PREFIX="initramfs"
623     fi
624    
625   if [[ $(uname -m) = ia64 ]]   if [[ $(uname -m) = ia64 ]]
626   then   then
# Line 488  then Line 631  then
631  fi  fi
632  [[ -n ${verbose} ]] && echo "initrdfile is ${initrdfile}"  [[ -n ${verbose} ]] && echo "initrdfile is ${initrdfile}"
633    
634    # add dracut i18n, keyboard and plymouth kernel args if requested
635    if [[ -n ${dracut} ]] || [[ -n ${adddracutargs} ]]
636    then
637     [ -r /etc/conf.d/keymap ] && . /etc/conf.d/keymap
638     [ -r /etc/conf.d/consolefont ] && . /etc/conf.d/consolefont
639    
640     if [[ -n ${KEYMAP} ]]
641     then
642     kernargs="${kernargs} KEYTABLE=${KEYMAP}"
643     fi
644    
645     if [[ -n ${CONSOLEFONT} ]]
646     then
647     kernargs="${kernargs} SYSFONT=${CONSOLEFONT}"
648     fi
649    fi
650    
651  # set this as the default if we have the package and it matches  # set this as the default if we have the package and it matches
652  if [[ ${mode} = --install ]] && [[ ${UPDATEDEFAULT} = yes ]] && [[ -n ${package} ]] &&  if [[ ${mode} = --install ]] && [[ ${UPDATEDEFAULT} = yes ]] && [[ -n ${package} ]] &&
653   [[ -n ${DEFAULTKERNEL} ]] && [[ ${package} = ${DEFAULTKERNEL} ]]   [[ -n ${DEFAULTKERNEL} ]] && [[ ${package} = ${DEFAULTKERNEL} ]]
# Line 521  fi Line 681  fi
681  [[ -n ${grubConfig} ]] && [ -f ${grubConfig} ] && cfgGrub=1  [[ -n ${grubConfig} ]] && [ -f ${grubConfig} ] && cfgGrub=1
682  [[ -n ${liloConfig} ]] && [ -f ${liloConfig} ] && cfgLilo=1  [[ -n ${liloConfig} ]] && [ -f ${liloConfig} ] && cfgLilo=1
683    
684    # if we have a uBoot directory, check if it is mounted.
685    # if not, mount it. Then check if a boot script exists.
686    if [[ -n ${ubootDir} ]]
687    then
688     mountEntry=$(mount | grep ${ubootDir})
689     if [[ -z ${mountEntry} ]]
690     then
691     mount ${ubootDevice} ${ubootDir}
692     mounted=1
693     fi
694     [ -f ${ubootScript} ] && cfguBoot=1
695    fi
696    
697  # if we have a lilo config on an x86 box, see if the default boot loader  # if we have a lilo config on an x86 box, see if the default boot loader
698  # is lilo to determine if it should be run  # is lilo to determine if it should be run
699  if [[ -n ${cfgLilo} ]] && [[ -n ${isx86} ]]  if [[ -n ${cfgLilo} ]] && [[ -n ${isx86} ]]

Legend:
Removed from v.1305  
changed lines
  Added in v.1691