| 1 | [wiki:howto <- Back to the HOWTO section] |
| 2 | |
| 3 | = How to build Avoid master_sites Redirects = |
| 4 | |
| 5 | * Audience: Portfile authors |
| 6 | * Requires: MacPorts >=2.0 |
| 7 | |
| 8 | == Introduction == |
| 9 | |
| 10 | In order to be a good 'Net citizen, it is worthwhile to minimize the load on other's servers. One simple technique is to specify the `master_sites` parameter as specifically as possible so that the other side does not have to supply redirects in order to serve the file we want. This how-to currently addresses only SourceForge. |
| 11 | |
| 12 | == SourceForge == |
| 13 | |
| 14 | Hopefully, the following example, using mediainfo version 0.7.60, will illuminate the process. The SourceForge home page for mediainfo is [[http://mediainfo.sourceforge.net]]. Initially, just specifying `'master_sites sourceforge'` in the portfile under development worked to retrieve the distfile. The log for `'port fetch'` showed: |
| 15 | |
| 16 | {{{ |
| 17 | DEBUG: Executing org.macports.fetch (mediainfo) |
| 18 | ---> MediaInfo_CLI_0.7.60_GNU_FromSource.tar.bz2 doesn't seem to exist in /opt/local/var/macports/distfiles/mediainfo |
| 19 | ---> Attempting to fetch MediaInfo_CLI_0.7.60_GNU_FromSource.tar.bz2 from http://iweb.dl.sourceforge.net/mediainfo |
| 20 | }}} |
| 21 | |
| 22 | Use 'curl -IL !http://iweb.dl.sourceforge.net/mediainfo/MediaInfo_CLI_0.7.60_GNU_FromSource.tar.bz2' to check for redirects. In this case the output indicated redirects to a final address of: |
| 23 | |
| 24 | {{{ |
| 25 | Location: http://voxel.dl.sourceforge.net/project/mediainfo/binary/mediainfo/0.7.60/MediaInfo_CLI_0.7.60_GNU_FromSource.tar.bz2 |
| 26 | }}} |
| 27 | |
| 28 | To improve the `master_sites` parameter, extract the bit: `project/mediainfo/binary/mediainfo/0.7.60` (and replace "0.7.60"--the version number in this case--with ${version}). Thus `'master_sites sourceforge:project/mediainfo/binary/mediainfo/${version}'`. |
| 29 | |
| 30 | Pat yourself on the back--you're done! |
| 31 | |
| 32 | |
| 33 | |
| 34 | [wiki:howto <- Back to the HOWTO section] |