app-admin/perl-cleaner: add Prefix support
authorFabian Groffen <grobian@gentoo.org>
Fri, 21 Aug 2015 18:44:17 +0000 (20:44 +0200)
committerFabian Groffen <grobian@gentoo.org>
Fri, 21 Aug 2015 18:44:41 +0000 (20:44 +0200)
Package-Manager: portage-2.2.20-prefix

app-admin/perl-cleaner/files/perl-cleaner-2.20-prefix.patch [new file with mode: 0644]
app-admin/perl-cleaner/perl-cleaner-2.20.ebuild

diff --git a/app-admin/perl-cleaner/files/perl-cleaner-2.20-prefix.patch b/app-admin/perl-cleaner/files/perl-cleaner-2.20-prefix.patch
new file mode 100644 (file)
index 0000000..27d5b1d
--- /dev/null
@@ -0,0 +1,111 @@
+add Prefix and Darwin support
+
+--- perl-cleaner
++++ perl-cleaner
+@@ -1,4 +1,4 @@
+-#!/bin/bash
++#!@GENTOO_PORTAGE_EPREFIX@/bin/bash
+ # vim: set et sw=4 sts=4 tw=80:
+ # Copyright 2005-2014 Gentoo Foundation
+ # Distributed under the terms of the GNU General Public License v2
+@@ -22,13 +22,13 @@
+ PKGS_EXCEPTIONS="dev-lang/perl sys-devel/libperl app-emulation/emul-linux-x86-baselibs"
+ PKGS_MANUAL=""
+-PKG_DBDIR=/var/db/pkg
++PKG_DBDIR="@GENTOO_PORTAGE_EPREFIX@/var/db/pkg"
+ # See bug 504116 for details
+-if [ -e /lib/gentoo/functions.sh ]; then
+-    . /lib/gentoo/functions.sh
+-elif [ -e /etc/init.d/functions.sh ]; then
+-    . /etc/init.d/functions.sh
++if [ -e "@GENTOO_PORTAGE_EPREFIX@/lib/gentoo/functions.sh" ]; then
++    . "@GENTOO_PORTAGE_EPREFIX@/lib/gentoo/functions.sh"
++elif [ -e "@GENTOO_PORTAGE_EPREFIX@/etc/init.d/functions.sh" ]; then
++    . "@GENTOO_PORTAGE_EPREFIX@/etc/init.d/functions.sh"
+ else
+     echo "$0: Unable to find functions.sh"
+     exit 1
+@@ -157,7 +157,7 @@
+     veinfo 1 "Locating ph files for removal"
+     eindent ""
+-    for i in /usr/lib{,64,x32}/perl5 ; do
++    for i in "@GENTOO_PORTAGE_EPREFIX@"/usr/lib{,64,x32}/perl5 ; do
+         [[ ! -d ${i} ]] && continue
+         veinfo 4 "...in ${i}"
+         while IFS= read -r -d $'\0' file ; do
+@@ -183,13 +183,13 @@
+         veinfo 1 "Pretend. Nothing to do."
+         return
+     fi
+-    pushd /usr/include > /dev/null
++    pushd "@GENTOO_PORTAGE_EPREFIX@"/usr/include > /dev/null
+     if [[ ${version} =~ ^5.(8|10) ]] ; then
+         eindent
+-        veinfo 2 "...in /usr/include"
++        veinfo 2 "...in @GENTOO_PORTAGE_EPREFIX@/usr/include"
+         h2ph ${option} * 2>/dev/null
+         for dir in sys arpa netinet bits security asm gnu linux ; do
+-            veinfo 2 "...in /usr/include/$dir/"
++            veinfo 2 "...in @GENTOO_PORTAGE_EPREFIX@/usr/include/$dir/"
+             h2ph ${option} -r $dir/*
+         done
+         eoutdent
+@@ -220,13 +220,16 @@
+         veinfo 1 "Locating ebuilds linked against libperl"
+     fi
++    local scanelf=scanelf
++    [[ -e "@GENTOO_PORTAGE_EPREFIX@"/usr/lib/libperl.dylib ]] \
++        && scanelf=scanmacho
+     if ${LIBPERL} ; then
+-        if ! type -P scanelf >/dev/null 2>&1; then
+-            ewarn "scanelf not found! Install app-misc/pax-utils."
++        if ! type -P ${scanelf} >/dev/null 2>&1; then
++            ewarn "${scanelf} not found! Install app-misc/pax-utils."
+             ewarn "--libperl is disbled."
+             LIBPERL=false
+         else
+-            SONAME="$(scanelf -qBS "$(realpath /usr/lib/libperl.so 2>/dev/null )" | awk '{ print $1 }')"
++            SONAME="$(${scanelf} -qBS "$(realpath "@GENTOO_PORTAGE_EPREFIX@"/usr/lib/libperl.{so,dylib} 2>/dev/null )" | awk '{ print $1 }')"
+             veinfo 4 SONAME="${SONAME}"
+         fi
+     fi
+@@ -268,7 +271,7 @@
+             while read -r type file ; do
+                 shopt -s extglob
+                 [[ ${type} == obj ]] || [[ ${type} == sym ]] || continue
+-                [[ ${file} =~ ^/usr/(share|lib(32|64|x32)?)/perl5 ]] || continue
++                [[ ${file} =~ ^"@GENTOO_PORTAGE_EPREFIX@"/usr/(share|lib(32|64|x32)?)/perl5 ]] || continue
+                 file=${file% +(!([[:space:]])) +([[:digit:]])}
+                 shopt -u extglob
+                 if ${FORCE} || outdated_path "${file}" ; then
+@@ -302,7 +305,7 @@
+         if ${LIBPERL} ; then
+             # We assume the broken libs have all bin or lib in their path
+-            broken_libs="$(scanelf -qBn < <(awk '/^(obj|sym) [^ ]*\/(s?bin|lib(32|64|x32)?)\// && ! /^obj [^ ]*\/usr\/lib\/debug\//{ print $2 }' ${content} ) | grep -o 'libperl\.so\.[0-9.]*' | sort -u )"
++            broken_libs="$(${scanelf} -qBn < <(awk '/^(obj|sym) [^ ]*\/(s?bin|lib(32|64|x32)?)\// && ! /^obj [^ ]*\/usr\/lib\/debug\//{ print $2 }' ${content} ) | grep -o 'libperl\.\(so\|dylib\)\.[0-9.]*' | sort -u )"
+             if [[ -n "${broken_libs}" ]] ; then
+                 if ${FORCE} || [[ ${broken_libs} != ${SONAME} ]] ; then
+                     PKGS_TO_REMERGE+=" ${CATPKGVER}"
+@@ -327,7 +330,7 @@
+         exit $?
+     fi
+-    if [[ ${PMS_COMMAND[${PMS_INDEX}]} == emerge && -x /usr/bin/portageq ]] ; then
++    if [[ ${PMS_COMMAND[${PMS_INDEX}]} == emerge && -x "@GENTOO_PORTAGE_EPREFIX@"/usr/bin/portageq ]] ; then
+         # Filter out --getbinpkg, --getbinpkgonly, --usepkg and --usepkgonly options in EMERGE_DEFAULT_OPTS
+         emerge_default_opts=""
+         for option in $(portageq envvar EMERGE_DEFAULT_OPTS ) ; do
+@@ -383,7 +386,7 @@
+     veinfo 1 "or edited. This script cannot deal with them."
+     vecho 1
+-    for i in /usr/{share,lib{,32,64,x32}}/perl5 ; do
++    for i in "@GENTOO_PORTAGE_EPREFIX@"/usr/{share,lib{,32,64,x32}}/perl5 ; do
+         [[ -d $i ]] && perlpath[${#perlpath[*]}]="$(realpath $i 2>/dev/null )"
+     done
+     [[ ${#perlpath[*]} == 0 ]] && return
index 4cf5a6ef5c72cc6306cc264602e7bc1d977274b8..4df092fd9c274602c40e93b4c714d139c02bea9c 100644 (file)
@@ -4,6 +4,8 @@
 
 EAPI=5
 
+inherit eutils prefix
+
 DESCRIPTION="User land tool for cleaning up old perl installs"
 HOMEPAGE="http://www.gentoo.org/proj/en/perl/"
 
@@ -12,7 +14,7 @@ if [[ "${PV}" == "9999" ]] ; then
        EGIT_REPO_URI="http://github.com/gentoo-perl/perl-cleaner.git"
 else
        SRC_URI="mirror://gentoo/${P}.tar.bz2 http://dev.gentoo.org/~dilfridge/distfiles/${P}.tar.bz2"
-       KEYWORDS="~alpha ~amd64 ~arm ~arm64 ~hppa ~ia64 ~m68k ~mips ~ppc ~ppc64 ~s390 ~sh ~sparc ~x86 ~amd64-fbsd ~sparc-fbsd ~x86-fbsd"
+       KEYWORDS="~alpha ~amd64 ~arm ~arm64 ~hppa ~ia64 ~m68k ~mips ~ppc ~ppc64 ~s390 ~sh ~sparc ~x86 ~amd64-fbsd ~sparc-fbsd ~x86-fbsd ~ppc-aix ~x64-freebsd ~x86-freebsd ~hppa-hpux ~ia64-hpux ~x86-interix ~amd64-linux ~ia64-linux ~x86-linux ~ppc-macos ~x64-macos ~x86-macos ~m68k-mint ~sparc-solaris ~sparc64-solaris ~x64-solaris ~x86-solaris"
 fi
 
 LICENSE="GPL-2"
@@ -31,6 +33,15 @@ RDEPEND="app-shells/bash
        )
 "
 
+src_prepare() {
+       if use prefix ; then
+               # I don't dare to throw non Prefix users for the bus, but this
+               # patch should be safe for them
+               epatch "${FILESDIR}"/${P}-prefix.patch
+               eprefixify ${PN}
+       fi
+}
+
 src_install() {
        dosbin perl-cleaner
        doman perl-cleaner.1