Sunday, December 18, 2011

Compiling mplayer on Mac OS X 10.7

Compiling mplayer on Mac OS X 10.7 (Lion)

Have been doing this for ages, but with Lion there's a new error:

~/mplayer > ./configure
No FFmpeg checkout, press enter to download one with git or CTRL+C to abort

Cloning into ffmpeg...
remote: Counting objects: 7969, done.
remote: Compressing objects: 100% (5420/5420), done.
Receiving objects: 100% (7969/7969), 9.84 MiB | 1.40 MiB/s, done.
remote: Total 7969 (delta 5169), reused 4198 (delta 2409)
Resolving deltas: 100% (5169/5169), done.
Checking for cc version ... 4.2.1 
Checking for working compiler ... yes
Detected operating system: Darwin
Detected host architecture: x86_64
Checking for cross compilation ... no 
Checking for host cc ... cc 
Checking for CPU vendor ... GenuineIntel (6:23:10) 
Checking for CPU type ...  Intel(R) Core(TM)2 Duo CPU     E8335  @ 2.93GHz 
Checking for kernel support of mmx ... yes 
Checking for kernel support of mmxext ... yes 
Checking for kernel support of sse ... yes 
Checking for kernel support of sse2 ... yes 
Checking for kernel support of ssse3 ... yes 
Checking for kernel support of cmov ... yes 
Checking for mtrr support ... yes 
Checking for GCC & CPU optimization abilities ... core2 
Checking for byte order ... little-endian 
Checking for extern symbol prefix ... _ 
Checking for assembler support of -pipe option ... yes 
Checking for GCC support of -mstackrealign ... no 
Checking for PIC ... yes 

Error: Your binutils version is too old to compile for 64-bit

Check "config.log" if you do not understand why it failed.

Googling for the answer didn't help, but I finally came across the solution: use clang.

~/mplayer > ./configure '--cc=clang'

and off it goes...

Tuesday, September 27, 2011

iViewFox compatibility...

I have been having issues with iViewFox ceasing to work every time there's a FireFox update. Not sure why - it seems to be a problem on some computers and not others. Turns out there's a version compatibility string in one of the Add On's files, which can be edited...

The file is install.rdf, and it's located at ~/Library/Application Support/Firefox/Profiles/.default/extensions/ It's an XML file that can be edited in your favourite text editor. In the file there's a line that says:


which I changed to:


Restarted FireFox, and the Add On seems to be functioning correctly.

Thursday, August 25, 2011

Migrating redmine and subversion to Mac OS X 10.7

I've been meaning to write up an article on setting up redmine and subversion on Mac OS X 10.6 - mostly to aid my own memory in case I need to do it again, but also for anyone else who might want to do it. When I first set these things up they had to be built from source (along with their dependencies), and then configured from the ground up. Thankfully now lots of the required components are part of Mac OS X, so the process is much, much simpler.

Last week the Mac Pro I've been running as a server failed (suspected dud power supply), and while it's out for repair I've had to shift the redmine and subversion installations onto an alternate server to keep things moving. Mac OS X 10.7 is now out too, so I'm migrating the installation from 10.6, and updating some things along the way.

Why would you want do this? If you're into developing software you need source control. There are lots of other options, but subversion suits my workflow, and allows previous versions of source to be pulled, and allows work to be done and synchronised from multiple computers. I'm in a development team of 1, so I don't need multi-user features, but it's for that too. Redmine is a tool that can do a heap of stuff - I just use it for logging 'issues' with the software I'm working on (bugs, new feature requests...). I find myself using it as a sort of to-do list that I can access and update over the web. It runs using ruby on rails, so it's a good excuse to look at that too.

Starting conditions:

I have had redmine and subversion running under Mac OS X 10.6.8 on a Mac Pro. I'm migrating to an iMac running Mac OS X 10.7.2, with all updates current to December 12, 2011. Developer tools are installed, but there's nothing yet in /usr/local/. apache2 is installed on Mac OS X by default.

Here's some terminal output showing versions of relevant software components. You can see that mysql is not installed, and no ruby gems are installed:

server:~ user$ ruby --version
ruby 1.8.7 (2010-01-10 patchlevel 249) [universal-darwin11.0]
server:~ user$ gem --version; rake --version; rails --version;
rake, version 0.8.7
Rails is not currently installed on this system...
server:~ user$ mysql --version
-bash: mysql: command not found
server:~ user$ gem list

*** LOCAL GEMS ***

server:~ user$

Before we start, some of the more useful websites I've consulted are:

The Redmine Install wiki.

The Redmine Mac OS X - Snow Leopard installation notes.

A page describing moving redmine from one server to another, and a page with some info about installing MySQL on Mac OS X 10.6.

