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 2263 by niro, Mon Oct 21 14:08:21 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     extlinuxConfig=$(readlink -f /etc/extlinux.conf 2>/dev/null)
120     ubootDir=${UBOOT_DIR:-"/boot"}
121     ubootScript=$ubootDir/${UBOOT_SCR:-"boot.scr"}
122     ubootKList=${UBOOT_KLIST:-"klist.txt"}
123     ubootDevice=/dev/${UBOOT_DEVICE:-"mmcblk0p1"}
124     ubootDefaultImage=${UBOOT_UIMAGE:-"uImage"}
125     ubootDefaultInitrd=${UBOOT_UINITRD:-"uInitrd"}
126     ubootAddress=${UBOOT_IMGADDR:-"0x00008000"}
127     mounted=""
128     liloFlag=""
129     isx86=""
130  else  else
131   # this leaves i?86 and x86_64   # this leaves i?86 and x86_64
132   liloConfig=/etc/lilo.conf   liloConfig=/etc/lilo.conf
133   grubConfig=/boot/grub/grub.conf   grubConfig=/boot/grub/grub.conf
134     grub2Config=/boot/grub/grub.cfg
135     grub2EfiConfig=/boot/grub/grub-efi.cfg
136     extlinuxConfig=/boot/extlinux/extlinux.conf
137   bootPrefix=/boot   bootPrefix=/boot
138   liloFlag=lilo   liloFlag=lilo
139   isx86="yes"   isx86="yes"
# Line 89  fi Line 142  fi
142  mode=""  mode=""
143  version=""  version=""
144  initrd=""  initrd=""
145    dracut=""
146    dracuthostonly=""
147  initrdfile=""  initrdfile=""
148  moddep=""  moddep=""
149  verbose=""  verbose=""
150  makedefault=""  makedefault=""
151  package=""  package=""
152  mbkernel=""  mbkernel="${HYPERVISOR}"
153  mbargs=""  mbargs="${HYPERVISOR_ARGS}"
154    adddracutargs=""
155    addplymouthinitrd=""
156    
157  usage()  usage()
158  {  {
159   echo "Usage: $(basename $0) [-v] [--mkinitrd] [--rminitrd]" >&2   echo "Usage: $(basename $0) [-v] [--mkinitrd] [--rminitrd] [--dracut]" >&2
160   echo "       [--initrdfile=<initrd-image>] [--depmod] [--rmmoddep]" >&2   echo "       [--initrdfile=<initrd-image>] [--depmod] [--rmmoddep]" >&2
161   echo "       [--kernel-args=<args>] [--remove-args=<args>]" >&2   echo "       [--kernel-args=<args>] [--remove-args=<args>]" >&2
162   echo "       [--banner=<banner>] [--multiboot=multiboot]" >&2   echo "       [--banner=<banner>] [--multiboot=multiboot]" >&2
163   echo "       [--mbargs=mbargs] [--make-default]" >&2   echo "       [--mbargs=mbargs] [--make-default] [--add-dracut-args]" >&2
164     echo "       [--add-plymouth-initrd]" >&2
165     echo "       [--host-only]" >&2
166   echo "       <--install | --remove | --update> <kernel-version>" >&2   echo "       <--install | --remove | --update> <kernel-version>" >&2
167   echo "       (ex: $(basename $0) --mkinitrd --depmod --install 2.4.7-2)" >&2   echo "       (ex: $(basename $0) --mkinitrd --depmod --install 2.4.7-2)" >&2
168   exit 1   exit 1
169  }  }
170    
 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  
 }  
   
