Magellan Linux

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

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

revision 2248 by niro, Mon Oct 21 13:55:31 2013 UTC revision 2971 by niro, Thu Jun 30 10:06:57 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 116  elif [[ ${ARCH} =~ armv[5|7].*l ]] Line 117  elif [[ ${ARCH} =~ armv[5|7].*l ]]
117  then  then
118   liloConfig=""   liloConfig=""
119   bootPrefix=/boot   bootPrefix=/boot
120     extlinuxConfig=$(readlink -f /etc/extlinux.conf 2>/dev/null)
121   ubootDir=${UBOOT_DIR:-"/boot"}   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"}
# Line 144  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 152  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 161  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)
# Line 188  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 217  install() Line 271  install()
271   cfgLilo=""   cfgLilo=""
272   fi   fi
273    
274   if [[ -n ${banner} ]]   set_title
  then  
  title="${banner} [ ${version} ]"  
  elif [[ $(read_os_release id) = magellan ]]  
  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  
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   ${grubby} --grub -c ${grubConfig} \   ARGS="--grub -c ${grubConfig} --add-kernel=${kernelImage} ${INITRD} \
281   --add-kernel=${kernelImage} \   ${mbkernel:+--add-multiboot=\"${mbkernel}\"} \
282   ${INITRD} --copy-default ${makedefault} --title "${title}" \   ${mbargs:+--mbargs=\"${mbargs}\"} \
283   ${mbkernel:+--add-multiboot="${mbkernel}"} ${mbargs:+--mbargs="${mbargs}"} \   --title=\"${title}\${debugtitle}\" --copy-default \
284   --args="root=${rootdevice} ${kernargs}" --remove-kernel="TITLE=${title}"   --args=\"root=${rootdevice} ${kernargs} \${debugargs}\" \
285     --remove-kernel=\"TITLE=${title}\${debugtitle}\""
286     rungrubby --debug ${ARGS}
287     rungrubby ${ARGS} ${makedefault}
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 246  install() Line 292  install()
292   then   then
293   [[ -n ${verbose} ]] && echo "adding ${version} to ${grub2Config}"   [[ -n ${verbose} ]] && echo "adding ${version} to ${grub2Config}"
294    
295   ${grubby} --grub2 -c ${grub2Config} \   ARGS="--grub2 -c ${grub2Config} --add-kernel=${kernelImage} ${INITRD} \
296   --add-kernel=${kernelImage} \   --copy-default --title \"${title}\${debugtitle}\" \
297   ${INITRD} --copy-default ${makedefault} --title "${title}" \   ${mbkernel:+--add-multiboot=\"${mbkernel}\"} \
298   ${mbkernel:+--add-multiboot="${mbkernel}"} \   ${mbargs:+--mbargs=\"${mbargs}\"} \
299   ${mbargs:+--mbargs="${mbargs}"} \   --args=\"root=${rootdevice} ${kernargs} \${debugargs}\" \
300   --args="root=${rootdevice} ${kernargs}" --remove-kernel="TITLE=${title}"   --remove-kernel=\"TITLE=${title}\${debugtitle}\""
301     rungrubby --debug ${ARGS}
302     rungrubby ${ARGS} ${makedefault}
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 259  install() Line 307  install()
307   then   then
308   [[ -n ${verbose} ]] && echo "adding ${version} to ${grub2EfiConfig}"   [[ -n ${verbose} ]] && echo "adding ${version} to ${grub2EfiConfig}"
309    
310   ${grubby} --grub2 -c ${grub2EfiConfig} --efi \   ARGS="--grub2 -c ${grub2EfiConfig} --efi \
311   --add-kernel=${kernelImage} \   --add-kernel=${kernelImage} ${DEVTREE} ${INITRD} \
312   ${INITRD} --copy-default ${makedefault} --title "${title}" \   --copy-default --title \"${title}\${debugtitle}\" \
313   ${mbkernel:+--add-multiboot="${mbkernel}"} \   ${mbkernel:+--add-multiboot=\"${mbkernel}\"} \
314   ${mbargs:+--mbargs="${mbargs}"} \   ${mbargs:+--mbargs=\"${mbargs}\"} \
315   --args="root=${rootdevice} ${kernargs}" --remove-kernel="TITLE=${title}"   --args=\"root=${rootdevice} ${kernargs} \${debugargs}\" \
316     --remove-kernel=\"TITLE=${title}\${debugtitle}\""
317     rungrubby --debug ${ARGS}
318     rungrubby ${ARGS} ${makedefault}
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 273  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=${kernelImage} ${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 297  install() Line 351  install()
351   then   then
352   [[ -n ${verbose} ]] && echo "adding ${version} to ${extlinuxConfig}"   [[ -n ${verbose} ]] && echo "adding ${version} to ${extlinuxConfig}"
353    
354   ${grubby} --extlinux -c ${extlinuxConfig} \   ARGS="--extlinux -c ${extlinuxConfig} --add-kernel=${kernelImage} \
355   --add-kernel=${kernelImage} \   ${DEVTREE} ${INITRD} --copy-default --title \"${title}\${debugtitle}\" \
356   ${INITRD} --copy-default ${makedefault} --title "${title}" \   ${mbkernel:+--add-multiboot=\"${mbkernel}\"} \
357   ${mbkernel:+--add-multiboot="${mbkernel}"} ${mbargs:+--mbargs="${mbargs}"} \   ${mbargs:+--mbargs=\"${mbargs}\"} \
358   --args="root=${rootdevice} ${kernargs}" --remove-kernel="TITLE=${title}"   --args=\"root=${rootdevice} ${kernargs} \${debugargs}\" \
359     --remove-kernel=\"TITLE=${title}\${debugtitle}\""
360     rungrubby --debug ${ARGS}
361     rungrubby ${ARGS} ${makedefault}
362   else   else
363   [[ -n ${verbose} ]] && echo "${extlinuxConfig} does not exist, not running grubby for extlinux"   [[ -n ${verbose} ]] && echo "${extlinuxConfig} does not exist, not running grubby for extlinux"
364   fi   fi
# Line 434  update() Line 491  update()
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 446  update() Line 505  update()
505   fi   fi
506   fi   fi
507    
508     DEVTREE=""
509     if [[ x${devtreefile} != x ]] && [ -f ${devtreefile} ]
510     then
511     [[ -n ${verbose} ]] && echo "found ${devtreefile} and using it with grubby"
512     DEVTREE="--devtree ${devtreefile}"
513     fi
514    
515   if [[ -n ${cfgGrub} ]]   if [[ -n ${cfgGrub} ]]
516   then   then
517   [[ -n ${verbose} ]] && echo "updating ${version} from ${grubConfig}"   [[ -n ${verbose} ]] && echo "updating ${version} from ${grubConfig}"
518   ${grubby} --grub -c ${grubConfig} \   ARGS="--grub -c ${grubConfig} --update-kernel=${kernelImage} ${INITRD} \
519   --update-kernel=${kernelImage} \   ${kernargs:+--args=\"${kernargs}\"} \
520   ${INITRD} \   ${removeargs:+--remove-args=\"${removeargs}\"} \
521   ${kernargs:+--args="${kernargs}"} \   ${mbkernel:+--add-multiboot=\"${mbkernel}\"} \
522   ${removeargs:+--remove-args="${removeargs}"}   --title=\"${title}\${debugtitle}\""
523     rungrubby --debug ${ARGS}
524     rungrubby ${ARGS}
525   else   else
526   [[ -n ${verbose} ]] && echo "${grubConfig} does not exist, not running grubby"   [[ -n ${verbose} ]] && echo "${grubConfig} does not exist, not running grubby"
527   fi   fi
# Line 461  update() Line 529  update()
529   if [[ -n ${cfgGrub2} ]]   if [[ -n ${cfgGrub2} ]]
530   then   then
531   [[ -n ${verbose} ]] && echo "updating ${version} from ${grub2Config}"   [[ -n ${verbose} ]] && echo "updating ${version} from ${grub2Config}"
532   ${grubby} --grub2 -c ${grub2Config} \   ARGS="--grub2 -c ${grub2Config} --update-kernel=${kernelImage} ${INITRD} \
533   --update-kernel=${kernelImage} \   ${kernargs:+--args=\"${kernargs}\"} \
534   ${INITRD} \   ${removeargs:+--remove-args=\"${removeargs}\"} \
535   ${kernargs:+--args="${kernargs}"} \   --title=\"${title}\${debugtitle}\""
536   ${removeargs:+--remove-args="${removeargs}"}   rungrubby --debug ${ARGS}
537     rungrubby ${ARGS}
538   else   else
539   [[ -n ${verbose} ]] && echo "${grub2Config} does not exist, not running grubby"   [[ -n ${verbose} ]] && echo "${grub2Config} does not exist, not running grubby"
540   fi   fi
# Line 473  update() Line 542  update()
542   if [[ -n ${cfgGrub2Efi} ]]   if [[ -n ${cfgGrub2Efi} ]]
543   then   then
544   [[ -n ${verbose} ]] && echo "updating ${version} from ${grub2EfiConfig}"   [[ -n ${verbose} ]] && echo "updating ${version} from ${grub2EfiConfig}"
545   ${grubby} --grub2 -c ${grub2EfiConfig} --efi \   ARGS="--grub2 -c ${grub2EfiConfig} --efi --update-kernel=${kernelImage} \
546   --update-kernel=${kernelImage} \   ${INITRD} ${kernargs:+--args=\"${kernargs}\"} \
547   ${INITRD} \   ${removeargs:+--remove-args=\"${removeargs}\"} \
548   ${kernargs:+--args="${kernargs}"} \   --title=\"${title}\${debugtitle}\""
549   ${removeargs:+--remove-args="${removeargs}"}   rungrubby --debug ${ARGS}
550     rungrubby ${ARGS}
551   else   else
552   [[ -n ${verbose} ]] && echo "${grub2EfiConfig} does not exist, not running grubby"   [[ -n ${verbose} ]] && echo "${grub2EfiConfig} does not exist, not running grubby"
553   fi   fi
# Line 485  update() Line 555  update()
555   if [[ -n ${cfgLilo} ]]   if [[ -n ${cfgLilo} ]]
556   then   then
557   [[ -n ${verbose} ]] && echo "updating ${version} from ${liloConfig}"   [[ -n ${verbose} ]] && echo "updating ${version} from ${liloConfig}"
558   ${grubby} --update-kernel=${kernelImage} \   ARGS="--${liloFlag} --update-kernel=${kernelImage} ${INITRD} \
559   ${INITRD} \   ${kernargs:+--args=\"${kernargs}\"} \
560   ${kernargs:+--args="${kernargs}"} \   ${removeargs:+--remove-args=\"${removeargs}\"} \
561   ${removeargs:+--remove-args="${removeargs}"} \   --title=\"${title}\${debugtitle}\""
562   --${liloFlag}   rungrubby --debug ${ARGS}
563     rungrubby ${ARGS}
564    
565   if [[ -n ${runLilo} ]]   if [[ -n ${runLilo} ]]
566   then   then
# Line 542  update() Line 613  update()
613   if [[ -n ${cfgExtlinux} ]]   if [[ -n ${cfgExtlinux} ]]
614   then   then
615   [[ -n ${verbose} ]] && echo "updating ${version} from ${extlinuxConfig}"   [[ -n ${verbose} ]] && echo "updating ${version} from ${extlinuxConfig}"
616   ${grubby} --extlinux -c ${extlinuxConfig} \   ARGS="--extlinux -c ${extlinuxConfig} --update-kernel=${kernelImage} \
617   --update-kernel=${kernelImage} \   ${DEVTREE} ${INITRD} ${kernargs:+--args=\"${kernargs}\"} \
618   ${INITRD} \   ${removeargs:+--remove-args=\"${removeargs}\"} \
619   ${kernargs:+--args="${kernargs}"} \   --title=\"${title}\${debugtitle}\""
620   ${removeargs:+--remove-args="${removeargs}"}   rungrubby --debug ${ARGS}
621     rungrubby ${ARGS}
622   else   else
623   [[ -n ${verbose} ]] && echo "${extlinuxConfig} does not exist, not running grubby"   [[ -n ${verbose} ]] && echo "${extlinuxConfig} does not exist, not running grubby"
624   fi   fi
# Line 592  doRmmoddep() Line 664  doRmmoddep()
664   fi   fi
665  }  }
666    
667    # kernel image for 2.4 is kernel
668    if [[ ${ARCH} = ppc64 ]] || [[ ${ARCH} = ppc ]]
669    then
670     if [[ ${kernelmajor} = 2.4 ]]
671     then
672     kernelName=kernel
673     fi
674    fi
675    
676  while [ $# -gt 0 ]  while [ $# -gt 0 ]
677  do  do
# Line 604  do Line 684  do
684   initrd="remove"   initrd="remove"
685   ;;   ;;
686    
687     --devtree*)
688     if [[ $1 == --devtree\=* ]]
689     then
690     devtreefile="${1#--devtreefile=}"
691     else
692     devtreefile="$2"
693     shift
694     fi
695     ;;
696    
697   --dracut)   --dracut)
698   dracut=--dracut   dracut=--dracut
699   ;;   ;;
# Line 719  do Line 809  do
809   fi   fi
810   ;;   ;;
811    
812     --kernel-name*)
813     if [[ $1 == --kernel-name\=* ]]
814     then
815     kernelName=${1#--kernel-name=}
816     else
817     kernelName="$2"
818     shift
819     fi
820     ;;
821    
822   -v)   -v)
823   verbose=-v   verbose=-v
824   ;;   ;;
# Line 757  fi Line 857  fi
857    
858  kernelmajor=$(echo ${kernel} | cut -d . -f 1,2)  kernelmajor=$(echo ${kernel} | cut -d . -f 1,2)
859    
 # kernel image for 2.4 is kernel  
 if [[ ${ARCH} = ppc64 ]] || [[ ${ARCH} = ppc ]]  
 then  
  if [[ ${kernelmajor} = 2.4 ]]  
  then  
  kernelName=kernel  
  fi  
 fi  
   
