gnuconfig.eclass 3.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899
  1. # Copyright 1999-2012 Gentoo Foundation
  2. # Distributed under the terms of the GNU General Public License v2
  3. #
  4. # THIS ECLASS IS DEAD: It has been integrated into portage
  5. #
  6. # Author: Will Woods <wwoods@gentoo.org>
  7. #
  8. # This eclass is used to automatically update files that typically come with
  9. # automake to the newest version available on the system. The most common use
  10. # of this is to update config.guess and config.sub when configure dies from
  11. # misguessing your canonical system name (CHOST). It can also be used to update
  12. # other files that come with automake, e.g. depcomp, mkinstalldirs, etc.
  13. #
  14. # usage: gnuconfig_update [file1 file2 ...]
  15. # if called without arguments, config.guess and config.sub will be updated.
  16. # All files in the source tree ($S) with the given name(s) will be replaced
  17. # with the newest available versions chosen from the list of locations in
  18. # gnuconfig_findnewest(), below.
  19. #
  20. # gnuconfig_update should generally be called from src_unpack()
  21. DEPEND="sys-devel/gnuconfig"
  22. # Wrapper function for gnuconfig_do_update. If no arguments are given, update
  23. # config.sub and config.guess (old default behavior), otherwise update the
  24. # named files.
  25. gnuconfig_update() {
  26. # hmm some packages (like binutils gcc glibc) still use this ...
  27. # echo
  28. # ewarn "QA Notice: Please stop using me, portage updates files for you."
  29. # echo
  30. local startdir # declared here ... used in gnuconfig_do_update
  31. if [[ $1 == /* ]] ; then
  32. startdir=$1
  33. shift
  34. else
  35. startdir=${S}
  36. fi
  37. if [[ $# -gt 0 ]] ; then
  38. gnuconfig_do_update "$@"
  39. else
  40. gnuconfig_do_update config.sub config.guess
  41. fi
  42. return $?
  43. }
  44. # Copy the newest available version of specified files over any old ones in the
  45. # source dir. This function shouldn't be called directly - use gnuconfig_update
  46. #
  47. # Note that since bash using dynamic scoping, startdir is available here from
  48. # the gnuconfig_update function
  49. gnuconfig_do_update() {
  50. local configsubs_dir target targetlist file
  51. [[ $# -eq 0 ]] && die "do not call gnuconfig_do_update; use gnuconfig_update"
  52. configsubs_dir=$(gnuconfig_findnewest)
  53. einfo "Using GNU config files from ${configsubs_dir}"
  54. for file in "$@" ; do
  55. if [[ ! -r ${configsubs_dir}/${file} ]] ; then
  56. eerror "Can't read ${configsubs_dir}/${file}, skipping.."
  57. continue
  58. fi
  59. targetlist=$(find "${startdir}" -name "${file}")
  60. if [[ -n ${targetlist} ]] ; then
  61. for target in ${targetlist} ; do
  62. [[ -L ${target} ]] && rm -f "${target}"
  63. einfo " Updating ${target/$startdir\//}"
  64. cp -f "${configsubs_dir}/${file}" "${target}"
  65. eend $?
  66. done
  67. else
  68. ewarn " No ${file} found in ${startdir}, skipping ..."
  69. fi
  70. done
  71. return 0
  72. }
  73. # this searches the standard locations for the newest config.{sub|guess}, and
  74. # returns the directory where they can be found.
  75. gnuconfig_findnewest() {
  76. local locations=(
  77. "${EPREFIX}"/usr/share/misc/config.sub
  78. "${EPREFIX}"/usr/share/gnuconfig/config.sub
  79. "${EPREFIX}"/usr/share/automake*/config.sub
  80. "${EPREFIX}"/usr/share/libtool/config.sub
  81. )
  82. grep -s '^timestamp' "${locations[@]}" | \
  83. sort -r -n -t\' -k2 | \
  84. sed -n '1{s,/config.sub:.*$,,;p;q}'
  85. }