[enhancement] proposal - make all ports independent of which version of Perl is installed or the major one

Bjarne D Mathiesen macintosh at mathiesen.info
Wed May 23 20:36:44 PDT 2012


Bjarne D Mathiesen wrote:
> Eric Hall wrote:
>> On Wed, May 23, 2012 at 09:07:58PM +0200, Bjarne D Mathiesen wrote:
>>> Now, we do have 96 ports that have perl5.12 hardcoded into them.
>>> That means, that they are presently 2 (two) years behind schedule as I
>>> see it.
>>>
>>> If we don't come to a resolution as a group, I'll just implement my own
>>> solution and post my procedure here on the lists for other interested
>>> parties should they be interested.
>>>
>>
>> 	I don't see a problem with providing a variable that can be
>> set somewhere that will make bumping the perl revs easier.  It's
>> certainly been a pain while trying to test things for perl5.14 to
>> have to go in and edit port files to avoid installing perl5.12.
> 
> OK ... I'll post a way to mass-migrate all 96 ports in one go then ...

attached, find my solution to mass-migrate all the ports in one go :-)
I hope it'll be of use for the hackers in here :-D
I've tried to make the coding descriptive as well as commented my code.
If there are points in my code that are un-clear, please don't hesitate
to ask me here on the list :-)

You can use the results in two ways:

1) create a local repo that takes precedence over the macports repo
   the Portfiles generated will thus supercede the ones provided by
   macports major
2) use the patch-files to modify the macports repo.
   to make this work, you'll have to add an additional step after a
   /port sync/ in order to apply the patches:

port sync
for patchFile in $(find ${macportsRoot} \
                   -type f -name 'patch-Portfile.diff')
do
    patch -u -p0 <${patchFile}
done

OH ... and you'll have to modify the #! script path in the script ;-)
I do recommend installing bash from MacPorts and using that :-)

Happy Hacking !!! :-D
-- 
Bjarne D Mathiesen
København N ; Danmark ; Europa
----------------------------------------------------------------------
denne besked er skrevet i et totalt M$-frit miljø
MacOS X 10.7.3 Lion ; 2.8GHz Intel Core i7 ; 16GB 1067MHz DDR3
-------------- next part --------------
#!/macports/bin/bash

#
# change these to reflect your installation:
#
# prefix       : where you have installed macports
# macportsRoot : where you want to store the modifed Portfiles
#
declare prefix='/macports'
declare macportsRoot='/Volumes/Bjarne/WebServer/MacPorts/test'

# don't change this
declare rsyncMacportsOrg='/var/macports/sources/rsync.macports.org/release/tarballs/ports'

mkdir -pv ${macportsRoot}
declare -i counter=0
declare -i totalPorts=$( port -q list | wc -l )
declare -i portrev

#
# this time we're only interested in perl5.12
#
declare -i version=12

cd "${macportsRoot}"

#
# find all the ports that are dependent on perl5.${version}
# or p5.${version}-<something>
#
while read portname[0] portname[1] portname[2]
do
    (( counter++ ))
    printf "\r[ %5i | %5i ] " ${counter} ${totalPorts}
    fundet=$( \
        grep -E -e "(perl${version}|p5.${version})" $(port file ${portname[0]}) \
    |   wc -l )
    if [ ${fundet} -gt 0 ]
    then
        #
        # copy the Portfile
        #
        mkdir -pv ${portname[2]}
        cd  ${portname[2]}
        cp  $(port file ${portname[0]}) 'Portfile.orig'

        #
        # splice the PortGroup command into the Portfile
        #
        portrev=$( grep -i "PortGroup.*perl5" 'Portfile.orig' | wc -l )
        if [ ${portrev} -eq 0 ]
        then
            sed -En -e "1,/^PortSystem/p" 'Portfile.orig' \
                >  'Portfile'
            echo -e "PortGroup\t\t\tperl5\t1.0" \
                >> 'Portfile'
            sed -E  -e "1,/^PortSystem/d" 'Portfile.orig' \
                >> 'Portfile'
        else
            cp 'Portfile.orig' 'Portfile'
        fi

        #
        # replace the hardcoded values with a variable
        #
        sed -i '' -E \
            -e "/^\#/!s/perl5.${version}/perl\$\{perl5.major\}/g" \
            -e "/^\#/!s/p5.${version}/p\$\{perl5.major\}/g" \
            'Portfile'

        #
        # create *.diff files for all the copied Portfiles
        #
        rm 'patch-Portfile.diff' 2>/dev/null
        diff -u \
            $( port file ${portname[0]} ) \
            'Portfile' \
        > 'patch-Portfile.diff'

        cd ${OLDPWD}
   fi
done < <( port list )



More information about the macports-dev mailing list