Magellan Linux

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

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

revision 1702 by niro, Sat Feb 18 00:21:34 2012 UTC revision 2965 by niro, Wed Jun 29 14:52:33 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 46  cfgGrub2="" Line 72  cfgGrub2=""
72  cfgGrub2Efi=""  cfgGrub2Efi=""
73  cfgGrub=""  cfgGrub=""
74  cfgLilo=""  cfgLilo=""
75    cfgExtlinux=""
76  cfguBoot=""  cfguBoot=""
77  runLilo=""  runLilo=""
78  grubConfig=""  grubConfig=""
79  grub2Config=""  grub2Config=""
80  grub2EfiConfig=""  grub2EfiConfig=""
81    extlinuxConfig=""
82    ubootScript="/boot/boot.scr"
83    
84  ARCH=$(uname -m)  ARCH=$(uname -m)
85    
# Line 63  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 83  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 102  else Line 134  else
134   grubConfig=/boot/grub/grub.conf   grubConfig=/boot/grub/grub.conf
135   grub2Config=/boot/grub/grub.cfg   grub2Config=/boot/grub/grub.cfg
136   grub2EfiConfig=/boot/grub/grub-efi.cfg   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 113  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 130  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>]" >&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    rungrubby()
175    {
176     if [[ $1 == --debug ]]
177     then
178     [[ ${MAKEDEBUG} != yes ]] && return 0
179     [[ -n ${verbose} ]] && echo "- First, making a debug entry."
180     declare -x debugtitle=" with debugging"
181     declare -x debugargs="${DEBUGARG}"
182     shift
183     else
184     [[ -n ${verbose} ] && echo "- Making a normal entry."
185     fi
186     $(eval $grubby $@)
187     export -n debugargs
188     export -n debugtitle
189     unset debugargs
190     unset debugtitle
191    }
192    
193    set_title()
194    {
195     if [[ -n ${banner} ]]
196     then
197     if [[ ${ARCH} = s390 ]] || [[ ${ARCH} = s390x ]]
198     then
199     title=$(echo ${banner} | sed 's/ /_/g')
200     else
201     title="${banner} [ ${version} ]"
202     fi
203     elif [[ ${ARCH} = s390 ]] || [[ ${ARCH} = s390x ]]
204     then
205     title=$(echo ${version} | sed 's/ /_/g')
206     elif [ -f /etc/os-release ]
207     then
208     title="$(read_os_release name) $(read_os_release version_id) [ ${version} ]"
209     elif [ -f /etc/mageversion ]
210     then
211     title="Magellan Linux $(< /etc/mageversion) [ ${version} ]"
212     else
213     title="Magellan Linux [ ${version} ]"
214     fi
215    }
216    
217  install()  install()
218  {  {
219   # 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)
220   if [ ! -f ${bootPrefix}/${kernelName}-${version} ]   if [ ! -f ${kernelImage} ]
221   then   then
222   [[ -n ${verbose} ]] && echo "kernel for ${version} does not exist, not running grubby"   [[ -n ${verbose} ]] && echo "kernel for ${version} does not exist, not running grubby"
223   return   return
# Line 157  install() Line 235  install()
235   fi   fi
236   fi   fi
237    
238     DEVTREE=""
239     if [[ x${devtreefile} != x ]] && [ -f "${devtreefile}" ]
240     then
241     [[ -n ${verbose} ]] && echo "found ${devtreefile} and using it with grubby"
242     DEVTREE="--devtree ${devtreefile}"
243     fi
244    
245   # 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?
246   if [ -d /proc/iSeries ]   if [ -d /proc/iSeries ]
247   then   then
# Line 164  install() Line 249  install()
249   if [[ -z ${initrdfile} ]]   if [[ -z ${initrdfile} ]]
250   then   then
251   [[ -n ${verbose} ]] && echo "No initrd, just adding system map"   [[ -n ${verbose} ]] && echo "No initrd, just adding system map"
252   /sbin/addSystemMap ${bootPrefix}/System.map-${version} ${bootPrefix}/${kernelName}-${version} ${bootPrefix}/vmlinitrd-${version}   /sbin/addSystemMap ${bootPrefix}/System.map-${version} ${kernelImage} ${bootPrefix}/vmlinitrd-${version}
253   else   else
254   /sbin/addSystemMap ${bootPrefix}/System.map-${version} ${bootPrefix}/${kernelName}-${version} ${bootPrefix}/vmlinux.sm-${version}   /sbin/addSystemMap ${bootPrefix}/System.map-${version} ${kernelImage} ${bootPrefix}/vmlinux.sm-${version}
255   /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
256   rm ${bootPrefix}/vmlinux.sm-${version}   rm ${bootPrefix}/vmlinux.sm-${version}
257   fi   fi
# Line 174  install() Line 259  install()
259   fi   fi
260    
261   # get the root filesystem to use   # get the root filesystem to use
262   rootdevice=$(awk '{ if ($1 !~ /^[ \t]*#/ && $2 == "/") { print $1; }}' /etc/fstab)   rootdevice=$(awk '{ if ($1 !~ /^[ \t]*#/ && $2 == "/") { print $1; }}' /etc/fstab  2>/dev/null)
263     if [[ -z $rootdevice ]]
264     then
265     rootdevice=$(grep -o -P "(?<=root=)\S+" /proc/cmdline)
266     fi
267    
268   if [[ -n ${mbkernel} ]] && [[ -n ${cfgLilo} ]] && [[ ${liloFlag} != elilo ]]   if [[ -n ${mbkernel} ]] && [[ -n ${cfgLilo} ]] && [[ ${liloFlag} != elilo ]]
269   then   then
# Line 182  install() Line 271  install()
271   cfgLilo=""   cfgLilo=""
272   fi   fi
273    
274     set_title
275    
276   if [[ -n ${cfgGrub} ]]   if [[ -n ${cfgGrub} ]]
277   then   then
278   [[ -n ${verbose} ]] && echo "adding ${version} to ${grubConfig}"   [[ -n ${verbose} ]] && echo "adding ${version} to ${grubConfig}"
279    
280   if [[ -n ${banner} ]]   ARGS="--grub -c ${grubConfig} --add-kernel=${kernelImage} ${INITRD} \
281   then   ${mbkernel:+--add-multiboot=\"${mbkernel}\"} \
282   title="${banner} (${version})"   ${mbargs:+--mbargs=\"${mbargs}\"} \
283   elif [ -f /etc/mageversion ]   --title=\"${title}\${debugtitle}\" --copy-default \
284   then   --args=\"root=${rootdevice} ${kernargs} \${debugargs}\" \
285   title="Magellan Linux $(< /etc/mageversion) (${version})"   --remove-kernel=\"TITLE=${title}\${debugtitle}\""
286   else   rungrubby --debug ${ARGS}
287   title="Magellan Linux (${version})"   rungrubby ${ARGS} ${makedefault}
  fi  
  ${grubby} --grub --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}"  
288   else   else
289   [[ -n ${verbose} ]] && echo "${grubConfig} does not exist, not running grubby for grub 0.97"   [[ -n ${verbose} ]] && echo "${grubConfig} does not exist, not running grubby for grub 0.97"
290   fi   fi
# Line 206  install() Line 292  install()
292   then   then
293   [[ -n ${verbose} ]] && echo "adding ${version} to ${grub2Config}"   [[ -n ${verbose} ]] && echo "adding ${version} to ${grub2Config}"
294    
295   if [[ -n ${banner} ]]   ARGS="--grub2 -c ${grub2Config} --add-kernel=${kernelImage} ${INITRD} \
296   then   --copy-default --title \"${title}\${debugtitle}\" \
297   title="${banner} (${version})"   ${mbkernel:+--add-multiboot=\"${mbkernel}\"} \
298   elif [ -f /etc/mageversion ]   ${mbargs:+--mbargs=\"${mbargs}\"} \
299   then   --args=\"root=${rootdevice} ${kernargs} \${debugargs}\" \
300   title="Magellan Linux $(< /etc/mageversion) (${version})"   --remove-kernel=\"TITLE=${title}\${debugtitle}\""
301   else   rungrubby --debug ${ARGS}
302   title="Magellan Linux (${version})"   rungrubby ${ARGS} ${makedefault}
  fi  
  ${grubby} --grub2 -c ${grub2Config} \  
  --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}"  
303   else   else
304   [[ -n ${verbose} ]] && echo "${grub2Config} does not exist, not running grubby for grub 2"   [[ -n ${verbose} ]] && echo "${grub2Config} does not exist, not running grubby for grub 2"
305   fi   fi
# Line 228  install() Line 307  install()
307   then   then
308   [[ -n ${verbose} ]] && echo "adding ${version} to ${grub2EfiConfig}"   [[ -n ${verbose} ]] && echo "adding ${version} to ${grub2EfiConfig}"
309    
310   if [[ -n ${banner} ]]   ARGS="--grub2 -c ${grub2EfiConfig} --efi \
311   then   --add-kernel=${kernelImage} ${DEVTREE} ${INITRD} \
312   title="${banner} (${version})"   --copy-default --title \"${title}\${debugtitle}\" \
313   elif [ -f /etc/mageversion ]   ${mbkernel:+--add-multiboot=\"${mbkernel}\"} \
314   then   ${mbargs:+--mbargs=\"${mbargs}\"} \
315   title="Magellan Linux $(< /etc/mageversion) (${version})"   --args=\"root=${rootdevice} ${kernargs} \${debugargs}\" \
316   else   --remove-kernel=\"TITLE=${title}\${debugtitle}\""
317   title="Magellan Linux (${version})"   rungrubby --debug ${ARGS}
318   fi   rungrubby ${ARGS} ${makedefault}
  ${grubby} --grub2 -c ${grub2EfiConfig} \  
  --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}"  
