Category Archives: OS X

Setting up Perforce Helix Core Service on OS X High Sierra

Here is a guide about how to start Perforce Helix Core as a global daemon on OS X High Sierra, running under a separate user called perforce. By the nature of this guide, some of it applies directly to my own system; readers are expected to identify those instances and change appropriately.

First, we download the p4d and p4 executable files. Some people may prefer the visual client, but this guide is focused on the command line.

Then we install the binaries into /usr/local/sbin and /usr/local/bin, respectively.

Install the server binary.

  sudo mkdir -p /usr/local/sbin
  sudo cp p4d /usr/local/sbin
  sudo chown root:wheel /usr/local/sbin/p4d
  sudo chmod 555 /usr/local/sbin/p4d

And install the client binary.

  sudo mkdir -p /usrl/local/bin
  sudo cp p4 /usr/local/bin/
  sudo chown root:wheel /usr/local/bin/p4
  sudo chmod 555 /usr/local/bin/p4

We’ll create a group and user called perforce, and store the version control database in /usr/local/var/perforce with the log in /usr/local/var/log/p4d.log.

Here I’ve carefully chosen the unique id 268 for both the group and user because it’s free on my system. To see all group ids in use on a system, this one liner can be used,

  for f in `dscl . -list /Groups`; do dscl . -read /Groups/$f; \
      done | grep PrimaryGroupID | sort -k2 -n

and to see all the user ids, this one liner can be used.

  for f in `dscl . -list /Users`; do dscl . -read /Users/$f; \
      done | grep UniqueID | sort -k2 -n

We create the group with

  sudo dscl . -create /Groups/perforce
  sudo dscl . -create /Groups/perforce PrimaryGroupID 268
  sudo dscl . -create /Groups/perforce Password '*'

and then we create the user with

  sudo dscl . -create /Users/perforce      
  sudo dscl . -create /Users/perforce UniqueID 268
  sudo dscl . -create /Users/perforce UserShell /usr/bin/false
  sudo dscl . -create /Users/perforce RealName 'Perforce Server'
  sudo dscl . -create /Users/perforce NFSHomeDirectory /usr/local/var/perforce
  sudo dscl . -create /Users/perforce PrimaryGroupID 268
  sudo dscl . -create /Users/perforce Password '*'

Then we create the log file and database directory

  sudo mkdir -p /usr/local/var/log
  sudo touch    /usr/local/var/log/p4d.log
  sudo mkdir -p /usr/local/var/perforce

and set the ownership to the new user and group.

  sudo chown perforce:perforce /usr/local/var/perforce
  sudo chown perforce:perforce /usr/local/var/log/p4d.log 

Then we create the launch daemon description file.

  sudo nano /Library/LaunchDaemons/com.perforce.plist

and add the following.

  <?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>Debug</key>
      <false/>
      <key>Label</key>
      <string>com.perforce</string>
      <key>OnDemand</key>
      <false/>
      <key>Program</key>
      <string>/usr/local/sbin/p4d</string>
      <key>ProgramArguments</key>
      <array>
        <string>/usr/local/sbin/p4d</string>
      </array>
      <key>EnvironmentVariables</key>
      <dict>
        <key>P4LOG</key>
        <string>/usr/local/var/log/p4d.log</string>
        <key>P4PORT</key>
        <string>1666</string>
        <key>P4ROOT</key>
        <string>/usr/local/var/perforce/</string>
        <key>P4NAME</key>
        <string>Shinka</string> 
        <key>P4DESCRIPTION</key>
        <string>Myrkraverk's Perforce</string> 
      </dict>
      <key>RunAtLoad</key>
      <true/>
      <key>ServiceDescription</key>
      <string>Launches Perforce Server</string>
      <key>StartInterval</key>
      <integer>180</integer> 
      <key>KeepAlive</key>
      <true/>
      <key>UserName</key>
      <string>perforce</string>
      <key>GroupName<key>
      <string>perforce</string>
    </dict>
  </plist>

And finally, start the Helix Core service with

  sudo launchctl load /Library/LaunchDaemons/com.perforce.plist

we then issue

   p4 set P4PORT=localhost:1666

and we test it with

  p4 help

which outputs at the end

  Server 2018.1/1637071.

so we know it's all working.

The steps to properly set up Helix Core with p4 protect and so forth are left out of this guide; please see the administration guide from Perforce.

To use SSL for the connection, the P4PORT should start with ssl:.

Compiling Sysbench on OS X Yosemite or Later

These instructions are applicable after cloning the git repository and generating the autoconfigure scripts.

git clone 'https://github.com/akopytov/sysbench.git' sysbench
cd sysbench
./autogen.sh

In order to build Sysbench1 with PostgreSQL and MariaDB support, you need to make sure both mysql_config and pg_config are in your path.

I use Zsh, so this is my way of doing it, when both Postgres and MariaDB have been installed with MacPorts.

path=( /opt/local/lib/mariadb-10.1/bin /opt/local/lib/postgresql96/bin $path )

Then run

./configure --with-pgsql --with-mysql --prefix=/path/of/your/choice

You are likely to get an error like

ld: library not found for -lgcc_s.10.4

if you do not also

export MACOSX_DEPLOYMENT_TARGET=10.10

before running make, while building the bundled LuaJit. This is documented in their installation instructions.

Of course, this isn’t taken care of by the wrapper Autotools, nor is there a configure flag to set this.

An alternative might be --with-system-luajit but that depends on your situation.

Then you finish it off with make install. Happy benchmarking.


1 I hope I’m linking to the right git repository.

Celebrate Jurassic Park with File System Visualizer on OS X

If you thought the 3D program in the original Jurassic Park movie was fake, you’re wrong. And you can install it on OS X.  It’s called File System Visualizer (clone of the original 1992 SGI program, fsn) and has been around since 1999.

 

The music files in the video are from Obsidian Shell and available for personal use at Jamendo.

Continue reading Celebrate Jurassic Park with File System Visualizer on OS X