Version 19 (modified by dweber@…, 15 years ago) (diff) |
---|
Tips and Tricks for committers
This page provides some useful hints how to work with our infrastructure. And they can also make your work a lot easier.
Set svn properties automatically on new Portfiles
In the configuration for your Subversion client, enable automatic property setting and, for all files named Portfile, setting "svn:eol-style" to "native" and "svn:keywords" to "Id". If you are not using Subversion's own svn command-line client, see its documentation. For svn, you can make the appropriate changes by editing ~/.subversion/config
as follows:
... [miscellany] enable-auto-props = yes ... [auto-props] Portfile = svn:eol-style=native;svn:keywords=Id
Create your own users directory in the MacPorts Subversion repository
Use the Trac Browser to explore the MacPorts Subversion repository. The repository root is located at https://svn.macosforge.org/repository/macports
.
See also the explanation of local development port trees in the guide.
To create your own users directory:
svn mkdir https://svn.macports.org/repository/macports/users/<YourMacPortsUserName>
Then, checkout your user directory:
$ svn co https://svn.macports.org/repository/macports/users/<YourMacPortsUserName> ~/myports
Then edit your MacPorts sources.conf file /opt/local/etc/macports/sources.conf
to add ~/myports to the list before the main rsync source at rsync.macports.org, e.g.:
file:///Users/<YourSystemUserName>/myports
To work on a copy of a port from MacPorts trunk, use svn copy
. For example, to test changes on the cableswig port, you can copy the repository trunk (at the HEAD revision) to your new user branch:
$ svn mkdir ~/myports/devel $ svn copy https://svn.macosforge.org/repository/macports/trunk/dports/devel/cableswig ~/myports/devel/
Another option for a large branch is to copy everything at the server side, where the copy is equivalent to a unix hard link in the file system; e.g.:
$ svn mkdir https://svn.macports.org/repository/macports/users/<YourMacPortsUserName>/devel $ svn copy \ https://svn.macosforge.org/repository/macports/trunk/dports/devel/cableswig \ https://svn.macports.org/repository/macports/users/<YourMacPortsUserName>/devel/cableswig \ -m "testing modifications to cableswig" $ cd ~/myports $ svn update
After the copy, run portindex
in ~/myports
(do this any time you add a new Portfile), e.g.:
$ cd ~/myports $ svn update $ portindex $ port file cableswig
For more information about branches and merging, see http://svnbook.red-bean.com/en/1.5/svn.branchmerge.using.html
Apply patches directly from Trac URL
Installation
Add the following functions to your .bashrc
in order to apply patches directly from Trac.
function trac-get { local url=$1 local dir=$2 if [ -z $dir ]; then dir=. fi curl "$url?format=raw" --create-dirs -o $dir/$(basename $1) } function trac-patch { local cmd="" while [[ $1 == -* ]]; do if [ "$1" == "--" ]; then break fi cmd="$cmd $1" shift done if [ -z $cmd ]; then cmd="-p0" fi trac-get $1 patch $cmd < $(basename $1) }
Usage
Use like this:
- Copy the URL to the patch from the Trac ticket page
- Switch to the ports directory
$ cd $(port dir foo)
- Apply the patch
$ trac-patch http://trac.macports.org/attachment/ticket/.../Portfile.diff
You can also add options to trac-patch
which will get passed through to the patch tool. This is especially useful when the patch needs another prefix level.
$ trac-patch -p1 http://trac.macports.org/attachment/ticket/.../Portfile.diff
If you don't add any option, -p0
is used as a default. This should be the most common case.
trac-get
can also download to another directory. If the directory does not yet exist, it will be created. Just add a second parameter with the name of the directory. If you omit the second parameter, the current directory is used.
$ trac-get http://trac.macports.org/attachment/ticket/.../Portfile new-port
Do Explorative Programming in tclsh with Readline Support
tclsh does not offer readline support by itself, which is quite annoying. When writing portfiles or tinkering with changes to Macports base, I need to experiment in a Tcl shell all the time to tests small things. But for that, command history and Emacs-like navigation within the line are essential. Unfortunately tclsh does not offer this.
Solution: use port rlwrap
together with tclsh. When you invoke tclsh via rlwrap you get all the convenience you know from bash.
rlwrap tclsh
Or, put even an alias into ~/.bashrc
alias tclsh='rlwrap tclsh'
and don't think about it ever again.
If you want to test MacPorts Tcl extensions, you need to require the appropriate packages. For access to the 'strsed', 'reinplace', and other macport commands, put the following into ~/bin/macports_testing.tcl:
source /Library/Tcl/macports1.0/macports_fastload.tcl package require macports 1.0 set portarchivemode no package require port 1.0 package require Pextlib set prefix /opt/local
Then source the file in tclsh8.4 (which is the Tcl version shipped with Leopard), i.e.:
$ rlwrap tclsh8.4 % source ~/bin/macports_testing.tcl 1.0 % strsed "foo" "s/f/m/" moo %
Syntax Coloring When Editing Portfiles with Text Editors
See this page for setting up BBEdit or TextWrangler to have a MacPorts Language Module