319   else   else
320   [[ -n ${verbose} ]] && echo "${grub2EfiConfig} does not exist, not running grubby for grub 2 with UEFI"   [[ -n ${verbose} ]] && echo "${grub2EfiConfig} does not exist, not running grubby for grub 2 with UEFI"
321   fi   fi
# Line 251  install() Line 324  install()
324   then   then
325   [[ -n ${verbose} ]] && echo "adding ${version} to ${liloConfig}"   [[ -n ${verbose} ]] && echo "adding ${version} to ${liloConfig}"
326    
327   ${grubby} --add-kernel=${bootPrefix}/${kernelName}-${version} ${INITRD} \   ARGS="--${liloFlag} --add-kernel=${kernelImage} ${INITRD} \
328   --copy-default ${makedefault} --title ${version} \   --copy-default --title \"${title}\${debugtitle}\" \
329   ${mbkernel:+--add-multiboot="${mbkernel}"} ${mbargs:+--mbargs="${mbargs}"} \   ${mbkernel:+--add-multiboot=\"${mbkernel}\"} \
330   --args="root=${rootdevice} ${kernargs}" --remove-kernel="TITLE=${version}" \   ${mbargs:+--mbargs=\"${mbargs}\"} \
331   --${liloFlag}   --args=\"root=${rootdevice} ${kernargs} \${debugargs}\" \
332     --remove-kernel=\"TITLE=${version}\""
333     rungrubby --debug ${ARGS}
334     rungrubby ${ARGS} ${makedefault}
335    
336   if [[ -n ${runLilo} ]]   if [[ -n ${runLilo} ]]
337   then   then
# Line 270  install() Line 346  install()
346   else   else
347   [[ -n ${verbose} ]] && echo "${liloConfig} does not exist, not running grubby"   [[ -n ${verbose} ]] && echo "${liloConfig} does not exist, not running grubby"
348   fi   fi
349    
350     if [[ -n ${cfgExtlinux} ]]
351     then
352     [[ -n ${verbose} ]] && echo "adding ${version} to ${extlinuxConfig}"
353    
354     ARGS="--extlinux -c ${extlinuxConfig} --add-kernel=${kernelImage} \
355     ${INITRD} --copy-default --title \"${title}\${debugtitle}\" \
356     ${mbkernel:+--add-multiboot=\"${mbkernel}\"} \
357     ${mbargs:+--mbargs=\"${mbargs}\"} \
358     --args=\"root=${rootdevice} ${kernargs} \${debugargs}\" \
359     --remove-kernel=\"TITLE=${title}\${debugtitle}\""
360     rungrubby --debug ${ARGS}
361     rungrubby ${ARGS} ${makedefault}
362     else
363     [[ -n ${verbose} ]] && echo "${extlinuxConfig} does not exist, not running grubby for extlinux"
364     fi
365  }  }
366    
367  remove()  remove()
# Line 278  remove() Line 370  remove()
370   if [ -d /proc/iSeries ]   if [ -d /proc/iSeries ]
371   then   then
372   [[ -n ${verbose} ]] && echo "On an iSeries, remove img file"   [[ -n ${verbose} ]] && echo "On an iSeries, remove img file"
373   rm -f ${bootPrefix}/${kernelName}-${version}.img 2>/dev/null   rm -f ${kernelImage}.img 2>/dev/null
374   return   return
375   fi   fi
376    
377   if [[ -n ${cfgGrub} ]]   if [[ -n ${cfgGrub} ]]
378   then   then
379   [[ -n ${verbose} ]] && echo "removing ${version} from ${grubConfig}"   [[ -n ${verbose} ]] && echo "removing ${version} from ${grubConfig}"
380   ${grubby} --grub --remove-kernel=${bootPrefix}/${kernelName}-${version}   ${grubby} --grub -c ${grubConfig} \
381     --remove-kernel=${kernelImage}
382   else   else
383   [[ -n ${verbose} ]] && echo "${grubConfig} does not exist, not running grubby for grub 0.97"   [[ -n ${verbose} ]] && echo "${grubConfig} does not exist, not running grubby for grub 0.97"
384   fi   fi
# Line 293  remove() Line 386  remove()
386   then   then
387   [[ -n ${verbose} ]] && echo "removing ${version} from ${grub2Config}"   [[ -n ${verbose} ]] && echo "removing ${version} from ${grub2Config}"
388   ${grubby} --grub2 -c ${grub2Config} \   ${grubby} --grub2 -c ${grub2Config} \
389   --remove-kernel=${bootPrefix}/${kernelName}-${version}   --remove-kernel=${kernelImage}
390   else   else
391   [[ -n ${verbose} ]] && echo "${grub2Config} does not exist, not running grubby for grub 2"   [[ -n ${verbose} ]] && echo "${grub2Config} does not exist, not running grubby for grub 2"
392   fi   fi
393   if [[ -n ${cfgGrub2Efi} ]]   if [[ -n ${cfgGrub2Efi} ]]
394   then   then
395   [[ -n ${verbose} ]] && echo "removing ${version} from ${grub2EfiConfig}"   [[ -n ${verbose} ]] && echo "removing ${version} from ${grub2EfiConfig}"
396   ${grubby} --grub2 -c ${grub2EfiConfig} \   ${grubby} --grub2 -c ${grub2EfiConfig} --efi \
397   --remove-kernel=${bootPrefix}/${kernelName}-${version}   --remove-kernel=${kernelImage}
398   else   else
399   [[ -n ${verbose} ]] && echo "${grub2EfiConfig} does not exist, not running grubby grub 2 with UEFI"   [[ -n ${verbose} ]] && echo "${grub2EfiConfig} does not exist, not running grubby grub 2 with UEFI"
400   fi   fi
# Line 309  remove() Line 402  remove()
402   if [[ -n ${cfgLilo} ]]   if [[ -n ${cfgLilo} ]]
403   then   then
404   [[ -n ${verbose} ]] && echo "removing ${version} from ${liloConfig}"   [[ -n ${verbose} ]] && echo "removing ${version} from ${liloConfig}"
405   ${grubby} --remove-kernel=${bootPrefix}/${kernelName}-${version} --${liloFlag}   ${grubby} --remove-kernel=${kernelImage} --${liloFlag}
406    
407   if [[ -n ${runLilo} ]]   if [[ -n ${runLilo} ]]
408   then   then
# Line 333  remove() Line 426  remove()
426   then   then
427   tmpKList=$(mktemp ${ubootDir}/${ubootKList}.XXXX)   tmpKList=$(mktemp ${ubootDir}/${ubootKList}.XXXX)
428   curversion=$(tail -n1 ${ubootDir}/${ubootKList})   curversion=$(tail -n1 ${ubootDir}/${ubootKList})
429   sed "/${version}/d" ${ubootDir}/${ubootKList} > ${tmpKList}   sed "/$version$/d" ${ubootDir}/${ubootKList} > ${tmpKList}
430   newversion=$(tail -n1 ${tmpKList})   newversion=$(tail -n1 ${tmpKList})
431   if [ -f ${ubootDir}/uImage-${newversion} ] && [ -f ${ubootDir}/uInitrd-${newversion} ]   if [ -f ${ubootDir}/uImage-${newversion} ] && [ -f ${ubootDir}/uInitrd-${newversion} ]
432   then   then
# Line 368  remove() Line 461  remove()
461   fi   fi
462    
463   mv ${tmpKList} ${ubootDir}/${ubootKList}   mv ${tmpKList} ${ubootDir}/${ubootKList}
464     [ -x /sbin/a-b-c ] && /sbin/a-b-c
465   else   else
466   [[ -n ${verbose} ]] && echo "uImage ${newversion} does not exist!"   [[ -n ${verbose} ]] && echo "uImage ${newversion} does not exist!"
467   [ -f ${tmpKList} ] && rm -f ${tmpKList}   [ -f ${tmpKList} ] && rm -f ${tmpKList}
468   fi   fi
469   else   else
470   [[ -n ${verbose} ]] && echo "No previous kernel version. uBoot images not removed!"   [[ -n ${verbose} ]] && echo "No previous kernel version.  U-Boot images not removed!"
471   fi   fi
472   else   else
473   [[ -n ${verbose} ]] && echo "${ubootScript} does not exist, not modifying ${ubootDir}"   [[ -n ${verbose} ]] && echo "${ubootScript} does not exist, not modifying ${ubootDir}"
474   fi   fi
475    
476     if [[ -n ${cfgExtlinux} ]]
477     then
478     [[ -n ${verbose} ]] && echo "removing ${version} from ${extlinuxConfig}"
479     ${grubby} --extlinux -c ${extlinuxConfig} \
480     --remove-kernel=${kernelImage}
481     else
482     [[ -n ${verbose} ]] && echo "${extlinuxConfig} does not exist, not running grubby for extlinux"
483     fi
484  }  }
485    
486  update()  update()
487  {  {
488   if [ ! -f ${bootPrefix}/${kernelName}-${version} ]   if [ ! -f ${kernelImage} ]
489   then   then
490   [[ -n ${verbose} ]] && echo "kernel for ${version} does not exist, not running grubby"   [[ -n ${verbose} ]] && echo "kernel for ${version} does not exist, not running grubby"
491   return   return
492   fi   fi
493    
494     set_title
495    
496   INITRD=""   INITRD=""
497   if [ -f ${initrdfile} ]   if [ -f ${initrdfile} ]
498   then   then
# Line 403  update() Line 508  update()
508   if [[ -n ${cfgGrub} ]]   if [[ -n ${cfgGrub} ]]
509   then   then
510   [[ -n ${verbose} ]] && echo "updating ${version} from ${grubConfig}"   [[ -n ${verbose} ]] && echo "updating ${version} from ${grubConfig}"
511   ${grubby} --update-kernel=${bootPrefix}/${kernelName}-${version} \   ARGS="--grub -c ${grubConfig} --update-kernel=${kernelImage} ${INITRD} \
512   ${INITRD} \   ${kernargs:+--args=\"${kernargs}\"} \
513   ${kernargs:+--args="${kernargs}"} \   ${removeargs:+--remove-args=\"${removeargs}\"} \
514   ${removeargs:+--remove-args="${removeargs}"}   ${mbkernel:+--add-multiboot=\"${mbkernel}\"} \
515     --title=\"${title}\${debugtitle}\""
516     rungrubby --debug ${ARGS}
517     rungrubby ${ARGS}
518   else   else
519   [[ -n ${verbose} ]] && echo "${grubConfig} does not exist, not running grubby"   [[ -n ${verbose} ]] && echo "${grubConfig} does not exist, not running grubby"
520   fi   fi
# Line 414  update() Line 522  update()
522   if [[ -n ${cfgGrub2} ]]   if [[ -n ${cfgGrub2} ]]
523   then   then
524   [[ -n ${verbose} ]] && echo "updating ${version} from ${grub2Config}"   [[ -n ${verbose} ]] && echo "updating ${version} from ${grub2Config}"
525   ${grubby} --grub2 -c ${grub2Config} \   ARGS="--grub2 -c ${grub2Config} --update-kernel=${kernelImage} ${INITRD} \
526   --update-kernel=${bootPrefix}/${kernelName}-${version} \   ${kernargs:+--args=\"${kernargs}\"} \
527   ${INITRD} \   ${removeargs:+--remove-args=\"${removeargs}\"} \
528   ${kernargs:+--args="${kernargs}"} \   --title=\"${title}\${debugtitle}\""
529   ${removeargs:+--remove-args="${removeargs}"}   rungrubby --debug ${ARGS}
530     rungrubby ${ARGS}
531   else   else
532   [[ -n ${verbose} ]] && echo "${grub2Config} does not exist, not running grubby"   [[ -n ${verbose} ]] && echo "${grub2Config} does not exist, not running grubby"
533   fi   fi
# Line 426  update() Line 535  update()
535   if [[ -n ${cfgGrub2Efi} ]]   if [[ -n ${cfgGrub2Efi} ]]
536   then   then
537   [[ -n ${verbose} ]] && echo "updating ${version} from ${grub2EfiConfig}"   [[ -n ${verbose} ]] && echo "updating ${version} from ${grub2EfiConfig}"
538   ${grubby} --grub2 -c ${grub2EfiConfig} \   ARGS="--grub2 -c ${grub2EfiConfig} --efi --update-kernel=${kernelImage} \
539   --update-kernel=${bootPrefix}/${kernelName}-${version} \   ${INITRD} ${kernargs:+--args=\"${kernargs}\"} \
540   ${INITRD} \   ${removeargs:+--remove-args=\"${removeargs}\"} \
541   ${kernargs:+--args="${kernargs}"} \   --title=\"${title}\${debugtitle}\""
542   ${removeargs:+--remove-args="${removeargs}"}   rungrubby --debug ${ARGS}
543     rungrubby ${ARGS}
544   else   else
545   [[ -n ${verbose} ]] && echo "${grub2EfiConfig} does not exist, not running grubby"   [[ -n ${verbose} ]] && echo "${grub2EfiConfig} does not exist, not running grubby"
546   fi   fi
# Line 438  update() Line 548  update()
548   if [[ -n ${cfgLilo} ]]   if [[ -n ${cfgLilo} ]]
549   then   then
550   [[ -n ${verbose} ]] && echo "updating ${version} from ${liloConfig}"   [[ -n ${verbose} ]] && echo "updating ${version} from ${liloConfig}"
551   ${grubby} --update-kernel=${bootPrefix}/${kernelName}-${version} \   ARGS="--${liloFlag} --update-kernel=${kernelImage} ${INITRD} \
552   ${INITRD} \   ${kernargs:+--args=\"${kernargs}\"} \
553   ${kernargs:+--args="${kernargs}"} \   ${removeargs:+--remove-args=\"${removeargs}\"} \
554   ${removeargs:+--remove-args="${removeargs}"} \   --title=\"${title}\${debugtitle}\""
555   --${liloFlag}   rungrubby --debug ${ARGS}
556     rungrubby ${ARGS}
557    
558   if [[ -n ${runLilo} ]]   if [[ -n ${runLilo} ]]
559   then   then
# Line 463  update() Line 574  update()
574   [[ -n ${verbose} ]] && echo "adding $version to ${ubootDir}..."   [[ -n ${verbose} ]] && echo "adding $version to ${ubootDir}..."
575    
576   [[ -n ${verbose} ]] && echo "creating uImage-${version}"   [[ -n ${verbose} ]] && echo "creating uImage-${version}"
577   mkimage -A arm -O linux -T kernel -C none -a 0x80008000 -e 0x80008000 \   mkimage -A arm -O linux -T kernel -C none -a ${ubootAddress} \
578   -n ${version} -d ${bootPrefix}/${kernelName}-${version} ${ubootDir}/uImage-${version}   -e ${ubootAddress} -n ${version} \
579     -d ${kernelImage} ${ubootDir}/uImage-${version}
580    
581   [[ -n ${verbose} ]] && echo "creating uInitrd-${version}"   [[ -n ${verbose} ]] && echo "creating uInitrd-${version}"
582   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 483  update() Line 595  update()
595   [[ -n ${verbose} ]] && echo "copy uInitrd-${version} error, kernel not installed!" && exit   [[ -n ${verbose} ]] && echo "copy uInitrd-${version} error, kernel not installed!" && exit
596   fi   fi
597   echo ${version} >> ${ubootDir}/${ubootKList}   echo ${version} >> ${ubootDir}/${ubootKList}
598     [ -x /sbin/a-b-c ] && /sbin/a-b-c
599   else   else
600   [[ -n ${verbose} ]] && echo "cannot make ${version} the default"   [[ -n ${verbose} ]] && echo "cannot make ${version} the default"
601   fi   fi
602   else   else
603   [[ -n ${verbose} ]] && echo "${ubootScript} does not exist, not setting up ${ubootDir}"   [[ -n ${verbose} ]] && echo "${ubootScript} does not exist, not setting up ${ubootDir}"
604   fi   fi
605    
606     if [[ -n ${cfgExtlinux} ]]
607     then
608     [[ -n ${verbose} ]] && echo "updating ${version} from ${extlinuxConfig}"
609     ARGS="--extlinux -c ${extlinuxConfig} --update-kernel=${kernelImage} \
610     ${INITRD} ${kernargs:+--args=\"${kernargs}\"} \
611     ${removeargs:+--remove-args=\"${removeargs}\"} \
612     --title=\"${title}\${debugtitle}\""
613     rungrubby --debug ${ARGS}
614     rungrubby ${ARGS}
615     else
616     [[ -n ${verbose} ]] && echo "${extlinuxConfig} does not exist, not running grubby"
617     fi
618  }  }
619    
620  mkinitrd()  makeinitrd()
621  {  {
622   if [[ -n ${dracut} ]]   if [[ -n ${dracut} ]]
623   then   then
624   tool="/sbin/dracut ${dracuthostonly} -f ${initrdfile} ${version}"   tool="dracut ${dracuthostonly} -f ${initrdfile} ${version}"
625   else   else
626   tool="/sbin/mkinitrd --allow-missing -f ${initrdfile} ${version}"   tool="mkinitrd --allow-missing -f ${initrdfile} ${version}"
627   fi   fi
628   [[ -n ${verbose} ]] && echo "creating initrd ${initrdfile} using ${version}"   [[ -n ${verbose} ]] && echo "creating initrd ${initrdfile} using ${version}"
629   ${tool}   ${tool}
# Line 524  doDepmod() Line 650  doDepmod()
650  doRmmoddep()  doRmmoddep()
651  {  {
652   [[ -n ${verbose} ]] && echo "removing modules.dep info for ${version}"   [[ -n ${verbose} ]] && echo "removing modules.dep info for ${version}"
653   [ -d /lib/modules/${version} ] && rm -f /lib/modules/${version}/modules.*   if [ -d /lib/modules/${version} ]
654     then
655     rm -f /lib/modules/${version}/modules.*.bin \
656     /lib/modules/${version}/modules.{alias,dep,devname,symbols,softdep}
657     fi
658  }  }
659    
660    # kernel image for 2.4 is kernel
661    if [[ ${ARCH} = ppc64 ]] || [[ ${ARCH} = ppc ]]
662    then
663     if [[ ${kernelmajor} = 2.4 ]]
664     then
665     kernelName=kernel
666     fi
667    fi
668    
669  while [ $# -gt 0 ]  while [ $# -gt 0 ]
670  do  do
# Line 539  do Line 677  do
677   initrd="remove"   initrd="remove"
678   ;;   ;;
679    
680     --devtree*)
681     if [[ $1 == --devtree\=* ]]
682     then
683     devtreefile="${1#--devtreefile=}"
684     else
685     devtreefile="$2"
686     shift
687     fi
688     ;;
689    
690   --dracut)   --dracut)
691   dracut=--dracut   dracut=--dracut
692   ;;   ;;
# Line 548  do Line 696  do
696   ;;   ;;
697    
698   --initrdfile*)   --initrdfile*)
699   if echo $1 | grep '=' >/dev/null   if [[ $1 == --initrdfile\=* ]]
700   then   then
701   initrdfile=$(echo $1 | sed 's/^--initrdfile=//')   initrdfile=${1#--initrdfile=}
702   else   else
703   initrdfile=$2   initrdfile=$2
704   shift   shift
# Line 558  do Line 706  do
706   ;;   ;;
707    
708   --kernel-args*)   --kernel-args*)
709   if echo $1 | grep '=' >/dev/null   if [[ $1 == --kernel-args\=* ]]
710   then   then
711   kernargs=$(echo $1 | sed 's/^--kernel-args=//')   kernargs=${1#--kernel-args=}
712   else   else
713   kernargs=$2   kernargs=$2
714   shift   shift
# Line 568  do Line 716  do
716   ;;   ;;
717    
718   --remove-args*)   --remove-args*)
719   if echo $1 | grep '=' >/dev/null   if [[ $1 == --remove-args\=* ]]
720   then   then
721   removeargs=$(echo $1 | sed 's/^--remove-args=//')   removeargs=${1#--remove-args=}
722   else   else
723   removeargs=$2   removeargs=$2
724   shift   shift
# Line 578  do Line 726  do
726   ;;   ;;
727    
728   --banner*)   --banner*)
729   if echo $1 | grep '=' >/dev/null   if [[ $1 == --banner\=* ]]
730   then   then
731   banner=$(echo $1 | sed 's/^--banner=//')   banner=${1#--banner=}
732   else   else
733   banner=$2   banner=$2
734   shift   shift
# Line 588  do Line 736  do
736   ;;   ;;
737    
738   --multiboot*)   --multiboot*)
739   if echo $1 |grep '=' >/dev/null   if [[ $1 == --multiboot\=* ]]
740   then   then
741   mbkernel=$(echo $1 | sed 's/^--multiboot=//')   mbkernel=${1#--multiboot=}
742   else   else
743   # can't really support having an optional second arg here   # can't really support having an optional second arg here
744   # sorry!   # sorry!
# Line 599  do Line 747  do
747   ;;   ;;
748    
749   --mbargs*)   --mbargs*)
750   if echo $1 |grep '=' >/dev/null   if [[ $1 == --mbargs\=* ]]
751   then   then
752   mbargs=$(echo $1 | sed 's/^--mbargs=//')   mbargs=${1#--mbargs=}
753   else   else
754   mbargs="$2"   mbargs="$2"
755   shift   shift
# Line 620  do Line 768  do
768   makedefault="--make-default"   makedefault="--make-default"
769   ;;   ;;
770    
771   --package)   --package*)
772   if echo $1 | grep '=' >/dev/null   if [[ $1 == --package\=* ]]
773   then   then
774   package=$(echo $1 | sed 's/^--package=//')   package=${1#--package=}
775   else   else
776   package=$2   package=$2
777   shift   shift
# Line 638  do Line 786  do
786   addplymouthinitrd=--add-plymouth-initrd   addplymouthinitrd=--add-plymouth-initrd
787   ;;   ;;
788    
789     --kernel-image*)
790     if [[ $1 == --kernel-image\=* ]]
791     then
792     kernelImage=${1#--kernel-image=}
793     else
794     kernelImage="$2"
795     shift
796     fi
797     if ! [[ -f ${kernelImage} ]]
798     then
799     echo "Can't find kernel image '${kernelImage}'" >&2
800     usage
801     exit 1
802     fi
803     ;;
804    
805     --kernel-name*)
806     if [[ $1 == --kernel-name\=* ]]
807     then
808     kernelName=${1#--kernel-name=}
809     else
810     kernelName="$2"
811     shift
812     fi
813     ;;
814    
815   -v)   -v)
816   verbose=-v   verbose=-v
817   ;;   ;;
# Line 676  fi Line 850  fi
850    
851  kernelmajor=$(echo ${kernel} | cut -d . -f 1,2)  kernelmajor=$(echo ${kernel} | cut -d . -f 1,2)
852    
853  # 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  
854    
855  # 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
856  if [[ -z ${initrdfile} ]]  if [[ -z ${initrdfile} ]]
# Line 706  fi Line 873  fi
873  # add dracut i18n, keyboard and plymouth kernel args if requested  # add dracut i18n, keyboard and plymouth kernel args if requested
874  if [[ -n ${dracut} ]] || [[ -n ${adddracutargs} ]]  if [[ -n ${dracut} ]] || [[ -n ${adddracutargs} ]]
875  then  then
876   [ -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} ]]  
877   then   then
878   kernargs="${kernargs} KEYTABLE=${KEYMAP}"   . /etc/vconsole.conf
879    
880     for i in SYSFONT SYSFONTACM UNIMAP KEYTABLE
881     do
882     val=$(eval echo \$$i)
883     [[ -n ${val} ]] && kernargs="${kernargs} ${i}=${val}"
884     done
885     else
886     if [ -r /etc/conf.d/consolefont ]
887     then
888     . /etc/conf.d/consolefont
889    
890     if [[ -n ${CONSOLEFONT} ]]
891     then
892     kernargs="${kernargs} SYSFONT=${CONSOLEFONT}"
893     fi
894     fi
895    
896     if  [ -r /etc/conf.d/keymap ]
897     then
898     . /etc/conf.d/keymap
899    
900     if [[ -n ${KEYMAP} ]]
901     then
902     kernargs="${kernargs} KEYTABLE=${KEYMAP}"
903     fi
904     fi
905   fi   fi
906    
907   if [[ -n ${CONSOLEFONT} ]]   if [ -r /etc/locale.conf ]
908   then   then
909   kernargs="${kernargs} SYSFONT=${CONSOLEFONT}"   . /etc/locale.conf
910    
911     if [[ -n ${LANG} ]]
912     then
913     kernargs="${kernargs} LANG=${LANG}"
914     fi
915   fi   fi
916  fi  fi
917    
918  # 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
919  if [[ ${mode} = --install ]] && [[ ${UPDATEDEFAULT} = yes ]] && [[ -n ${package} ]] &&  if [[ ${mode} = --install ]] && [[ ${UPDATEDEFAULT} = yes ]] && [[ -n ${package} ]] && [[ -n ${DEFAULTKERNEL} ]]
  [[ -n ${DEFAULTKERNEL} ]] && [[ ${package} = ${DEFAULTKERNEL} ]]  
