Magellan Linux

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

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

revision 1691 by niro, Fri Feb 17 23:10:15 2012 UTC revision 2990 by niro, Thu Jun 30 10:33:57 2016 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 42  fi Line 68  fi
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  [ -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=""  cfguBoot=""
77  runLilo=""  runLilo=""
78  grubConfig=""  grubConfig=""
79    grub2Config=""
80    grub2EfiConfig=""
81    extlinuxConfig=""
82    ubootScript="/boot/boot.scr"
83    
84  ARCH=$(uname -m)  ARCH=$(uname -m)
85    
# Line 59  then Line 92  then
92  elif [[ ${ARCH} = ppc64 ]] || [[ ${ARCH} = ppc ]]  elif [[ ${ARCH} = ppc64 ]] || [[ ${ARCH} = ppc ]]
93  then  then
94   liloConfig=/etc/yaboot.conf   liloConfig=/etc/yaboot.conf
95     grub2Config=/boot/grub/grub.cfg
96   bootPrefix=/boot   bootPrefix=/boot
97   lilo=/sbin/ybin   lilo=/sbin/ybin
98   liloFlag=yaboot   liloFlag=yaboot
# Line 79  then Line 113  then
113   lilo=/sbin/zipl   lilo=/sbin/zipl
114   runLilo="yes"   runLilo="yes"
115   isx86=""   isx86=""
116  elif [[ ${ARCH} = armv7l ]]  elif [[ ${ARCH} =~ armv[5|7].*l ]]
117  then  then
118   liloConfig=""   liloConfig=""
119   bootPrefix=/boot   bootPrefix=/boot
120   ubootDir=${UBOOT_DIR:-"/boot/uboot"}   extlinuxConfig=$(readlink -f /etc/extlinux.conf 2>/dev/null)
121     ubootDir=${UBOOT_DIR:-"/boot"}
122   ubootScript=$ubootDir/${UBOOT_SCR:-"boot.scr"}   ubootScript=$ubootDir/${UBOOT_SCR:-"boot.scr"}
123   ubootKList=${UBOOT_KLIST:-"klist.txt"}   ubootKList=${UBOOT_KLIST:-"klist.txt"}
124   ubootDevice=/dev/${UBOOT_DEVICE:-"mmcblk0p1"}   ubootDevice=/dev/${UBOOT_DEVICE:-"mmcblk0p1"}
125   ubootDefaultImage=${UBOOT_UIMAGE:-"uImage"}   ubootDefaultImage=${UBOOT_UIMAGE:-"uImage"}
126   ubootDefaultInitrd=${UBOOT_UINITRD:-"uInitrd"}   ubootDefaultInitrd=${UBOOT_UINITRD:-"uInitrd"}
127     ubootAddress=${UBOOT_IMGADDR:-"0x00008000"}
128   mounted=""   mounted=""
129   liloFlag=""   liloFlag=""
130   isx86=""   isx86=""
# Line 96  else Line 132  else
132   # this leaves i?86 and x86_64   # this leaves i?86 and x86_64
133   liloConfig=/etc/lilo.conf   liloConfig=/etc/lilo.conf
134   grubConfig=/boot/grub/grub.conf   grubConfig=/boot/grub/grub.conf
135     grub2Config=/boot/grub/grub.cfg
136     grub2EfiConfig=/boot/grub/grub-efi.cfg
137     extlinuxConfig=/boot/extlinux/extlinux.conf
138   bootPrefix=/boot   bootPrefix=/boot
139   liloFlag=lilo   liloFlag=lilo
140   isx86="yes"   isx86="yes"
# Line 107  initrd="" Line 146  initrd=""
146  dracut=""  dracut=""
147  dracuthostonly=""  dracuthostonly=""
148  initrdfile=""  initrdfile=""
149    devtreefile=""
150  moddep=""  moddep=""
151  verbose=""  verbose=""
152  makedefault=""  makedefault=""
153  package=""  package=""
154  mbkernel=""  mbkernel="${HYPERVISOR}"
155  mbargs=""  mbargs="${HYPERVISOR_ARGS}"
156  adddracutargs=""  adddracutargs=""
157  addplymouthinitrd=""  addplymouthinitrd=""
158    DEBUGARG="systemd.debug"
159    
160  usage()  usage()
161  {  {
# Line 124  usage() Line 165  usage()
165   echo "       [--banner=<banner>] [--multiboot=multiboot]" >&2   echo "       [--banner=<banner>] [--multiboot=multiboot]" >&2
166   echo "       [--mbargs=mbargs] [--make-default] [--add-dracut-args]" >&2   echo "       [--mbargs=mbargs] [--make-default] [--add-dracut-args]" >&2
167   echo "       [--add-plymouth-initrd]" >&2   echo "       [--add-plymouth-initrd]" >&2
168   echo "       [--host-only]" >&2   echo "       [--host-only] [--devtree=<devicetree.dtb>] [--devtreedir=</devicetree/path/>]" >&2
169   echo "       <--install | --remove | --update> <kernel-version>" >&2   echo "       <--install | --remove | --update> <kernel-version>" >&2
170   echo "       (ex: $(basename $0) --mkinitrd --depmod --install 2.4.7-2)" >&2   echo "       (ex: $(basename $0) --mkinitrd --depmod --install 2.4.7-2)" >&2
171   exit 1   exit 1
172  }  }
173    
174  run_grub2()  rungrubby()
175    {
176     if [[ $1 == --debug ]]
177     then
178     [[ ${MAKEDEBUG} != yes ]] && return 0
179     [[ -n ${verbose} ]] && echo "- First, making a debug entry."
180     if [[ ${ARCH} = s390 ]] || [[ ${ARCH} = s390x ]]
181     then
182     declare -x debugtitle="_with_debugging"
183     else
184     declare -x debugtitle=" with debugging"
185     fi
186     declare -x debugargs="${DEBUGARG}"
187     shift
188     else
189     [[ -n ${verbose} ] && echo "- Making a normal entry."
190     fi
191     $(eval $grubby $@)
192     export -n debugargs
193     export -n debugtitle
194     unset debugargs
195     unset debugtitle
196    }
197    
198    set_title()
199  {  {
200   if [ -d /boot/grub -a -x /sbin/grub-mkconfig ]   if [[ -n ${banner} ]]
201     then
202     if [[ ${ARCH} = s390 ]] || [[ ${ARCH} = s390x ]]
203     then
204     title=$(echo ${banner} | sed 's/ /_/g')
205     else
206     title="${banner} [ ${version} ]"
207     fi
208     elif [[ ${ARCH} = s390 ]] || [[ ${ARCH} = s390x ]]
209     then
210     title=$(echo ${version} | sed 's/ /_/g')
211     elif [ -f /etc/os-release ]
212   then   then
213   cp /boot/grub/grub.cfg /boot/grub/grub.cfg.old   title="$(read_os_release name) $(read_os_release version_id) [ ${version} ]"
214   /sbin/grub-mkconfig -o /boot/grub/grub.cfg   elif [ -f /etc/mageversion ]
215     then
216     title="Magellan Linux $(< /etc/mageversion) [ ${version} ]"
217     else
218     title="Magellan Linux [ ${version} ]"
219   fi   fi
220  }  }
221    
222  install()  install()
223  {  {
224   # 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)
225   if [ ! -f ${bootPrefix}/${kernelName}-${version} ]   if [ ! -f ${kernelImage} ]
226   then   then
227   [[ -n ${verbose} ]] && echo "kernel for ${version} does not exist, not running grubby"   [[ -n ${verbose} ]] && echo "kernel for ${version} does not exist, not running grubby"
228   return   return
# Line 160  install() Line 240  install()
240   fi   fi
241   fi   fi
242    
243     DEVTREE=""
244     if [[ -n ${devtreefile} ]] && [ -f ${devtreefile} ]
245     then
246     [[ -n ${verbose} ]] && echo "found ${devtreefile} and using it with grubby"
247     DEVTREE="--devtree ${devtreefile}"
248     fi
249    
250     DEVTREEDIR=""
251     if [[ -n ${devtreedir} ]] && [ -d ${devtreedir} ]
252     then
253     [ -n ${verbose} ] && echo "found ${devtreedir} and using it with grubby"
254     DEVTREEDIR="--devtreedir ${devtreedir}"
255     fi
256    
257   # 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?
258   if [ -d /proc/iSeries ]   if [ -d /proc/iSeries ]
259   then   then
# Line 167  install() Line 261  install()
261   if [[ -z ${initrdfile} ]]   if [[ -z ${initrdfile} ]]
262   then   then
263   [[ -n ${verbose} ]] && echo "No initrd, just adding system map"   [[ -n ${verbose} ]] && echo "No initrd, just adding system map"
264   /sbin/addSystemMap ${bootPrefix}/System.map-${version} ${bootPrefix}/${kernelName}-${version} ${bootPrefix}/vmlinitrd-${version}   /sbin/addSystemMap ${bootPrefix}/System.map-${version} ${kernelImage} ${bootPrefix}/vmlinitrd-${version}
265   else   else
266   /sbin/addSystemMap ${bootPrefix}/System.map-${version} ${bootPrefix}/${kernelName}-${version} ${bootPrefix}/vmlinux.sm-${version}   /sbin/addSystemMap ${bootPrefix}/System.map-${version} ${kernelImage} ${bootPrefix}/vmlinux.sm-${version}
267   /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
268   rm ${bootPrefix}/vmlinux.sm-${version}   rm ${bootPrefix}/vmlinux.sm-${version}
269   fi   fi
270   return   return
271   fi   fi
272    
  # Run grub2's configuration update in parallel, if it is installed  
  run_grub2  
   
273   # get the root filesystem to use   # get the root filesystem to use
274   rootdevice=$(awk '{ if ($1 !~ /^[ \t]*#/ && $2 == "/") { print $1; }}' /etc/fstab)   rootdevice=$(awk '{ if ($1 !~ /^[ \t]*#/ && $2 == "/") { print $1; }}' /etc/fstab  2>/dev/null)
275     if [[ -z $rootdevice ]]
276     then
277     rootdevice=$(grep -o -P "(?<=root=)\S+" /proc/cmdline)
278     fi
279    
280   if [[ -n ${mbkernel} ]] && [[ -n ${cfgLilo} ]] && [[ ${liloFlag} != elilo ]]   if [[ -n ${mbkernel} ]] && [[ -n ${cfgLilo} ]] && [[ ${liloFlag} != elilo ]]
281   then   then
# Line 188  install() Line 283  install()
283   cfgLilo=""   cfgLilo=""
284   fi   fi
285    
286     set_title
287    
288   if [[ -n ${cfgGrub} ]]   if [[ -n ${cfgGrub} ]]
289   then   then
290   [[ -n ${verbose} ]] && echo "adding ${version} to ${grubConfig}"   [[ -n ${verbose} ]] && echo "adding ${version} to ${grubConfig}"
291    
292   if [[ -n ${banner} ]]   ARGS="--grub -c ${grubConfig} --add-kernel=${kernelImage} ${INITRD} \
293   then   ${mbkernel:+--add-multiboot=\"${mbkernel}\"} \
294   title="${banner} (${version})"   ${mbargs:+--mbargs=\"${mbargs}\"} \
295   elif [ -f /etc/mageversion ]   --title=\"${title}\${debugtitle}\" --copy-default \
296   then   --args=\"root=${rootdevice} ${kernargs} \${debugargs}\" \
297   title="Magellan Linux $(< /etc/mageversion) (${version})"   --remove-kernel=\"TITLE=${title}\${debugtitle}\""
298   else   rungrubby --debug ${ARGS}
299   title="Magellan Linux (${version})"   rungrubby ${ARGS} ${makedefault}
  fi  
  ${grubby} --add-kernel=${bootPrefix}/${kernelName}-${version} \  
  ${INITRD} --copy-default ${makedefault} --title "${title}" \  
  ${mbkernel:+--add-multiboot="${mbkernel}"} ${mbargs:+--mbargs="${mbargs}"} \  
  --args="root=${rootdevice} ${kernargs}" --remove-kernel="TITLE=${title}"  
300   else   else
301   [[ -n ${verbose} ]] && echo "${grubConfig} does not exist, not running grubby"   [[ -n ${verbose} ]] && echo "${grubConfig} does not exist, not running grubby for grub 0.97"
302     fi
303     if [[ -n ${cfgGrub2} ]]
304     then
305     [[ -n ${verbose} ]] && echo "adding ${version} to ${grub2Config}"
306    
307     ARGS="--grub2 -c ${grub2Config} --add-kernel=${kernelImage} ${INITRD} \
308     --copy-default --title \"${title}\${debugtitle}\" \
309     ${mbkernel:+--add-multiboot=\"${mbkernel}\"} \
310     ${mbargs:+--mbargs=\"${mbargs}\"} \
311     --args=\"root=${rootdevice} ${kernargs} \${debugargs}\" \
312     --remove-kernel=\"TITLE=${title}\${debugtitle}\""
313     rungrubby --debug ${ARGS}
314     rungrubby ${ARGS} ${makedefault}
315     else
316     [[ -n ${verbose} ]] && echo "${grub2Config} does not exist, not running grubby for grub 2"
317     fi
318     if [[ -n ${cfgGrub2Efi} ]]
319     then
320     [[ -n ${verbose} ]] && echo "adding ${version} to ${grub2EfiConfig}"
321    
322     ARGS="--grub2 -c ${grub2EfiConfig} --efi \
323     --add-kernel=${kernelImage} ${DEVTREE} ${INITRD} \
324     --copy-default --title \"${title}\${debugtitle}\" \
325     ${mbkernel:+--add-multiboot=\"${mbkernel}\"} \
326     ${mbargs:+--mbargs=\"${mbargs}\"} \
327     --args=\"root=${rootdevice} ${kernargs} \${debugargs}\" \
328     --remove-kernel=\"TITLE=${title}\${debugtitle}\""
329     rungrubby --debug ${ARGS}
330     rungrubby ${ARGS} ${makedefault}
331     else
332     [[ -n ${verbose} ]] && echo "${grub2EfiConfig} does not exist, not running grubby for grub 2 with UEFI"
333   fi   fi
334    
335   if [[ -n ${cfgLilo} ]]   if [[ -n ${cfgLilo} ]]
336   then   then
337   [[ -n ${verbose} ]] && echo "adding ${version} to ${liloConfig}"   [[ -n ${verbose} ]] && echo "adding ${version} to ${liloConfig}"
338    
339   ${grubby} --add-kernel=${bootPrefix}/${kernelName}-${version} ${INITRD} \   ARGS="--${liloFlag} --add-kernel=${kernelImage} ${INITRD} \
340   --copy-default ${makedefault} --title ${version} \   --copy-default --title \"${title}\${debugtitle}\" \
341   ${mbkernel:+--add-multiboot="${mbkernel}"} ${mbargs:+--mbargs="${mbargs}"} \   ${mbkernel:+--add-multiboot=\"${mbkernel}\"} \
342   --args="root=${rootdevice} ${kernargs}" --remove-kernel="TITLE=${version}" \   ${mbargs:+--mbargs=\"${mbargs}\"} \
343   --${liloFlag}   --args=\"root=${rootdevice} ${kernargs} \${debugargs}\" \
344     --remove-kernel=\"TITLE=${version}\""
345     rungrubby --debug ${ARGS}
346     rungrubby ${ARGS} ${makedefault}
347    
348   if [[ -n ${runLilo} ]]   if [[ -n ${runLilo} ]]
349   then   then
# Line 232  install() Line 358  install()
358   else   else
359   [[ -n ${verbose} ]] && echo "${liloConfig} does not exist, not running grubby"   [[ -n ${verbose} ]] && echo "${liloConfig} does not exist, not running grubby"
360   fi   fi
361    
362     if [[ -n ${cfgExtlinux} ]]
363     then
364     [[ -n ${verbose} ]] && echo "adding ${version} to ${extlinuxConfig}"
365    
366     ARGS="--extlinux -c ${extlinuxConfig} --add-kernel=${kernelImage} \
367     ${DEVTREEDIR} ${DEVTREE} \
368     ${INITRD} --copy-default --title \"${title}\${debugtitle}\" \
369     ${mbkernel:+--add-multiboot=\"${mbkernel}\"} \
370     ${mbargs:+--mbargs=\"${mbargs}\"} \
371     --args=\"root=${rootdevice} ${kernargs} \${debugargs}\" \
372     --remove-kernel=\"TITLE=${title}\${debugtitle}\""
373     rungrubby --debug ${ARGS}
374     rungrubby ${ARGS} ${makedefault}
375     else
376     [[ -n ${verbose} ]] && echo "${extlinuxConfig} does not exist, not running grubby for extlinux"
377     fi
378  }  }
379    
380  remove()  remove()
# Line 240  remove() Line 383  remove()
383   if [ -d /proc/iSeries ]   if [ -d /proc/iSeries ]
384   then   then
385   [[ -n ${verbose} ]] && echo "On an iSeries, remove img file"   [[ -n ${verbose} ]] && echo "On an iSeries, remove img file"
386   rm -f ${bootPrefix}/${kernelName}-${version}.img 2>/dev/null   rm -f ${kernelImage}.img 2>/dev/null
387   return   return
388   fi   fi
389    
  # Run grub2's configuration update in parallel, if it is installed  
  run_grub2  
   
390   if [[ -n ${cfgGrub} ]]   if [[ -n ${cfgGrub} ]]
391   then   then
392   [[ -n ${verbose} ]] && echo "removing ${version} from ${grubConfig}"   [[ -n ${verbose} ]] && echo "removing ${version} from ${grubConfig}"
393   ${grubby} --remove-kernel=${bootPrefix}/${kernelName}-${version}   ${grubby} --grub -c ${grubConfig} \
394     --remove-kernel=${kernelImage}
395   else   else
396   [[ -n ${verbose} ]] && echo "${grubConfig} does not exist, not running grubby"   [[ -n ${verbose} ]] && echo "${grubConfig} does not exist, not running grubby for grub 0.97"
397     fi
398     if [[ -n ${cfgGrub2} ]]
399     then
400     [[ -n ${verbose} ]] && echo "removing ${version} from ${grub2Config}"
401     ${grubby} --grub2 -c ${grub2Config} \
402     --remove-kernel=${kernelImage}
403     else
404     [[ -n ${verbose} ]] && echo "${grub2Config} does not exist, not running grubby for grub 2"
405     fi
406     if [[ -n ${cfgGrub2Efi} ]]
407     then
408     [[ -n ${verbose} ]] && echo "removing ${version} from ${grub2EfiConfig}"
409     ${grubby} --grub2 -c ${grub2EfiConfig} --efi \
410     --remove-kernel=${kernelImage}
411     else
412     [[ -n ${verbose} ]] && echo "${grub2EfiConfig} does not exist, not running grubby grub 2 with UEFI"
413   fi   fi
414    
415   if [[ -n ${cfgLilo} ]]   if [[ -n ${cfgLilo} ]]
416   then   then
417   [[ -n ${verbose} ]] && echo "removing ${version} from ${liloConfig}"   [[ -n ${verbose} ]] && echo "removing ${version} from ${liloConfig}"
418   ${grubby} --remove-kernel=${bootPrefix}/${kernelName}-${version} --${liloFlag}   ${grubby} --remove-kernel=${kernelImage} --${liloFlag}
419    
420   if [[ -n ${runLilo} ]]   if [[ -n ${runLilo} ]]
421   then   then
# Line 282  remove() Line 439  remove()
439   then   then
440   tmpKList=$(mktemp ${ubootDir}/${ubootKList}.XXXX)   tmpKList=$(mktemp ${ubootDir}/${ubootKList}.XXXX)
441   curversion=$(tail -n1 ${ubootDir}/${ubootKList})   curversion=$(tail -n1 ${ubootDir}/${ubootKList})
442   sed "/${version}/d" ${ubootDir}/${ubootKList} > ${tmpKList}   sed "/$version$/d" ${ubootDir}/${ubootKList} > ${tmpKList}
443   newversion=$(tail -n1 ${tmpKList})   newversion=$(tail -n1 ${tmpKList})
444   if [ -f ${ubootDir}/uImage-${newversion} ] && [ -f ${ubootDir}/uInitrd-${newversion} ]   if [ -f ${ubootDir}/uImage-${newversion} ] && [ -f ${ubootDir}/uInitrd-${newversion} ]
445   then   then
# Line 317  remove() Line 474  remove()
474   fi   fi
475    
476   mv ${tmpKList} ${ubootDir}/${ubootKList}   mv ${tmpKList} ${ubootDir}/${ubootKList}
477     [ -x /sbin/a-b-c ] && /sbin/a-b-c
478   else   else
479   [[ -n ${verbose} ]] && echo "uImage ${newversion} does not exist!"   [[ -n ${verbose} ]] && echo "uImage ${newversion} does not exist!"
480   [ -f ${tmpKList} ] && rm -f ${tmpKList}   [ -f ${tmpKList} ] && rm -f ${tmpKList}
481   fi   fi
482   else   else
483   [[ -n ${verbose} ]] && echo "No previous kernel version. uBoot images not removed!"   [[ -n ${verbose} ]] && echo "No previous kernel version.  U-Boot images not removed!"
484   fi   fi
485   else   else
486   [[ -n ${verbose} ]] && echo "${ubootScript} does not exist, not modifying ${ubootDir}"   [[ -n ${verbose} ]] && echo "${ubootScript} does not exist, not modifying ${ubootDir}"
487   fi   fi
488    
489     if [[ -n ${cfgExtlinux} ]]
490     then
491     [[ -n ${verbose} ]] && echo "removing ${version} from ${extlinuxConfig}"
492     ${grubby} --extlinux -c ${extlinuxConfig} \
493     --remove-kernel=${kernelImage}
494     else
495     [[ -n ${verbose} ]] && echo "${extlinuxConfig} does not exist, not running grubby for extlinux"
496     fi
497  }  }
498    
499  update()  update()
500  {  {
501   if [ ! -f ${bootPrefix}/${kernelName}-${version} ]   if [ ! -f ${kernelImage} ]
502   then   then
503   [[ -n ${verbose} ]] && echo "kernel for ${version} does not exist, not running grubby"   [[ -n ${verbose} ]] && echo "kernel for ${version} does not exist, not running grubby"
504   return   return
505   fi   fi
506    
507     set_title
508    
509   INITRD=""   INITRD=""
510   if [ -f ${initrdfile} ]   if [ -f ${initrdfile} ]
511   then   then
# Line 349  update() Line 518  update()
518   fi   fi
519   fi   fi
520    
521   # Run grub2's configuration update in parallel, if it is installed   DEVTREE=""
522   run_grub2   if [[ -n ${devtreefile} ]] && [ -f ${devtreefile} ]
523     then
524     [[ -n ${verbose} ]] && echo "found ${devtreefile} and using it with grubby"
525     DEVTREE="--devtree ${devtreefile}"
526     fi
527    
528     DEVTREEDIR=""
529     if [[ -n ${devtreedir} ]] && [ -d ${devtreedir} ]
530     then
531     [[ -n ${verbose} ]] && echo "found ${devtreedir} and using it with grubby"
532     DEVTREEDIR="--devtreedir ${devtreedir}"
533     fi
534    
535   if [[ -n ${cfgGrub} ]]   if [[ -n ${cfgGrub} ]]
536   then   then
537   [[ -n ${verbose} ]] && echo "updating ${version} from ${grubConfig}"   [[ -n ${verbose} ]] && echo "updating ${version} from ${grubConfig}"
538   ${grubby} --update-kernel=${bootPrefix}/${kernelName}-${version} \   ARGS="--grub -c ${grubConfig} --update-kernel=${kernelImage} ${INITRD} \
539   ${INITRD} \   ${kernargs:+--args=\"${kernargs}\"} \
540   ${kernargs:+--args="${kernargs}"} \   ${removeargs:+--remove-args=\"${removeargs}\"} \
541   ${removeargs:+--remove-args="${removeargs}"}   ${mbkernel:+--add-multiboot=\"${mbkernel}\"} \
542     --title=\"${title}\${debugtitle}\""
543     rungrubby --debug ${ARGS}
544     rungrubby ${ARGS}
545   else   else
546   [[ -n ${verbose} ]] && echo "${grubConfig} does not exist, not running grubby"   [[ -n ${verbose} ]] && echo "${grubConfig} does not exist, not running grubby"
547   fi   fi
548    
549     if [[ -n ${cfgGrub2} ]]
550     then
551     [[ -n ${verbose} ]] && echo "updating ${version} from ${grub2Config}"
552     ARGS="--grub2 -c ${grub2Config} --update-kernel=${kernelImage} ${INITRD} \
553     ${kernargs:+--args=\"${kernargs}\"} \
554     ${removeargs:+--remove-args=\"${removeargs}\"} \
555     --title=\"${title}\${debugtitle}\""
556     rungrubby --debug ${ARGS}
557     rungrubby ${ARGS}
558     else
559     [[ -n ${verbose} ]] && echo "${grub2Config} does not exist, not running grubby"
560     fi
561    
562     if [[ -n ${cfgGrub2Efi} ]]
563     then
564     [[ -n ${verbose} ]] && echo "updating ${version} from ${grub2EfiConfig}"
565     ARGS="--grub2 -c ${grub2EfiConfig} --efi --update-kernel=${kernelImage} \
566     ${INITRD} ${kernargs:+--args=\"${kernargs}\"} \
567     ${removeargs:+--remove-args=\"${removeargs}\"} \
568     --title=\"${title}\${debugtitle}\""
569     rungrubby --debug ${ARGS}
570     rungrubby ${ARGS}
571     else
572     [[ -n ${verbose} ]] && echo "${grub2EfiConfig} does not exist, not running grubby"
573     fi
574    
575   if [[ -n ${cfgLilo} ]]   if [[ -n ${cfgLilo} ]]
576   then   then
577   [[ -n ${verbose} ]] && echo "updating ${version} from ${liloConfig}"   [[ -n ${verbose} ]] && echo "updating ${version} from ${liloConfig}"
578   ${grubby} --update-kernel=${bootPrefix}/${kernelName}-${version} \   ARGS="--${liloFlag} --update-kernel=${kernelImage} ${INITRD} \
579   ${INITRD} \   ${kernargs:+--args=\"${kernargs}\"} \
580   ${kernargs:+--args="${kernargs}"} \   ${removeargs:+--remove-args=\"${removeargs}\"} \
581   ${removeargs:+--remove-args="${removeargs}"} \   --title=\"${title}\${debugtitle}\""
582   --${liloFlag}   rungrubby --debug ${ARGS}
583     rungrubby ${ARGS}
584    
585   if [[ -n ${runLilo} ]]   if [[ -n ${runLilo} ]]
586   then   then
# Line 391  update() Line 601  update()
601   [[ -n ${verbose} ]] && echo "adding $version to ${ubootDir}..."   [[ -n ${verbose} ]] && echo "adding $version to ${ubootDir}..."
602    
603   [[ -n ${verbose} ]] && echo "creating uImage-${version}"   [[ -n ${verbose} ]] && echo "creating uImage-${version}"
604   mkimage -A arm -O linux -T kernel -C none -a 0x80008000 -e 0x80008000 \   mkimage -A arm -O linux -T kernel -C none -a ${ubootAddress} \
605   -n ${version} -d ${bootPrefix}/${kernelName}-${version} ${ubootDir}/uImage-${version}   -e ${ubootAddress} -n ${version} \
606     -d ${kernelImage} ${ubootDir}/uImage-${version}
607    
608   [[ -n ${verbose} ]] && echo "creating uInitrd-${version}"   [[ -n ${verbose} ]] && echo "creating uInitrd-${version}"
609   mkimage -A arm -O linux -T ramdisk -C none -a 0 -e 0 \   mkimage -A arm -O linux -T ramdisk -C none -a 0 -e 0 \
# Line 411  update() Line 622  update()
622   [[ -n ${verbose} ]] && echo "copy uInitrd-${version} error, kernel not installed!" && exit   [[ -n ${verbose} ]] && echo "copy uInitrd-${version} error, kernel not installed!" && exit
623   fi   fi
624   echo ${version} >> ${ubootDir}/${ubootKList}   echo ${version} >> ${ubootDir}/${ubootKList}
625     [ -x /sbin/a-b-c ] && /sbin/a-b-c
626   else   else
627   [[ -n ${verbose} ]] && echo "cannot make ${version} the default"   [[ -n ${verbose} ]] && echo "cannot make ${version} the default"
628   fi   fi
629   else   else
630   [[ -n ${verbose} ]] && echo "${ubootScript} does not exist, not setting up ${ubootDir}"   [[ -n ${verbose} ]] && echo "${ubootScript} does not exist, not setting up ${ubootDir}"
631   fi   fi
632    
633     if [[ -n ${cfgExtlinux} ]]
634     then
635     [[ -n ${verbose} ]] && echo "updating ${version} from ${extlinuxConfig}"
636     ARGS="--extlinux -c ${extlinuxConfig} --update-kernel=${kernelImage} \
637     ${DEVTREE} ${DEVTREEDIR} ${INITRD} ${kernargs:+--args=\"${kernargs}\"} \
638     ${removeargs:+--remove-args=\"${removeargs}\"} \
639     --title=\"${title}\${debugtitle}\""
640     rungrubby --debug ${ARGS}
641     rungrubby ${ARGS}
642     else
643     [[ -n ${verbose} ]] && echo "${extlinuxConfig} does not exist, not running grubby"
644     fi
645  }  }
646    
647  mkinitrd()  makeinitrd()
648  {  {
649   if [[ -n ${dracut} ]]   if [[ -n ${dracut} ]]
650   then   then
651   tool="/sbin/dracut ${dracuthostonly} -f ${initrdfile} ${version}"   tool="dracut ${dracuthostonly} -f ${initrdfile} ${version}"
652   else   else
653   tool="/sbin/mkinitrd --allow-missing -f ${initrdfile} ${version}"   tool="mkinitrd --allow-missing -f ${initrdfile} ${version}"
654   fi   fi
655   [[ -n ${verbose} ]] && echo "creating initrd ${initrdfile} using ${version}"   [[ -n ${verbose} ]] && echo "creating initrd ${initrdfile} using ${version}"
656   ${tool}   ${tool}
# Line 452  doDepmod() Line 677  doDepmod()
677  doRmmoddep()  doRmmoddep()
678  {  {
679   [[ -n ${verbose} ]] && echo "removing modules.dep info for ${version}"   [[ -n ${verbose} ]] && echo "removing modules.dep info for ${version}"
680   [ -d /lib/modules/${version} ] && rm -f /lib/modules/${version}/modules.*   if [ -d /lib/modules/${version} ]
681     then
682     rm -f /lib/modules/${version}/modules.*.bin \
683     /lib/modules/${version}/modules.{alias,dep,devname,symbols,softdep}
684     fi
685  }  }
686    
687    # kernel image for 2.4 is kernel
688    if [[ ${ARCH} = ppc64 ]] || [[ ${ARCH} = ppc ]]
689    then
690     if [[ ${kernelmajor} = 2.4 ]]
691     then
692     kernelName=kernel
693     fi
694    fi
695    
696  while [ $# -gt 0 ]  while [ $# -gt 0 ]
697  do  do
# Line 467  do Line 704  do
704   initrd="remove"   initrd="remove"
705   ;;   ;;
706    
707     --devtree*)
708     if [[ $1 == --devtree\=* ]]
709     then
710     devtreefile="${1#--devtreefile=}"
711     else
712     devtreefile="$2"
713     shift
714     fi
715     ;;
716    
717     --devtreedir*)
718     if [[ $1 == --devtreedir\=* ]]
719     then
720     devtreedir=${1#--devtreedir=}
721     else
722     devtreedir=$2
723     shift
724     fi
725     ;;
726    
727   --dracut)   --dracut)
728   dracut=--dracut   dracut=--dracut
729   ;;   ;;
# Line 476  do Line 733  do
733   ;;   ;;
734    
735   --initrdfile*)   --initrdfile*)
736   if echo $1 | grep '=' >/dev/null   if [[ $1 == --initrdfile\=* ]]
737   then   then
738   initrdfile=$(echo $1 | sed 's/^--initrdfile=//')   initrdfile=${1#--initrdfile=}
739   else   else
740   initrdfile=$2   initrdfile=$2
741   shift   shift
# Line 486  do Line 743  do
743   ;;   ;;
744    
745   --kernel-args*)   --kernel-args*)
746   if echo $1 | grep '=' >/dev/null   if [[ $1 == --kernel-args\=* ]]
747   then   then
748   kernargs=$(echo $1 | sed 's/^--kernel-args=//')   kernargs=${1#--kernel-args=}
749   else   else
750   kernargs=$2   kernargs=$2
751   shift   shift
# Line 496  do Line 753  do
753   ;;   ;;
754    
755   --remove-args*)   --remove-args*)
756   if echo $1 | grep '=' >/dev/null   if [[ $1 == --remove-args\=* ]]
757   then   then
758   removeargs=$(echo $1 | sed 's/^--remove-args=//')   removeargs=${1#--remove-args=}
759   else   else
760   removeargs=$2   removeargs=$2
761   shift   shift
# Line 506  do Line 763  do
763   ;;   ;;
764    
765   --banner*)   --banner*)
766   if echo $1 | grep '=' >/dev/null   if [[ $1 == --banner\=* ]]
767   then   then
768   banner=$(echo $1 | sed 's/^--banner=//')   banner=${1#--banner=}
769   else   else
770   banner=$2   banner=$2
771   shift   shift
# Line 516  do Line 773  do
773   ;;   ;;
774    
775   --multiboot*)   --multiboot*)
776   if echo $1 |grep '=' >/dev/null   if [[ $1 == --multiboot\=* ]]
777   then   then
778   mbkernel=$(echo $1 | sed 's/^--multiboot=//')   mbkernel=${1#--multiboot=}
779   else   else
780   # can't really support having an optional second arg here   # can't really support having an optional second arg here
781   # sorry!   # sorry!
# Line 527  do Line 784  do
784   ;;   ;;
785    
786   --mbargs*)   --mbargs*)
787   if echo $1 |grep '=' >/dev/null   if [[ $1 == --mbargs\=* ]]
788   then   then
789   mbargs=$(echo $1 | sed 's/^--mbargs=//')   mbargs=${1#--mbargs=}
790   else   else
791   mbargs="$2"   mbargs="$2"
792   shift   shift
# Line 548  do Line 805  do
805   makedefault="--make-default"   makedefault="--make-default"
806   ;;   ;;
807    
808   --package)   --package*)
809   if echo $1 | grep '=' >/dev/null   if [[ $1 == --package\=* ]]
810   then   then
811   package=$(echo $1 | sed 's/^--package=//')   package=${1#--package=}
812   else   else
813   package=$2   package=$2
814   shift   shift
# Line 566  do Line 823  do
823   addplymouthinitrd=--add-plymouth-initrd   addplymouthinitrd=--add-plymouth-initrd
824   ;;   ;;
825    
826     --kernel-image*)
827     if [[ $1 == --kernel-image\=* ]]
828     then
829     kernelImage=${1#--kernel-image=}
830     else
831     kernelImage="$2"
832     shift
833     fi
834     if ! [[ -f ${kernelImage} ]]
835     then
836     echo "Can't find kernel image '${kernelImage}'" >&2
837     usage
838     exit 1
839     fi
840     ;;
841    
842     --kernel-name*)
843     if [[ $1 == --kernel-name\=* ]]
844     then
845     kernelName=${1#--kernel-name=}
846     else
847     kernelName="$2"
848     shift
849     fi
850     ;;
851    
852   -v)   -v)
853   verbose=-v   verbose=-v
854   ;;   ;;
# Line 604  fi Line 887  fi
887    
888  kernelmajor=$(echo ${kernel} | cut -d . -f 1,2)  kernelmajor=$(echo ${kernel} | cut -d . -f 1,2)
889    
890  # kernel image for 2.4 is kernel  [[ ${kernelImage} ]] || kernelImage="${bootPrefix}/${kernelName}-${version}"
 if [[ ${ARCH} = ppc64 ]] || [[ ${ARCH} = ppc ]]  
 then  
  if [[ ${kernelmajor} = 2.4 ]]  
  then  
  kernelName=kernel  
  fi  
 fi  
891    
892  # 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
893  if [[ -z ${initrdfile} ]]  if [[ -z ${initrdfile} ]]
# Line 631  then Line 907  then
907  fi  fi
908  [[ -n ${verbose} ]] && echo "initrdfile is ${initrdfile}"  [[ -n ${verbose} ]] && echo "initrdfile is ${initrdfile}"
909    
910    if [[ ${ARCH} =~ armv[5|7].*l ]]
911    then
912     if [[ -z ${SHIPSDTB} ]] || [[ ${SHIPSDTB} != yes ]]
913     then
914     if [[ -n ${dtbfile} ]] && [ -f ${bootPrefix}/dtb-${version}/${dtbfile} ]
915     then
916     devtreefile="${bootPrefix}/dtb-${version}/${dtbfile}"
917     [[ -n ${verbose} ]] && echo "devtreefile is ${devtreefile}"
918     elif [ -d ${bootPrefix}/dtb-${version}/ ]
919     then
920     devtreedir="${bootPrefix}/dtb-${version}/"
921     [[ -n ${verbose} ]] && echo "devtreedir is ${devtreedir}"
922     fi
923     fi
924    fi
925    [[ -n ${verbose} ]] && echo "devtreedir is ${devtreedir}"
926    
927  # add dracut i18n, keyboard and plymouth kernel args if requested  # add dracut i18n, keyboard and plymouth kernel args if requested
928  if [[ -n ${dracut} ]] || [[ -n ${adddracutargs} ]]  if [[ -n ${dracut} ]] || [[ -n ${adddracutargs} ]]
929  then  then
930   [ -r /etc/conf.d/keymap ] && . /etc/conf.d/keymap   if [ -r /etc/vconsole.conf ]
  [ -r /etc/conf.d/consolefont ] && . /etc/conf.d/consolefont  
   
  if [[ -n ${KEYMAP} ]]  
931   then   then
932   kernargs="${kernargs} KEYTABLE=${KEYMAP}"   . /etc/vconsole.conf
933    
934     for i in SYSFONT SYSFONTACM UNIMAP KEYTABLE
935     do
936     val=$(eval echo \$$i)
937     [[ -n ${val} ]] && kernargs="${kernargs} ${i}=${val}"
938     done
939     else
940     if [ -r /etc/conf.d/consolefont ]
941     then
942     . /etc/conf.d/consolefont
943    
944     if [[ -n ${CONSOLEFONT} ]]
945     then
946     kernargs="${kernargs} SYSFONT=${CONSOLEFONT}"
947     fi
948     fi
949    
950     if  [ -r /etc/conf.d/keymap ]
951     then
952     . /etc/conf.d/keymap
953    
954     if [[ -n ${KEYMAP} ]]
955     then
956     kernargs="${kernargs} KEYTABLE=${KEYMAP}"
957     fi
958     fi
959   fi   fi
960    
961   if [[ -n ${CONSOLEFONT} ]]   if [ -r /etc/locale.conf ]
962   then   then
963   kernargs="${kernargs} SYSFONT=${CONSOLEFONT}"   . /etc/locale.conf
964    
965     if [[ -n ${LANG} ]]
966     then
967     kernargs="${kernargs} LANG=${LANG}"
968     fi
969   fi   fi
970  fi  fi
971    
972  # 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
973  if [[ ${mode} = --install ]] && [[ ${UPDATEDEFAULT} = yes ]] && [[ -n ${package} ]] &&  if [[ ${mode} = --install ]] && [[ ${UPDATEDEFAULT} = yes ]] && [[ -n ${package} ]] && [[ -n ${DEFAULTKERNEL} ]]
  [[ -n ${DEFAULTKERNEL} ]] && [[ ${package} = ${DEFAULTKERNEL} ]]  
974  then  then
975   makedefault="--make-default"   if [[ ${package} = ${DEFAULTKERNEL} ]] || [[ ${package}-core = ${DEFAULTKERNEL} ]]
976   [[ -n ${verbose} ]] && echo "making it the default based on config"   then
977     makedefault="--make-default"
978     [[ -n ${verbose} ]] && echo "making it the default based on config"
979     fi
980  fi  fi
981    
982  if [[ ${moddep} = make ]]  if [[ ${moddep} = make ]]
# Line 666  fi Line 989  fi
989    
990  if [[ ${initrd} = make ]]  if [[ ${initrd} = make ]]
991  then  then
992   mkinitrd   makeinitrd
993  elif [[ ${initrd} = remove ]]  elif [[ ${initrd} = remove ]]
994  then  then
995   rminitrd   rminitrd
# Line 679  then Line 1002  then
1002  fi  fi
1003    
1004  [[ -n ${grubConfig} ]] && [ -f ${grubConfig} ] && cfgGrub=1  [[ -n ${grubConfig} ]] && [ -f ${grubConfig} ] && cfgGrub=1
1005    [[ -n ${grub2Config} ]] && [ -f ${grub2Config} ] && cfgGrub2=1
1006    [[ -n ${grub2EfiConfig} ]] && [ -f ${grub2EfiConfig} ] && cfgGrub2Efi=1
1007  [[ -n ${liloConfig} ]] && [ -f ${liloConfig} ] && cfgLilo=1  [[ -n ${liloConfig} ]] && [ -f ${liloConfig} ] && cfgLilo=1
1008    [[ -n ${extlinuxConfig} ]] && [ -f ${extlinuxConfig} ] && cfgExtlinux=1
1009    
1010  # if we have a uBoot directory, check if it is mounted.  # if we have a U-Boot directory, but no boot script, check if the directory
1011  # if not, mount it. Then check if a boot script exists.  # is mounted.  If not, mount it, and then check if a boot script exists.
1012  if [[ -n ${ubootDir} ]]  if [[ -n ${ubootDir} ]]
1013  then  then
1014   mountEntry=$(mount | grep ${ubootDir})   if [ -f ${ubootScript} ]
  if [[ -z ${mountEntry} ]]  
