Monday 26 January 2015

Trying to build PHP for 3 days and binary comparing

Someone asked me about writing a wordpress plugin for them, and to do this I needed to rely on another wordpress plugin. Only problem was that the other plugin wouldn't run on my PHP installation as it required the gmp or bcmath extensions, neither of which my PHP installation included.

So I tried building the latest version of PHP, along with the latest versions of the libs the various extensions I need depend on. The first problem I had was that I couldn't get openldap to build. After looking into it, it seems that Oracle changed their licence terms for the newer versions of BerkleyDB and openldap is not 'compatible' with these licence terms. So it includes a check to make sure it won't work with the newer versions of BerkleyDB.

I couldn't see how to get openldap compiled without BerkleyDB, so I just gave up. I don't really need the ldap extension for PHP anyway.

After building all the needed dependencies, I tried building PHP, but got an error during compiling. I searched to see if anyone else had the same problem, and there didn't seem to be a solution. Just debugging advice - try and work out the minimum configure needed to reproduce the error, so you can see if it is a certain extension or two conflicting extensions causing the problem.

I then spent almost three days just trying to build PHP, changing some option, trying again, etc. in an effort to work out what the problem was.

The strange thing is, that when I started doing this, I got a different error relating to openssl, even if I was compiling with no other extensions specified in my configure line. Adding --disable-all to configure, I then managed to build with openssl. Gradually adding all the options back got me to the point where the original error message popped up again.

After many more build attempts I figured out the issue was my usage of the tidy-nu lib rather than the very old and outdated tidy. Changing this back to the old tidy and removing the --disable-all I was able to build okay. But that doesn't really make sense - what happened to the openssl error I was getting previously? Anyway, I guess finally getting it to build was the main thing.

Each build attempt takes at least half an hour before you see whether it was successful or not. This is why it took three days of changing the different configure options, rebuilding, then seeing if it worked or not before trying again with different options to narrow down the problem.

Today I was doing my morning backup as usual, but my backup drive was full. So I decided to re-organise my files a bit and move some to another drive. After moving the files I did a binary compare against one of the backups, and a few files were different. One was a Photoshop file, and one of the layers in the backup file had become corrupted. Another was a NEF (Nikon RAW file) that had become corrupted on the backup.

Two were large panoramas with many layers. I looked through the images, layer by layer, looking to see any evidence of corruption, both the backup copies and the originals. This took quite a while. However I couldn't see any problems. Since the other two images were both corrupted on the backups I decided to just copy the originals over the backups. The reason for doing this is just to avoid those files being flagged again in a binary compare in the future and me having to perform the same procedure.

With the files safely in their new location I backed them up to one of the disks I use for backing up the drive they are now located on. After doing that I ran a binary compare between the two drives. The new files had all copied okay, but there were a few corrupted files in other places, again, all on the backup. As well as images there were also some shortcuts that had become corrupted, and even a text file:

No comments: