Magellan Linux

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

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

revision 1332 by niro, Fri Jun 3 20:32:19 2011 UTC revision 2238 by niro, Mon Oct 21 13:22:57 2013 UTC
# Line 25  Line 25 
25  # along with this program.  If not, see <http://www.gnu.org/licenses/>.  # along with this program.  If not, see <http://www.gnu.org/licenses/>.
26  #  #
27    
28    read_os_release()
29    {
30     local NAME
31     local ID
32     local Version
33     local Version_ID
34     local PRETTY_NAME
35     local ANSI_COLOR
36     local CPE_NAME
37    
38     if [[ -f /etc/os-release ]]
39     then
40     source /etc/os-release
41    
42     case $1 in
43     name) echo "${NAME}" ;;
44     id) echo "${ID}" ;;
45     version) echo "${Version}" ;;
46     version_id) echo "${Version_ID}" ;;
47     pretty_name) echo "${PRETTY_NAME}" ;;
48     ansi_color) echo "${ANSI_COLOR}" ;;
49     cpe_name) echo "${CPE_NAME}" ;;
50     esac
51     fi
52    }
53    
54  PATH=/sbin:/bin:$PATH  PATH=/sbin:/bin:$PATH
55    
56  lilo=/sbin/lilo  lilo=/sbin/lilo
# Line 40  else Line 66  else
66  fi  fi
67    
68  [ -f /etc/conf.d/grubby ] && . /etc/conf.d/grubby  [ -f /etc/conf.d/grubby ] && . /etc/conf.d/grubby
69    [ -f /etc/conf.d/grubby-uboot ] && . /etc/conf.d/grubby-uboot
70    
71    cfgGrub2=""
72    cfgGrub2Efi=""
73  cfgGrub=""  cfgGrub=""
74  cfgLilo=""  cfgLilo=""
75    cfgExtlinux=""
76    cfguBoot=""
77  runLilo=""  runLilo=""
78  grubConfig=""  grubConfig=""
79    grub2Config=""
80    grub2EfiConfig=""
81    extlinuxConfig=""
82    
83  ARCH=$(uname -m)  ARCH=$(uname -m)
84    
# Line 57  then Line 91  then
91  elif [[ ${ARCH} = ppc64 ]] || [[ ${ARCH} = ppc ]]  elif [[ ${ARCH} = ppc64 ]] || [[ ${ARCH} = ppc ]]
92  then  then
93   liloConfig=/etc/yaboot.conf   liloConfig=/etc/yaboot.conf
94     grub2Config=/boot/grub/grub.cfg
95   bootPrefix=/boot   bootPrefix=/boot
96   lilo=/sbin/ybin   lilo=/sbin/ybin
97   liloFlag=yaboot   liloFlag=yaboot
# Line 77  then Line 112  then
112   lilo=/sbin/zipl   lilo=/sbin/zipl
113   runLilo="yes"   runLilo="yes"
114   isx86=""   isx86=""
115    elif [[ ${ARCH} =~ armv[5|7].*l ]]
116    then
117     liloConfig=""
118     bootPrefix=/boot
119     ubootDir=${UBOOT_DIR:-"/boot"}
120     ubootScript=$ubootDir/${UBOOT_SCR:-"boot.scr"}
121     ubootKList=${UBOOT_KLIST:-"klist.txt"}
122     ubootDevice=/dev/${UBOOT_DEVICE:-"mmcblk0p1"}
123     ubootDefaultImage=${UBOOT_UIMAGE:-"uImage"}
124     ubootDefaultInitrd=${UBOOT_UINITRD:-"uInitrd"}
125     ubootAddress=${UBOOT_IMGADDR:-"0x00008000"}
126     mounted=""
127     liloFlag=""
128     isx86=""
129  else  else
130   # this leaves i?86 and x86_64   # this leaves i?86 and x86_64
131   liloConfig=/etc/lilo.conf   liloConfig=/etc/lilo.conf
132   grubConfig=/boot/grub/grub.conf   grubConfig=/boot/grub/grub.conf
133     grub2Config=/boot/grub/grub.cfg
134     grub2EfiConfig=/boot/grub/grub-efi.cfg
135     extlinuxConfig=/boot/extlinux/extlinux.conf
136   bootPrefix=/boot   bootPrefix=/boot
137   liloFlag=lilo   liloFlag=lilo
138   isx86="yes"   isx86="yes"
# Line 89  fi Line 141  fi
141  mode=""  mode=""
142  version=""  version=""
143  initrd=""  initrd=""
144    dracut=""
145    dracuthostonly=""
146  initrdfile=""  initrdfile=""
147  moddep=""  moddep=""
148  verbose=""  verbose=""
149  makedefault=""  makedefault=""
150  package=""  package=""
151  mbkernel=""  mbkernel="${HYPERVISOR}"
152  mbargs=""  mbargs="${HYPERVISOR_ARGS}"
153    adddracutargs=""
154    addplymouthinitrd=""
155    
156  usage()  usage()
157  {  {
158   echo "Usage: $(basename $0) [-v] [--mkinitrd] [--rminitrd]" >&2   echo "Usage: $(basename $0) [-v] [--mkinitrd] [--rminitrd] [--dracut]" >&2
159   echo "       [--initrdfile=<initrd-image>] [--depmod] [--rmmoddep]" >&2   echo "       [--initrdfile=<initrd-image>] [--depmod] [--rmmoddep]" >&2
160   echo "       [--kernel-args=<args>] [--remove-args=<args>]" >&2   echo "       [--kernel-args=<args>] [--remove-args=<args>]" >&2
161   echo "       [--banner=<banner>] [--multiboot=multiboot]" >&2   echo "       [--banner=<banner>] [--multiboot=multiboot]" >&2
162   echo "       [--mbargs=mbargs] [--make-default]" >&2   echo "       [--mbargs=mbargs] [--make-default] [--add-dracut-args]" >&2
163     echo "       [--add-plymouth-initrd]" >&2
164     echo "       [--host-only]" >&2
165   echo "       <--install | --remove | --update> <kernel-version>" >&2   echo "       <--install | --remove | --update> <kernel-version>" >&2
166   echo "       (ex: $(basename $0) --mkinitrd --depmod --install 2.4.7-2)" >&2   echo "       (ex: $(basename $0) --mkinitrd --depmod --install 2.4.7-2)" >&2
167   exit 1   exit 1
168  }  }
169    
 run_grub2()  
 {  
  if [ -d /boot/grub2 -a -x /sbin/grub2-mkconfig ]  
  then  
  cp /boot/grub2/grub.cfg /boot/grub2/grub.cfg.old  
  /sbin/grub2-mkconfig -o /boot/grub2/grub.cfg  
  fi  
 }  
   
170  install()  install()
171  {  {
172   # XXX kernel should be able to be specified also (or work right on ia64)   # XXX kernel should be able to be specified also (or work right on ia64)
# Line 132  install() Line 181  install()
181   then   then
182   [[ -n ${verbose} ]] && echo "found ${initrdfile} and using it with grubby"   [[ -n ${verbose} ]] && echo "found ${initrdfile} and using it with grubby"
183   INITRD="--initrd ${initrdfile}"   INITRD="--initrd ${initrdfile}"
184    
185     if [[ -n ${addplymouthinitrd} ]]
186     then
187     INITRD="${INITRD} --extra-initrd ${bootPrefix}/initrd-plymouth.img"
188     fi
189   fi   fi
190    
191   # 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 150  install() Line 204  install()
204   return   return
205   fi   fi
206    
  # Run grub2's configuration update in parallel, if it is installed  
  run_grub2  
   
207   # get the root filesystem to use   # get the root filesystem to use
208   rootdevice=$(awk '{ if ($1 !~ /^[ \t]*#/ && $2 == "/") { print $1; }}' /etc/fstab)   rootdevice=$(awk '{ if ($1 !~ /^[ \t]*#/ && $2 == "/") { print $1; }}' /etc/fstab  2>/dev/null)
209     if [[ -z $rootdevice ]]
210     then
211     rootdevice=$(grep -o -P "(?<=root=)\S+" /proc/cmdline)
212     fi
213    
214   if [[ -n ${mbkernel} ]] && [[ -n ${cfgLilo} ]] && [[ ${liloFlag} != elilo ]]   if [[ -n ${mbkernel} ]] && [[ -n ${cfgLilo} ]] && [[ ${liloFlag} != elilo ]]
215   then   then
# Line 168  install() Line 223  install()
223    
224   if [[ -n ${banner} ]]   if [[ -n ${banner} ]]
225   then   then
226   title="${banner} (${version})"   title="${banner} [ ${version} ]"
227   elif [ -f /etc/mageversion ]   elif [ -f /etc/mageversion ]
228   then   then
229   title="Magellan Linux $(< /etc/mageversion) (${version})"   title="Magellan Linux $(< /etc/mageversion) [ ${version} ]"
230     elif [[ $(read_os_release id) = magellan ]]
231     then
232     title="$(read_os_release name) $(read_os_release version_id) [ ${version} ]"
233   else   else
234   title="Magellan Linux (${version})"   title="Magellan Linux [ ${version} ]"
235   fi   fi
236   ${grubby} --add-kernel=${bootPrefix}/${kernelName}-${version} \   ${grubby} --grub -c ${grubConfig} \
237     --add-kernel=${bootPrefix}/${kernelName}-${version} \
238   ${INITRD} --copy-default ${makedefault} --title "${title}" \   ${INITRD} --copy-default ${makedefault} --title "${title}" \
239   ${mbkernel:+--add-multiboot="${mbkernel}"} ${mbargs:+--mbargs="${mbargs}"} \   ${mbkernel:+--add-multiboot="${mbkernel}"} ${mbargs:+--mbargs="${mbargs}"} \
240   --args="root=${rootdevice} ${kernargs}" --remove-kernel="TITLE=${title}"   --args="root=${rootdevice} ${kernargs}" --remove-kernel="TITLE=${title}"
241   else   else
242   [[ -n ${verbose} ]] && echo "${grubConfig} does not exist, not running grubby"   [[ -n ${verbose} ]] && echo "${grubConfig} does not exist, not running grubby for grub 0.97"
243     fi
244     if [[ -n ${cfgGrub2} ]]
245     then
246     [[ -n ${verbose} ]] && echo "adding ${version} to ${grub2Config}"
247    
248     if [[ -n ${banner} ]]
249     then
250     title="${banner} [ ${version} ]"
251     elif [ -f /etc/mageversion ]
252     then
253     title="Magellan Linux $(< /etc/mageversion) [ ${version} ]"
254     elif [[ $(read_os_release id) = magellan ]]
255     then
256     title="$(read_os_release name) $(read_os_release version_id) [ ${version} ]"
257     else
258     title="Magellan Linux [ ${version} ]"
259     fi
260     ${grubby} --grub2 -c ${grub2Config} \
261     --add-kernel=${bootPrefix}/${kernelName}-${version} \
262     ${INITRD} --copy-default ${makedefault} --title "${title}" \
263     ${mbkernel:+--add-multiboot="${mbkernel}"} \
264     ${mbargs:+--mbargs="${mbargs}"} \
265     --args="root=${rootdevice} ${kernargs}" --remove-kernel="TITLE=${title}"
266     else
267     [[ -n ${verbose} ]] && echo "${grub2Config} does not exist, not running grubby for grub 2"
268     fi
269     if [[ -n ${cfgGrub2Efi} ]]
270     then
271     [[ -n ${verbose} ]] && echo "adding ${version} to ${grub2EfiConfig}"
272    
273     if [[ -n ${banner} ]]
274     then
275     title="${banner} [ ${version} ]"
276     elif [ -f /etc/mageversion ]
277     then
278     title="Magellan Linux $(< /etc/mageversion) [ ${version} ]"
279     elif [[ $(read_os_release id) = magellan ]]
280     then
281     title="$(read_os_release name) $(read_os_release version_id) [ ${version} ]"
282     else
283     title="Magellan Linux [ ${version} ]"
284     fi
285     ${grubby} --grub2 -c ${grub2EfiConfig} --efi \
286     --add-kernel=${bootPrefix}/${kernelName}-${version} \
287     ${INITRD} --copy-default ${makedefault} --title "${title}" \
288     ${mbkernel:+--add-multiboot="${mbkernel}"} \
289     ${mbargs:+--mbargs="${mbargs}"} \
290     --args="root=${rootdevice} ${kernargs}" --remove-kernel="TITLE=${title}"
291     else
292     [[ -n ${verbose} ]] && echo "${grub2EfiConfig} does not exist, not running grubby for grub 2 with UEFI"
293   fi   fi
294    
295   if [[ -n ${cfgLilo} ]]   if [[ -n ${cfgLilo} ]]
# Line 206  install() Line 315  install()
315   else   else
316   [[ -n ${verbose} ]] && echo "${liloConfig} does not exist, not running grubby"   [[ -n ${verbose} ]] && echo "${liloConfig} does not exist, not running grubby"
317   fi   fi
318    
319     if [[ -n ${cfgExtlinux} ]]
320     then
321     [[ -n ${verbose} ]] && echo "adding ${version} to ${extlinuxConfig}"
322    
323     if [[ -n ${banner} ]]
324     then
325     title="${banner} [ ${version} ]"
326     elif [ -f /etc/mageversion ]
327     then
328     title="Magellan Linux $(< /etc/mageversion) [ ${version} ]"
329     elif [[ $(read_os_release id) = magellan ]]
330     then
331     title="$(read_os_release name) $(read_os_release version_id) [ ${version} ]"
332     else
333     title="Magellan Linux [ ${version} ]"
334     fi
335     ${grubby} --extlinux -c ${extlinuxConfig} \
336     --add-kernel=${bootPrefix}/${kernelName}-${version} \
337     ${INITRD} --copy-default ${makedefault} --title "${title}" \
338     ${mbkernel:+--add-multiboot="${mbkernel}"} ${mbargs:+--mbargs="${mbargs}"} \
339     --args="root=${rootdevice} ${kernargs}" --remove-kernel="TITLE=${title}"
340     else
341     [[ -n ${verbose} ]] && echo "${extlinuxConfig} does not exist, not running grubby for extlinux"
342     fi
343  }  }
344    
345  remove()  remove()
# Line 218  remove() Line 352  remove()
352   return   return
353   fi   fi
354    
  # Run grub2's configuration update in parallel, if it is installed  
  run_grub2  
   
355   if [[ -n ${cfgGrub} ]]   if [[ -n ${cfgGrub} ]]
356   then   then
357   [[ -n ${verbose} ]] && echo "removing ${version} from ${grubConfig}"   [[ -n ${verbose} ]] && echo "removing ${version} from ${grubConfig}"
358   ${grubby} --remove-kernel=${bootPrefix}/${kernelName}-${version}   ${grubby} --grub -c ${grubConfig} \
359     --remove-kernel=${bootPrefix}/${kernelName}-${version}
360   else   else
361   [[ -n ${verbose} ]] && echo "${grubConfig} does not exist, not running grubby"   [[ -n ${verbose} ]] && echo "${grubConfig} does not exist, not running grubby for grub 0.97"
362     fi
363     if [[ -n ${cfgGrub2} ]]
364     then
365     [[ -n ${verbose} ]] && echo "removing ${version} from ${grub2Config}"
366     ${grubby} --grub2 -c ${grub2Config} \
367     --remove-kernel=${bootPrefix}/${kernelName}-${version}
368     else
369     [[ -n ${verbose} ]] && echo "${grub2Config} does not exist, not running grubby for grub 2"
370     fi
371     if [[ -n ${cfgGrub2Efi} ]]
372     then
373     [[ -n ${verbose} ]] && echo "removing ${version} from ${grub2EfiConfig}"
374     ${grubby} --grub2 -c ${grub2EfiConfig} --efi \
375     --remove-kernel=${bootPrefix}/${kernelName}-${version}
376     else
377     [[ -n ${verbose} ]] && echo "${grub2EfiConfig} does not exist, not running grubby grub 2 with UEFI"
378   fi   fi
379    
380   if [[ -n ${cfgLilo} ]]   if [[ -n ${cfgLilo} ]]
# Line 247  remove() Line 395  remove()
395   else   else
396   [[ -n ${verbose} ]] && echo "${liloConfig} does not exist, not running grubby"   [[ -n ${verbose} ]] && echo "${liloConfig} does not exist, not running grubby"
397   fi   fi
398    
399     if [[ -n ${cfguBoot} ]]
400     then
401     [[ -n ${verbose} ]] && echo "removing ${version} from ${ubootDir}..."
402    
403     if [ -f ${ubootDir}/${ubootKList} ]
404     then
405     tmpKList=$(mktemp ${ubootDir}/${ubootKList}.XXXX)
406     curversion=$(tail -n1 ${ubootDir}/${ubootKList})
407     sed "/$version$/d" ${ubootDir}/${ubootKList} > ${tmpKList}
408     newversion=$(tail -n1 ${tmpKList})
409     if [ -f ${ubootDir}/uImage-${newversion} ] && [ -f ${ubootDir}/uInitrd-${newversion} ]
410     then
411     if [[ ${curversion} != ${newversion} ]]
412     then
413     cp -fp ${ubootDir}/uImage-${newversion} ${ubootDir}/${ubootDefaultImage}
414     if [ $? -ne 0 ]
415     then
416     [[ -n ${verbose} ]] && echo "copy uImage-${newversion} error, default kernel not replaced!" && exit
417     fi
418     cp -fp ${ubootDir}/uInitrd-${newversion} ${ubootDir}/${ubootDefaultInitrd}
419     if [ $? -ne 0 ]
420     then
421     [[ -n ${verbose} ]] && echo "copy uInitrd-${newversion} error, default Initrd not replaced!" && exit
422     fi
423     fi
424    
425     [[ -n ${verbose} ]] && echo "removing uImage-${version}"
426     if [ -f ${ubootDir}/uImage-${version} ]
427     then
428     rm -f ${ubootDir}/uImage-${version}
429     else
430     [[ -n ${verbose} ]] && echo "uImage-${version} did not exist!"
431     fi
432    
433     [[ -n ${verbose} ]] && echo "removing uInitrd-${version}"
434     if [ -f ${ubootDir}/uInitrd-${version} ]
435     then
436     rm -f ${ubootDir}/uInitrd-${version}
437     else
438     [[ -n ${verbose} ]] && echo "uInitrd-${version} did not exist!"
439     fi
440    
441     mv ${tmpKList} ${ubootDir}/${ubootKList}
442     else
443     [[ -n ${verbose} ]] && echo "uImage ${newversion} does not exist!"
444     [ -f ${tmpKList} ] && rm -f ${tmpKList}
445     fi
446     else
447     [[ -n ${verbose} ]] && echo "No previous kernel version.  U-Boot images not removed!"
448     fi
449     else
450     [[ -n ${verbose} ]] && echo "${ubootScript} does not exist, not modifying ${ubootDir}"
451     fi
452    
453     if [[ -n ${cfgExtlinux} ]]
454     then
455     [[ -n ${verbose} ]] && echo "removing ${version} from ${extlinuxConfig}"
456     ${grubby} --extlinux -c ${extlinuxConfig} \
457     --remove-kernel=${bootPrefix}/${kernelName}-${version}
458     else
459     [[ -n ${verbose} ]] && echo "${extlinuxConfig} does not exist, not running grubby for extlinux"
460     fi
461  }  }
462    
463  update()  update()
# Line 262  update() Line 473  update()
473   then   then
474   [[ -n ${verbose} ]] && echo "found ${initrdfile} and using it with grubby"   [[ -n ${verbose} ]] && echo "found ${initrdfile} and using it with grubby"
475   INITRD="--initrd ${initrdfile}"   INITRD="--initrd ${initrdfile}"
  fi  
476    
477   # Run grub2's configuration update in parallel, if it is installed   if [[ -n ${addplymouthinitrd} ]]
478   run_grub2   then
479     INITRD="${INITRD} --extra-initrd ${bootPrefix}/initrd-plymouth.img"
480     fi
481     fi
482    
483   if [[ -n ${cfgGrub} ]]   if [[ -n ${cfgGrub} ]]
484   then   then
485   [[ -n ${verbose} ]] && echo "updating ${version} from ${grubConfig}"   [[ -n ${verbose} ]] && echo "updating ${version} from ${grubConfig}"
486   ${grubby} --update-kernel=${bootPrefix}/${kernelName}-${version} \   ${grubby} --grub -c ${grubConfig} \
487     --update-kernel=${bootPrefix}/${kernelName}-${version} \
488   ${INITRD} \   ${INITRD} \
489   ${kernargs:+--args="${kernargs}"} \   ${kernargs:+--args="${kernargs}"} \
490   ${removeargs:+--remove-args="${removeargs}"}   ${removeargs:+--remove-args="${removeargs}"}
# Line 278  update() Line 492  update()
492   [[ -n ${verbose} ]] && echo "${grubConfig} does not exist, not running grubby"   [[ -n ${verbose} ]] && echo "${grubConfig} does not exist, not running grubby"
493   fi   fi
494    
495     if [[ -n ${cfgGrub2} ]]
496     then
497     [[ -n ${verbose} ]] && echo "updating ${version} from ${grub2Config}"
498     ${grubby} --grub2 -c ${grub2Config} \
499     --update-kernel=${bootPrefix}/${kernelName}-${version} \
500     ${INITRD} \
501     ${kernargs:+--args="${kernargs}"} \
502     ${removeargs:+--remove-args="${removeargs}"}
503     else
504     [[ -n ${verbose} ]] && echo "${grub2Config} does not exist, not running grubby"
505     fi
506    
507     if [[ -n ${cfgGrub2Efi} ]]
508     then
509     [[ -n ${verbose} ]] && echo "updating ${version} from ${grub2EfiConfig}"
510     ${grubby} --grub2 -c ${grub2EfiConfig} --efi \
511     --update-kernel=${bootPrefix}/${kernelName}-${version} \
512     ${INITRD} \
513     ${kernargs:+--args="${kernargs}"} \
514     ${removeargs:+--remove-args="${removeargs}"}
515     else
516     [[ -n ${verbose} ]] && echo "${grub2EfiConfig} does not exist, not running grubby"
517     fi
518    
519   if [[ -n ${cfgLilo} ]]   if [[ -n ${cfgLilo} ]]
520   then   then
521   [[ -n ${verbose} ]] && echo "updating ${version} from ${liloConfig}"   [[ -n ${verbose} ]] && echo "updating ${version} from ${liloConfig}"
# Line 300  update() Line 538  update()
538   else   else
539   [[ -n ${verbose} ]] && echo "${liloConfig} does not exist, not running grubby"   [[ -n ${verbose} ]] && echo "${liloConfig} does not exist, not running grubby"
540   fi   fi
541    
542     if [[ -n ${cfguBoot} ]]
543     then
544     [[ -n ${verbose} ]] && echo "adding $version to ${ubootDir}..."
545    
546     [[ -n ${verbose} ]] && echo "creating uImage-${version}"
547     mkimage -A arm -O linux -T kernel -C none -a ${ubootAddress} \
548     -e ${ubootAddress} -n ${version} \
549     -d ${bootPrefix}/${kernelName}-${version} ${ubootDir}/uImage-${version}
550    
551     [[ -n ${verbose} ]] && echo "creating uInitrd-${version}"
552     mkimage -A arm -O linux -T ramdisk -C none -a 0 -e 0 \
553     -n initramfs -d ${initrdfile} ${ubootDir}/uInitrd-${version}
554    
555     if [ -f ${ubootDir}/uImage-${version} ] && [ -f ${ubootDir}/uInitrd-${version} ]
556     then
557     cp -fp ${ubootDir}/uImage-${version} ${ubootDir}/${ubootDefaultImage}
558     if [ $? -ne 0 ]
559     then
560     [[ -n ${verbose} ]] && echo "copy uImage-${version} error, kernel not installed!" && exit
561     fi
562     cp -fp ${ubootDir}/uInitrd-${version} ${ubootDir}/${ubootDefaultInitrd}
563     if [ $? -ne 0 ]
564     then
565     [[ -n ${verbose} ]] && echo "copy uInitrd-${version} error, kernel not installed!" && exit
566     fi
567     echo ${version} >> ${ubootDir}/${ubootKList}
568     else
569     [[ -n ${verbose} ]] && echo "cannot make ${version} the default"
570     fi
571     else
572     [[ -n ${verbose} ]] && echo "${ubootScript} does not exist, not setting up ${ubootDir}"
573     fi
574    
575     if [[ -n ${cfgExtlinux} ]]
576     then
577     [[ -n ${verbose} ]] && echo "updating ${version} from ${extlinuxConfig}"
578     ${grubby} --extlinux -c ${extlinuxConfig} \
579     --update-kernel=${bootPrefix}/${kernelName}-${version} \
580     ${INITRD} \
581     ${kernargs:+--args="${kernargs}"} \
582     ${removeargs:+--remove-args="${removeargs}"}
583     else
584     [[ -n ${verbose} ]] && echo "${extlinuxConfig} does not exist, not running grubby"
585     fi
586  }  }
587    
588  mkinitrd()  makeinitrd()
589  {  {
590     if [[ -n ${dracut} ]]
591     then
592     tool="dracut ${dracuthostonly} -f ${initrdfile} ${version}"
593     else
594     tool="mkinitrd --allow-missing -f ${initrdfile} ${version}"
595     fi
596   [[ -n ${verbose} ]] && echo "creating initrd ${initrdfile} using ${version}"   [[ -n ${verbose} ]] && echo "creating initrd ${initrdfile} using ${version}"
597   /sbin/mkinitrd --allow-missing -f ${initrdfile} ${version}   ${tool}
598   rc=$?   rc=$?
599   if [ ${rc} != 0 ]   if [ ${rc} != 0 ]
600   then   then
# Line 344  do Line 633  do
633   initrd="remove"   initrd="remove"
634   ;;   ;;
635    
636     --dracut)
637     dracut=--dracut
638     ;;
639    
640     --host-only)
641     dracuthostonly=-H
642     ;;
643    
644   --initrdfile*)   --initrdfile*)
645   if echo $1 | grep '=' >/dev/null   if echo $1 | grep '=' >/dev/null
646   then   then
# Line 427  do Line 724  do
724   fi   fi
725   ;;   ;;
726    
727     --add-dracut-args)
728     adddracutargs=--add-dracut-args
729     ;;
730    
731     --add-plymouth-initrd)
732     addplymouthinitrd=--add-plymouth-initrd
733     ;;
734    
735   -v)   -v)
736   verbose=-v   verbose=-v
737   ;;   ;;
# Line 478  fi Line 783  fi
783  if [[ -z ${initrdfile} ]]  if [[ -z ${initrdfile} ]]
784  then  then
785   INITRD_NAME_PREFIX="initrd"   INITRD_NAME_PREFIX="initrd"
786     if [[ -n ${dracut} ]]
787     then
788     INITRD_NAME_PREFIX="initramfs"
789     fi
790    
791   if [[ $(uname -m) = ia64 ]]   if [[ $(uname -m) = ia64 ]]
792   then   then
# Line 488  then Line 797  then
797  fi  fi
798  [[ -n ${verbose} ]] && echo "initrdfile is ${initrdfile}"  [[ -n ${verbose} ]] && echo "initrdfile is ${initrdfile}"
799    
800    # add dracut i18n, keyboard and plymouth kernel args if requested
801    if [[ -n ${dracut} ]] || [[ -n ${adddracutargs} ]]
802    then
803     if [ -r /etc/vconsole.conf ]
804     then
805     . /etc/vconsole.conf
806    
807     for i in SYSFONT SYSFONTACM UNIMAP KEYTABLE
808     do
809     val=$(eval echo \$$i)
810     [[ -n ${val} ]] && kernargs="${kernargs} ${i}=${val}"
811     done
812     else
813     if [ -r /etc/conf.d/consolefont ]
814     then
815     . /etc/conf.d/consolefont
816    
817     if [[ -n ${CONSOLEFONT} ]]
818     then
819     kernargs="${kernargs} SYSFONT=${CONSOLEFONT}"
820     fi
821     fi
822    
823     if  [ -r /etc/conf.d/keymap ]
824     then
825     . /etc/conf.d/keymap
826    
827     if [[ -n ${KEYMAP} ]]
828     then
829     kernargs="${kernargs} KEYTABLE=${KEYMAP}"
830     fi
831     fi
832     fi
833    
834     if [ -r /etc/locale.conf ]
835     then
836     . /etc/locale.conf
837    
838     if [[ -n ${LANG} ]]
839     then
840     kernargs="${kernargs} LANG=${LANG}"
841     fi
842     fi
843    fi
844    
845  # 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
846  if [[ ${mode} = --install ]] && [[ ${UPDATEDEFAULT} = yes ]] && [[ -n ${package} ]] &&  if [[ ${mode} = --install ]] && [[ ${UPDATEDEFAULT} = yes ]] && [[ -n ${package} ]] &&
847   [[ -n ${DEFAULTKERNEL} ]] && [[ ${package} = ${DEFAULTKERNEL} ]]   [[ -n ${DEFAULTKERNEL} ]] && [[ ${package} = ${DEFAULTKERNEL} ]]
# Line 506  fi Line 860  fi
860    
861  if [[ ${initrd} = make ]]  if [[ ${initrd} = make ]]
862  then  then
863   mkinitrd   makeinitrd
864  elif [[ ${initrd} = remove ]]  elif [[ ${initrd} = remove ]]
865  then  then
866   rminitrd   rminitrd
# Line 519  then Line 873  then
873  fi  fi
874    
875  [[ -n ${grubConfig} ]] && [ -f ${grubConfig} ] && cfgGrub=1  [[ -n ${grubConfig} ]] && [ -f ${grubConfig} ] && cfgGrub=1
876    [[ -n ${grub2Config} ]] && [ -f ${grub2Config} ] && cfgGrub2=1
877    [[ -n ${grub2EfiConfig} ]] && [ -f ${grub2EfiConfig} ] && cfgGrub2Efi=1
878  [[ -n ${liloConfig} ]] && [ -f ${liloConfig} ] && cfgLilo=1  [[ -n ${liloConfig} ]] && [ -f ${liloConfig} ] && cfgLilo=1
879    [[ -n ${extlinuxConfig} ]] && [ -f ${extlinuxConfig} ] && cfgExtlinux=1
880    
881    # if we have a U-Boot directory, but no boot script, check if the directory
882    # is mounted.  If not, mount it, and then check if a boot script exists.
883    if [[ -n ${ubootDir} ]]
884    then
885     if [ -f ${ubootScript} ]
886     then
887     cfguBoot=1
888     else
889     mountEntry=$(mount | grep ${ubootDir})
890     if [[ -z ${mountEntry} ]]
891     then
892     mount ${ubootDevice} ${ubootDir}
893     mounted=1
894     fi
895     [ -f ${ubootScript} ] && cfguBoot=1
896     fi
897    fi
898    
899    # if we're using U-Boot, check if the default load address should change
900    if [[ -n ${cfguBoot} ]] && [[ -z ${UBOOT_IMGADDR} ]]
901    then
902     [[ ${version}  =~ .([^.]*)$ ]]
903     platform=${BASH_REMATCH[1]}
904     # A few platforms use an alternate kernel load address
905     if [[ ${platform} = omap ]]
906     then
907     ubootAddress=0x80008000
908     elif [[ ${platform} = imx ]]
909     then
910     ubootAddress=0x90008000
911     fi
912    fi
913    
914  # 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
915  # is lilo to determine if it should be run  # is lilo to determine if it should be run
# Line 539  then Line 929  then
929   update   update
930  fi  fi
931    
932    # if we mounted the U-Boot directory, unmount it.
933    [[ -n ${mounted} ]] && umount ${ubootDir}
934    
935  exit 0  exit 0

Legend:
Removed from v.1332  
changed lines
  Added in v.2238