Modified ebuild to use ghc-package.eclass (bug #69270) and to include ghc-updater...
authorAndres Loeh <kosmikus@gentoo.org>
Mon, 22 Nov 2004 15:24:17 +0000 (15:24 +0000)
committerAndres Loeh <kosmikus@gentoo.org>
Mon, 22 Nov 2004 15:24:17 +0000 (15:24 +0000)
dev-lang/ghc/ChangeLog
dev-lang/ghc/Manifest
dev-lang/ghc/files/ghc-updater [new file with mode: 0755]
dev-lang/ghc/ghc-6.2.2.ebuild

index deb5e3ccf678a25188567b784ee5768928d80a2c..901402abbe55b340632981ef7956539a8043054a 100644 (file)
@@ -1,6 +1,11 @@
 # ChangeLog for dev-lang/ghc
 # Copyright 2002-2004 Gentoo Foundation; Distributed under the GPL v2
-# $Header: /var/cvsroot/gentoo-x86/dev-lang/ghc/ChangeLog,v 1.45 2004/10/26 13:50:12 kosmikus Exp $
+# $Header: /var/cvsroot/gentoo-x86/dev-lang/ghc/ChangeLog,v 1.46 2004/11/22 15:24:17 kosmikus Exp $
+
+  22 Nov 2004; Andres Loeh <kosmikus@gentoo.org> +files/ghc-updater,
+  ghc-6.2.2.ebuild:
+  Modified ebuild to use ghc-package.eclass (bug #69270) and to include
+  ghc-updater script (bug #69142).
 
   26 Oct 2004; Andres Loeh <kosmikus@gentoo.org> ghc-6.2.2.ebuild:
   Modified CFLAG testing code, following discussion in bug #59709.
index e15d609c9331c1fed0fff791702f62aaccc0e1a8..d9529ea8ef024ad0b255bfe74d3637cfc21d8ba6 100644 (file)
@@ -1,10 +1,11 @@
 MD5 fea7650a5492528d515692c8a26f1ab8 ghc-6.2.1-r1.ebuild 5790
 MD5 cdc2c51fea57a0f87af76599f73c64f8 ghc-6.2.ebuild 5000
 MD5 1bab1224823b1bdf22fe21cbf40d8a56 ghc-6.0.1.ebuild 4709
-MD5 8b6147f5154782f3a280b784ca668d85 ghc-6.2.2.ebuild 4730
-MD5 1fb3de6853518ec7296c3326095353e8 ChangeLog 8981
+MD5 02bd12e92144ceebbcd3f1497f990689 ghc-6.2.2.ebuild 4996
+MD5 e8df20d2a8aa86dc679c43e8eff4a49b ChangeLog 9178
 MD5 a769ecfcd1cdd2d40986627df7dfb249 metadata.xml 224
 MD5 700ce4a5a2ed7953404345f57ac8bbc7 ghc-6.2-r1.ebuild 5182
+MD5 ee4e4b2265839fca7a4c06d565a51334 files/ghc-updater 8068
 MD5 627087e51858d514520531cedbd372f8 files/ghc-6.2.1-linker.patch.bz2 658
 MD5 1ae8c6b539b6706ba0e8b988a918a944 files/ghc-6.2.hardened.patch 525
 MD5 9da9270be8ac4d92d6a5c23fd519cc3c files/lndir.c 8050
diff --git a/dev-lang/ghc/files/ghc-updater b/dev-lang/ghc/files/ghc-updater
new file mode 100755 (executable)
index 0000000..c2111b4
--- /dev/null
@@ -0,0 +1,292 @@
+#!/bin/sh
+#
+# This script has been modified by kosmikus and is based on 
+# python-updater by liquidx.
+#
+# It tries to update any package that provides a ghc library.
+# This script can be run as many times as you like. It will log the 
+# results in /var/log/ghc-updater.log
+#
+# OLD_GHC_VER     = old ghc version we are upgrading from
+# NEW_GHC_VER     = new ghc version we are upgrading to
+# PKGS_EXCEPTIONS = packages that should NOT be re-emerged for any reason
+# PKGS_MANUAL     = packages that should be re-emerged even if they don't
+#                   fit the criteria
+#
+# Runtime Variables:
+# 
+# PKGS_TO_REMERGE = list of packages we deem to need re-emerging
+# PKGS_OK         = list of packages that should be merged without any problems
+# PKGS_MISSING    = list of packages that are installed, but cannot be merged
+#                   because they have been pruned from portage
+# PKGS_MASKED     = list of packages that are installed, but masked.
+#
+
+OLD_GHC_VER=$(ls -d /usr/lib/ghc-* | sed 's:^.*ghc-::' \
+               | sort -g | tail -n 2 | head -n 1)
+NEW_GHC_VER=$(ghc --version | sed 's:^.*version ::')
+
+PKGS_EXCEPTIONS="dev-lang/ghc dev-lang/ghc-bin"
+PKGS_MANUAL=""
+LOGFILE="/var/log/ghc-updater.log"
+
+# portage variables
+PKG_DBDIR=/var/db/pkg
+
+# moved the portageq checks into a function to make command
+# line parsing immediate
+
+setup_portdir() {
+       PORTDIR=`portageq portdir`
+       PORTDIR_OVERLAYS=`portageq portdir_overlay`
+}
+
+PRETEND=0
+PKGS_TO_REMERGE=""
+PKGS_COUNT_REMERGE=0
+PORTAGE_PYTHON="/usr/bin/python"
+
+usage() {
+       echo "usage: ghc-updater [options]"
+       echo " -h, -?, --help   help"
+       echo " -p, --pretend    pretend (don't do anything)"
+       echo " -o version       set old ghc version to upgrade from [default: ${OLD_GHC_VER}]"
+       echo " -n version       set new ghc version to upgrade to [default: ${NEW_GHC_VER}]"
+}
+
+# 
+#
+# Command Line Parsing
+#
+#
+while [ -n "$1" ]; do
+       case "$1" in
+               -h | -\? | --help)
+                       usage
+                       exit 0
+                       ;;
+               -p | --pretend)
+                       PRETEND=1
+                       ;;
+               -o)
+                       shift
+                       OLD_GHC_VER="$1"
+                       ;;
+               -n)
+                       shift
+                       NEW_GHC_VER="$1"
+                       ;;
+               *)
+                       usage
+                       echo "unrecognised option: $1"
+                       ;;
+       esac
+       shift
+done
+
+# load the gentoo-style info macros, but hack to get around
+# it thinking this is an rc script
+EBUILD="1"
+source /sbin/functions.sh
+
+# misc helper functions
+eloginfo() {
+       einfo $*
+       DATESTRING=`date +"%Y/%m/%d %H:%M:%S"`
+       (echo "${DATESTRING} - ${*}" >> ${LOGFILE}) 2>/dev/null
+}
+
+elogecho() {
+       echo -n "   "
+       echo $*
+       DATESTRING=`date +"%Y/%m/%d %H:%M:%S"`
+       (echo "${DATESTRING} - ${*}" >> ${LOGFILE}) 2>/dev/null
+}
+
+elogerr() {
+       eerror $*
+       DATESTRING=`date +"%Y/%m/%d %H:%M:%S"`
+       (echo "${DATESTRING} ! ${*}" >> ${LOGFILE}) 2>/dev/null
+}
+
+elog() {
+       DATESTRING=`date +"%Y/%m/%d %H:%M:%S"`
+       (echo "${DATESTRING} - ${*}" >> ${LOGFILE}) 2>/dev/null
+}
+
+#
+# Sanity check
+#
+
+setup_portdir
+
+if [ -z "${PORTDIR}" ]; then
+       eerror "Unable to proceed. Can not find PORTDIR. Make sure the command:"
+       eerror " "
+       eerror "  portageq portdir"
+       eerror " "
+       eerror "returns a value. If it doesn't, make sure you have updated to"
+       eerror "latest portage version."
+       eerror " "
+       eerror "Report bugs to http://bugs.gentoo.org/"
+       exit 1
+fi
+
+#
+#
+# Find all packages that have installed something in 
+# /usr/lib/ghc-${OLD_GHC_VER}
+# /usr/lib/ghc-bin-${OLD_GHC_VER}
+#
+OLD_PACKAGES_DIR="/usr/lib/ghc-${OLD_GHC_VER} /usr/lib/ghc-bin-${OLD_GHC_VER} \
+       /opt/ghc/lib/ghc-${OLD_GHC_VER}"
+
+eloginfo "Starting GHC Updater from ${OLD_GHC_VER} to ${NEW_GHC_VER} :"
+eloginfo "Searching for packages with files in the directories:"
+eloginfo "${OLD_PACKAGES_DIR}"
+
+# iterate thru all the installed package's contents
+for content in `find ${PKG_DBDIR} -name CONTENTS`; do
+    # extract the category, package name and package version
+    CATPKGVER=$(echo ${content} | sed "s:${PKG_DBDIR}/\(.*\)/CONTENTS:\1:")
+    
+    # exclude packages that are an exception, like portage and python itself.
+    exception=0
+    for exp in ${PKGS_EXCEPTIONS}; do
+       if [ -n "$(echo ${CATPKGVER} | grep ${exp})" ]; then
+                       exception=1
+                       break;
+               fi
+    done
+       
+    if [ ${exception} = 1 ]; then
+       continue;
+    fi
+
+    for d in ${OLD_PACKAGES_DIR}; do
+        if fgrep "${d}" ${content} > /dev/null; then
+            PKGS_TO_REMERGE="${PKGS_TO_REMERGE} ${CATPKGVER}"
+            elogecho "Adding to list: ${CATPKGVER}"
+        fi
+    done
+done    
+
+# now we have to do each emerge seperately because if an installed version
+# does not have the corresponding ebuild in portage, then it will bail.
+
+eloginfo "Calculating Upgrade Package List .."
+
+PKGS_OK=""
+PKGS_MASKED=""
+PKGS_MISSING=""
+
+MASKED_STRING="been masked"
+MISSING_STRING="there are no masked or unmasked ebuilds to satisfy"
+
+for pkg in ${PKGS_TO_REMERGE}; do
+   emerge_output="$(emerge -p \~$pkg 2>&1)"
+   if $(echo "${emerge_output}" | grep "${MASKED_STRING}" > /dev/null); then
+      PKGS_MASKED="${PKGS_MASKED} $pkg"
+         elogecho "$pkg is masked"       
+   elif $(echo "${emerge_output}" | grep "${MISSING_STRING}" > /dev/null); then
+      PKGS_MISSING="${PKGS_MISSING} $pkg"
+         elogecho "$pkg is missing from portage"
+   else
+      PKGS_OK="${PKGS_OK} $pkg"
+         PKGS_COUNT_REMERGE=$((PKGS_COUNT_REMERGE + 1))
+   fi
+done      
+
+#
+# Use my super dumb package reordering algorithm that works most of the time
+#
+
+eloginfo "Re-ordering packages to merge .."
+
+PKGS_OK_SORTED="$(${PORTAGE_PYTHON} ${PORTDIR}/dev-lang/python/files/depreorder.py ${PKGS_OK} | xargs)"
+
+eloginfo "Preparing to merge these packages in this order:"
+for pkg in $PKGS_OK_SORTED; do
+       elogecho "$pkg"
+done
+
+# we emerge each package seperately to ensure we know exactly which ones might
+# cause an error, and then report it at the end
+
+COUNT=1
+PKGS_FAILED=""
+if [ "${PRETEND}" != "1" ]; then
+       for pkg in ${PKGS_OK_SORTED}; do
+               eloginfo "Starting to merge ($COUNT/$PKGS_COUNT_REMERGE) $pkg .."
+               if ! emerge --oneshot --nodeps \~$pkg; then
+                       PKGS_FAILED="${PKGS_FAILED} $pkg"
+                       elogerr "Failed merging $pkg ($COUNT/$PKGS_COUNT_REMERGE)!"
+               fi
+               COUNT=$((COUNT+1))              
+       done
+fi
+
+# final output stuff
+OUTPUT_PKGS_MASKED=""
+for pkg in ${PKGS_MASKED}; do OUTPUT_PKGS_MASKED="${OUTPUT_PKGS_MASKED} \~$pkg"; done
+OUTPUT_PKGS_MISSING=""
+for pkg in ${PKGS_MISSING}; do OUTPUT_PKGS_MISSING="${OUTPUT_PKGS_MISSING} $pkg"; done
+OUTPUT_PKGS_FAILED=""
+for pkg in ${PKGS_FAILED}; do OUTPUT_PKGS_FAILED="${OUTPUT_PKGS_FAILED} \~$pkg"; done
+
+if [ -n "${PKGS_FAILED}" -o -n "${PKGS_MISSING}" -o -n "${PKGS_MASKED}" ]; then
+   echo
+   ewarn "************************************************************"
+   ewarn "* Packages that still need to be manually emerged :        *"
+   ewarn "************************************************************"
+   if [ -n "${OUTPUT_PKGS_MASKED}" ]; then
+      echo
+      ewarn " Masked Packages:"
+         ewarn " ----------------"
+      ewarn " Unmask the following packages (at your own risk) and  "
+      ewarn " emerge them using this command after removing the '-p'"
+      ewarn " parameter."
+      echo
+      ewarn " emerge -p ${OUTPUT_PKGS_MASKED}"
+      echo
+   fi
+   if [ -n "${OUTPUT_PKGS_MISSING}" ]; then
+      echo
+      ewarn " Missing Packages:"
+         ewarn " -----------------"
+      ewarn " These packages need to be updated because their versions do"
+      ewarn " not exist in portage anymore."
+      echo
+      for x in ${OUTPUT_PKGS_MISSING}; do 
+         echo "   ${x}"
+      done
+   fi
+   if [ -n "${OUTPUT_PKGS_FAILED}" ]; then
+      echo
+      ewarn " Failed Packages:"
+         ewarn " ----------------"
+      ewarn " These packages have failed and need to be re-emerged again."
+         ewarn " Alternatively, try re-running this script again to see if it"
+         ewarn " can be fixed."
+      echo
+      ewarn " emerge -p ${OUTPUT_PKGS_FAILED}"
+      echo
+   fi
+   
+   elog "Python update completed with errors."
+   elog "Masked Packages:"
+   for x in ${PKGS_MASKED}; do
+               elog $x
+   done
+   elog "Missing Packages:"
+   for x in ${PKGS_MISSING}; do
+               elog $x
+   done
+   elog "Failed Packages:"
+   for x in ${PKGS_FAILED}; do
+               elog $x
+   done   
+   elog "Update script completed."
+else
+   eloginfo "GHC update completed successfully."
+fi
index 2fd905c1a0d2f942b0131ad35b47c468555cf631..acb678e0b03fce8c951376faca62e0f9354378b8 100644 (file)
@@ -1,6 +1,6 @@
 # Copyright 1999-2004 Gentoo Foundation
 # Distributed under the terms of the GNU General Public License v2
