Fixed dirname on 12.04

Added two patches to fix dirname for 12.04 and checked patch folder.