timezone-data-2017a.ebuild 4.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157
  1. # Copyright 1999-2017 Gentoo Foundation
  2. # Distributed under the terms of the GNU General Public License v2
  3. EAPI="5"
  4. inherit eutils toolchain-funcs flag-o-matic
  5. code_ver=${PV}
  6. data_ver=${PV}
  7. DESCRIPTION="Timezone data (/usr/share/zoneinfo) and utilities (tzselect/zic/zdump)"
  8. HOMEPAGE="http://www.iana.org/time-zones http://www.twinsun.com/tz/tz-link.htm"
  9. SRC_URI="http://www.iana.org/time-zones/repository/releases/tzdata${data_ver}.tar.gz
  10. http://www.iana.org/time-zones/repository/releases/tzcode${code_ver}.tar.gz"
  11. LICENSE="BSD public-domain"
  12. SLOT="0"
  13. KEYWORDS="alpha amd64 arm arm64 hppa ia64 m68k ~mips ppc ppc64 s390 sh sparc x86 ~amd64-fbsd ~sparc-fbsd ~x86-fbsd ~amd64-linux ~x86-linux ~ppc-macos ~x64-macos ~x86-macos"
  14. IUSE="nls leaps_timezone elibc_FreeBSD"
  15. DEPEND="nls? ( virtual/libintl )"
  16. RDEPEND="${DEPEND}
  17. !sys-libs/glibc[vanilla(+)]"
  18. S=${WORKDIR}
  19. src_prepare() {
  20. epatch "${FILESDIR}"/${PN}-2016g-makefile.patch
  21. tc-is-cross-compiler && cp -pR "${S}" "${S}"-native
  22. }
  23. src_configure() {
  24. tc-export CC
  25. append-lfs-flags #471102
  26. if use elibc_FreeBSD || use elibc_Darwin ; then
  27. append-cppflags -DSTD_INSPIRED #138251
  28. fi
  29. append-cppflags -DHAVE_GETTEXT=$(usex nls 1 0) -DTZ_DOMAIN='\"libc\"'
  30. LDLIBS=""
  31. if use nls ; then
  32. # See if an external libintl is available. #154181 #578424
  33. local c="${T}/test"
  34. echo 'main(){}' > "${c}.c"
  35. if $(tc-getCC) ${CPPFLAGS} ${CFLAGS} ${LDFLAGS} "${c}.c" -o "${c}" -lintl 2>/dev/null ; then
  36. LDLIBS+=" -lintl"
  37. fi
  38. fi
  39. }
  40. _emake() {
  41. emake \
  42. TOPDIR="${EPREFIX}/usr" \
  43. REDO=$(usex leaps_timezone posix_right posix_only) \
  44. "$@"
  45. }
  46. src_compile() {
  47. # TOPDIR is used in some utils when compiling.
  48. _emake \
  49. AR="$(tc-getAR)" \
  50. CC="$(tc-getCC)" \
  51. RANLIB="$(tc-getRANLIB)" \
  52. CFLAGS="${CFLAGS} -std=gnu99" \
  53. LDFLAGS="${LDFLAGS}" \
  54. LDLIBS="${LDLIBS}"
  55. if tc-is-cross-compiler ; then
  56. _emake -C "${S}"-native \
  57. CC="$(tc-getBUILD_CC)" \
  58. CFLAGS="${BUILD_CFLAGS}" \
  59. CPPFLAGS="${BUILD_CPPFLAGS}" \
  60. LDFLAGS="${BUILD_LDFLAGS}" \
  61. LDLIBS="${LDLIBS}" \
  62. zic
  63. fi
  64. }
  65. src_install() {
  66. local zic=""
  67. tc-is-cross-compiler && zic="zic=${S}-native/zic"
  68. _emake install ${zic} DESTDIR="${D}"
  69. dodoc CONTRIBUTING README NEWS Theory
  70. dohtml *.htm
  71. }
  72. get_TIMEZONE() {
  73. local tz src="${EROOT}etc/timezone"
  74. if [[ -e ${src} ]] ; then
  75. tz=$(sed -e 's:#.*::' -e 's:[[:space:]]*::g' -e '/^$/d' "${src}")
  76. else
  77. tz="FOOKABLOIE"
  78. fi
  79. [[ -z ${tz} ]] && return 1 || echo "${tz}"
  80. }
  81. pkg_preinst() {
  82. local tz=$(get_TIMEZONE)
  83. if [[ ${tz} == right/* || ${tz} == posix/* ]] ; then
  84. eerror "The right & posix subdirs are no longer installed as subdirs -- they have been"
  85. eerror "relocated to match upstream paths as sibling paths. Further, posix/xxx is the"
  86. eerror "same as xxx, so you should simply drop the posix/ prefix. You also should not"
  87. eerror "be using right/xxx for the system timezone as it breaks programs."
  88. die "Please fix your timezone setting"
  89. fi
  90. # Trim the symlink by hand to avoid portage's automatic protection checks.
  91. rm -f "${EROOT}"/usr/share/zoneinfo/posix
  92. if has_version "<=${CATEGORY}/${PN}-2015c" ; then
  93. elog "Support for accessing posix/ and right/ directly has been dropped to match"
  94. elog "upstream. There is no need to set TZ=posix/xxx as it is the same as TZ=xxx."
  95. elog "For TZ=right/, you can use TZ=../zoneinfo-leaps/xxx instead. See this post"
  96. elog "for details: https://mm.icann.org/pipermail/tz/2015-February/022024.html"
  97. fi
  98. }
  99. pkg_config() {
  100. # make sure the /etc/localtime file does not get stale #127899
  101. local tz src="${EROOT}etc/timezone" etc_lt="${EROOT}etc/localtime"
  102. # If it's a symlink, assume the user knows what they're doing and
  103. # they're managing it themselves. #511474
  104. if [[ -L ${etc_lt} ]] ; then
  105. einfo "Assuming your ${etc_lt} symlink is what you want; skipping update."
  106. return 0
  107. fi
  108. if ! tz=$(get_TIMEZONE) ; then
  109. einfo "Assuming your empty ${etc_lt} file is what you want; skipping update."
  110. return 0
  111. fi
  112. if [[ ${tz} == "FOOKABLOIE" ]] ; then
  113. elog "You do not have TIMEZONE set in ${src}."
  114. if [[ ! -e ${etc_lt} ]] ; then
  115. cp -f "${EROOT}"/usr/share/zoneinfo/Factory "${etc_lt}"
  116. elog "Setting ${etc_lt} to Factory."
  117. else
  118. elog "Skipping auto-update of ${etc_lt}."
  119. fi
  120. return 0
  121. fi
  122. if [[ ! -e ${EROOT}/usr/share/zoneinfo/${tz} ]] ; then
  123. elog "You have an invalid TIMEZONE setting in ${src}"
  124. elog "Your ${etc_lt} has been reset to Factory; enjoy!"
  125. tz="Factory"
  126. fi
  127. einfo "Updating ${etc_lt} with ${EROOT}usr/share/zoneinfo/${tz}"
  128. cp -f "${EROOT}"/usr/share/zoneinfo/"${tz}" "${etc_lt}"
  129. }
  130. pkg_postinst() {
  131. pkg_config
  132. }