-# $Header: /var/cvsroot/gentoo-x86/dev-lang/ghc/ghc-6.2.2.ebuild,v 1.5 2004/11/10 18:32:41 kosmikus Exp $
+# $Header: /var/cvsroot/gentoo-x86/dev-lang/ghc/ghc-6.2.2.ebuild,v 1.6 2004/11/22 15:24:17 kosmikus Exp $
 
 # Brief explanation of the bootstrap logic:
 #
@@ -14,7 +14,7 @@
 # can be removed once an forall after the first succesful install
 # of ghc.
 
-inherit base flag-o-matic eutils
+inherit base flag-o-matic eutils ghc-package
 
 IUSE="doc tetex opengl"
 
@@ -38,6 +38,7 @@ DEPEND="virtual/ghc
        >=sys-apps/sed-3.02.80
        >=sys-devel/flex-2.5.4a
        >=dev-libs/gmp-4.1
+       >=sys-libs/readline-4.2
        doc? ( >=app-text/openjade-1.3.1
                >=app-text/sgml-common-0.6.3
                ~app-text/docbook-sgml-dtd-3.1
@@ -53,11 +54,9 @@ RDEPEND="virtual/libc
        >=sys-devel/gcc-2.95.3
        >=dev-lang/perl-5.6.1
        >=dev-libs/gmp-4.1
+       >=sys-libs/readline-4.2
        opengl? ( virtual/opengl virtual/glu virtual/glut )"
 
-# extend path to /opt/ghc/bin to guarantee that ghc-bin is found
-GHCPATH="${PATH}:/opt/ghc/bin"
-
 SUPPORTED_CFLAGS=""
 
 # Setup supported CFLAGS.
@@ -118,7 +117,7 @@ src_compile() {
        # unset SGML_CATALOG_FILES because documentation installation
        # breaks otherwise ...
        # (--enable-threaded-rts is no longer needed)
-       PATH="${GHCPATH}" SGML_CATALOG_FILES="" econf \
+       SGML_CATALOG_FILES="" econf \
                ${myconf} || die "econf failed"
 
        # the build does not seem to work all that
@@ -155,11 +154,14 @@ src_install () {
        fi
        echo SGMLDocWays="${mydoc}" >> mk/build.mk
 
+       # the libdir0 setting is needed for amd64, and does not
+       # harm for other arches
        emake -j1 ${insttarget} \
                prefix="${D}/usr" \
                datadir="${D}/usr/share/doc/${PF}" \
                infodir="${D}/usr/share/info" \
                mandir="${D}/usr/share/man" \
+               libdir0="${D}/usr/$(get_libdir)" \
                || die "make ${insttarget} failed"
 
        #need to remove ${D} from ghcprof script
@@ -171,10 +173,17 @@ src_install () {
 
        cd ${S}/ghc
        dodoc README ANNOUNCE LICENSE VERSION
-}
 
+       dosbin ${FILESDIR}/ghc-updater
+}
 
 pkg_postinst () {
+       ghc-reregister
        einfo "If you have dev-lang/ghc-bin installed, you might"
-       einfo "want to unmerge it again. It is no longer needed."
+       einfo "want to unmerge it. It is no longer needed."
+       einfo " "
+       ewarn "If you upgrade from another ghc version, please run"
+       ewarn "/usr/sbin/ghc-updater to re-merge all ghc-based"
+       ewarn "Haskell libraries."
 }
+