22 | | 1. [=#ports] **Reinstall ports.** |
23 | | {{{ |
24 | | # If there is an argument, then don't preserve 'requested' flags. |
25 | | function reinstallPorts() { |
26 | | local -r dontPreserveRequestedFlags=$1 |
27 | | set -e |
28 | | # This will fail if xcode-select needs to be run. |
29 | | clang --version |
30 | | # Save the list of installed ports. |
| 22 | 1. [=#ports] **Reinstall ports.** To reinstall your ports: |
| 23 | a. Save the list of installed ports: |
| 24 | {{{ |
32 | | # Preserve the requested flags (optional). |
33 | | if [[ ! $dontPreserveRequestedFlags ]] ; then |
34 | | port echo requested | cut -d ' ' -f 1 > requested.txt |
35 | | fi |
36 | | # Download the restore_ports script. |
| 26 | }}} |
| 27 | a. (optional) Save the list of requested ports: |
| 28 | {{{ |
| 29 | port echo requested | cut -d ' ' -f 1 > requested.txt |
| 30 | }}} |
| 31 | a. Uninstall all installed ports: |
| 32 | {{{ |
| 33 | sudo port -f uninstall installed |
| 34 | }}} |
| 35 | a. Clean any partially-completed builds: |
| 36 | {{{ |
| 37 | sudo port clean all |
| 38 | }}} |
| 39 | a. Download and execute the restore_ports script. (If you installed MacPorts from source and used a custom prefix, then you'll need to use the -p option when you run restore_ports.tcl; see `./restore_ports.tcl -h`.) |
| 40 | {{{ |
39 | | sudo bash << EOF |
40 | | # Start with the latest data. |
41 | | port selfupdate |
42 | | # Uninstall all installed ports. |
43 | | port -f uninstall installed |
44 | | # Clean any partially-completed builds. |
45 | | port clean all |
46 | | # Change this if your installation is somewhere else. |
47 | | # (There should be a way to get the port command to report this.) |
48 | | MACPORTS_HOME=/opt/local |
49 | | # Execute the restore_ports script. |
50 | | ./restore_ports.tcl -p $MACPORTS_HOME myports.txt |
51 | | if [[ ! $dontPreserveRequestedFlags ]] ; then |
52 | | port unsetrequested installed |
53 | | < requested.txt xargs port setrequested |
54 | | fi |
55 | | EOF |
56 | | } |
57 | | }}} |
| 43 | sudo ./restore_ports.tcl myports.txt |
| 44 | }}} |
| 45 | a. (optional) Restore requested status: |
| 46 | If you saved the list of requested ports, you can now restore the requested flags for your newly installed ports to their former states. |
| 47 | {{{ |
| 48 | sudo port unsetrequested installed |
| 49 | < requested.txt xargs sudo port setrequested |
| 50 | }}} |