I'll break this into 4 parts: mysql (required for redmine), redmine, subversion, and configuring apache.

Installing MySQL:

Mac OS X doesn't come with MySQL, although I think the Server version does. Good installers are provided at I chose to install from a disk image using a GUI installer. The file I downloaded is mysql-5.5.18-osx10.6-x86_64.dmg.

Here are the steps:

  • install the mysql binary
  • install the startup item
  • install the prefPane in /Library/PreferencePanes

    It used to be necessary to set permissions on the startup item to get the prefPane to work. The code to do it is provided here for completeness, but with this version of mysql I found it was not necessary.

    In a Terminal:

    sudo chown -R root:wheel /Library/StartupItems/MySQLCOM

  • use the preference pane to start/stop mysql. Hopefully you get some green text that says "The MySQL Server Instance is running".

  • add mysql to the PATH. Do this by adding the following line to ~/.bashrc:

    export PATH=${PATH}:/usr/local/mysql/bin

    Then start a new terminal to load ~/.bashrc, or type

    source ~/.bashrc

    at the command line. You can check that mysql is installed correctly by running it (as superuser).

Installing Redmine

There are lots of docs around on how to do this - although there are some subtle differences between different operating systems. They tend to end at 'testing the development setup using webrick', which is not intended for production use. Here I'll describe setting up redmine to run through apache and be world visible.

I started by downloading the latest stable version:

svn co redmine-1.2

On Mac OS X the root of the web server is at /Library/WebServer/Documents, so a good place for redmine is in /Library/WebServer/Documents/redmine-1.2, with a symlink to /Library/WebServer/Documents/redmine. This is a restricted access directory, so all the terminal commands will need to be run as superuser. The following terminal commands assume you've cd'd into the redmine directory.

Configure database access

Copy config/database.yml.example to config/database.yml

cp config/database.yml.example config/database.yml

Edit config/database.yml, removing all but the 'production' section. In my case, I've edited it to look like this:

  adapter: mysql
  database: redmine
  host: localhost
  username: redmine
  password: redmine_pass

Create the log file if necessary:

touch log/production.log

Change permission for the log file [may need to be created first]:

sudo chmod 0666 log/production.log

Change the owner for the files directory, where redmine will save files:

sudo chown -R _www files

NOTE: If migrating an existing redmine installation, the contents of the files directory need to be copied across, and the appropriate permissions set.

Create the mysql database for redmine

Run mysql as superuser

sudo mysql

Run the following commands in mysql to create the database. Note that the values are the same as those in config/database.yml

create database redmine character set utf8;
create user 'redmine'@'localhost' identified by 'redmine_pass';
grant all privileges on redmine.* to 'redmine'@'localhost';

Again, if you're migrating an existing redmine installation, the database content needs to be copied across. To do this the mysql database needs to be 'dumped' from the old server with the following command (the password will be requested by mysql):

mysqldump -u redmine -p redmine > /location/of/dump/file.sql

The dumped database can be reloaded on the new server:

mysql -uredmine -p redmine < /location/of/dump/file.sql

Set up the necessary Ruby gems


sudo gem install -v 0.4.2 i18n


I started by installing the v 2.3.5 version, but had some issues and ended up going to v 2.3.11 (see below).

sudo gem install -v 2.3.5 rails


Redmine needs this to access the mysql database where it stores its stuff. I started by not specifying a version number, which installed 2.8.1. If you read on you'll find that this is a problem, and version 2.7 is the magic version.

export ARCHFLAGS="-arch x86_64"
sudo gem install --no-rdoc --no-ri mysql -- \
    --with-mysql-dir=/usr/local/mysql \ 

In order to ensure ruby can access the mysql libraries execute the following (first check the paths are relevant for your versions). This assumes your current directory is /usr/local/mysql/lib.

sudo install_name_tool -change libmysqlclient.18.dylib \
    /usr/local/mysql/lib/libmysqlclient.18.dylib \

You can then check things are OK by running irb and checking that mysql can be accessed:

> irb
require 'mysql'

If you see 'true', you're good to go.

Versions... here's where the fun stuff begins...

The next thing to do is go into the redmine directory, and run a rake command to generate the session store. This is to generate a session store secret. Not sure exactly what that means, but it sounds important.

> sudo rake generate_session_store

Now, if you're lucky a heap of text will fly by, and there are no errors. More likely there will be some problems... Here's what I got:

Missing the Rails 2.3.11 gem. Please `gem install -v=2.3.11 rails`, update your \
RAILS_GEM_VERSION setting in config/environment.rb for the Rails version you do \
have installed, or comment out RAILS_GEM_VERSION to use the latest version installed.

So, I installed the 2.3.11 version.

sudo gem install -v 2.3.11 rails

Now, try again...

