Magellan Linux

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

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

revision 1728 by niro, Sat Feb 18 00:59:04 2012 UTC revision 1848 by niro, Mon Jul 2 13:07:56 2012 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 65  then Line 91  then
91  elif [[ ${ARCH} = ppc64 ]] || [[ ${ARCH} = ppc ]]  elif [[ ${ARCH} = ppc64 ]] || [[ ${ARCH} = ppc ]]
92  then  then
93   liloConfig=/etc/yaboot.conf   liloConfig=/etc/yaboot.conf
94     grub2Config=/boot/grub/grub.cfg
95   bootPrefix=/boot   bootPrefix=/boot
96   lilo=/sbin/ybin   lilo=/sbin/ybin
97   liloFlag=yaboot   liloFlag=yaboot
# Line 85  then Line 112  then
112   lilo=/sbin/zipl   lilo=/sbin/zipl
113   runLilo="yes"   runLilo="yes"
114   isx86=""   isx86=""
115  elif [[ ${ARCH} = armv7l ]]  elif [[ ${ARCH} =~ armv[5|7].*l ]]
116  then  then
117   liloConfig=""   liloConfig=""
118   bootPrefix=/boot   bootPrefix=/boot
119   ubootDir=${UBOOT_DIR:-"/boot/uboot"}   ubootDir=${UBOOT_DIR:-"/boot"}
120   ubootScript=$ubootDir/${UBOOT_SCR:-"boot.scr"}   ubootScript=$ubootDir/${UBOOT_SCR:-"boot.scr"}
121   ubootKList=${UBOOT_KLIST:-"klist.txt"}   ubootKList=${UBOOT_KLIST:-"klist.txt"}
122   ubootDevice=/dev/${UBOOT_DEVICE:-"mmcblk0p1"}   ubootDevice=/dev/${UBOOT_DEVICE:-"mmcblk0p1"}
# Line 98  then Line 125  then
125   mounted=""   mounted=""
126   liloFlag=""   liloFlag=""
127   isx86=""   isx86=""
128     if [[ -z ${UBOOT_IMGADDR} ]]
129     then
130     machine=${MACHINE:-$(grep "^Hardware" /proc/cpuinfo | sed 's/Hardware\s*:\s*//')}
131     # A few machines use an alternate kernel load address
132     if [[ "${machine}" =~ ^OMAP[3|4].* ]]
133     then
134     ubootAddress=0x80008000
135     elif [[ "${machine}" =~ ^Efika\ MX.* ]]
136     then
137     ubootAddress=0x90008000
138     else
139     ubootAddress=0x00008000
140     fi
141     else
142     ubootAddress="${UBOOT_IMGADDR}"
143     fi
144  else  else
145   # this leaves i?86 and x86_64   # this leaves i?86 and x86_64
146   liloConfig=/etc/lilo.conf   liloConfig=/etc/lilo.conf
# Line 191  install() Line 234  install()
234    
235   if [[ -n ${banner} ]]   if [[ -n ${banner} ]]
236   then   then
237   title="${banner} (${version})"   title="${banner} [ ${version} ]"
238   elif [ -f /etc/mageversion ]   elif [ -f /etc/mageversion ]
239   then   then
240   title="Magellan Linux $(< /etc/mageversion) (${version})"   title="Magellan Linux $(< /etc/mageversion) [ ${version} ]"
241     elif [[ $(read_os_release id) = magellan ]]
242     then
243     title="$(read_os_release name) $(read_os_release version_id) [ ${version} ]"
244   else   else
245   title="Magellan Linux (${version})"   title="Magellan Linux [ ${version} ]"
246   fi   fi
247   ${grubby} --grub -c ${grubConfig} \   ${grubby} --grub -c ${grubConfig} \
248   --add-kernel=${bootPrefix}/${kernelName}-${version} \   --add-kernel=${bootPrefix}/${kernelName}-${version} \
# Line 212  install() Line 258  install()
258    
259   if [[ -n ${banner} ]]   if [[ -n ${banner} ]]
260   then   then
261   title="${banner} (${version})"   title="${banner} [ ${version} ]"
262   elif [ -f /etc/mageversion ]   elif [ -f /etc/mageversion ]
263   then   then
264   title="Magellan Linux $(< /etc/mageversion) (${version})"   title="Magellan Linux $(< /etc/mageversion) [ ${version} ]"
265     elif [[ $(read_os_release id) = magellan ]]
266     then
267     title="$(read_os_release name) $(read_os_release version_id) [ ${version} ]"
268   else   else
269   title="Magellan Linux (${version})"   title="Magellan Linux [ ${version} ]"
270   fi   fi
271   ${grubby} --grub2 -c ${grub2Config} \   ${grubby} --grub2 -c ${grub2Config} \
272   --add-kernel=${bootPrefix}/${kernelName}-${version} \   --add-kernel=${bootPrefix}/${kernelName}-${version} \
# Line 234  install() Line 283  install()
283    
284   if [[ -n ${banner} ]]   if [[ -n ${banner} ]]
285   then   then
286   title="${banner} (${version})"   title="${banner} [ ${version} ]"
287   elif [ -f /etc/mageversion ]   elif [ -f /etc/mageversion ]
288   then   then
289   title="Magellan Linux $(< /etc/mageversion) (${version})"   title="Magellan Linux $(< /etc/mageversion) [ ${version} ]"
290     elif [[ $(read_os_release id) = magellan ]]
291     then
292     title="$(read_os_release name) $(read_os_release version_id) [ ${version} ]"
293   else   else
294   title="Magellan Linux (${version})"   title="Magellan Linux [ ${version} ]"
295   fi   fi
296   ${grubby} --grub2 -c ${grub2EfiConfig} \   ${grubby} --grub2 -c ${grub2EfiConfig} \
297   --add-kernel=${bootPrefix}/${kernelName}-${version} \   --add-kernel=${bootPrefix}/${kernelName}-${version} \
# Line 281  install() Line 333  install()
333    
334   if [[ -n ${banner} ]]   if [[ -n ${banner} ]]
335   then   then
336   title="${banner} (${version})"   title="${banner} [ ${version} ]"
337   elif [ -f /etc/mageversion ]   elif [ -f /etc/mageversion ]
338   then   then
339   title="Magellan Linux $(< /etc/mageversion) (${version})"   title="Magellan Linux $(< /etc/mageversion) [ ${version} ]"
340     elif [[ $(read_os_release id) = magellan ]]
341     then
342     title="$(read_os_release name) $(read_os_release version_id) [ ${version} ]"
343   else   else
344   title="Magellan Linux (${version})"   title="Magellan Linux [ ${version} ]"
345   fi   fi
346   ${grubby} --extlinux -c ${extlinuxConfig} \   ${grubby} --extlinux -c ${extlinuxConfig} \
347   --add-kernel=${bootPrefix}/${kernelName}-${version} \   --add-kernel=${bootPrefix}/${kernelName}-${version} \
# Line 360  remove() Line 415  remove()
415   then   then
416   tmpKList=$(mktemp ${ubootDir}/${ubootKList}.XXXX)   tmpKList=$(mktemp ${ubootDir}/${ubootKList}.XXXX)
417   curversion=$(tail -n1 ${ubootDir}/${ubootKList})   curversion=$(tail -n1 ${ubootDir}/${ubootKList})
418   sed "/${version}/d" ${ubootDir}/${ubootKList} > ${tmpKList}   sed "/$version$/d" ${ubootDir}/${ubootKList} > ${tmpKList}
419   newversion=$(tail -n1 ${tmpKList})   newversion=$(tail -n1 ${tmpKList})
420   if [ -f ${ubootDir}/uImage-${newversion} ] && [ -f ${ubootDir}/uInitrd-${newversion} ]   if [ -f ${ubootDir}/uImage-${newversion} ] && [ -f ${ubootDir}/uInitrd-${newversion} ]
421   then   then
# Line 400  remove() Line 455  remove()
455   [ -f ${tmpKList} ] && rm -f ${tmpKList}   [ -f ${tmpKList} ] && rm -f ${tmpKList}
456   fi   fi
457   else   else
458   [[ -n ${verbose} ]] && echo "No previous kernel version. uBoot images not removed!"   [[ -n ${verbose} ]] && echo "No previous kernel version.  U-Boot images not removed!"
459   fi   fi
460   else   else
461   [[ -n ${verbose} ]] && echo "${ubootScript} does not exist, not modifying ${ubootDir}"   [[ -n ${verbose} ]] && echo "${ubootScript} does not exist, not modifying ${ubootDir}"
# Line 500  update() Line 555  update()
555   [[ -n ${verbose} ]] && echo "adding $version to ${ubootDir}..."   [[ -n ${verbose} ]] && echo "adding $version to ${ubootDir}..."
556    
557   [[ -n ${verbose} ]] && echo "creating uImage-${version}"   [[ -n ${verbose} ]] && echo "creating uImage-${version}"
558   mkimage -A arm -O linux -T kernel -C none -a 0x80008000 -e 0x80008000 \   mkimage -A arm -O linux -T kernel -C none -a ${ubootAddress} \
559   -n ${version} -d ${bootPrefix}/${kernelName}-${version} ${ubootDir}/uImage-${version}   -e ${ubootAddress} -n ${version} \
560     -d ${bootPrefix}/${kernelName}-${version} ${ubootDir}/uImage-${version}
561    
562   [[ -n ${verbose} ]] && echo "creating uInitrd-${version}"   [[ -n ${verbose} ]] && echo "creating uInitrd-${version}"
563   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 540  update() Line 596  update()
596   fi   fi
597  }  }
598    
599  mkinitrd()  makeinitrd()
600  {  {
601   if [[ -n ${dracut} ]]   if [[ -n ${dracut} ]]
602   then   then
603   tool="dracut ${dracuthostonly} -f ${initrdfile} ${version}"   tool="dracut ${dracuthostonly} -f ${initrdfile} ${version}"
604   else   else
605   tool="/sbin/mkinitrd --allow-missing -f ${initrdfile} ${version}"   tool="mkinitrd --allow-missing -f ${initrdfile} ${version}"
606   fi   fi
607   [[ -n ${verbose} ]] && echo "creating initrd ${initrdfile} using ${version}"   [[ -n ${verbose} ]] && echo "creating initrd ${initrdfile} using ${version}"
608   ${tool}   ${tool}
# Line 787  fi Line 843  fi
843    
844  if [[ ${initrd} = make ]]  if [[ ${initrd} = make ]]
845  then  then
846   mkinitrd   makeinitrd
847  elif [[ ${initrd} = remove ]]  elif [[ ${initrd} = remove ]]
848  then  then
849   rminitrd   rminitrd
# Line 805  fi Line 861  fi
861  [[ -n ${liloConfig} ]] && [ -f ${liloConfig} ] && cfgLilo=1  [[ -n ${liloConfig} ]] && [ -f ${liloConfig} ] && cfgLilo=1
862  [[ -n ${extlinuxConfig} ]] && [ -f ${extlinuxConfig} ] && cfgExtlinux=1  [[ -n ${extlinuxConfig} ]] && [ -f ${extlinuxConfig} ] && cfgExtlinux=1
863    
864  # 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
865  # 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.
866  if [[ -n ${ubootDir} ]]  if [[ -n ${ubootDir} ]]
867  then  then
868   mountEntry=$(mount | grep ${ubootDir})   if [ -f ${ubootScript} ]
  if [[ -z ${mountEntry} ]]  
869   then   then
870   mount ${ubootDevice} ${ubootDir}   cfguBoot=1
871   mounted=1   else
872     mountEntry=$(mount | grep ${ubootDir})
873     if [[ -z ${mountEntry} ]]
874     then
875     mount ${ubootDevice} ${ubootDir}
876     mounted=1
877     fi
878     [ -f ${ubootScript} ] && cfguBoot=1
879   fi   fi
  [ -f ${ubootScript} ] && cfguBoot=1  
880  fi  fi
881    
882  # 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 836  then Line 897  then
897   update   update
898  fi  fi
899    
900    # if we mounted the U-Boot directory, unmount it.
901    [[ -n ${mounted} ]] && umount ${ubootDir}
902    
903  exit 0  exit 0

Legend:
Removed from v.1728  
changed lines
  Added in v.1848