update.sh 1.7 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485
  1. #!/bin/bash
  2. DISTDIR="$(portageq envvar DISTDIR 2>/dev/null)"
  3. DISTDIR="${DISTDIR:-/usr/portage/distfiles}"
  4. if [[ ! -d "${DISTDIR}" ]] ; then
  5. echo "No DISTDIR found."
  6. exit 1
  7. fi
  8. PN=debugedit
  9. gentoo_functions="/lib/gentoo/functions.sh"
  10. if [[ -f "${gentoo_functions}" ]] ; then
  11. . "${gentoo_functions}"
  12. else
  13. echo "Failed to source ${gentoo_functions} file."
  14. echo "Please install sys-apps/gentoo-functions package."
  15. exit 1
  16. fi
  17. set -e
  18. einfo "Getting updated index"
  19. rm -f index.html
  20. wget -q http://rpm5.org/
  21. PV=$(sed -n '/Production:/{n;s:.*RPM ::;s:<.*::;p;q}' index.html)
  22. einfo "Latest upstream version: ${PV}"
  23. rm -f index.html
  24. P="${PN}-${PV}"
  25. A=${P}.tar.bz2
  26. e=${P}.ebuild
  27. if [[ -e ../${e} ]] ; then
  28. einfo "All up to date"
  29. exit 0
  30. fi
  31. #tf=${DISTDIR}/${A}
  32. #if [[ ! -e ${tf} ]] ; then
  33. # einfo "Cannot find ${tf}"
  34. # exit 0
  35. #fi
  36. einfo "Fetching latest rpm tarball"
  37. r=rpm-${PV}
  38. wget -nv http://rpm5.org/files/rpm/rpm-${PV%.*}/${r}.tar.gz -P ${DISTDIR} -c
  39. einfo "Unpacking ${r}"
  40. rm -rf ${r}
  41. tar xf ${DISTDIR}/${r}.tar.gz
  42. einfo "Creating ${P}"
  43. rm -rf ${P}
  44. mkdir ${P}
  45. cp Makefile ${r}/tools/{hashtab.?,debugedit.c} ${P}/
  46. pushd ${P} >/dev/null
  47. more=true
  48. while ${more} ; do
  49. more=false
  50. for h in $(grep '#include' *.[ch] | awk '{print $NF}' | sed 's:[<>"]::g') ; do
  51. [[ ${h} == */* ]] && continue
  52. rh=$(find ../${r} -name ${h##*/})
  53. if [[ -n ${rh} ]] && [[ ! -e ${rh##*/} ]] ; then
  54. # don't copy glibc includes
  55. if ! grep -qs 'This file is part of the GNU C Library' ${rh} ; then
  56. cp ${rh} ./
  57. more=true
  58. fi
  59. fi
  60. done
  61. done
  62. popd >/dev/null
  63. tar jcf ${A} ${P}
  64. einfo "Testing build"
  65. pushd ${P} >/dev/null
  66. make -s
  67. popd >/dev/null
  68. einfo "Cleaning up"
  69. rm -rf ${P} ${r}
  70. du -b ${A}