Why git is Better Than Whatever You’re Using Now

Just found this interesting link:

Why Git is Better than X

Answers a lot of questions about why Git is taking over the world.

Setting up Perforce command line

Set up your client (Mac OS X)

If you’ve been following along, you’re running a publicly accessible server

To set up the client on your local machine (mine’s OS X).

Add the following lines to the end of .bash_profile.

# Perforce Settings
export P4PORT=yourdomain.com:1666
export P4CLIENT=a_workspace_you_ve_set_up
export P4USER=your_user_name

Quit and restart terminal and type p4.

You shouldn’t get any errors, just a helpful list of commands you might want to use.

Installing Perforce on Red Hat Linux — The Gory Details

Do I Have A Pain In My Ass Yet?ere does not seem to be an RPMish installer for Perforce for Red Hat Linux.

I started following the instructions at Installing PerForce on Ubuntu but ran into some incompatibilities (apt-get not existing on Red Hat, for example).

Also, as I was following along, modifying the instructions along the way to adapt to Red Hat, I realized that some of the steps are out of order.

I’m just going to create my own instructions for Red Hat, based somewhat on the Ubuntu ones, but with my own improvements and adaptations. Hopefully it will be of some use to someone in the same boat down the road (maybe even me!). I have modified the original instructions enough that I’m not going to reference them or comment on the differences.

You just want to get Perforce installed on Red Hat Linux, right? Good, me too!

There was an installation script in the original post that I’ve saved and if I ever have to do this again, I’ll modify it and post a completed script that will work on Red Hat. For now, this is enough; I have work to do!

Configure Perforce

This information is a reprise of the Admin Guide along with some hard-won details and improvements.