860  [[ ${kernelImage} ]] || kernelImage="${bootPrefix}/${kernelName}-${version}"  [[ ${kernelImage} ]] || kernelImage="${bootPrefix}/${kernelName}-${version}"
861    
862  # 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 786  then Line 877  then
877  fi  fi
878  [[ -n ${verbose} ]] && echo "initrdfile is ${initrdfile}"  [[ -n ${verbose} ]] && echo "initrdfile is ${initrdfile}"
879    
880    if [[ ${ARCH} =~ armv[5|7].*l ]]
881    then
882     if [ -d ${bootPrefix}/dtb-${version}/ ]
883     then
884     devtreedir="${bootPrefix}/dtb-${version}/"
885     if [[ -n ${dtbfile} ]] && [ -f ${devtreedir}/${dtbfile} ]
886     then
887     devtreefile="${devtreedir}/${dtbfile}"
888     fi
889     fi
890    fi
891    [[ -n ${verbose} ]] && echo "devtreedir is ${devtreedir}"
892    
893  # add dracut i18n, keyboard and plymouth kernel args if requested  # add dracut i18n, keyboard and plymouth kernel args if requested
894  if [[ -n ${dracut} ]] || [[ -n ${adddracutargs} ]]  if [[ -n ${dracut} ]] || [[ -n ${adddracutargs} ]]
895  then  then
# Line 832  then Line 936  then
936  fi  fi
937    
938  # 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
939  if [[ ${mode} = --install ]] && [[ ${UPDATEDEFAULT} = yes ]] && [[ -n ${package} ]] &&  if [[ ${mode} = --install ]] && [[ ${UPDATEDEFAULT} = yes ]] && [[ -n ${package} ]] && [[ -n ${DEFAULTKERNEL} ]]
  [[ -n ${DEFAULTKERNEL} ]] && [[ ${package} = ${DEFAULTKERNEL} ]]  
940  then  then
941   makedefault="--make-default"   if [[ ${package} = ${DEFAULTKERNEL} ]] || [[ ${package}-core = ${DEFAULTKERNEL} ]]
942   [[ -n ${verbose} ]] && echo "making it the default based on config"   then
943     makedefault="--make-default"
944     [[ -n ${verbose} ]] && echo "making it the default based on config"
945     fi
946  fi  fi
947    
948  if [[ ${moddep} = make ]]  if [[ ${moddep} = make ]]

Legend:
Removed from v.2248  
changed lines
  Added in v.2971