171  install()  install()
172  {  {
173   # 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)
174   if [ ! -f ${bootPrefix}/${kernelName}-${version} ]   if [ ! -f ${kernelImage} ]
175   then   then
176   [[ -n ${verbose} ]] && echo "kernel for ${version} does not exist, not running grubby"   [[ -n ${verbose} ]] && echo "kernel for ${version} does not exist, not running grubby"
177   return   return
# Line 132  install() Line 182  install()
182   then   then
183   [[ -n ${verbose} ]] && echo "found ${initrdfile} and using it with grubby"   [[ -n ${verbose} ]] && echo "found ${initrdfile} and using it with grubby"
184   INITRD="--initrd ${initrdfile}"   INITRD="--initrd ${initrdfile}"
185    
186     if [[ -n ${addplymouthinitrd} ]]
187     then
188     INITRD="${INITRD} --extra-initrd ${bootPrefix}/initrd-plymouth.img"
189     fi
190   fi   fi
191    
192   # 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 141  install() Line 196  install()
196   if [[ -z ${initrdfile} ]]   if [[ -z ${initrdfile} ]]
197   then   then
198   [[ -n ${verbose} ]] && echo "No initrd, just adding system map"   [[ -n ${verbose} ]] && echo "No initrd, just adding system map"
199   /sbin/addSystemMap ${bootPrefix}/System.map-${version} ${bootPrefix}/${kernelName}-${version} ${bootPrefix}/vmlinitrd-${version}   /sbin/addSystemMap ${bootPrefix}/System.map-${version} ${kernelImage} ${bootPrefix}/vmlinitrd-${version}
200   else   else
201   /sbin/addSystemMap ${bootPrefix}/System.map-${version} ${bootPrefix}/${kernelName}-${version} ${bootPrefix}/vmlinux.sm-${version}   /sbin/addSystemMap ${bootPrefix}/System.map-${version} ${kernelImage} ${bootPrefix}/vmlinux.sm-${version}
202   /sbin/addRamDisk ${initrdfile} ${bootPrefix}/System.map-${version} ${bootPrefix}/vmlinux.sm-${version} ${bootPrefix}/vmlinitrd-${version} 2>/dev/null   /sbin/addRamDisk ${initrdfile} ${bootPrefix}/System.map-${version} ${bootPrefix}/vmlinux.sm-${version} ${bootPrefix}/vmlinitrd-${version} 2>/dev/null
203   rm ${bootPrefix}/vmlinux.sm-${version}   rm ${bootPrefix}/vmlinux.sm-${version}
204   fi   fi
205   return   return
206   fi   fi
207    
  # Run grub2's configuration update in parallel, if it is installed  
  run_grub2  
   
208   # get the root filesystem to use   # get the root filesystem to use
209   rootdevice=$(awk '{ if ($1 !~ /^[ \t]*#/ && $2 == "/") { print $1; }}' /etc/fstab)   rootdevice=$(awk '{ if ($1 !~ /^[ \t]*#/ && $2 == "/") { print $1; }}' /etc/fstab  2>/dev/null)
210     if [[ -z $rootdevice ]]
211     then
212     rootdevice=$(grep -o -P "(?<=root=)\S+" /proc/cmdline)
213     fi
214    
215   if [[ -n ${mbkernel} ]] && [[ -n ${cfgLilo} ]] && [[ ${liloFlag} != elilo ]]   if [[ -n ${mbkernel} ]] && [[ -n ${cfgLilo} ]] && [[ ${liloFlag} != elilo ]]
216   then   then
# Line 162  install() Line 218  install()
218   cfgLilo=""   cfgLilo=""
219   fi   fi
220    
221     if [[ -n ${banner} ]]
222     then
223     title="${banner} [ ${version} ]"
224     elif [[ $(read_os_release id) = magellan ]]
225     then
226     title="$(read_os_release name) $(read_os_release version_id) [ ${version} ]"
227     elif [ -f /etc/mageversion ]
228     then
229     title="Magellan Linux $(< /etc/mageversion) [ ${version} ]"
230     else
231     title="Magellan Linux [ ${version} ]"
232     fi
233    
234   if [[ -n ${cfgGrub} ]]   if [[ -n ${cfgGrub} ]]
235   then   then
236   [[ -n ${verbose} ]] && echo "adding ${version} to ${grubConfig}"   [[ -n ${verbose} ]] && echo "adding ${version} to ${grubConfig}"
237    
238   if [[ -n ${banner} ]]   ${grubby} --grub -c ${grubConfig} \
239   then   --add-kernel=${kernelImage} \
  title="${banner} (${version})"  
  elif [ -f /etc/mageversion ]  
  then  
  title="Magellan Linux $(< /etc/mageversion) (${version})"  
  else  
  title="Magellan Linux (${version})"  
  fi  
  ${grubby} --add-kernel=${bootPrefix}/${kernelName}-${version} \  
240   ${INITRD} --copy-default ${makedefault} --title "${title}" \   ${INITRD} --copy-default ${makedefault} --title "${title}" \
241   ${mbkernel:+--add-multiboot="${mbkernel}"} ${mbargs:+--mbargs="${mbargs}"} \   ${mbkernel:+--add-multiboot="${mbkernel}"} ${mbargs:+--mbargs="${mbargs}"} \
242   --args="root=${rootdevice} ${kernargs}" --remove-kernel="TITLE=${title}"   --args="root=${rootdevice} ${kernargs}" --remove-kernel="TITLE=${title}"
243   else   else
244   [[ -n ${verbose} ]] && echo "${grubConfig} does not exist, not running grubby"   [[ -n ${verbose} ]] && echo "${grubConfig} does not exist, not running grubby for grub 0.97"
245     fi
246     if [[ -n ${cfgGrub2} ]]
247     then
248     [[ -n ${verbose} ]] && echo "adding ${version} to ${grub2Config}"
249    
250     ${grubby} --grub2 -c ${grub2Config} \
251     --add-kernel=${kernelImage} \
252     ${INITRD} --copy-default ${makedefault} --title "${title}" \
253     ${mbkernel:+--add-multiboot="${mbkernel}"} \
254     ${mbargs:+--mbargs="${mbargs}"} \
255     --args="root=${rootdevice} ${kernargs}" --remove-kernel="TITLE=${title}"
256     else
257     [[ -n ${verbose} ]] && echo "${grub2Config} does not exist, not running grubby for grub 2"
258     fi
259     if [[ -n ${cfgGrub2Efi} ]]
260     then
261     [[ -n ${verbose} ]] && echo "adding ${version} to ${grub2EfiConfig}"
262    
263     ${grubby} --grub2 -c ${grub2EfiConfig} --efi \
264     --add-kernel=${kernelImage} \
265     ${INITRD} --copy-default ${makedefault} --title "${title}" \
266     ${mbkernel:+--add-multiboot="${mbkernel}"} \
267     ${mbargs:+--mbargs="${mbargs}"} \
268     --args="root=${rootdevice} ${kernargs}" --remove-kernel="TITLE=${title}"
269     else
270     [[ -n ${verbose} ]] && echo "${grub2EfiConfig} does not exist, not running grubby for grub 2 with UEFI"
271   fi   fi
272    
273   if [[ -n ${cfgLilo} ]]   if [[ -n ${cfgLilo} ]]
274   then   then
275   [[ -n ${verbose} ]] && echo "adding ${version} to ${liloConfig}"   [[ -n ${verbose} ]] && echo "adding ${version} to ${liloConfig}"
276    
277   ${grubby} --add-kernel=${bootPrefix}/${kernelName}-${version} ${INITRD} \   ${grubby} --add-kernel=${kernelImage} ${INITRD} \
278   --copy-default ${makedefault} --title ${version} \   --copy-default ${makedefault} --title ${version} \
279   ${mbkernel:+--add-multiboot="${mbkernel}"} ${mbargs:+--mbargs="${mbargs}"} \   ${mbkernel:+--add-multiboot="${mbkernel}"} ${mbargs:+--mbargs="${mbargs}"} \
280   --args="root=${rootdevice} ${kernargs}" --remove-kernel="TITLE=${version}" \   --args="root=${rootdevice} ${kernargs}" --remove-kernel="TITLE=${version}" \
# Line 206  install() Line 293  install()
293   else   else
294   [[ -n ${verbose} ]] && echo "${liloConfig} does not exist, not running grubby"   [[ -n ${verbose} ]] && echo "${liloConfig} does not exist, not running grubby"
295   fi   fi
296    
297     if [[ -n ${cfgExtlinux} ]]
298     then
299     [[ -n ${verbose} ]] && echo "adding ${version} to ${extlinuxConfig}"
300    
301     ${grubby} --extlinux -c ${extlinuxConfig} \
302     --add-kernel=${kernelImage} \
303     ${INITRD} --copy-default ${makedefault} --title "${title}" \
304     ${mbkernel:+--add-multiboot="${mbkernel}"} ${mbargs:+--mbargs="${mbargs}"} \
305     --args="root=${rootdevice} ${kernargs}" --remove-kernel="TITLE=${title}"
306     else
307     [[ -n ${verbose} ]] && echo "${extlinuxConfig} does not exist, not running grubby for extlinux"
308     fi
309  }  }
310    
311  remove()  remove()
# Line 214  remove() Line 314  remove()
314   if [ -d /proc/iSeries ]   if [ -d /proc/iSeries ]
315   then   then
316   [[ -n ${verbose} ]] && echo "On an iSeries, remove img file"   [[ -n ${verbose} ]] && echo "On an iSeries, remove img file"
317   rm -f ${bootPrefix}/${kernelName}-${version}.img 2>/dev/null   rm -f ${kernelImage}.img 2>/dev/null
318   return   return
319   fi   fi
320    
  # Run grub2's configuration update in parallel, if it is installed  
  run_grub2  
   
