Version 28 (modified by dweber@…, 15 years ago) (diff) |
---|
Migrating a MacPorts install to a new major OS version or CPU architecture
An installation of MacPorts and the ports installed by it are only designed to work on a single OS release and a single CPU architecture. If you upgrade to a new OS version (e.g. from Leopard to Snow Leopard) or migrate to a new machine with a different type of CPU (e.g. PowerPC to Intel), you may get lucky and have your ports keep working, but in general, things will break.
Reinstall Xcode and MacPorts
After performing either of these types of system upgrades, you will first need to install the base MacPorts system again, either from the appropriate disk image or from source. If you are upgrading from a prior version of Mac OS X, install the latest version of Xcode for your new OS. This will not be done for you automatically; Xcode is not updated by Software Update, so you must update it manually. You will find the Xcode installer on the Mac OS X installation DVD or on the Apple Developer web site. Finally, reinstall all your ports.
Update archs in macports.conf
If your macports.conf contains uncommented settings for universal_archs or build_arch, you will likely want to update them, since unlike earlier OS versions, the compiler on Snow Leopard will build for x86_64 by default on systems that support it. The default values will be fine for almost all users, so unless you know you need something different, just comment out these two lines.
Reinstall ports
To reinstall your ports:
- Save the list of installed ports:
port installed > myports.txt
- Uninstall all installed ports:
sudo port -f uninstall installed
- Clean any partially-completed builds and remove any archives:
sudo port clean --work --archive all
Note: If the 'clean' command fails with a message like "Error: Unable to open port: Could not find Portfile in /opt/local/var/macports/sources/rsync.macports.org/release/ports/<something>", run sudo port -d sync
and try again,
- Browse
myports.txt
and install the ports that you actually want to use (as opposed to those that are only needed as dependencies) one by one, remembering to specify the appropriate variants:sudo port install portname +variant1 +variant2 ...
Note that if you have specified variants which are not the default, you may need to install ports in an order other than the alphabetical order recorded in myports.txt
.
Automatically reinstall ports (EXPERIMENTAL)
A script has been written to automate Step 4 above, though it is still experimental. If it fails, you will just have to do it manually.
To use it, you will first need to run steps 1-3 as described above. Then:
- Run these commands to download and execute the restore_ports script. (If you installed MacPorts from source and put its Tcl package somewhere other than /Library/Tcl, then you'll need to use the -t option when you run restore_ports.tcl; see
./restore_ports.tcl -h
.curl -O http://svn.macports.org/repository/macports/users/jmr/restore_ports/restore_ports.tcl chmod +x restore_ports.tcl sudo ./restore_ports.tcl myports.txt
Convert myports.txt into an install script (EXPERIMENTAL)
These sed scripts will get close to coverting myports.txt into an installation script. It will not arrange the order of the installation according to the dependency tree and it cannot check the most recent variants against those of the installed ports. It will strip away any variants with '+darwin*', '+macosx' or '+i386', because any platform or architecture variants should be determined automatically. The myports.bash
file should be reviewed carefully and the variant specifications should be compared with the output from port variants <aPort>
. Some ports may have a long list of +variant options, but they might all be replaced with a +huge
variant. Also look for duplicate ports with different versions, some of them might not be required (e.g., docbook-xml-*).
The '&& \'
at the end of each command line will effectively create one long command line, with contingent installation of successive ports; should any one port install fail, no others will run (e.g., try ls abc.txt && cat abc.txt
where no file abc.txt exists). When any one of the ports fails to install, the myports.bash
script can be edited to remove all the prior ports that are already installed.
$ cat myports.txt | /usr/bin/sed \ -e 's/@[._0-9a-zA-Z\-]*+/+/' \ -e 's/@[._0-9a-zA-Z \-]*(active)//' \ -e 's/(active)//' \ -e 's/+/ +/g' \ -e 's/[+]darwin[_i0-9]*//g' \ -e 's/+macosx//g' \ -e 's/+i386//g' \ -e 's/+gcc[0-9]*//' \ -e 's/$/ \&\& \\/' \ -e 's/^./sudo port install /' \ -e 's/.*currently installed:.*/#!\/bin\/bash/' \ > myports.bash $ chmod +x myports.bash $ # Remove the '&& \' from the last line of the file. $ ./myports.bash
This is another possibility, which will list all the ports on one sudo port install
command, rather than a separate command for each port. In a perfect world (ha! ha! ha!), this port command might resolve the dependency tree and arrange the correct installation order, but don't hold your breath for that ;-)
$ cat myports.txt | /usr/bin/sed \ -e 's/@[._0-9a-zA-Z\-]*+/+/' \ -e 's/@[._0-9a-zA-Z \-]*(active)//' \ -e 's/(active)//' \ -e 's/+/ +/g' \ -e 's/[+]darwin[_i0-9]*//g' \ -e 's/+macosx//g' \ -e 's/+i386//g' \ -e 's/+gcc[0-9]*//' \ -e '$q;s/$/ \\/' \ -e 's/.*currently installed:.*/#!\/bin\/bash/' \ -e '/\bin\/bash/ a\ sudo port install \\ ' > myports.bash $ chmod +x myports.bash $ ./myports.bash