Magellan Linux

Diff of /trunk/grubby/new-kernel-pkg

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

revision 2681 by niro, Wed Jul 16 09:48:55 2014 UTC revision 2972 by niro, Thu Jun 30 10:17:00 2016 UTC
# Line 79  grubConfig="" Line 79  grubConfig=""
79  grub2Config=""  grub2Config=""
80  grub2EfiConfig=""  grub2EfiConfig=""
81  extlinuxConfig=""  extlinuxConfig=""
82    ubootScript="/boot/boot.scr"
83    
84  ARCH=$(uname -m)  ARCH=$(uname -m)
85    
# Line 145  initrd="" Line 146  initrd=""
146  dracut=""  dracut=""
147  dracuthostonly=""  dracuthostonly=""
148  initrdfile=""  initrdfile=""
149    devtreefile=""
150  moddep=""  moddep=""
151  verbose=""  verbose=""
152  makedefault=""  makedefault=""
# Line 153  mbkernel="${HYPERVISOR}" Line 155  mbkernel="${HYPERVISOR}"
155  mbargs="${HYPERVISOR_ARGS}"  mbargs="${HYPERVISOR_ARGS}"
156  adddracutargs=""  adddracutargs=""
157  addplymouthinitrd=""  addplymouthinitrd=""
158    DEBUGARG="systemd.debug"
159    
160  usage()  usage()
161  {  {
# Line 162  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    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)
# Line 189  install() Line 235  install()
235   fi   fi
236   fi   fi
237    
238     DEVTREE=""
239     if [[ -n ${devtreefile} ]] && [ -f ${devtreefile} ]
240     then
241     [[ -n ${verbose} ]] && echo "found ${devtreefile} and using it with grubby"
242     DEVTREE="--devtree ${devtreefile}"
243     fi
244    
245     DEVTREEDIR=""
246     if [[ -n ${devtreedir} ]] && [ -d ${devtreedir} ]
247     then
248     [ -n ${verbose} ] && echo "found ${devtreedir} and using it with grubby"
249     DEVTREEDIR="--devtreedir ${devtreedir}"
250     fi
251    
252   # 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?
253   if [ -d /proc/iSeries ]   if [ -d /proc/iSeries ]
254   then   then
# Line 218  install() Line 278  install()
278   cfgLilo=""   cfgLilo=""
279   fi   fi
280    
281   if [[ -n ${banner} ]]   set_title
  then  
  title="${banner} [ ${version} ]"  
  elif [ -f /etc/os-release ]  
  then  
  title="$(read_os_release name) $(read_os_release version_id) [ ${version} ]"  
  elif [ -f /etc/mageversion ]  
  then  
  title="Magellan Linux $(< /etc/mageversion) [ ${version} ]"  
  else  
  title="Magellan Linux [ ${version} ]"  
  fi  
282    
283   if [[ -n ${cfgGrub} ]]   if [[ -n ${cfgGrub} ]]
284   then   then
285   [[ -n ${verbose} ]] && echo "adding ${version} to ${grubConfig}"   [[ -n ${verbose} ]] && echo "adding ${version} to ${grubConfig}"
286    
287   ${grubby} --grub -c ${grubConfig} \   ARGS="--grub -c ${grubConfig} --add-kernel=${kernelImage} ${INITRD} \
288   --add-kernel=${kernelImage} \   ${mbkernel:+--add-multiboot=\"${mbkernel}\"} \
289   ${INITRD} --copy-default ${makedefault} --title "${title}" \   ${mbargs:+--mbargs=\"${mbargs}\"} \
290   ${mbkernel:+--add-multiboot="${mbkernel}"} ${mbargs:+--mbargs="${mbargs}"} \   --title=\"${title}\${debugtitle}\" --copy-default \
291   --args="root=${rootdevice} ${kernargs}" --remove-kernel="TITLE=${title}"   --args=\"root=${rootdevice} ${kernargs} \${debugargs}\" \
292     --remove-kernel=\"TITLE=${title}\${debugtitle}\""
293     rungrubby --debug ${ARGS}
294     rungrubby ${ARGS} ${makedefault}
295   else   else
296   [[ -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"
297   fi   fi
# Line 247  install() Line 299  install()
299   then   then
300   [[ -n ${verbose} ]] && echo "adding ${version} to ${grub2Config}"   [[ -n ${verbose} ]] && echo "adding ${version} to ${grub2Config}"
301    
302   ${grubby} --grub2 -c ${grub2Config} \   ARGS="--grub2 -c ${grub2Config} --add-kernel=${kernelImage} ${INITRD} \
303   --add-kernel=${kernelImage} \   --copy-default --title \"${title}\${debugtitle}\" \
304   ${INITRD} --copy-default ${makedefault} --title "${title}" \   ${mbkernel:+--add-multiboot=\"${mbkernel}\"} \
305   ${mbkernel:+--add-multiboot="${mbkernel}"} \   ${mbargs:+--mbargs=\"${mbargs}\"} \
306   ${mbargs:+--mbargs="${mbargs}"} \   --args=\"root=${rootdevice} ${kernargs} \${debugargs}\" \
307   --args="root=${rootdevice} ${kernargs}" --remove-kernel="TITLE=${title}"   --remove-kernel=\"TITLE=${title}\${debugtitle}\""
308     rungrubby --debug ${ARGS}
309     rungrubby ${ARGS} ${makedefault}
310   else   else
311   [[ -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"
312   fi   fi
# Line 260  install() Line 314  install()
314   then   then
315   [[ -n ${verbose} ]] && echo "adding ${version} to ${grub2EfiConfig}"   [[ -n ${verbose} ]] && echo "adding ${version} to ${grub2EfiConfig}"
316    
317   ${grubby} --grub2 -c ${grub2EfiConfig} --efi \   ARGS="--grub2 -c ${grub2EfiConfig} --efi \
318   --add-kernel=${kernelImage} \   --add-kernel=${kernelImage} ${DEVTREE} ${INITRD} \
319   ${INITRD} --copy-default ${makedefault} --title "${title}" \   --copy-default --title \"${title}\${debugtitle}\" \
320   ${mbkernel:+--add-multiboot="${mbkernel}"} \   ${mbkernel:+--add-multiboot=\"${mbkernel}\"} \
321   ${mbargs:+--mbargs="${mbargs}"} \   ${mbargs:+--mbargs=\"${mbargs}\"} \
322   --args="root=${rootdevice} ${kernargs}" --remove-kernel="TITLE=${title}"   --args=\"root=${rootdevice} ${kernargs} \${debugargs}\" \
323     --remove-kernel=\"TITLE=${title}\${debugtitle}\""
324     rungrubby --debug ${ARGS}
325     rungrubby ${ARGS} ${makedefault}
326   else   else
327   [[ -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"
328   fi   fi
# Line 274  install() Line 331  install()
331   then   then
332   [[ -n ${verbose} ]] && echo "adding ${version} to ${liloConfig}"   [[ -n ${verbose} ]] && echo "adding ${version} to ${liloConfig}"
333    
334   ${grubby} --add-kernel=${kernelImage} ${INITRD} \   ARGS="--${liloFlag} --add-kernel=${kernelImage} ${INITRD} \
335   --copy-default ${makedefault} --title ${version} \   --copy-default --title \"${title}\${debugtitle}\" \
336   ${mbkernel:+--add-multiboot="${mbkernel}"} ${mbargs:+--mbargs="${mbargs}"} \   ${mbkernel:+--add-multiboot=\"${mbkernel}\"} \
337   --args="root=${rootdevice} ${kernargs}" --remove-kernel="TITLE=${version}" \   ${mbargs:+--mbargs=\"${mbargs}\"} \
338   --${liloFlag}   --args=\"root=${rootdevice} ${kernargs} \${debugargs}\" \
339     --remove-kernel=\"TITLE=${version}\""
340     rungrubby --debug ${ARGS}
341     rungrubby ${ARGS} ${makedefault}
342    
343   if [[ -n ${runLilo} ]]   if [[ -n ${runLilo} ]]
344   then   then
# Line 298  install() Line 358  install()
358   then   then
359   [[ -n ${verbose} ]] && echo "adding ${version} to ${extlinuxConfig}"   [[ -n ${verbose} ]] && echo "adding ${version} to ${extlinuxConfig}"
360    
361   ${grubby} --extlinux -c ${extlinuxConfig} \   ARGS="--extlinux -c ${extlinuxConfig} --add-kernel=${kernelImage} \
362   --add-kernel=${kernelImage} \   ${DEVTREEDIR} ${DEVTREE} \
363   ${INITRD} --copy-default ${makedefault} --title "${title}" \   ${INITRD} --copy-default --title \"${title}\${debugtitle}\" \
364   ${mbkernel:+--add-multiboot="${mbkernel}"} ${mbargs:+--mbargs="${mbargs}"} \   ${mbkernel:+--add-multiboot=\"${mbkernel}\"} \
365   --args="root=${rootdevice} ${kernargs}" --remove-kernel="TITLE=${title}"   ${mbargs:+--mbargs=\"${mbargs}\"} \
366     --args=\"root=${rootdevice} ${kernargs} \${debugargs}\" \
367     --remove-kernel=\"TITLE=${title}\${debugtitle}\""
368     rungrubby --debug ${ARGS}
369     rungrubby ${ARGS} ${makedefault}
370   else   else
371   [[ -n ${verbose} ]] && echo "${extlinuxConfig} does not exist, not running grubby for extlinux"   [[ -n ${verbose} ]] && echo "${extlinuxConfig} does not exist, not running grubby for extlinux"
372   fi   fi
# Line 435  update() Line 499  update()
499   return   return
500   fi   fi
501    
502     set_title
503    
504   INITRD=""   INITRD=""
505   if [ -f ${initrdfile} ]   if [ -f ${initrdfile} ]
506   then   then
# Line 447  update() Line 513  update()
513   fi   fi
514   fi   fi
515    
516     DEVTREE=""
517     if [[ -n ${devtreefile} ]] && [ -f ${devtreefile} ]
518     then
519     [[ -n ${verbose} ]] && echo "found ${devtreefile} and using it with grubby"
520     DEVTREE="--devtree ${devtreefile}"
521     fi
522    
523     DEVTREEDIR=""
524     if [[ -n ${devtreedir} ]] && [ -d ${devtreedir} ]
525     then
526     [[ -n ${verbose} ]] && echo "found ${devtreedir} and using it with grubby"
527     DEVTREEDIR="--devtreedir ${devtreedir}"
528     fi
529    
530   if [[ -n ${cfgGrub} ]]   if [[ -n ${cfgGrub} ]]
531   then   then
532   [[ -n ${verbose} ]] && echo "updating ${version} from ${grubConfig}"   [[ -n ${verbose} ]] && echo "updating ${version} from ${grubConfig}"
533   ${grubby} --grub -c ${grubConfig} \   ARGS="--grub -c ${grubConfig} --update-kernel=${kernelImage} ${INITRD} \
534   --update-kernel=${kernelImage} \   ${kernargs:+--args=\"${kernargs}\"} \
535   ${INITRD} \   ${removeargs:+--remove-args=\"${removeargs}\"} \
536   ${kernargs:+--args="${kernargs}"} \   ${mbkernel:+--add-multiboot=\"${mbkernel}\"} \
537   ${removeargs:+--remove-args="${removeargs}"} \   --title=\"${title}\${debugtitle}\""
538   ${mbkernel:+--add-multiboot="${mbkernel}"}   rungrubby --debug ${ARGS}
539     rungrubby ${ARGS}
540   else   else
541   [[ -n ${verbose} ]] && echo "${grubConfig} does not exist, not running grubby"   [[ -n ${verbose} ]] && echo "${grubConfig} does not exist, not running grubby"
542   fi   fi
# Line 463  update() Line 544  update()
544   if [[ -n ${cfgGrub2} ]]   if [[ -n ${cfgGrub2} ]]
545   then   then
546   [[ -n ${verbose} ]] && echo "updating ${version} from ${grub2Config}"   [[ -n ${verbose} ]] && echo "updating ${version} from ${grub2Config}"
547   ${grubby} --grub2 -c ${grub2Config} \   ARGS="--grub2 -c ${grub2Config} --update-kernel=${kernelImage} ${INITRD} \
548   --update-kernel=${kernelImage} \   ${kernargs:+--args=\"${kernargs}\"} \
549   ${INITRD} \   ${removeargs:+--remove-args=\"${removeargs}\"} \
550   ${kernargs:+--args="${kernargs}"} \   --title=\"${title}\${debugtitle}\""
551   ${removeargs:+--remove-args="${removeargs}"}   rungrubby --debug ${ARGS}
552     rungrubby ${ARGS}
553   else   else
554   [[ -n ${verbose} ]] && echo "${grub2Config} does not exist, not running grubby"   [[ -n ${verbose} ]] && echo "${grub2Config} does not exist, not running grubby"
555   fi   fi
# Line 475  update() Line 557  update()
557   if [[ -n ${cfgGrub2Efi} ]]   if [[ -n ${cfgGrub2Efi} ]]
558   then   then
559   [[ -n ${verbose} ]] && echo "updating ${version} from ${grub2EfiConfig}"   [[ -n ${verbose} ]] && echo "updating ${version} from ${grub2EfiConfig}"
560   ${grubby} --grub2 -c ${grub2EfiConfig} --efi \   ARGS="--grub2 -c ${grub2EfiConfig} --efi --update-kernel=${kernelImage} \
561   --update-kernel=${kernelImage} \   ${INITRD} ${kernargs:+--args=\"${kernargs}\"} \
562   ${INITRD} \   ${removeargs:+--remove-args=\"${removeargs}\"} \
563   ${kernargs:+--args="${kernargs}"} \   --title=\"${title}\${debugtitle}\""
564   ${removeargs:+--remove-args="${removeargs}"}   rungrubby --debug ${ARGS}
565     rungrubby ${ARGS}
566   else   else
567   [[ -n ${verbose} ]] && echo "${grub2EfiConfig} does not exist, not running grubby"   [[ -n ${verbose} ]] && echo "${grub2EfiConfig} does not exist, not running grubby"
568   fi   fi
# Line 487  update() Line 570  update()
570   if [[ -n ${cfgLilo} ]]   if [[ -n ${cfgLilo} ]]
571   then   then
572   [[ -n ${verbose} ]] && echo "updating ${version} from ${liloConfig}"   [[ -n ${verbose} ]] && echo "updating ${version} from ${liloConfig}"
573   ${grubby} --update-kernel=${kernelImage} \   ARGS="--${liloFlag} --update-kernel=${kernelImage} ${INITRD} \
574   ${INITRD} \   ${kernargs:+--args=\"${kernargs}\"} \
575   ${kernargs:+--args="${kernargs}"} \   ${removeargs:+--remove-args=\"${removeargs}\"} \
576   ${removeargs:+--remove-args="${removeargs}"} \   --title=\"${title}\${debugtitle}\""
577   --${liloFlag}   rungrubby --debug ${ARGS}
578     rungrubby ${ARGS}
579    
580   if [[ -n ${runLilo} ]]   if [[ -n ${runLilo} ]]
581   then   then
# Line 544  update() Line 628  update()
628   if [[ -n ${cfgExtlinux} ]]   if [[ -n ${cfgExtlinux} ]]
629   then   then
630   [[ -n ${verbose} ]] && echo "updating ${version} from ${extlinuxConfig}"   [[ -n ${verbose} ]] && echo "updating ${version} from ${extlinuxConfig}"
631   ${grubby} --extlinux -c ${extlinuxConfig} \   ARGS="--extlinux -c ${extlinuxConfig} --update-kernel=${kernelImage} \
632   --update-kernel=${kernelImage} \   ${DEVTREE} ${DEVTREEDIR} ${INITRD} ${kernargs:+--args=\"${kernargs}\"} \
633   ${INITRD} \   ${removeargs:+--remove-args=\"${removeargs}\"} \
634   ${kernargs:+--args="${kernargs}"} \   --title=\"${title}\${debugtitle}\""
635   ${removeargs:+--remove-args="${removeargs}"}   rungrubby --debug ${ARGS}
636     rungrubby ${ARGS}
637   else   else
638   [[ -n ${verbose} ]] && echo "${extlinuxConfig} does not exist, not running grubby"   [[ -n ${verbose} ]] && echo "${extlinuxConfig} does not exist, not running grubby"
639   fi   fi
# Line 594  doRmmoddep() Line 679  doRmmoddep()
679   fi   fi
680  }  }
681    
682    # kernel image for 2.4 is kernel
683    if [[ ${ARCH} = ppc64 ]] || [[ ${ARCH} = ppc ]]
684    then
685     if [[ ${kernelmajor} = 2.4 ]]
686     then
687     kernelName=kernel
688     fi
689    fi
690    
691  while [ $# -gt 0 ]  while [ $# -gt 0 ]
692  do  do
# Line 606  do Line 699  do
699   initrd="remove"   initrd="remove"
700   ;;   ;;
701    
702     --devtree*)
703     if [[ $1 == --devtree\=* ]]
704     then
705     devtreefile="${1#--devtreefile=}"
706     else
707     devtreefile="$2"
708     shift
709     fi
710     ;;
711    
712     --devtreedir*)
713     if [[ $1 == --devtreedir\=* ]]
714     then
715     devtreedir=${1#--devtreedir=}
716     else
717     devtreedir=$2
718     shift
719     fi
720     ;;
721    
722   --dracut)   --dracut)
723   dracut=--dracut   dracut=--dracut
724   ;;   ;;
# Line 721  do Line 834  do
834   fi   fi
835   ;;   ;;
836    
837     --kernel-name*)
838     if [[ $1 == --kernel-name\=* ]]
839     then
840     kernelName=${1#--kernel-name=}
841     else
842     kernelName="$2"
843     shift
844     fi
845     ;;
846    
847   -v)   -v)
848   verbose=-v   verbose=-v
849   ;;   ;;
# Line 759  fi Line 882  fi
882    
883  kernelmajor=$(echo ${kernel} | cut -d . -f 1,2)  kernelmajor=$(echo ${kernel} | cut -d . -f 1,2)
884    
 # kernel image for 2.4 is kernel  
 if [[ ${ARCH} = ppc64 ]] || [[ ${ARCH} = ppc ]]  
 then  
  if [[ ${kernelmajor} = 2.4 ]]  
  then  
  kernelName=kernel  
  fi  
 fi  
   
885  [[ ${kernelImage} ]] || kernelImage="${bootPrefix}/${kernelName}-${version}"  [[ ${kernelImage} ]] || kernelImage="${bootPrefix}/${kernelName}-${version}"
886    
887  # 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
# Line 788  then Line 902  then
902  fi  fi
903  [[ -n ${verbose} ]] && echo "initrdfile is ${initrdfile}"  [[ -n ${verbose} ]] && echo "initrdfile is ${initrdfile}"
904    
905    if [[ ${ARCH} =~ armv[5|7].*l ]]
906    then
907     if [ -d ${bootPrefix}/dtb-${version}/ ]
908     then
909     devtreedir="${bootPrefix}/dtb-${version}/"
910     if [[ -n ${dtbfile} ]] && [ -f ${devtreedir}/${dtbfile} ]
911     then
912     devtreefile="${devtreedir}/${dtbfile}"
913     fi
914     fi
915    fi
916    [[ -n ${verbose} ]] && echo "devtreedir is ${devtreedir}"
917    
918  # add dracut i18n, keyboard and plymouth kernel args if requested  # add dracut i18n, keyboard and plymouth kernel args if requested
919  if [[ -n ${dracut} ]] || [[ -n ${adddracutargs} ]]  if [[ -n ${dracut} ]] || [[ -n ${adddracutargs} ]]
920  then  then
# Line 834  then Line 961  then
961  fi  fi
962    
963  # 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
964  if [[ ${mode} = --install ]] && [[ ${UPDATEDEFAULT} = yes ]] && [[ -n ${package} ]] &&  if [[ ${mode} = --install ]] && [[ ${UPDATEDEFAULT} = yes ]] && [[ -n ${package} ]] && [[ -n ${DEFAULTKERNEL} ]]
  [[ -n ${DEFAULTKERNEL} ]] && [[ ${package} = ${DEFAULTKERNEL} ]]  
965  then  then
966   makedefault="--make-default"   if [[ ${package} = ${DEFAULTKERNEL} ]] || [[ ${package}-core = ${DEFAULTKERNEL} ]]
967   [[ -n ${verbose} ]] && echo "making it the default based on config"   then
968     makedefault="--make-default"
969     [[ -n ${verbose} ]] && echo "making it the default based on config"
970     fi
971  fi  fi
972    
973  if [[ ${moddep} = make ]]  if [[ ${moddep} = make ]]

Legend:
Removed from v.2681  
changed lines
  Added in v.2972