321   if [[ -n ${cfgGrub} ]]   if [[ -n ${cfgGrub} ]]
322   then   then
323   [[ -n ${verbose} ]] && echo "removing ${version} from ${grubConfig}"   [[ -n ${verbose} ]] && echo "removing ${version} from ${grubConfig}"
324   ${grubby} --remove-kernel=${bootPrefix}/${kernelName}-${version}   ${grubby} --grub -c ${grubConfig} \
325     --remove-kernel=${kernelImage}
326   else   else
327   [[ -n ${verbose} ]] && echo "${grubConfig} does not exist, not running grubby"   [[ -n ${verbose} ]] && echo "${grubConfig} does not exist, not running grubby for grub 0.97"
328     fi
329     if [[ -n ${cfgGrub2} ]]
330     then
331     [[ -n ${verbose} ]] && echo "removing ${version} from ${grub2Config}"
332     ${grubby} --grub2 -c ${grub2Config} \
333     --remove-kernel=${kernelImage}
334     else
335     [[ -n ${verbose} ]] && echo "${grub2Config} does not exist, not running grubby for grub 2"
336     fi
337     if [[ -n ${cfgGrub2Efi} ]]
338     then
339     [[ -n ${verbose} ]] && echo "removing ${version} from ${grub2EfiConfig}"
340     ${grubby} --grub2 -c ${grub2EfiConfig} --efi \
341     --remove-kernel=${kernelImage}
342     else
343     [[ -n ${verbose} ]] && echo "${grub2EfiConfig} does not exist, not running grubby grub 2 with UEFI"
344   fi   fi
345    
346   if [[ -n ${cfgLilo} ]]   if [[ -n ${cfgLilo} ]]
347   then   then
348   [[ -n ${verbose} ]] && echo "removing ${version} from ${liloConfig}"   [[ -n ${verbose} ]] && echo "removing ${version} from ${liloConfig}"
349   ${grubby} --remove-kernel=${bootPrefix}/${kernelName}-${version} --${liloFlag}   ${grubby} --remove-kernel=${kernelImage} --${liloFlag}
350    
351   if [[ -n ${runLilo} ]]   if [[ -n ${runLilo} ]]
352   then   then
# Line 247  remove() Line 361  remove()
361   else   else
362   [[ -n ${verbose} ]] && echo "${liloConfig} does not exist, not running grubby"   [[ -n ${verbose} ]] && echo "${liloConfig} does not exist, not running grubby"
363   fi   fi
364    
365     if [[ -n ${cfguBoot} ]]
366     then
367     [[ -n ${verbose} ]] && echo "removing ${version} from ${ubootDir}..."
368    
369     if [ -f ${ubootDir}/${ubootKList} ]
370     then
371     tmpKList=$(mktemp ${ubootDir}/${ubootKList}.XXXX)
372     curversion=$(tail -n1 ${ubootDir}/${ubootKList})
373     sed "/$version$/d" ${ubootDir}/${ubootKList} > ${tmpKList}
374     newversion=$(tail -n1 ${tmpKList})
375     if [ -f ${ubootDir}/uImage-${newversion} ] && [ -f ${ubootDir}/uInitrd-${newversion} ]
376     then
377     if [[ ${curversion} != ${newversion} ]]
378     then
379     cp -fp ${ubootDir}/uImage-${newversion} ${ubootDir}/${ubootDefaultImage}
380     if [ $? -ne 0 ]
381     then
382     [[ -n ${verbose} ]] && echo "copy uImage-${newversion} error, default kernel not replaced!" && exit
383     fi
384     cp -fp ${ubootDir}/uInitrd-${newversion} ${ubootDir}/${ubootDefaultInitrd}
385     if [ $? -ne 0 ]
386     then
387     [[ -n ${verbose} ]] && echo "copy uInitrd-${newversion} error, default Initrd not replaced!" && exit
388     fi
389     fi
390    
391     [[ -n ${verbose} ]] && echo "removing uImage-${version}"
392     if [ -f ${ubootDir}/uImage-${version} ]
393     then
394     rm -f ${ubootDir}/uImage-${version}
395     else
396     [[ -n ${verbose} ]] && echo "uImage-${version} did not exist!"
397     fi
398    
399     [[ -n ${verbose} ]] && echo "removing uInitrd-${version}"
400     if [ -f ${ubootDir}/uInitrd-${version} ]
401     then
402     rm -f ${ubootDir}/uInitrd-${version}
403     else
404     [[ -n ${verbose} ]] && echo "uInitrd-${version} did not exist!"
405     fi
406    
407     mv ${tmpKList} ${ubootDir}/${ubootKList}
408     [ -x /sbin/a-b-c ] && /sbin/a-b-c
409     else
410     [[ -n ${verbose} ]] && echo "uImage ${newversion} does not exist!"
411     [ -f ${tmpKList} ] && rm -f ${tmpKList}
412     fi
413     else
414     [[ -n ${verbose} ]] && echo "No previous kernel version.  U-Boot images not removed!"
415     fi
416     else
417     [[ -n ${verbose} ]] && echo "${ubootScript} does not exist, not modifying ${ubootDir}"
418     fi
419    
420     if [[ -n ${cfgExtlinux} ]]
421     then
422     [[ -n ${verbose} ]] && echo "removing ${version} from ${extlinuxConfig}"
423     ${grubby} --extlinux -c ${extlinuxConfig} \
424     --remove-kernel=${kernelImage}
425     else
426     [[ -n ${verbose} ]] && echo "${extlinuxConfig} does not exist, not running grubby for extlinux"
427     fi
428  }  }
429    
430  update()  update()
431  {  {
432   if [ ! -f ${bootPrefix}/${kernelName}-${version} ]   if [ ! -f ${kernelImage} ]
433   then   then
434   [[ -n ${verbose} ]] && echo "kernel for ${version} does not exist, not running grubby"   [[ -n ${verbose} ]] && echo "kernel for ${version} does not exist, not running grubby"
435   return   return
# Line 262  update() Line 440  update()
440   then   then
441   [[ -n ${verbose} ]] && echo "found ${initrdfile} and using it with grubby"   [[ -n ${verbose} ]] && echo "found ${initrdfile} and using it with grubby"
442   INITRD="--initrd ${initrdfile}"   INITRD="--initrd ${initrdfile}"
  fi  
443    
444   # Run grub2's configuration update in parallel, if it is installed   if [[ -n ${addplymouthinitrd} ]]
445   run_grub2   then
446     INITRD="${INITRD} --extra-initrd ${bootPrefix}/initrd-plymouth.img"
447     fi
448     fi
449    
450   if [[ -n ${cfgGrub} ]]   if [[ -n ${cfgGrub} ]]
451   then   then
452   [[ -n ${verbose} ]] && echo "updating ${version} from ${grubConfig}"   [[ -n ${verbose} ]] && echo "updating ${version} from ${grubConfig}"
453   ${grubby} --update-kernel=${bootPrefix}/${kernelName}-${version} \   ${grubby} --grub -c ${grubConfig} \
454     --update-kernel=${kernelImage} \
455   ${INITRD} \   ${INITRD} \
456   ${kernargs:+--args="${kernargs}"} \   ${kernargs:+--args="${kernargs}"} \
457   ${removeargs:+--remove-args="${removeargs}"}   ${removeargs:+--remove-args="${removeargs}"} \
458     ${mbkernel:+--add-multiboot="${mbkernel}"}
459   else   else
460   [[ -n ${verbose} ]] && echo "${grubConfig} does not exist, not running grubby"   [[ -n ${verbose} ]] && echo "${grubConfig} does not exist, not running grubby"
461   fi   fi
462    
463     if [[ -n ${cfgGrub2} ]]
464     then
465     [[ -n ${verbose} ]] && echo "updating ${version} from ${grub2Config}"
466     ${grubby} --grub2 -c ${grub2Config} \
467     --update-kernel=${kernelImage} \
468     ${INITRD} \
469     ${kernargs:+--args="${kernargs}"} \
470     ${removeargs:+--remove-args="${removeargs}"}
471     else
472     [[ -n ${verbose} ]] && echo "${grub2Config} does not exist, not running grubby"
473     fi
474    
475     if [[ -n ${cfgGrub2Efi} ]]
476     then
477     [[ -n ${verbose} ]] && echo "updating ${version} from ${grub2EfiConfig}"
478     ${grubby} --grub2 -c ${grub2EfiConfig} --efi \
479     --update-kernel=${kernelImage} \
480     ${INITRD} \
481     ${kernargs:+--args="${kernargs}"} \
482     ${removeargs:+--remove-args="${removeargs}"}
483     else
484     [[ -n ${verbose} ]] && echo "${grub2EfiConfig} does not exist, not running grubby"
485     fi
486    
487   if [[ -n ${cfgLilo} ]]   if [[ -n ${cfgLilo} ]]
488   then   then
489   [[ -n ${verbose} ]] && echo "updating ${version} from ${liloConfig}"   [[ -n ${verbose} ]] && echo "updating ${version} from ${liloConfig}"
490   ${grubby} --update-kernel=${bootPrefix}/${kernelName}-${version} \   ${grubby} --update-kernel=${kernelImage} \
491   ${INITRD} \   ${INITRD} \
492   ${kernargs:+--args="${kernargs}"} \   ${kernargs:+--args="${kernargs}"} \
493   ${removeargs:+--remove-args="${removeargs}"} \   ${removeargs:+--remove-args="${removeargs}"} \
# Line 300  update() Line 506  update()
506   else   else
507   [[ -n ${verbose} ]] && echo "${liloConfig} does not exist, not running grubby"   [[ -n ${verbose} ]] && echo "${liloConfig} does not exist, not running grubby"
508   fi   fi
509    
510     if [[ -n ${cfguBoot} ]]
511     then
512     [[ -n ${verbose} ]] && echo "adding $version to ${ubootDir}..."
513    
514     [[ -n ${verbose} ]] && echo "creating uImage-${version}"
515     mkimage -A arm -O linux -T kernel -C none -a ${ubootAddress} \
516     -e ${ubootAddress} -n ${version} \
517     -d ${kernelImage} ${ubootDir}/uImage-${version}
518    
519     [[ -n ${verbose} ]] && echo "creating uInitrd-${version}"
520     mkimage -A arm -O linux -T ramdisk -C none -a 0 -e 0 \
521     -n initramfs -d ${initrdfile} ${ubootDir}/uInitrd-${version}
522    
523     if [ -f ${ubootDir}/uImage-${version} ] && [ -f ${ubootDir}/uInitrd-${version} ]
524     then
525     cp -fp ${ubootDir}/uImage-${version} ${ubootDir}/${ubootDefaultImage}
526     if [ $? -ne 0 ]
527     then
528     [[ -n ${verbose} ]] && echo "copy uImage-${version} error, kernel not installed!" && exit
529     fi
530     cp -fp ${ubootDir}/uInitrd-${version} ${ubootDir}/${ubootDefaultInitrd}
531     if [ $? -ne 0 ]
532     then
533     [[ -n ${verbose} ]] && echo "copy uInitrd-${version} error, kernel not installed!" && exit
534     fi
535     echo ${version} >> ${ubootDir}/${ubootKList}
536     [ -x /sbin/a-b-c ] && /sbin/a-b-c
537     else
538     [[ -n ${verbose} ]] && echo "cannot make ${version} the default"
539     fi
540     else
541     [[ -n ${verbose} ]] && echo "${ubootScript} does not exist, not setting up ${ubootDir}"
542     fi
543    
544     if [[ -n ${cfgExtlinux} ]]
545     then
546     [[ -n ${verbose} ]] && echo "updating ${version} from ${extlinuxConfig}"
547     ${grubby} --extlinux -c ${extlinuxConfig} \
548     --update-kernel=${kernelImage} \
549     ${INITRD} \
550     ${kernargs:+--args="${kernargs}"} \
551     ${removeargs:+--remove-args="${removeargs}"}
552     else
553     [[ -n ${verbose} ]] && echo "${extlinuxConfig} does not exist, not running grubby"
554     fi
555  }  }
556    
557  mkinitrd()  makeinitrd()
558  {  {
559     if [[ -n ${dracut} ]]
560     then
561     tool="dracut ${dracuthostonly} -f ${initrdfile} ${version}"
562     else
563     tool="mkinitrd --allow-missing -f ${initrdfile} ${version}"
564     fi
565   [[ -n ${verbose} ]] && echo "creating initrd ${initrdfile} using ${version}"   [[ -n ${verbose} ]] && echo "creating initrd ${initrdfile} using ${version}"
566   /sbin/mkinitrd --allow-missing -f ${initrdfile} ${version}   ${tool}
567   rc=$?   rc=$?
568   if [ ${rc} != 0 ]   if [ ${rc} != 0 ]
569   then   then
# Line 329  doDepmod() Line 587  doDepmod()
587  doRmmoddep()  doRmmoddep()
588  {  {
589   [[ -n ${verbose} ]] && echo "removing modules.dep info for ${version}"   [[ -n ${verbose} ]] && echo "removing modules.dep info for ${version}"
590   [ -d /lib/modules/${version} ] && rm -f /lib/modules/${version}/modules.*   if [ -d /lib/modules/${version} ]
591     then
592     rm -f /lib/modules/${version}/modules.*.bin \
593     /lib/modules/${version}/modules.{alias,dep,devname,symbols,softdep}
594     fi
595  }  }
596    
597    
# Line 344  do Line 606  do
606   initrd="remove"   initrd="remove"
607   ;;   ;;
608    
609     --dracut)
610     dracut=--dracut
611     ;;
612    
613     --host-only)
614     dracuthostonly=-H
615     ;;
616    
617   --initrdfile*)   --initrdfile*)
618   if echo $1 | grep '=' >/dev/null   if [[ $1 == --initrdfile\=* ]]
619   then   then
620   initrdfile=$(echo $1 | sed 's/^--initrdfile=//')   initrdfile=${1#--initrdfile=}
621   else   else
622   initrdfile=$2   initrdfile=$2
623   shift   shift
# Line 355  do Line 625  do
625   ;;   ;;
626    
627   --kernel-args*)   --kernel-args*)
628   if echo $1 | grep '=' >/dev/null   if [[ $1 == --kernel-args\=* ]]
629   then   then
630   kernargs=$(echo $1 | sed 's/^--kernel-args=//')   kernargs=${1#--kernel-args=}
631   else   else
632   kernargs=$2   kernargs=$2
633   shift   shift
# Line 365  do Line 635  do
635   ;;   ;;
636    
637   --remove-args*)   --remove-args*)
638   if echo $1 | grep '=' >/dev/null   if [[ $1 == --remove-args\=* ]]
639   then   then
640   removeargs=$(echo $1 | sed 's/^--remove-args=//')   removeargs=${1#--remove-args=}
641   else   else
642   removeargs=$2   removeargs=$2
643   shift   shift
# Line 375  do Line 645  do
645   ;;   ;;
646    
647   --banner*)   --banner*)
648   if echo $1 | grep '=' >/dev/null   if [[ $1 == --banner\=* ]]
649   then   then
650   banner=$(echo $1 | sed 's/^--banner=//')   banner=${1#--banner=}
651   else   else
652   banner=$2   banner=$2
653   shift   shift
# Line 385  do Line 655  do
655   ;;   ;;
656    
657   --multiboot*)   --multiboot*)
658   if echo $1 |grep '=' >/dev/null   if [[ $1 == --multiboot\=* ]]
659   then   then
660   mbkernel=$(echo $1 | sed 's/^--multiboot=//')   mbkernel=${1#--multiboot=}
661   else   else
662   # can't really support having an optional second arg here   # can't really support having an optional second arg here
663   # sorry!   # sorry!
# Line 396  do Line 666  do
666   ;;   ;;
667    
668   --mbargs*)   --mbargs*)
669   if echo $1 |grep '=' >/dev/null   if [[ $1 == --mbargs\=* ]]
670   then   then
671   mbargs=$(echo $1 | sed 's/^--mbargs=//')   mbargs=${1#--mbargs=}
672   else   else
673   mbargs="$2"   mbargs="$2"
674   shift   shift
# Line 417  do Line 687  do
687   makedefault="--make-default"   makedefault="--make-default"
688   ;;   ;;
689    
690   --package)   --package*)
691   if echo $1 | grep '=' >/dev/null   if [[ $1 == --package\=* ]]
692   then   then
693   package=$(echo $1 | sed 's/^--package=//')   package=${1#--package=}
694   else   else
695   package=$2   package=$2
696   shift   shift
697   fi   fi
698   ;;   ;;
699    
700     --add-dracut-args)
701     adddracutargs=--add-dracut-args
702     ;;
703    
704     --add-plymouth-initrd)
705     addplymouthinitrd=--add-plymouth-initrd
706     ;;
707    
708     --kernel-image*)
709     if [[ $1 == --kernel-image\=* ]]
710     then
711     kernelImage=${1#--kernel-image=}
712     else
713     kernelImage="$2"
714     shift
715     fi
716     if ! [[ -f ${kernelImage} ]]
717     then
718     echo "Can't find kernel image '${kernelImage}'" >&2
719     usage
720     exit 1
721     fi
722     ;;
723    
724   -v)   -v)
725   verbose=-v   verbose=-v
726   ;;   ;;
# Line 474  then Line 768  then
768   fi   fi
769  fi  fi
770    
771    [[ ${kernelImage} ]] || kernelImage="${bootPrefix}/${kernelName}-${version}"
772    
773  # set the initrd file based on arch; ia64 is the only currently known oddball  # set the initrd file based on arch; ia64 is the only currently known oddball
774  if [[ -z ${initrdfile} ]]  if [[ -z ${initrdfile} ]]
775  then  then
776   INITRD_NAME_PREFIX="initrd"   INITRD_NAME_PREFIX="initrd"
777     if [[ -n ${dracut} ]]
778     then
779     INITRD_NAME_PREFIX="initramfs"
780     fi
781    
782   if [[ $(uname -m) = ia64 ]]   if [[ $(uname -m) = ia64 ]]
783   then   then
# Line 488  then Line 788  then
788  fi  fi
789  [[ -n ${verbose} ]] && echo "initrdfile is ${initrdfile}"  [[ -n ${verbose} ]] && echo "initrdfile is ${initrdfile}"
790    
791    # add dracut i18n, keyboard and plymouth kernel args if requested
792    if [[ -n ${dracut} ]] || [[ -n ${adddracutargs} ]]
793    then
794     if [ -r /etc/vconsole.conf ]
795     then
796     . /etc/vconsole.conf
797    
798     for i in SYSFONT SYSFONTACM UNIMAP KEYTABLE
799     do
800     val=$(eval echo \$$i)
801     [[ -n ${val} ]] && kernargs="${kernargs} ${i}=${val}"
802     done
803     else
804     if [ -r /etc/conf.d/consolefont ]
805     then
806     . /etc/conf.d/consolefont
807    
808     if [[ -n ${CONSOLEFONT} ]]
809     then
810     kernargs="${kernargs} SYSFONT=${CONSOLEFONT}"
811     fi
812     fi
813    
814     if  [ -r /etc/conf.d/keymap ]
815     then
816     . /etc/conf.d/keymap
817    
818     if [[ -n ${KEYMAP} ]]
819     then
820     kernargs="${kernargs} KEYTABLE=${KEYMAP}"
821     fi
822     fi
823     fi
824    
825     if [ -r /etc/locale.conf ]
826     then
827     . /etc/locale.conf
828    
829     if [[ -n ${LANG} ]]
830     then
831     kernargs="${kernargs} LANG=${LANG}"
832     fi
833     fi
834    fi
835    
836  # 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
837  if [[ ${mode} = --install ]] && [[ ${UPDATEDEFAULT} = yes ]] && [[ -n ${package} ]] &&  if [[ ${mode} = --install ]] && [[ ${UPDATEDEFAULT} = yes ]] && [[ -n ${package} ]] &&
838   [[ -n ${DEFAULTKERNEL} ]] && [[ ${package} = ${DEFAULTKERNEL} ]]   [[ -n ${DEFAULTKERNEL} ]] && [[ ${package} = ${DEFAULTKERNEL} ]]
# Line 506  fi Line 851  fi
851    
852  if [[ ${initrd} = make ]]  if [[ ${initrd} = make ]]
853  then  then
854   mkinitrd   makeinitrd
855  elif [[ ${initrd} = remove ]]  elif [[ ${initrd} = remove ]]
856  then  then
857   rminitrd   rminitrd
# Line 519  then Line 864  then
864  fi  fi
865    
866  [[ -n ${grubConfig} ]] && [ -f ${grubConfig} ] && cfgGrub=1  [[ -n ${grubConfig} ]] && [ -f ${grubConfig} ] && cfgGrub=1
867    [[ -n ${grub2Config} ]] && [ -f ${grub2Config} ] && cfgGrub2=1
868    [[ -n ${grub2EfiConfig} ]] && [ -f ${grub2EfiConfig} ] && cfgGrub2Efi=1
869  [[ -n ${liloConfig} ]] && [ -f ${liloConfig} ] && cfgLilo=1  [[ -n ${liloConfig} ]] && [ -f ${liloConfig} ] && cfgLilo=1
870    [[ -n ${extlinuxConfig} ]] && [ -f ${extlinuxConfig} ] && cfgExtlinux=1
871    
872    # if we have a U-Boot directory, but no boot script, check if the directory
873    # is mounted.  If not, mount it, and then check if a boot script exists.
874    if [[ -n ${ubootDir} ]]
875    then
876     if [ -f ${ubootScript} ]
877     then
878     cfguBoot=1
879     else
880     mountEntry=$(mount | grep ${ubootDir})
881     if [[ -z ${mountEntry} ]]
882     then
883     mount ${ubootDevice} ${ubootDir}
884     mounted=1
885     fi
886     [ -f ${ubootScript} ] && cfguBoot=1
887     fi
888    fi
889    
890    # if we're using U-Boot, check if the default load address should change
891    if [[ -n ${cfguBoot} ]] && [[ -z ${UBOOT_IMGADDR} ]]
892    then
893     [[ ${version}  =~ .([^.]*)$ ]]
894     platform=${BASH_REMATCH[1]}
895     # A few platforms use an alternate kernel load address
896     if [[ ${platform} = omap ]]
897     then
898     ubootAddress=0x80008000
899     elif [[ ${platform} = imx ]]
900     then
901     ubootAddress=0x90008000
902     fi
903    fi
904    
905  # 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
906  # is lilo to determine if it should be run  # is lilo to determine if it should be run
# Line 539  then Line 920  then
920   update   update
921  fi  fi
922    
923    # if we mounted the U-Boot directory, unmount it.
924    [[ -n ${mounted} ]] && umount ${ubootDir}
925    
926  exit 0  exit 0

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