1. Download the `daemon` utility. This utility allows `p4d` to be run by the `perforce` user instead of `root`. I use /usr/local/src for the source of anything I install on the server so here’s what I did. If you’re not logged in as root, put a `sudo` ahead of each of the commands below or `su’ in first.

cd /usr/local/src

wget http://libslack.org/daemon/download/daemon-0.6.3.tar.gz
tar zxvf daemon-0.6.3.tar.gz
cd daemon-0.6.3.tar.gz
./configure
make install

2. Download the PerForce daemon file `p4d` and client `p4` files directly into /usr/local/bin. These files are for Linux installs using the 2.6 kernel version, adjust if you’re still running a 2.4.x kernel:

cd /usr/local/bin
wget http://www.perforce.com/downloads/perforce/r07.3/bin.linux26x86/p4d
wget http://www.perforce.com/downloads/perforce/r07.3/bin.linux26x86/p4

3. Make the `p4d` and `p4` files executable.

chmod +x p4d p4

4. Create a group for perforce files and a user for admin work:

groupadd p4admin
useradd -m -g p4admin perforce

5. Use `visudo` to give the perforce user account the ability to use `sudo`. Add the following line at the end o f the file. NOTE: visudo on Red Hat doesn’t actually use `vi` to do the work, it uses pico so don’t expect `vi` commands to work. Stupid Red Hat. Stupid pico.

perforce ALL = ALL

6. Log off your default user account.
7. Log in using the `perforce` account.
8. Create a directory to hold the repository. I based mine in /var/www.

sudo mkdir /var/www/perforce
sudo chown perforce:p4admin /var/perforce

9. Create a directory to hold Perforce log files under /var/log.

sudo mkdir /var/log/perforce
sudo chown perforce:p4admin /var/log/perforce

A. Add the following lines to the end of /etc/profile. These settings will be used by local client programs run on the Linux server – not by the Perforce server.

# Perforce Settings
export P4JOURNAL=/var/log/perforce/journal
export P4LOG=/var/log/perforce/p4err
export P4PORT=localhost:1666
export P4ROOT=/var/www/perforce
export P4USER=perforce

B. Load the Perforce settings.

source /etc/profile

Setup Perforce As Bootup Service

1. Change to the initialization control directory.

cd /etc/init.d

2. Create the Perforce control script using `sudo vi perforce`.

#!/bin/sh -e

export P4JOURNAL=/var/log/perforce/journal
export P4LOG=/var/log/perforce/p4err
export P4ROOT=/perforce_depot
export P4PORT=1666

PATH=”/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin”

p4start=”p4d -d”
p4stop=”p4 admin stop”
p4user=perforce

case “$1″ in
start)

# NOTE: in original, haven’t found RedHat equiv or source to include
# Haven’t found . /lib/lsb/init-functions
# log_action_begin_msg “Starting Perforce Server”
daemon -u $p4user $p4start;
;;

stop)
# see above
# log_action_begin_msg “Stopping Perforce Server”
daemon -u $p4user $p4stop;
;;

restart)
daemon -u $p4user $p4stop
daemon -u $p4user $p4start
;;

*)
echo “Usage: /etc/init.d/perforce (start|stop|restart)”
exit 1
;;

esac

exit 0

3. Goto your home directory then use the control script to start the Perforce server.

cd ~
sudo /etc/init.d/perforce start

4. Make sure it actually started

ps aux | grep perforce

I get:
userx@wonky [~]# ps aux | grep perforce
perforce 3669 0.0 0.0 1736 536 ? Ss 20:27 0:00 daemon -u perforce p4d -d
perforce 3672 0.0 0.0 5076 1492 ? S 20:27 0:00 p4d
userx 3689 0.0 0.0 1584 492 pts/0 S+ 20:27 0:00 grep perforce

14. Create a Perforce group to limit resource usage using:

sudo p4 group developers

This, on Red Hat, opens `pico` where you’re editing a text file to set the following values. See the Perforce site for more information.

Group: developers
MaxResults: 50000
MaxScanRows: 250000
MaxLocktime: 30000
Timeout: 4320
Subgroups:
Users: developer

To which perforce responds:
userx@wonky [~]# sudo p4 group developers
Group developers created.

5. Use the control script to restart the Perforce server.

sudo /etc/init.d/perforce restart

Housekeeping

Before Perforce can be used by a team there are two housekeeping task that need to be done – creating the journal and closing a security hole.

If you’ve been following along, the p4d server should already be started and all of your environment variables should be set properly.

1. Create the journal.
sudo p4d –jc
userx@wonky [~]# p4d -jc
Checkpointing to checkpoint.1...
Rotating /var/log/perforce/journal to journal.0...

2. Open the firewall.
We use the `apf` firewall, so the only thing left to do is to open the firewall for our chosen port. Edit /etc/apf/conf.apf and modify EG_TCP_CPORTS and IG_TCP_CPORTS to add our chosen port:

# Common egress (outbound) TCP ports
EG_TCP_CPORTS=”…,1666

# Common ingress (inbound) TCP ports
IG_TCP_CPORTS=”…,1666,…:”

Then restart the apf server, flushing and reloading firewall rules:

apf -rl --restart

3. NOTE: the original instructions suggest running p4 protect.
I’m not doing that since I don’t know what it does and I’m delegating further Perforce setup to others on my team.

4. Here’s my TODO list:

  • Is this secure? Are passwords etc. sent in the clear?
  • If not, is there a way to make it so?

5. According to the original blogger, these items remained on his “TODO” list. I leave them here in case I blog them later when I find out what they mean ;-) .
TODO

  • Journalling
  • checkpointing
  • backups

Resources

  • Perforce’s public depot
  • http://kb.perforce.com/AdminTasks/InstallAndUpgrade/RunningAPerf..InetdOnUnix How to start `p4d` via `inetd` instead of a startup script.

Installing Perforce

One good resource, though since I’m not installing on the same Linux version, the instructions are coming up a bit short:

Installing PerForce on Ubuntu

I’m installing on RedHat and so, `sudo apt-get daemon` doesn’t work.

Since ‘daemon’ is such a common word in the Google lexicon, finding the app to which they were referring was a bitch.

Sorry, I don’t know the search that I used to find it — I was in search mode, not blogging mode.

Anyway, the utility is “daemon”.

It allows you to daemonize any process while specifying the user under which to run and various other things. Since p4d itself has no support for running as a specific user, and since they specifically recommend running p4d as an ‘unpriviliged’ user, something had to be done.

More tomorrow when I finish the setup.

Perforce — IDC, PAY for Version Control?!

Update: please see my Git rants to see where we’re at now.

We’re starting a new software project here at IDC and some of the developers we’ve hired have strongly recommended using use Perforce. They also have recommended ExtraView for bug tracking which integrates with Perforce.

While it’s not against my religion to use expensive, proprietary software for business critical functions, especially server type functions, and especially when pricing is per user, it’s pretty damn close.

We’ve been using Subversion around here for a few years and, frankly, other than for storing revisions, it pretty much sucks.

The way it handles conflicts is a complete pain in the ass that always leaves me thinking “there’s got to be a better way”, pulling out older versions always sends me back to the manual, the monolithic numbering scheme has always given me agita, and God help you if you’ve got to merge a branch (or branches!) back to the trunk…the list goes on and on.

So, much as it pains me to face an $800/user licensing fee, the 2 user, 5 client workspaces limitation on the free, unlicensed version of Perforce has sucked me in.

ExtraView also has a limited, hosted version that will allow us to do this project and see how things go.

Who knows? We may actually have to pay for these things if they work well enough.

Next entry — my trials and tribulations getting it set up on one of our public-facing servers.