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 2684 by niro, Wed Jul 16 10:26:39 2014 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 ${cfgGrub} ]]   if [[ -n ${banner} ]]
222   then   then
223   [[ -n ${verbose} ]] && echo "adding ${version} to ${grubConfig}"   if [[ ${ARCH} = s390 ]] || [[ ${ARCH} = s390x ]]
   
  if [[ -n ${banner} ]]  
224   then   then
225   title="${banner} (${version})"   title=$(echo ${banner} | sed 's/ /_/g')
  elif [ -f /etc/mageversion ]  
  then  
  title="Magellan Linux $(< /etc/mageversion) (${version})"  
226   else   else
227   title="Magellan Linux (${version})"   title="${banner} [ ${version} ]"
228   fi   fi
229   ${grubby} --add-kernel=${bootPrefix}/${kernelName}-${version} \   elif [[ ${ARCH} = s390 ]] || [[ ${ARCH} = s390x ]]
230     then
231     title=$(echo ${version} | sed 's/ /_/g')
232     elif [ -f /etc/os-release ]
233     then
234     title="$(read_os_release name) $(read_os_release version_id) [ ${version} ]"
235     elif [ -f /etc/mageversion ]
236     then
237     title="Magellan Linux $(< /etc/mageversion) [ ${version} ]"
238     else
239     title="Magellan Linux [ ${version} ]"
240     fi
241    
242     if [[ -n ${cfgGrub} ]]
243     then
244     [[ -n ${verbose} ]] && echo "adding ${version} to ${grubConfig}"
245    
246     ${grubby} --grub -c ${grubConfig} \
247     --add-kernel=${kernelImage} \
248   ${INITRD} --copy-default ${makedefault} --title "${title}" \   ${INITRD} --copy-default ${makedefault} --title "${title}" \
249   ${mbkernel:+--add-multiboot="${mbkernel}"} ${mbargs:+--mbargs="${mbargs}"} \   ${mbkernel:+--add-multiboot="${mbkernel}"} ${mbargs:+--mbargs="${mbargs}"} \
250   --args="root=${rootdevice} ${kernargs}" --remove-kernel="TITLE=${title}"   --args="root=${rootdevice} ${kernargs}" --remove-kernel="TITLE=${title}"
251   else   else
252   [[ -n ${verbose} ]] && echo "${grubConfig} does not exist, not running grubby"   [[ -n ${verbose} ]] && echo "${grubConfig} does not exist, not running grubby for grub 0.97"
253     fi
254     if [[ -n ${cfgGrub2} ]]
255     then
256     [[ -n ${verbose} ]] && echo "adding ${version} to ${grub2Config}"
257    
258     ${grubby} --grub2 -c ${grub2Config} \
259     --add-kernel=${kernelImage} \
260     ${INITRD} --copy-default ${makedefault} --title "${title}" \
261     ${mbkernel:+--add-multiboot="${mbkernel}"} \
262     ${mbargs:+--mbargs="${mbargs}"} \
263     --args="root=${rootdevice} ${kernargs}" --remove-kernel="TITLE=${title}"
264     else
265     [[ -n ${verbose} ]] && echo "${grub2Config} does not exist, not running grubby for grub 2"
266     fi
267     if [[ -n ${cfgGrub2Efi} ]]
268     then
269     [[ -n ${verbose} ]] && echo "adding ${version} to ${grub2EfiConfig}"
270    
271     ${grubby} --grub2 -c ${grub2EfiConfig} --efi \
272     --add-kernel=${kernelImage} \
273     ${INITRD} --copy-default ${makedefault} --title "${title}" \
274     ${mbkernel:+--add-multiboot="${mbkernel}"} \
275     ${mbargs:+--mbargs="${mbargs}"} \
276     --args="root=${rootdevice} ${kernargs}" --remove-kernel="TITLE=${title}"
277     else
278     [[ -n ${verbose} ]] && echo "${grub2EfiConfig} does not exist, not running grubby for grub 2 with UEFI"
279   fi   fi
280    
281   if [[ -n ${cfgLilo} ]]   if [[ -n ${cfgLilo} ]]
282   then   then
283   [[ -n ${verbose} ]] && echo "adding ${version} to ${liloConfig}"   [[ -n ${verbose} ]] && echo "adding ${version} to ${liloConfig}"
284    
285   ${grubby} --add-kernel=${bootPrefix}/${kernelName}-${version} ${INITRD} \   ${grubby} --add-kernel=${kernelImage} ${INITRD} \
286   --copy-default ${makedefault} --title ${version} \   --copy-default ${makedefault} --title "${title}" \
287   ${mbkernel:+--add-multiboot="${mbkernel}"} ${mbargs:+--mbargs="${mbargs}"} \   ${mbkernel:+--add-multiboot="${mbkernel}"} ${mbargs:+--mbargs="${mbargs}"} \
288   --args="root=${rootdevice} ${kernargs}" --remove-kernel="TITLE=${version}" \   --args="root=${rootdevice} ${kernargs}" --remove-kernel="TITLE=${version}" \
289   --${liloFlag}   --${liloFlag}
# Line 206  install() Line 301  install()
301   else   else
302   [[ -n ${verbose} ]] && echo "${liloConfig} does not exist, not running grubby"   [[ -n ${verbose} ]] && echo "${liloConfig} does not exist, not running grubby"
303   fi   fi
304    
305     if [[ -n ${cfgExtlinux} ]]
306     then
307     [[ -n ${verbose} ]] && echo "adding ${version} to ${extlinuxConfig}"
308    
309     ${grubby} --extlinux -c ${extlinuxConfig} \
310     --add-kernel=${kernelImage} \
311     ${INITRD} --copy-default ${makedefault} --title "${title}" \
312     ${mbkernel:+--add-multiboot="${mbkernel}"} ${mbargs:+--mbargs="${mbargs}"} \
313     --args="root=${rootdevice} ${kernargs}" --remove-kernel="TITLE=${title}"
314     else
315     [[ -n ${verbose} ]] && echo "${extlinuxConfig} does not exist, not running grubby for extlinux"
316     fi
317  }  }
318    
319  remove()  remove()
# Line 214  remove() Line 322  remove()
322   if [ -d /proc/iSeries ]   if [ -d /proc/iSeries ]
323   then   then
324   [[ -n ${verbose} ]] && echo "On an iSeries, remove img file"   [[ -n ${verbose} ]] && echo "On an iSeries, remove img file"
325   rm -f ${bootPrefix}/${kernelName}-${version}.img 2>/dev/null   rm -f ${kernelImage}.img 2>/dev/null
326   return   return
327   fi   fi
328    
  # Run grub2's configuration update in parallel, if it is installed  
  run_grub2  
   
329   if [[ -n ${cfgGrub} ]]   if [[ -n ${cfgGrub} ]]
330   then   then
331   [[ -n ${verbose} ]] && echo "removing ${version} from ${grubConfig}"   [[ -n ${verbose} ]] && echo "removing ${version} from ${grubConfig}"
332   ${grubby} --remove-kernel=${bootPrefix}/${kernelName}-${version}   ${grubby} --grub -c ${grubConfig} \
333     --remove-kernel=${kernelImage}
334   else   else
335   [[ -n ${verbose} ]] && echo "${grubConfig} does not exist, not running grubby"   [[ -n ${verbose} ]] && echo "${grubConfig} does not exist, not running grubby for grub 0.97"
336     fi
337     if [[ -n ${cfgGrub2} ]]
338     then
339     [[ -n ${verbose} ]] && echo "removing ${version} from ${grub2Config}"
340     ${grubby} --grub2 -c ${grub2Config} \
341     --remove-kernel=${kernelImage}
342     else
343     [[ -n ${verbose} ]] && echo "${grub2Config} does not exist, not running grubby for grub 2"
344     fi
345     if [[ -n ${cfgGrub2Efi} ]]
346     then
347     [[ -n ${verbose} ]] && echo "removing ${version} from ${grub2EfiConfig}"
348     ${grubby} --grub2 -c ${grub2EfiConfig} --efi \
349     --remove-kernel=${kernelImage}
350     else
351     [[ -n ${verbose} ]] && echo "${grub2EfiConfig} does not exist, not running grubby grub 2 with UEFI"
352   fi   fi
353    
354   if [[ -n ${cfgLilo} ]]   if [[ -n ${cfgLilo} ]]
355   then   then
356   [[ -n ${verbose} ]] && echo "removing ${version} from ${liloConfig}"   [[ -n ${verbose} ]] && echo "removing ${version} from ${liloConfig}"
357   ${grubby} --remove-kernel=${bootPrefix}/${kernelName}-${version} --${liloFlag}   ${grubby} --remove-kernel=${kernelImage} --${liloFlag}
358    
359   if [[ -n ${runLilo} ]]   if [[ -n ${runLilo} ]]
360   then   then
# Line 247  remove() Line 369  remove()
369   else   else
370   [[ -n ${verbose} ]] && echo "${liloConfig} does not exist, not running grubby"   [[ -n ${verbose} ]] && echo "${liloConfig} does not exist, not running grubby"
371   fi   fi
372    
373     if [[ -n ${cfguBoot} ]]
374     then
375     [[ -n ${verbose} ]] && echo "removing ${version} from ${ubootDir}..."
376    
377     if [ -f ${ubootDir}/${ubootKList} ]
378     then
379     tmpKList=$(mktemp ${ubootDir}/${ubootKList}.XXXX)
380     curversion=$(tail -n1 ${ubootDir}/${ubootKList})
381     sed "/$version$/d" ${ubootDir}/${ubootKList} > ${tmpKList}
382     newversion=$(tail -n1 ${tmpKList})
383     if [ -f ${ubootDir}/uImage-${newversion} ] && [ -f ${ubootDir}/uInitrd-${newversion} ]
384     then
385     if [[ ${curversion} != ${newversion} ]]
386     then
387     cp -fp ${ubootDir}/uImage-${newversion} ${ubootDir}/${ubootDefaultImage}
388     if [ $? -ne 0 ]
389     then
390     [[ -n ${verbose} ]] && echo "copy uImage-${newversion} error, default kernel not replaced!" && exit
391     fi
392     cp -fp ${ubootDir}/uInitrd-${newversion} ${ubootDir}/${ubootDefaultInitrd}
393     if [ $? -ne 0 ]
394     then
395     [[ -n ${verbose} ]] && echo "copy uInitrd-${newversion} error, default Initrd not replaced!" && exit
396     fi
397     fi
398    
399     [[ -n ${verbose} ]] && echo "removing uImage-${version}"
400     if [ -f ${ubootDir}/uImage-${version} ]
401     then
402     rm -f ${ubootDir}/uImage-${version}
403     else
404     [[ -n ${verbose} ]] && echo "uImage-${version} did not exist!"
405     fi
406    
407     [[ -n ${verbose} ]] && echo "removing uInitrd-${version}"
408     if [ -f ${ubootDir}/uInitrd-${version} ]
409     then
410     rm -f ${ubootDir}/uInitrd-${version}
411     else
412     [[ -n ${verbose} ]] && echo "uInitrd-${version} did not exist!"
413     fi
414    
415     mv ${tmpKList} ${ubootDir}/${ubootKList}
416     [ -x /sbin/a-b-c ] && /sbin/a-b-c
417     else
418     [[ -n ${verbose} ]] && echo "uImage ${newversion} does not exist!"
419     [ -f ${tmpKList} ] && rm -f ${tmpKList}
420     fi
421     else
422     [[ -n ${verbose} ]] && echo "No previous kernel version.  U-Boot images not removed!"
423     fi
424     else
425     [[ -n ${verbose} ]] && echo "${ubootScript} does not exist, not modifying ${ubootDir}"
426     fi
427    
428     if [[ -n ${cfgExtlinux} ]]
429     then
430     [[ -n ${verbose} ]] && echo "removing ${version} from ${extlinuxConfig}"
431     ${grubby} --extlinux -c ${extlinuxConfig} \
432     --remove-kernel=${kernelImage}
433     else
434     [[ -n ${verbose} ]] && echo "${extlinuxConfig} does not exist, not running grubby for extlinux"
435     fi
436  }  }
437    
438  update()  update()
439  {  {
440   if [ ! -f ${bootPrefix}/${kernelName}-${version} ]   if [ ! -f ${kernelImage} ]
441   then   then
442   [[ -n ${verbose} ]] && echo "kernel for ${version} does not exist, not running grubby"   [[ -n ${verbose} ]] && echo "kernel for ${version} does not exist, not running grubby"
443   return   return
# Line 262  update() Line 448  update()
448   then   then
449   [[ -n ${verbose} ]] && echo "found ${initrdfile} and using it with grubby"   [[ -n ${verbose} ]] && echo "found ${initrdfile} and using it with grubby"
450   INITRD="--initrd ${initrdfile}"   INITRD="--initrd ${initrdfile}"
  fi  
451    
452   # Run grub2's configuration update in parallel, if it is installed   if [[ -n ${addplymouthinitrd} ]]
453   run_grub2   then
454     INITRD="${INITRD} --extra-initrd ${bootPrefix}/initrd-plymouth.img"
455     fi
456     fi
457    
458   if [[ -n ${cfgGrub} ]]   if [[ -n ${cfgGrub} ]]
459   then   then
460   [[ -n ${verbose} ]] && echo "updating ${version} from ${grubConfig}"   [[ -n ${verbose} ]] && echo "updating ${version} from ${grubConfig}"
461   ${grubby} --update-kernel=${bootPrefix}/${kernelName}-${version} \   ${grubby} --grub -c ${grubConfig} \
462     --update-kernel=${kernelImage} \
463   ${INITRD} \   ${INITRD} \
464   ${kernargs:+--args="${kernargs}"} \   ${kernargs:+--args="${kernargs}"} \
465   ${removeargs:+--remove-args="${removeargs}"}   ${removeargs:+--remove-args="${removeargs}"} \
466     ${mbkernel:+--add-multiboot="${mbkernel}"}
467   else   else
468   [[ -n ${verbose} ]] && echo "${grubConfig} does not exist, not running grubby"   [[ -n ${verbose} ]] && echo "${grubConfig} does not exist, not running grubby"
469   fi   fi
470    
471     if [[ -n ${cfgGrub2} ]]
472     then
473     [[ -n ${verbose} ]] && echo "updating ${version} from ${grub2Config}"
474     ${grubby} --grub2 -c ${grub2Config} \
475     --update-kernel=${kernelImage} \
476     ${INITRD} \
477     ${kernargs:+--args="${kernargs}"} \
478     ${removeargs:+--remove-args="${removeargs}"}
479     else
480     [[ -n ${verbose} ]] && echo "${grub2Config} does not exist, not running grubby"
481     fi
482    
483     if [[ -n ${cfgGrub2Efi} ]]
484     then
485     [[ -n ${verbose} ]] && echo "updating ${version} from ${grub2EfiConfig}"
486     ${grubby} --grub2 -c ${grub2EfiConfig} --efi \
487     --update-kernel=${kernelImage} \
488     ${INITRD} \
489     ${kernargs:+--args="${kernargs}"} \
490     ${removeargs:+--remove-args="${removeargs}"}
491     else
492     [[ -n ${verbose} ]] && echo "${grub2EfiConfig} does not exist, not running grubby"
493     fi
494    
495   if [[ -n ${cfgLilo} ]]   if [[ -n ${cfgLilo} ]]
496   then   then
497   [[ -n ${verbose} ]] && echo "updating ${version} from ${liloConfig}"   [[ -n ${verbose} ]] && echo "updating ${version} from ${liloConfig}"
498   ${grubby} --update-kernel=${bootPrefix}/${kernelName}-${version} \   ${grubby} --update-kernel=${kernelImage} \
499   ${INITRD} \   ${INITRD} \
500   ${kernargs:+--args="${kernargs}"} \   ${kernargs:+--args="${kernargs}"} \
501   ${removeargs:+--remove-args="${removeargs}"} \   ${removeargs:+--remove-args="${removeargs}"} \
# Line 300  update() Line 514  update()
514   else   else
515   [[ -n ${verbose} ]] && echo "${liloConfig} does not exist, not running grubby"   [[ -n ${verbose} ]] && echo "${liloConfig} does not exist, not running grubby"
516   fi   fi
517    
518     if [[ -n ${cfguBoot} ]]
519     then
520     [[ -n ${verbose} ]] && echo "adding $version to ${ubootDir}..."
521    
522     [[ -n ${verbose} ]] && echo "creating uImage-${version}"
523     mkimage -A arm -O linux -T kernel -C none -a ${ubootAddress} \
524     -e ${ubootAddress} -n ${version} \
525     -d ${kernelImage} ${ubootDir}/uImage-${version}
526    
527     [[ -n ${verbose} ]] && echo "creating uInitrd-${version}"
528     mkimage -A arm -O linux -T ramdisk -C none -a 0 -e 0 \
529     -n initramfs -d ${initrdfile} ${ubootDir}/uInitrd-${version}
530    
531     if [ -f ${ubootDir}/uImage-${version} ] && [ -f ${ubootDir}/uInitrd-${version} ]
532     then
533     cp -fp ${ubootDir}/uImage-${version} ${ubootDir}/${ubootDefaultImage}
534     if [ $? -ne 0 ]
535     then
536     [[ -n ${verbose} ]] && echo "copy uImage-${version} error, kernel not installed!" && exit
537     fi
538     cp -fp ${ubootDir}/uInitrd-${version} ${ubootDir}/${ubootDefaultInitrd}
539     if [ $? -ne 0 ]
540     then
541     [[ -n ${verbose} ]] && echo "copy uInitrd-${version} error, kernel not installed!" && exit
542     fi
543     echo ${version} >> ${ubootDir}/${ubootKList}
544     [ -x /sbin/a-b-c ] && /sbin/a-b-c
545     else
546     [[ -n ${verbose} ]] && echo "cannot make ${version} the default"
547     fi
548     else
549     [[ -n ${verbose} ]] && echo "${ubootScript} does not exist, not setting up ${ubootDir}"
550     fi
551    
552     if [[ -n ${cfgExtlinux} ]]
553     then
554     [[ -n ${verbose} ]] && echo "updating ${version} from ${extlinuxConfig}"
555     ${grubby} --extlinux -c ${extlinuxConfig} \
556     --update-kernel=${kernelImage} \
557     ${INITRD} \
558     ${kernargs:+--args="${kernargs}"} \
559     ${removeargs:+--remove-args="${removeargs}"}
560     else
561     [[ -n ${verbose} ]] && echo "${extlinuxConfig} does not exist, not running grubby"
562     fi
563  }  }
564    
565  mkinitrd()  makeinitrd()
566  {  {
567     if [[ -n ${dracut} ]]
568     then
569     tool="dracut ${dracuthostonly} -f ${initrdfile} ${version}"
570     else
571     tool="mkinitrd --allow-missing -f ${initrdfile} ${version}"
572     fi
573   [[ -n ${verbose} ]] && echo "creating initrd ${initrdfile} using ${version}"   [[ -n ${verbose} ]] && echo "creating initrd ${initrdfile} using ${version}"
574   /sbin/mkinitrd --allow-missing -f ${initrdfile} ${version}   ${tool}
575   rc=$?   rc=$?
576   if [ ${rc} != 0 ]   if [ ${rc} != 0 ]
577   then   then
# Line 329  doDepmod() Line 595  doDepmod()
595  doRmmoddep()  doRmmoddep()
596  {  {
597   [[ -n ${verbose} ]] && echo "removing modules.dep info for ${version}"   [[ -n ${verbose} ]] && echo "removing modules.dep info for ${version}"
598   [ -d /lib/modules/${version} ] && rm -f /lib/modules/${version}/modules.*   if [ -d /lib/modules/${version} ]
599     then
600     rm -f /lib/modules/${version}/modules.*.bin \
601     /lib/modules/${version}/modules.{alias,dep,devname,symbols,softdep}
602     fi
603  }  }
604    
605    
# Line 344  do Line 614  do
614   initrd="remove"   initrd="remove"
615   ;;   ;;
616    
617     --dracut)
618     dracut=--dracut
619     ;;
620    
621     --host-only)
622     dracuthostonly=-H
623     ;;
624    
625   --initrdfile*)   --initrdfile*)
626   if echo $1 | grep '=' >/dev/null   if [[ $1 == --initrdfile\=* ]]
627   then   then
628   initrdfile=$(echo $1 | sed 's/^--initrdfile=//')   initrdfile=${1#--initrdfile=}
629   else   else
630   initrdfile=$2   initrdfile=$2
631   shift   shift
# Line 355  do Line 633  do
633   ;;   ;;
634    
635   --kernel-args*)   --kernel-args*)
636   if echo $1 | grep '=' >/dev/null   if [[ $1 == --kernel-args\=* ]]
637   then   then
638   kernargs=$(echo $1 | sed 's/^--kernel-args=//')   kernargs=${1#--kernel-args=}
639   else   else
640   kernargs=$2   kernargs=$2
641   shift   shift
# Line 365  do Line 643  do
643   ;;   ;;
644    
645   --remove-args*)   --remove-args*)
646   if echo $1 | grep '=' >/dev/null   if [[ $1 == --remove-args\=* ]]
647   then   then
648   removeargs=$(echo $1 | sed 's/^--remove-args=//')   removeargs=${1#--remove-args=}
649   else   else
650   removeargs=$2   removeargs=$2
651   shift   shift
# Line 375  do Line 653  do
653   ;;   ;;
654    
655   --banner*)   --banner*)
656   if echo $1 | grep '=' >/dev/null   if [[ $1 == --banner\=* ]]
657   then   then
658   banner=$(echo $1 | sed 's/^--banner=//')   banner=${1#--banner=}
659   else   else
660   banner=$2   banner=$2
661   shift   shift
# Line 385  do Line 663  do
663   ;;   ;;
664    
665   --multiboot*)   --multiboot*)
666   if echo $1 |grep '=' >/dev/null   if [[ $1 == --multiboot\=* ]]
667   then   then
668   mbkernel=$(echo $1 | sed 's/^--multiboot=//')   mbkernel=${1#--multiboot=}
669   else   else
670   # can't really support having an optional second arg here   # can't really support having an optional second arg here
671   # sorry!   # sorry!
# Line 396  do Line 674  do
674   ;;   ;;
675    
676   --mbargs*)   --mbargs*)
677   if echo $1 |grep '=' >/dev/null   if [[ $1 == --mbargs\=* ]]
678   then   then
679   mbargs=$(echo $1 | sed 's/^--mbargs=//')   mbargs=${1#--mbargs=}
680   else   else
681   mbargs="$2"   mbargs="$2"
682   shift   shift
# Line 417  do Line 695  do
695   makedefault="--make-default"   makedefault="--make-default"
696   ;;   ;;
697    
698   --package)   --package*)
699   if echo $1 | grep '=' >/dev/null   if [[ $1 == --package\=* ]]
700   then   then
701   package=$(echo $1 | sed 's/^--package=//')   package=${1#--package=}
702   else   else
703   package=$2   package=$2
704   shift   shift
705   fi   fi
706   ;;   ;;
707    
708     --add-dracut-args)
709     adddracutargs=--add-dracut-args
710     ;;
711    
712     --add-plymouth-initrd)
713     addplymouthinitrd=--add-plymouth-initrd
714     ;;
715    
716     --kernel-image*)
717     if [[ $1 == --kernel-image\=* ]]
718     then
719     kernelImage=${1#--kernel-image=}
720     else
721     kernelImage="$2"
722     shift
723     fi
724     if ! [[ -f ${kernelImage} ]]
725     then
726     echo "Can't find kernel image '${kernelImage}'" >&2
727     usage
728     exit 1
729     fi
730     ;;
731    
732   -v)   -v)
733   verbose=-v   verbose=-v
734   ;;   ;;
# Line 474  then Line 776  then
776   fi   fi
777  fi  fi
778    
779    [[ ${kernelImage} ]] || kernelImage="${bootPrefix}/${kernelName}-${version}"
780    
781  # 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
782  if [[ -z ${initrdfile} ]]  if [[ -z ${initrdfile} ]]
783  then  then
784   INITRD_NAME_PREFIX="initrd"   INITRD_NAME_PREFIX="initrd"
785     if [[ -n ${dracut} ]]
786     then
787     INITRD_NAME_PREFIX="initramfs"
788     fi
789    
790   if [[ $(uname -m) = ia64 ]]   if [[ $(uname -m) = ia64 ]]
791   then   then
# Line 488  then Line 796  then
796  fi  fi
797  [[ -n ${verbose} ]] && echo "initrdfile is ${initrdfile}"  [[ -n ${verbose} ]] && echo "initrdfile is ${initrdfile}"
798    
799    # add dracut i18n, keyboard and plymouth kernel args if requested
800    if [[ -n ${dracut} ]] || [[ -n ${adddracutargs} ]]
801    then
802     if [ -r /etc/vconsole.conf ]
803     then
804     . /etc/vconsole.conf
805    
806     for i in SYSFONT SYSFONTACM UNIMAP KEYTABLE
807     do
808     val=$(eval echo \$$i)
809     [[ -n ${val} ]] && kernargs="${kernargs} ${i}=${val}"
810     done
811     else
812     if [ -r /etc/conf.d/consolefont ]
813     then
814     . /etc/conf.d/consolefont
815    
816     if [[ -n ${CONSOLEFONT} ]]
817     then
818     kernargs="${kernargs} SYSFONT=${CONSOLEFONT}"
819     fi
820     fi
821    
822     if  [ -r /etc/conf.d/keymap ]
823     then
824     . /etc/conf.d/keymap
825    
826     if [[ -n ${KEYMAP} ]]
827     then
828     kernargs="${kernargs} KEYTABLE=${KEYMAP}"
829     fi
830     fi
831     fi
832    
833     if [ -r /etc/locale.conf ]
834     then
835     . /etc/locale.conf
836    
837     if [[ -n ${LANG} ]]
838     then
839     kernargs="${kernargs} LANG=${LANG}"
840     fi
841     fi
842    fi
843    
844  # 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
845  if [[ ${mode} = --install ]] && [[ ${UPDATEDEFAULT} = yes ]] && [[ -n ${package} ]] &&  if [[ ${mode} = --install ]] && [[ ${UPDATEDEFAULT} = yes ]] && [[ -n ${package} ]] &&
846   [[ -n ${DEFAULTKERNEL} ]] && [[ ${package} = ${DEFAULTKERNEL} ]]   [[ -n ${DEFAULTKERNEL} ]] && [[ ${package} = ${DEFAULTKERNEL} ]]
# Line 506  fi Line 859  fi
859    
860  if [[ ${initrd} = make ]]  if [[ ${initrd} = make ]]
861  then  then
862   mkinitrd   makeinitrd
863  elif [[ ${initrd} = remove ]]  elif [[ ${initrd} = remove ]]
864  then  then
865   rminitrd   rminitrd
# Line 519  then Line 872  then
872  fi  fi
873    
874  [[ -n ${grubConfig} ]] && [ -f ${grubConfig} ] && cfgGrub=1  [[ -n ${grubConfig} ]] && [ -f ${grubConfig} ] && cfgGrub=1
875    [[ -n ${grub2Config} ]] && [ -f ${grub2Config} ] && cfgGrub2=1
876    [[ -n ${grub2EfiConfig} ]] && [ -f ${grub2EfiConfig} ] && cfgGrub2Efi=1
877  [[ -n ${liloConfig} ]] && [ -f ${liloConfig} ] && cfgLilo=1  [[ -n ${liloConfig} ]] && [ -f ${liloConfig} ] && cfgLilo=1
878    [[ -n ${extlinuxConfig} ]] && [ -f ${extlinuxConfig} ] && cfgExtlinux=1
879    
880    # if we have a U-Boot directory, but no boot script, check if the directory
881    # is mounted.  If not, mount it, and then check if a boot script exists.
882    if [[ -n ${ubootDir} ]]
883    then
884     if [ -f ${ubootScript} ]
885     then
886     cfguBoot=1
887     else
888     mountEntry=$(mount | grep ${ubootDir})
889     if [[ -z ${mountEntry} ]]
890     then
891     mount ${ubootDevice} ${ubootDir}
892     mounted=1
893     fi
894     [ -f ${ubootScript} ] && cfguBoot=1
895     fi
896    fi
897    
898    # if we're using U-Boot, check if the default load address should change
899    if [[ -n ${cfguBoot} ]] && [[ -z ${UBOOT_IMGADDR} ]]
900    then
901     [[ ${version}  =~ .([^.]*)$ ]]
902     platform=${BASH_REMATCH[1]}
903     # A few platforms use an alternate kernel load address
904     if [[ ${platform} = omap ]]
905     then
906     ubootAddress=0x80008000
907     elif [[ ${platform} = imx ]]
908     then
909     ubootAddress=0x90008000
910     fi
911    fi
912    
913  # 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
914  # is lilo to determine if it should be run  # is lilo to determine if it should be run
# Line 539  then Line 928  then
928   update   update
929  fi  fi
930    
931    # if we mounted the U-Boot directory, unmount it.
932    [[ -n ${mounted} ]] && umount ${ubootDir}
933    
934  exit 0  exit 0

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