920  then  then
921   makedefault="--make-default"   if [[ ${package} = ${DEFAULTKERNEL} ]] || [[ ${package}-core = ${DEFAULTKERNEL} ]]
922   [[ -n ${verbose} ]] && echo "making it the default based on config"   then
923     makedefault="--make-default"
924     [[ -n ${verbose} ]] && echo "making it the default based on config"
925     fi
926  fi  fi
927    
928  if [[ ${moddep} = make ]]  if [[ ${moddep} = make ]]
# Line 738  fi Line 935  fi
935    
936  if [[ ${initrd} = make ]]  if [[ ${initrd} = make ]]
937  then  then
938   mkinitrd   makeinitrd
939  elif [[ ${initrd} = remove ]]  elif [[ ${initrd} = remove ]]
940  then  then
941   rminitrd   rminitrd
# Line 754  fi Line 951  fi
951  [[ -n ${grub2Config} ]] && [ -f ${grub2Config} ] && cfgGrub2=1  [[ -n ${grub2Config} ]] && [ -f ${grub2Config} ] && cfgGrub2=1
952  [[ -n ${grub2EfiConfig} ]] && [ -f ${grub2EfiConfig} ] && cfgGrub2Efi=1  [[ -n ${grub2EfiConfig} ]] && [ -f ${grub2EfiConfig} ] && cfgGrub2Efi=1
953  [[ -n ${liloConfig} ]] && [ -f ${liloConfig} ] && cfgLilo=1  [[ -n ${liloConfig} ]] && [ -f ${liloConfig} ] && cfgLilo=1
954    [[ -n ${extlinuxConfig} ]] && [ -f ${extlinuxConfig} ] && cfgExtlinux=1
955    
956  # 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
957  # 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.
958  if [[ -n ${ubootDir} ]]  if [[ -n ${ubootDir} ]]
959  then  then
960   mountEntry=$(mount | grep ${ubootDir})   if [ -f ${ubootScript} ]
  if [[ -z ${mountEntry} ]]  
