| 1 | #!/bin/bash |
|---|
| 2 | # |
|---|
| 3 | # Copyright (c) 2007 Juan Manuel Palacios <jmpp@macports.org>, The MacPorts Project. |
|---|
| 4 | # All rights reserved. |
|---|
| 5 | # |
|---|
| 6 | # Redistribution and use in source and binary forms, with or without |
|---|
| 7 | # modification, are permitted provided that the following conditions |
|---|
| 8 | # are met: |
|---|
| 9 | # 1. Redistributions of source code must retain the above copyright |
|---|
| 10 | # notice, this list of conditions and the following disclaimer. |
|---|
| 11 | # 2. Redistributions in binary form must reproduce the above copyright |
|---|
| 12 | # notice, this list of conditions and the following disclaimer in the |
|---|
| 13 | # documentation and/or other materials provided with the distribution. |
|---|
| 14 | # 3. Neither the name of MacPorts Team nor the names of its contributors |
|---|
| 15 | # may be used to endorse or promote products derived from this software |
|---|
| 16 | # without specific prior written permission. |
|---|
| 17 | # |
|---|
| 18 | # THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" |
|---|
| 19 | # AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE |
|---|
| 20 | # IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE |
|---|
| 21 | # ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE |
|---|
| 22 | # LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR |
|---|
| 23 | # CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF |
|---|
| 24 | # SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS |
|---|
| 25 | # INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN |
|---|
| 26 | # CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) |
|---|
| 27 | # ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE |
|---|
| 28 | # POSSIBILITY OF SUCH DAMAGE. |
|---|
| 29 | |
|---|
| 30 | |
|---|
| 31 | ### |
|---|
| 32 | # dp2mp-move upgrading facility for users installing MacPorts through the pkg installer in the dmg. |
|---|
| 33 | # This script is meant to run as the preflight of the installer, to upgrade an existing MacPorts |
|---|
| 34 | # installation to the MacPorts namespace in the same way the "upgrade" target in base/Makefile |
|---|
| 35 | # does for users installing from source or selfupdate. |
|---|
| 36 | # preflight |
|---|
| 37 | # $Id$ |
|---|
| 38 | ### |
|---|
| 39 | |
|---|
| 40 | |
|---|
| 41 | PATH=/bin:/sbin:/usr/bin:/usr/sbin |
|---|
| 42 | UPGRADECHECK=/opt/local/var/macports/.mprename |
|---|
| 43 | |
|---|
| 44 | |
|---|
| 45 | [ ! -d /Library/Tcl/darwinports1.0 ] || rm -rf /Library/Tcl/darwinports1.0 |
|---|
| 46 | |
|---|
| 47 | [ ! -d /opt/local/share/darwinports ] || rm -rf /opt/local/share/darwinports |
|---|
| 48 | |
|---|
| 49 | [ ! -f /opt/local/etc/ports/dp_version ] || rm -vf /opt/local/etc/ports/dp_version |
|---|
| 50 | |
|---|
| 51 | [ ! -f /opt/local/share/man/man5/ports.conf.5 ] || rm -vf /opt/local/share/man/man5/ports.conf.5 |
|---|
| 52 | |
|---|
| 53 | [ ! -d /opt/local/etc/ports ] || mv -v /opt/local/etc/ports /opt/local/etc/macports |
|---|
| 54 | |
|---|
| 55 | [ -d /opt/local/var/macports ] || mkdir -vp /opt/local/var/macports |
|---|
| 56 | for dir in distfiles packages receipts software; do |
|---|
| 57 | [ ! -d /opt/local/var/db/dports/${dir} ] || mv -v /opt/local/var/db/dports/${dir} /opt/local/var/macports |
|---|
| 58 | done |
|---|
| 59 | |
|---|
| 60 | [ ! -d /opt/local/var/db/dports/sources/rsync.rsync.darwinports.org_dpupdate_dports ] || { |
|---|
| 61 | mkdir -vp /opt/local/var/macports/sources/rsync.macports.org/release && mv -v \ |
|---|
| 62 | /opt/local/var/db/dports/sources/rsync.rsync.darwinports.org_dpupdate_dports /opt/local/var/macports/sources/rsync.macports.org/release/ports |
|---|
| 63 | } |
|---|
| 64 | |
|---|
| 65 | for receipt in /opt/local/var/macports/receipts/*/*/receipt.bz2; do |
|---|
| 66 | [ ! \( -f ${receipt} -a ! -f ${receipt}.mpsaved \) ] || { cp -v ${receipt} ${receipt}.mpsaved && { |
|---|
| 67 | bzip2 -q -dc ${receipt} | sed 's/db\/dports/macports/g' | bzip2 -q -zf > ${receipt}.new |
|---|
| 68 | } && mv -v ${receipt}.new ${receipt} |
|---|
| 69 | }; done |
|---|
| 70 | |
|---|
| 71 | [ ! \( -f /opt/local/etc/macports/ports.conf -a ! -f ${UPGRADECHECK} \) ] || { |
|---|
| 72 | mv -v /opt/local/etc/macports/ports.conf /opt/local/etc/macports/macports.conf.mpsaved |
|---|
| 73 | sed 's/etc\/ports/etc\/macports/g' /opt/local/etc/macports/macports.conf.mpsaved > /opt/local/etc/macports/macports.conf.tmp && \ |
|---|
| 74 | mv -v /opt/local/etc/macports/macports.conf.tmp /opt/local/etc/macports/macports.conf |
|---|
| 75 | sed 's/db\/dports/macports/g' /opt/local/etc/macports/macports.conf > /opt/local/etc//macports/macports.conf.tmp && \ |
|---|
| 76 | mv -v /opt/local/etc//macports/macports.conf.tmp /opt/local/etc/macports/macports.conf |
|---|
| 77 | sed 's/darwinports/macports/g' /opt/local/etc/macports/macports.conf > /opt/local/etc/macports/macports.conf.tmp && \ |
|---|
| 78 | mv -v /opt/local/etc/macports/macports.conf.tmp /opt/local/etc/macports/macports.conf |
|---|
| 79 | sed 's/dpupdate1\/base/release\/base/g' /opt/local/etc/macports/macports.conf > /opt/local/etc/macports/macports.conf.tmp && \ |
|---|
| 80 | mv -v /opt/local/etc/macports/macports.conf.tmp /opt/local/etc/macports/macports.conf |
|---|
| 81 | sed 's/dpupdate\/base\/\{0,1\}/trunk\/base\//g' /opt/local/etc/macports/macports.conf > /opt/local/etc/macports/macports.conf.tmp && \ |
|---|
| 82 | mv -v /opt/local/etc/macports/macports.conf.tmp /opt/local/etc/macports/macports.conf |
|---|
| 83 | sed '/^rsync_options/s/"\(.*\)"/\1/' /opt/local/etc/macports/macports.conf > /opt/local/etc/macports/macports.conf.tmp && \ |
|---|
| 84 | mv -v /opt/local/etc/macports/macports.conf.tmp /opt/local/etc/macports/macports.conf |
|---|
| 85 | sed 's/ --delete / /' /opt/local/etc/macports/macports.conf > /opt/local/etc/macports/macports.conf.tmp && \ |
|---|
| 86 | mv -v /opt/local/etc/macports/macports.conf.tmp /opt/local/etc/macports/macports.conf |
|---|
| 87 | sed 's/ ports.conf(5)/ macports.conf(5)/g' /opt/local/etc/macports/macports.conf > /opt/local/etc/macports/macports.conf.tmp && \ |
|---|
| 88 | mv -v /opt/local/etc/macports/macports.conf.tmp /opt/local/etc/macports/macports.conf |
|---|
| 89 | } |
|---|
| 90 | |
|---|
| 91 | [ ! \( -f /opt/local/etc/macports/sources.conf -a ! -f ${UPGRADECHECK} \) ] || { |
|---|
| 92 | cp -v /opt/local/etc/macports/sources.conf /opt/local/etc/macports/sources.conf.mpsaved |
|---|
| 93 | sed 's/darwinports/macports/g' /opt/local/etc/macports/sources.conf > /opt/local/etc/macports/sources.conf.tmp && \ |
|---|
| 94 | mv -v /opt/local/etc/macports/sources.conf.tmp /opt/local/etc/macports/sources.conf |
|---|
| 95 | sed 's/dpupdate\/dports/release\/ports\//g' /opt/local/etc/macports/sources.conf > /opt/local/etc/macports/sources.conf.tmp && \ |
|---|
| 96 | mv -v /opt/local/etc/macports/sources.conf.tmp /opt/local/etc/macports/sources.conf |
|---|
| 97 | } |
|---|
| 98 | |
|---|
| 99 | [ ! \( -f "${HOME}/.macports/ports.conf" -a ! -f ${UPGRADECHECK} \) ] || { |
|---|
| 100 | mv -v "${HOME}/.macports/ports.conf" "${HOME}/.macports/macports.conf.mpsaved" |
|---|
| 101 | sed 's/etc\/ports/etc\/macports/g' "${HOME}/.macports/macports.conf.mpsaved" > "${HOME}/.macports/macports.conf.tmp" && \ |
|---|
| 102 | mv -v "${HOME}/.macports/macports.conf.tmp" "${HOME}/.macports/macports.conf" |
|---|
| 103 | sed 's/db\/dports/macports/g' "${HOME}/.macports/macports.conf" > "${HOME}/.macports/macports.conf.tmp" && \ |
|---|
| 104 | mv -v "${HOME}/.macports/macports.conf.tmp" "${HOME}/.macports/macports.conf" |
|---|
| 105 | sed 's/darwinports/macports/g' "${HOME}/.macports/macports.conf" > "${HOME}/.macports/macports.conf.tmp" && \ |
|---|
| 106 | mv -v "${HOME}/.macports/macports.conf.tmp" "${HOME}/.macports/macports.conf" |
|---|
| 107 | sed 's/dpupdate1\/base/release\/base/g' "${HOME}/.macports/macports.conf" > "${HOME}/.macports/macports.conf.tmp" && \ |
|---|
| 108 | mv -v "${HOME}/.macports/macports.conf.tmp" "${HOME}/.macports/macports.conf" |
|---|
| 109 | sed 's/dpupdate\/base\/\{0,1\}/trunk\/base\//g' "${HOME}/.macports/macports.conf" > "${HOME}/.macports/macports.conf.tmp" && \ |
|---|
| 110 | mv -v "${HOME}/.macports/macports.conf.tmp" "${HOME}/.macports/macports.conf" |
|---|
| 111 | sed '/^rsync_options/s/"\(.*\)"/\1/' "${HOME}/.macports/macports.conf" > "${HOME}/.macports/macports.conf.tmp" && \ |
|---|
| 112 | mv -v "${HOME}/.macports/macports.conf.tmp" "${HOME}/.macports/macports.conf" |
|---|
| 113 | sed 's/ --delete / /' "${HOME}/.macports/macports.conf" > "${HOME}/.macports/macports.conf.tmp" && \ |
|---|
| 114 | mv -v "${HOME}/.macports/macports.conf.tmp" "${HOME}/.macports/macports.conf" |
|---|
| 115 | sed 's/ ports.conf(5)/ macports.conf(5)/g' "${HOME}/.macports/macports.conf" > "${HOME}/.macports/macports.conf.tmp" && \ |
|---|
| 116 | mv -v "${HOME}/.macports/macports.conf.tmp" "${HOME}/.macports/macports.conf" |
|---|
| 117 | } |
|---|
| 118 | |
|---|
| 119 | |
|---|
| 120 | [ ! -f /opt/local/etc/macports/mp_version ] || rm -vf /opt/local/etc/macports/mp_version |
|---|
| 121 | |
|---|
| 122 | |
|---|
| 123 | [ -f ${UPGRADECHECK} ] || { |
|---|
| 124 | echo -e "\nMacPorts installation successfully upgraded from the old DarwinPorts namespace!\n" |
|---|
| 125 | echo "MacPorts rename update done!" > ${UPGRADECHECK} |
|---|
| 126 | } |
|---|