Monday, July 21, 2014

git: permanently purge file/folder from git repo including history

My config repo suffered from being too large after I had dumped my ~/.config directory into it. At some time I decided, that storing my ~/.config directory in a non-selective manner is pointless and and removed the .config directory from my config repo. However, the repo remained rather large (.git directory was 107MB, total repo size, including .git, 110MB), as both adding and removing the .config directory made fat commits.

Following this blog post, I was able to shrink my repo size from 110MB to 3.8MB, .git directory went from 107MB to 1.3MB. In addition to instructions on how to cleanup your repo history, the blog post also provides a script for finding big files in your repository, which was not necessary for me as I knew the location of the files/directory to be deleted.

A short summary of what I did, so you do not need to go through the complete blog post (Following these instructions will lead to irreversible changes in your commit history and potentially to unwanted loss of data. Only apply when you are 100% sure that you know what you are doing):

$ git filter-branch --tree-filter 'git rm -rf .config --ignore-unmatch' HEAD
$ rm -rf .git/refs/original/
$ git reflog expire --expire=now --all
$ git gc --aggressive --prune=now
$ git push origin master --force

Saturday, July 19, 2014

Bios Update Lenovo X1 Carbon

I finally fixed the closing lid issue of my Lenovo X1 Carbon (2nd gen). I had known the solution to it for a while, which is a BIOS update. While they offer an update utility for Windows, they also offer an iso image of the BIOS update. Supposedly, if you burn the iso image on a CD or DVD, they should be auto-bootable. However, the X1 Carbon does not have an optical drive, thus i tried to generate a bootable USB drive

beethoven:~:% dd if=gruj11us.iso of=/dev/sdX

which turned out to be not bootable and thus I let the issue rest for a while.

A couple of days ago I came across this blog post that suggests updating the BIOS using Windows while it's still on the Laptop (didn't work for me apparently) and also mentioned that you could extract the eltorito image from the ISO and create a bootable USB drive from that. Some more googling led to two forum posts that contained a link to a perl script that is exactly doing that.

So all you need to do is

beethoven:Downloads:% wget http://www.uni-koblenz.de/~krienke/ftp/noarch/geteltorito/geteltorito.pl
beethoven:Downloads:% perl geteltorito.pl bios-udpate.iso > bios-update.img
beethoven:Downloads:% dd if=bios-update.img of=/dev/sdX

and then reboot your machine, boot form your USB drive and follow the instructions. Keep in mind that you should not turn off the machine or remove the USB drive during the update!

Wednesday, July 16, 2014

gcc show filename of library

gcc provides the option

 -print-file-name=<library-name>

which is very helpful for debugging linking problems. When invoked with this flag, gcc does not compile/link, but prints the full path that it uses for that library, e.g:

 beethoven:~:% gcc -print-file-name=libvigraimpex.so
 /home/phil/local/lib/../lib/libvigraimpex.so

That way you can easily determine whether or not gcc sees the correct libraries.