sudo rake generate_session_store

And once more, crashed and burned:

WARNING: 'require 'rake/rdoctask'' is deprecated.  Please use 'require 'rdoc/task' (in RDoc 2.4.2+)' instead.
    at /Library/Ruby/Gems/1.8/gems/rake-
WARNING: 'task :t, arg, :needs => [deps]' is deprecated.  Please use 'task :t, [args] => [deps]' instead.
    at /Users/wpowell/Development/redmine-1.2/lib/tasks/email.rake:170

I looked around and concluded that the version of rake was too new, so downgraded:

sudo gem uninstall rake

Select gem to uninstall:
 1. rake-0.8.7
 2. rake-
 3. All versions
> 2
Successfully uninstalled rake-

So now we're running rake 0.8.7, let's have another go...

sudo rake generate_session_store

Woo Hoo! Seems to have worked. Next step is to migrate the database:

sudo RAILS_ENV=production rake db:migrate

And there's another error...

rake aborted!
Object is not missing constant Issue!

(See full trace by running task with --trace)

Cryptic. Running the full trace didn't really help. This error has bugged me in the past, and I eventually figured out that it's related to the version of the mysql gem. So, uninstall version 2.8.1 and install 2.7...

sudo gem uninstall mysql
export ARCHFLAGS="-arch x86_64"
sudo gem install -v 2.7 --no-rdoc --no-ri mysql -- \
    --with-mysql-dir=/usr/local/mysql \

Again, make sure ruby can access the mysql libraries...

sudo install_name_tool -change libmysqlclient.18.dylib \
    /usr/local/mysql/lib/libmysqlclient.18.dylib \

Now let's try that rake command again.

sudo RAILS_ENV=production rake db:migrate

...lots of printing out... looks promising. Now test with the WEBrick web server built into rails

ruby script/server webrick -e production

Open a web browser to and it works!!

Moving to apache

This can be covered in another post...

Monday, January 24, 2011

code blocks in blogger

Something I've just come across is the formatting of code blocks in blogger:
 here is some code

There are plenty of sites out there with information on how to do this [Dashboard->Design->Template Designer->Advanced->Add CSS], but what they fail to mention is that the CSS is not correctly implemented in blogger's preview pane [Edit Posts->Preview].
I spent ages testing out CSS changes, expecting to see the effect in the Preview pane, but nothing seemed to be working. After some frustration I decided to post anyway, viewed the post and there was the CSS formatting implemented correctly. If only someone had mentioned this sooner...

adding an smb share in linux

Another post of something I do regularly but can't quite remember...

Running df gives the mount point:
> df -h
Filesystem Size Used Avail Use% Mounted on
/dev/hda1 72G 4.7G 64G 7% /
tmpfs 253M 0 253M 0% /lib/init/rw
udev 10M 768K 9.3M 8% /dev
tmpfs 253M 0 253M 0% /dev/shm
/dev/sda1 917G 13G 859G 2% /mnt/raidk
/dev/sdb1 230G 11G 207G 5% /mnt/alfred

In this case it's /mnt/alfred I'd like to share.

Now to add the entry to /etc/samba/smb.conf:
> sudo gedit /etc/samba/smb.conf

I tend to copy an existing section of the config file and change the relevant parts. In this case, the new entry looks like:
path = /mnt/alfred
available = yes
browsable = yes
writable = yes
valid users = joeblo
admin users = joeblo

Once the changes are made, samba needs to be restarted:
> sudo /etc/init.d/samba restart
Stopping Samba daemons: nmbd smbd.
Starting Samba daemons: nmbd smbd.

Now that samba is restarted the new share is available on the network.

Sunday, January 23, 2011

connecting a new drive to linux

This is one of those things I do infrequently enough that I'm not quite able to remember all the details. So here's the procedure documented so that I can do it more quickly next time. Maybe someone else might find it useful too.

FYI, the linux distro I'm running is Debian, and I'm connected to it from Mac OS X via ssh.

1. Connect the drive, power it up, and see where linux has put it.
> sudo /sbin/fdisk -l
Disk /dev/hda: 80.0 GB, 80026361856 bytes
255 heads, 63 sectors/track, 9729 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes
Disk identifier: 0xdd27dd27

Device Boot Start End Blocks Id System
/dev/hda1 * 1 9541 76638051 83 Linux
/dev/hda2 9542 9729 1510110 5 Extended
/dev/hda5 9542 9729 1510078 82 Linux swap / Solaris

WARNING: GPT (GUID Partition Table) detected on '/dev/sda'! The util fdisk doesn't support GPT. Use GNU Parted.

Disk /dev/sda: 1000.1 GB, 1000153686016 bytes
255 heads, 63 sectors/track, 121595 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes
Disk identifier: 0x00000000

