From 2b724c2012e33a7e4fde1a4a61df41b99c81ba3c Mon Sep 17 00:00:00 2001 From: Duncan Coutts Date: Mon, 13 Mar 2006 17:22:50 +0000 Subject: [PATCH] Re-register packages on reinstall. Include an updated ghc-updater script and print a message after installation suggesting users run it if they have upgraded ghc-bin or switched from ghc. Package-Manager: portage-2.1_pre5-r4 --- dev-lang/ghc-bin/ChangeLog | 8 +- dev-lang/ghc-bin/Manifest | 25 +- dev-lang/ghc-bin/files/ghc-updater | 329 ++++++++++++++++++++++++++ dev-lang/ghc-bin/ghc-bin-6.4.1.ebuild | 19 +- 4 files changed, 372 insertions(+), 9 deletions(-) create mode 100755 dev-lang/ghc-bin/files/ghc-updater diff --git a/dev-lang/ghc-bin/ChangeLog b/dev-lang/ghc-bin/ChangeLog index 3126283a0072..28577cca9987 100644 --- a/dev-lang/ghc-bin/ChangeLog +++ b/dev-lang/ghc-bin/ChangeLog @@ -1,6 +1,12 @@ # ChangeLog for dev-lang/ghc-bin # Copyright 2002-2006 Gentoo Foundation; Distributed under the GPL v2 -# $Header: /var/cvsroot/gentoo-x86/dev-lang/ghc-bin/ChangeLog,v 1.42 2006/03/13 11:31:44 jer Exp $ +# $Header: /var/cvsroot/gentoo-x86/dev-lang/ghc-bin/ChangeLog,v 1.43 2006/03/13 17:22:50 dcoutts Exp $ + + 13 Mar 2006; Duncan Coutts +files/ghc-updater, + ghc-bin-6.4.1.ebuild: + Re-register packages on reinstall. Include an updated ghc-updater script and + print a message after installation suggesting users run it if they have + upgraded ghc-bin or switched from ghc. 13 Mar 2006; Jeroen Roovers ghc-bin-6.4.1.ebuild: Marked ~hppa (bug #125389). diff --git a/dev-lang/ghc-bin/Manifest b/dev-lang/ghc-bin/Manifest index 1fe23a09494a..d83329b262a8 100644 --- a/dev-lang/ghc-bin/Manifest +++ b/dev-lang/ghc-bin/Manifest @@ -1,6 +1,9 @@ -MD5 62b8c4a0163321426b8ba75da5c3acca ChangeLog 6763 -RMD160 8448b71abc9ef242ccf8b949c5f44cd62a64881e ChangeLog 6763 -SHA256 8c5bcac4962deb38a81c699c970365f30bac9121883a70d99e9a2635bdcdee5e ChangeLog 6763 +-----BEGIN PGP SIGNED MESSAGE----- +Hash: SHA1 + +MD5 16b34e17d02b19159e867940c9f378e0 ChangeLog 7056 +RMD160 a313ca86c8368c6b85cac6efd08587a263e45588 ChangeLog 7056 +SHA256 2c3fcb5fcb0ecb7a850cb6c4119c2702fcb9039aaf9c09f3c2d27a37d251cbaf ChangeLog 7056 MD5 a82ba08a8abb4ae38bcc8d467c665e7b files/10ghc 40 RMD160 1c9e367fa4ea2fa2d3a046986b066b157964390a files/10ghc 40 SHA256 86c80e876343456b1a1407365bfc2a441bf4c6ca23d3549d67bd800abd617e2f files/10ghc 40 @@ -13,15 +16,25 @@ SHA256 5e83dc0703f66384d8b2a45993ef6b4ffc2bbd2bd01c8d4ffd8234a25e984bd8 files/di MD5 63892ec148f4ffa7ed8436e18dac1f44 files/digest-ghc-bin-6.4.1 1798 RMD160 a45f8b4af959445df9b333b428ca6f4e4fe15bb9 files/digest-ghc-bin-6.4.1 1798 SHA256 84269835d835eefde158a58a65eb69e5909f8b5b09662e496caf200d1537e157 files/digest-ghc-bin-6.4.1 1798 +MD5 e7ba0887c43fd8333a4d1bd92c184244 files/ghc-updater 9045 +RMD160 b044a26add18464b583702f3cac667521c5eb06f files/ghc-updater 9045 +SHA256 eafc2eb58a9c1ad0263fd498cad00f50b0d04860cd8e26aa201910f77d74efbe files/ghc-updater 9045 MD5 d4c41357e843c4af8ce3e6a4c1596627 ghc-bin-6.2.2-r1.ebuild 1032 RMD160 461f55af3bb3f3476e728c13dd74218b92e7f3f5 ghc-bin-6.2.2-r1.ebuild 1032 SHA256 c9ab4aff68caa9f4aba1dd53d170d462546fce28edd78435595666ad60e9332b ghc-bin-6.2.2-r1.ebuild 1032 -MD5 f5e7bb5ca7d95dba53ee992d973bf1c0 ghc-bin-6.4.1.ebuild 2801 -RMD160 cf068bd0d33ecaf7175a1e3ed84743f80eec2ded ghc-bin-6.4.1.ebuild 2801 -SHA256 904c9bedddbdcf54b539a72515c08441e13734cf1bb54d9508c6b93a2c375c39 ghc-bin-6.4.1.ebuild 2801 +MD5 5e7a3fba32a9581c96f1db0c14dc07c3 ghc-bin-6.4.1.ebuild 3278 +RMD160 ada56dbea21a230d220b339d610eaa57eca2e171 ghc-bin-6.4.1.ebuild 3278 +SHA256 f0e8b8814efa0575fed0b9448b945827124db282723e72cd8ef64c899a8b92dd ghc-bin-6.4.1.ebuild 3278 MD5 9e5e3b68f1863c338a231811b31c00f1 ghc-bin-6.4.ebuild 1137 RMD160 4b91634424e684abe68dbfbc5556cf62614329a3 ghc-bin-6.4.ebuild 1137 SHA256 a6bcd36a94ce3232d6351e08415ebf591ff011f3604e6183d24da7f6728b4847 ghc-bin-6.4.ebuild 1137 MD5 c694674dcbef799cd4fdb6914683ebff metadata.xml 223 RMD160 7783e6057effb8b8f0b79cffe8b557b32c633839 metadata.xml 223 SHA256 1d00c8be162a6cb87b3de440b3e63e10b39c12d56e8fbfe592e75aed872b2508 metadata.xml 223 +-----BEGIN PGP SIGNATURE----- +Version: GnuPG v1.4.2.2 (GNU/Linux) + +iD8DBQFEFapc/B0cxt+cq+wRAnGFAJ0VWVDN0aIJzdEDyW1X9mUjm/ZfkwCfbCD2 +dO3qeBLuCctuhHgdFgSI69I= +=A3aV +-----END PGP SIGNATURE----- diff --git a/dev-lang/ghc-bin/files/ghc-updater b/dev-lang/ghc-bin/files/ghc-updater new file mode 100755 index 000000000000..32e3343c88ca --- /dev/null +++ b/dev-lang/ghc-bin/files/ghc-updater @@ -0,0 +1,329 @@ +#!/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 +# +# 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. +# + +shopt -s nullglob + +NEW_GHC_VER=$(ghc --version | sed 's:^.*version ::') +NEW_GHC_LIBDIR=$(ghc --print-libdir) + +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)" +} + +# +# +# Command Line Parsing +# +# +while [ -n "$1" ]; do + case "$1" in + -h | -\? | --help) + usage + exit 0 + ;; + -p | --pretend) + PRETEND=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 + +find_in_portdir() { + local f + for f in ${PORTDIR} ${PORTDIR_OVERLAYS}; do + if [[ -f "${f}/${1}" ]]; then + echo "${f}/${1}" + return 0 + fi + done + return 1 +} + +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 +# directories of the form +# /usr/lib/ghc- +# or similar. +# +# /usr/lib/ghc-bin- +# is included because an old ghc-bin ebuild was buggy and +# installed to a wrong dir. +# +OLD_PACKAGES_DIR="" +# Exclude new library dir and lib symlinks: +for d in /{usr,opt/ghc}/lib{,64}/ghc{,-bin}-*; do + [[ "${d}" == ${NEW_GHC_LIBDIR} ]] || [[ -L ${d%/*} ]] || OLD_PACKAGES_DIR="${OLD_PACKAGES_DIR}${d} " +done + +eloginfo "Starting GHC Updater to $(which ghc), version ${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 "${CATPKGVER} has files in ${d}" + 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_BLOCKED="" +PKGS_MISSING="" + +MASKED_STRING="been masked" +BLOCKED_STRING="is blocking" +MISSING_STRING='there are no 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 "${BLOCKED_STRING}" > /dev/null); then + PKGS_BLOCKED="${PKGS_BLOCKED} $pkg" + elogecho ">=$pkg is blocked" + 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 .." + +DEPSORT=$(find_in_portdir "dev-lang/ghc/files/depsort.py") +if [[ -z ${DEPSORT} ]]; then + eerror "Fatal error: File dev-lang/ghc/files/depsort.py in portage tree." + exit 1 +fi +PKGS_OK_SORTED="$(${PORTAGE_PYTHON} ${DEPSORT} ${PKGS_OK} | xargs)" + +if [[ -n ${PRETEND} ]]; then + eloginfo "These are the packages that would be merged, in order:" +else + eloginfo "Preparing to merge these packages in this order:" +fi +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_BLOCKED="" +for pkg in ${PKGS_BLOCKED}; do OUTPUT_PKGS_BLOCKED="${OUTPUT_PKGS_BLOCKED} $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_BLOCKED}" ]; then + echo + ewarn " Blocked Packages:" + ewarn " -----------------" + ewarn " These packages are currently blocked; they might not yet" + ewarn " be compatible with the current ghc. You can run ghc-updater" + ewarn " again at a later time." + echo + for x in ${OUTPUT_PKGS_BLOCKED}; do + echo " ${x}" + done + fi + if [ -n "${OUTPUT_PKGS_MISSING}" ]; then + echo + ewarn " Missing Packages:" + ewarn " -----------------" + ewarn " These packages cannot be updated because they do not exist" + ewarn " 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 diff --git a/dev-lang/ghc-bin/ghc-bin-6.4.1.ebuild b/dev-lang/ghc-bin/ghc-bin-6.4.1.ebuild index a8f028b7558e..33275e67e2ea 100644 --- a/dev-lang/ghc-bin/ghc-bin-6.4.1.ebuild +++ b/dev-lang/ghc-bin/ghc-bin-6.4.1.ebuild @@ -1,8 +1,8 @@ # Copyright 1999-2006 Gentoo Foundation # Distributed under the terms of the GNU General Public License v2 -# $Header: /var/cvsroot/gentoo-x86/dev-lang/ghc-bin/ghc-bin-6.4.1.ebuild,v 1.9 2006/03/13 11:31:44 jer Exp $ +# $Header: /var/cvsroot/gentoo-x86/dev-lang/ghc-bin/ghc-bin-6.4.1.ebuild,v 1.10 2006/03/13 17:22:50 dcoutts Exp $ -inherit base multilib +inherit base multilib ghc-package DESCRIPTION="Glasgow Haskell Compiler" HOMEPAGE="http://www.haskell.org/ghc/" @@ -84,6 +84,21 @@ src_compile() { src_install () { mv * "${D}" + + # remove this local copy of ghc-updater next time the .tbz2 files + # are rebuilt, since then we'll pick up the fix from the ghc ebuild + into /opt/ghc + dosbin ${FILESDIR}/ghc-updater + insinto /etc/env.d doins "${FILESDIR}/10ghc" } + +pkg_postinst () { + ghc-reregister + ewarn "IMPORTANT:" + ewarn "If you have upgraded from another version of ghc-bin or" + ewarn "if you have switched from ghc to ghc-bin, please run:" + ewarn " /opt/ghc/sbin/ghc-updater" + ewarn "to re-merge all ghc-based Haskell libraries." +} -- 2.26.2