1015   then   then
1016   mount ${ubootDevice} ${ubootDir}   cfguBoot=1
1017   mounted=1   else
1018     mountEntry=$(mount | grep ${ubootDir})
1019     if [[ -z ${mountEntry} ]]
1020     then
1021     mount ${ubootDevice} ${ubootDir}
1022     mounted=1
1023     fi
1024     [ -f ${ubootScript} ] && cfguBoot=1
1025     fi
1026    fi
1027    
1028    # if we're using U-Boot, check if the default load address should change
1029    if [[ -n ${cfguBoot} ]] && [[ -z ${UBOOT_IMGADDR} ]]
1030    then
1031     [[ ${version}  =~ .([^.]*)$ ]]
1032     platform=${BASH_REMATCH[1]}
1033     # A few platforms use an alternate kernel load address
1034     if [[ ${platform} = omap ]]
1035     then
1036     ubootAddress=0x80008000
1037     elif [[ ${platform} = imx ]]
1038     then
1039     ubootAddress=0x90008000
1040   fi   fi
  [ -f ${ubootScript} ] && cfguBoot=1  
1041  fi  fi
1042    
1043  # 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
# Line 712  then Line 1058  then
1058   update   update
1059  fi  fi
1060    
1061    # if we mounted the U-Boot directory, unmount it.
1062    [[ -n ${mounted} ]] && umount ${ubootDir}
1063    
1064  exit 0  exit 0

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