961   then   then
962   mount ${ubootDevice} ${ubootDir}   cfguBoot=1
963   mounted=1   else
964     mountEntry=$(mount | grep ${ubootDir})
965     if [[ -z ${mountEntry} ]]
966     then
967     mount ${ubootDevice} ${ubootDir}
968     mounted=1
969     fi
970     [ -f ${ubootScript} ] && cfguBoot=1
971     fi
972    fi
973    
974    # if we're using U-Boot, check if the default load address should change
975    if [[ -n ${cfguBoot} ]] && [[ -z ${UBOOT_IMGADDR} ]]
976    then
977     [[ ${version}  =~ .([^.]*)$ ]]
978     platform=${BASH_REMATCH[1]}
979     # A few platforms use an alternate kernel load address
980     if [[ ${platform} = omap ]]
981     then
982     ubootAddress=0x80008000
983     elif [[ ${platform} = imx ]]
984     then
985     ubootAddress=0x90008000
986   fi   fi
  [ -f ${ubootScript} ] && cfguBoot=1  
987  fi  fi
988    
989  # 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 786  then Line 1004  then
1004   update   update
1005  fi  fi
1006    
1007    # if we mounted the U-Boot directory, unmount it.
1008    [[ -n ${mounted} ]] && umount ${ubootDir}
1009    
1010  exit 0  exit 0

Legend:
Removed from v.1702  
changed lines
  Added in v.2965