category_name=blog%2Fscm-tools
Git Cheat Sheet
March 19, 2011 | Comments Off
After watching from the side lines for a few years as git gathered a following I finally made the switch out of necessity as a result of doing more projects in Ruby on Rails. The projects I work on are all hosted in the cloud (Heroku, Engine Yard, or directly on Amazon EC2). Many of the tools I use support direct deployment from git. So I now find myself migrating all of my projects from subversion to git.
I tend to write down a lot of notes as I learn a new technology or tool. The migration to git is no different. What is different is how GitHub (the hosted git solution I am using) makes it possible to record just about anything in what they call a gist. This is turning out to be a very useful tool for me. It is a great place to store little bits of code or notes.
Perforce launchd configuration on Mac OS Tiger (10.4)
February 20, 2006 | Comments Off
Mac OS Tiger introduced a new daemon control application called launchd. This application is supposed to take the place of rc scripts, xinitd scripts, and cron jobs. The launchd process is configured using XML text files that conform to the Apple plist DTD. Perforce does not provide a sample launchd configuration file for the p4d daemon.
The following is an example of how I configured p4d to run on my Tiger server. Be sure to edit it appropriately for your server configuration.
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple Computer//DTD PLIST 1.0//EN"
"http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>GroupName</key>
<string>perforce</string>
<key>Label</key>
<string>com.perforce.p4d</string>
<key>OnDemand</key>
<false/>
<key>Program</key>
<string>/usr/local/bin/p4d</string>
<key>ProgramArguments</key>
<array>
<string>/usr/local/bin/p4d</string>
<string>-r</string>
<string>/Depot</string>
<string>-p</string>
<string>1666</string>
<string>-J</string>
<string>/Depot/journal</string>
<string>-L</string>
<string>/Depot/p4err</string>
</array>
<key>RunAtLoad</key>
<true/>
<key>ServiceDescription</key>
<string>Perforce Daemon</string>
<key>StandardErrorPath</key>
<string>/Depot/p4d.stderr.txt</string>
<key>StandardOutPath</key>
<string>/Depot/p4d.stdout.txt</string>
<key>UserName</key>
<string>p4admin</string>
<key>WorkingDirectory</key>
<string>/Depot</string>
</dict>
</plist>
I place this file in the directory /Library/LaunchDaemons, and is named perforce.plist. The permissions look like this:
-rw-r----- 1 root wheel 1012 Jan 5 22:21 perforce.plist
You will need to tell launchd about the new plist by running:
$ sudo launchctl load perforce.plist
from the /Library/LaunchDaemons directory. To confirm that the new plist has been loaded correctly you can run this command:
$ sudo launchctl list
The list produced should contain a line that says com.perforce.p4d. That is the name given to the new plist for the p4d application.
At this point you should see a p4d process if you run
$ ps -aux
There should only be one of this process running, and it is the daemon controlling your Perforce server installation.
Working with Multiple Depots and/or Client Workspaces
January 10, 2006 | Comments Off
A typical configuration of Perforce is handled by setting the P4PORT, P4USER and P4CLIENT environment variables. These variables point at the desired depot, identify the user and select a client workspace.
To quickly switch between different depots or client workspaces I make sure the P4CONFIG environment variable specifies the name of a configuration file. On my Windows XP system this is done by running the command p4 set P4CONFIG=p4config.txt. The p4 command will recognize that this variable is set and will attempt to locate a configuration file each time it is launched. The search begins in the current directory and searches all parent directories until it reaches the root directory for the current drive.
I place a p4config.txt file in each workspace root directory. The file is formatted as a series of lines where each line contains name=value. For example, one of my p4config.txt files looks like this:
P4CLIENT=bsmith_pc
P4EDITOR=C:\Program Files\Vim\vim63\vim.exe
P4PORT=perforce.mysite.com:1666
P4USER=bsmith
My installation of Perforce is configured to use the ticket-based authentication system so I can login to the depot by issuing the p4 login command from a directory below the workspace root. I will be prompted for the password and a ticket will be issued. From this point on I can simply issue p4 commands and the appropriate depot and workspace will be automatically selected.
This technique can be applied to multiple client workspaces at the same time by setting up multiple p4config.txt files and logging into each depot. Then it is a simple matter of changing directories in my command window to switch between depots and/or client workspaces.
On Unix and Mac OS X I set P4CONFIG to point at a file called @.p4config@. The file contents are similar to the Windows example earlier in this post.
Configuring a Perforce Depot on Mac OS X 10.4 (Tiger) Server
January 6, 2006 | Comments Off
Download the latest version of Perforce from their web site (http://www.perforce.com). To setup the server you really only need to download the command-line tools p4 and p4d. Here are links to the versions I used when setting up my server in January 2006.
http://www.perforce.com/downloads/perforce/r05.2/bin.macosx102ppc/p4
http://www.perforce.com/downloads/perforce/r05.2/bin.darwin60ppc/p4d
You may also wish to install the graphical tools P4V and P4Merge. These are part of a single disk image.
http://www.perforce.com/downloads/perforce/r05.2/bin.macosx102ppc/P4V.dmg
Perforce recommends that p4d not be run as root so I created a new user account called p4admin. I also created a new group called perforce. I decided to install the software in the /usr/local/bin directory and to place the depot on a separate drive that is mounted under the /Depot directory.
Automatically starting p4d when the system boots is handled through the utility launchd. Configuring this is done by editing a plist file and then loading it with the utility launchctl. Attached is a copy of the plist file I used. I placed the plist file in the directory /Library/LaunchDaemons. The file is called perforce.plist.
Once the file exists use the launchctl application to tell the launchd program about it. The command I used was:
$ sudo launchctl load /Library/LaunchDaemons/perforce.plist
If you make changes to the plist file and want to reload it use the command below to unload the existing one. Then repeat the above command to load the changed plist.
$ sudo launchctl unload /Library/LaunchDaemons/perforce.plist
Perforce recommends setting up a regular job to create a checkpoint and a backup of the depot. The script p4backup illustrates how to handle this. Use the p4backup.plist file to teach launchd about this script so it will run on a regular basis. On my server I run this script every night. The backup is done using a copy from the /Depot directory to the /Depot.Backup directory, which is on a separate filesystem.
perforce.plist GroupName perforce Label com.perforce.p4d OnDemand Program /usr/local/bin/p4d ProgramArguments /usr/local/bin/p4d -r /Depot -p 1666 -J /Depot/journal -L /Depot/p4err RunAtLoad ServiceDescription Perforce Daemon StandardErrorPath /Depot/p4d.stderr.txt StandardOutPath /Depot/p4d.stdout.txt UserName p4admin WorkingDirectory /Depot