Device Boot Start End Blocks Id System
/dev/sda1 1 121596 976712583 ee EFI GPT

WARNING: GPT (GUID Partition Table) detected on '/dev/sdb'! The util fdisk doesn't support GPT. Use GNU Parted.

Disk /dev/sdb: 250.0 GB, 250059350016 bytes
255 heads, 63 sectors/track, 30401 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes
Disk identifier: 0x00000000

Device Boot Start End Blocks Id System
/dev/sdb1 1 30402 244198583 ee EFI GPT

In this case the drive I'm interested in is the 250 Gb one, and it is at /dev/sdb1.

2. Run gparted to partition the drive.
> sudo /usr/sbin/gparted

gparted is a gui application. I'm running it over an ssh connection (using the -Y option), so it will display on my Mac OS X machine using the X11 server that's part of Mac OS X. Choose the relevant drive (/dev/sdb), and delete all the current partitions. All the available space should be shown as "unallocated" when you're done. Click Apply to make the changes to the disk - note that this will destroy any data on the drive!
The new partition needs a filesystem before it can be used. This can also be done with gparted: click New, change to ext3, primary partition should already be selected and the other defaults are OK. Click Apply and wait a while. The bigger the partition, the longer the wait. Once this is complete the drive is ready for use, but the operating system needs to gain access by mounting it.

3. Now to define a mount point. In my system, these are at /mnt, and running ls -l /mnt shows the default permissions:
> ls -l /mnt
total 12
drwxr-xr-x 2 root root 4096 2010-04-30 14:18 cuda_80
drwxr-xr-x 2 root root 4096 2010-09-06 15:16 five_hundred
drwxr-xr-x 4 root root 4096 2010-12-23 13:59 raidk

cuda_80 is the drive that I'm replacing - the physical drive has already been removed from the system, and I've removed it from fstab and smb.conf. The new drive I'm calling alfred (I watched Batman last week), so I'll rename cuda_80 to alfred rather than deleting it and creating a new one. This will maintain the correct permissions, too.
> sudo mv /mnt/cuda_80 /mnt/alfred

4. I need to know the drive's UUID so I can add it to the fstab file. Using the UUID makes it independent of the /dev/* information, so that if other drives are added or removed and the drive ordering changes, this drive will still mount OK. The UUID is retrieved with:
> /sbin/blkid
/dev/hda1: UUID="0521aa47-4fdb-424e-bd83-0f6b164e55f5" TYPE="ext3"
/dev/hda5: TYPE="swap"
/dev/sda1: UUID="637d0461-72d5-40c2-9446-04a45912eb8e" SEC_TYPE="ext2" TYPE="ext3"
/dev/sda5: TYPE="swap"
/dev/sda2: UUID="13A3CE68BA98A5AF" LABEL="Untitled" TYPE="hfsplus"
/dev/sdb1: UUID="a5c5ba62-3c58-4ff4-9d1c-6d754f4430f0" SEC_TYPE="ext2" TYPE="ext3"

Using the information from step 1, I know the drive is at /dev/sdb1, so the UUID is the long string starting with a5c.

5. Now to edit fstab. I'll do this in gedit, which has a gui interface so I can cut and paste.
> sudo gedit /etc/fstab

I'm duplicating a fstab line that works, then changing the UUID and mount point to the values determined in the previous steps. My extra line in fstab is:
UUID=a5c5ba62-3c58-4ff4-9d1c-6d754f4430f0 /mnt/alfred ext3 defaults,errors=remount-ro 0 2

The line is made up of 6 fields separated by tabs. The UUID and the mount point are the first two. The third is the filesystem type (ext3 in this case), and the fourth is a collection of options (see the fstab or mount man pages for details), the fifth has something to do with dumping the filesytem (I've never really read the finer details) and the final field "determines the order in which filesystem checks are done at reboot time." Root filesystems should have the value of 1, but this is not a root filesystem so it has the value of 2. This also gives the USB drive time to get going during startup so that it's ready by the time the OS looks for it.

6. Now that the fstab has been edited, it should be possible to mount the filesystem. This can be done as follows:
> sudo mount -a

There's a little bit of noise from the drive, and running df -h shows that the drive is now mounted (the -h option causes the drive sizes to be shown "human readable").
> df -h
Filesystem Size Used Avail Use% Mounted on
/dev/hda1 72G 4.7G 64G 7% /
tmpfs 253M 0 253M 0% /lib/init/rw
udev 10M 768K 9.3M 8% /dev
tmpfs 253M 0 253M 0% /dev/shm
/dev/sda1 917G 200M 871G 1% /mnt/raidk
/dev/sdb1 230G 188M 218G 1% /mnt/alfred

It should also be mounted automatically when the system restarts.