Wednesday, June 5, 2013

Install git binaries without package management and fix missing helpers

Talk about flexibility. Suppose you need git, but don't have package management or a compiler. What's a SWE to do? Use git's --exec-path feature, which changes the search path for it's helpers, allowing you to install it pretty much anywhere.
$ mkdir ~/opt && cd ~/opt

$ wget http://archive.ubuntu.com/ubuntu/pool/main/g/git-core/git-core_1.7.0.4-1ubuntu0.2_amd64.deb

$ dpkg -x git-core_1.7.0.4-1ubuntu0.2_amd64.deb .

$ export GIT_EXEC_PATH=/home/ppetraki/opt/usr/lib/git-core

$ cd ~/Sandbox

$ ~/opt/usr/bin/git clone git://kernel.ubuntu.com/ubuntu/ubuntu-quantal.git
warning: templates not found /usr/share/git-core/templates
Initialized empty Git repository in /home/ppetraki/Sandbox/ubuntu-quantal/.git/
remote: Counting objects: 2721745, done.
remote: Compressing objects: 100% (419165/419165), done.
Receiving objects:   2% (78914/2721745), 21.36 MiB | 89 KiB/s 
Sweet! This feature also address the git-XXXX helper not found.

Friday, May 24, 2013

Zapping stale kernel images on Ubuntu

Spring cleaning time, I wanted to keep my current kernel and the one just installed by a recent upgrade. That argument could have been simplified by using $(uname -r)
dpkg -l | grep linux-image | egrep -v '3.2.0-4(3|4)-generic' | grep -v linux-image-generic | awk '{print $2}' | xargs apt-get remove -y

and the results

...
0 upgraded, 0 newly installed, 25 to remove and 0 not upgraded.
After this operation, 7,807 MB disk space will be freed.

Thursday, May 16, 2013

Introduction to bash coprocess

A complicated way to do something very simple. I suppose I need to brush up more on my bash file descriptor chops.
$ coproc virsh
[1] 14358
$ cat > flywheel.xml <&${COPROC[0]}
^Z
[2]+  Stopped                 cat > flywheel.xml 0<&${COPROC[0]}
$ bg
$ echo 'dumpxml flywheel' >&${COPROC[1]}
$ echo 'exit' >&${COPROC[1]}
$ 
[1]-  Done                    coproc COPROC virsh
[2]+  Done                    cat > flywheel.xml 0<&${COPROC[0]}
It may not be as efficient as this for small jobs:
echo "dumpxml $d" | virsh > $dest
But for driving longer running processes, this might be kinda cool.

Monday, May 13, 2013

scripting mdadm raid creation starting from a bare disk

I learned today that you can drive fdisk by just using echo. echo commands with no arguments serve as '/n' so you can take the defaults for starting and ending cylinder etc. Using fd "Linux raid auto" for the partition type.
for disk in $(ls /dev/disk/by-path/pci-0000:03:00.0-sas*lun-0);
do
  echo "zeroing $disk"
  dd if=/dev/zero of=$disk bs=1M count=10
  sync

  echo "creating RAID paritions on SAS disks"
  (echo n; echo p; echo 1; echo ; echo; echo t; echo fd; echo w) | fdisk $disk

  echo "verifying..."
  (echo p; echo q) | fdisk $disk
done
This is just a sample of the script found here:

https://github.com/ppetraki/storage-tools/blob/master/create-mdraid-from-scratch.sh

Which will take your disks from bare block devices all the way to running md and create the config.

Monday, April 1, 2013

Simple yet effective PDF content editing utility

Ever come across a PDF that you normally would print out and then fill in the form by hand? Well, there's a hard to find tool called flpsed that will edit any pdf and allow you put text anywhere you want it.
$ sudo apt-get install flpsed
$ flpsed foo.pdf

Position the cursor by mouse and just start typing. If you don't like the position you can use the arrow keys for fine movements or grab it with the mouse. It doesn't have the most attractive user interface but who cares, it delivers.

You can also save the modified pdf.

Creative uses include printing something as a pdf like a "html print form" and leveraging the medium with tools like flpsed.

Monday, November 26, 2012

OpenGrok is now in the Ubuntu Charm Store!

http://jujucharms.com/charms/precise/opengrok
  • Now supports multiple projects using a simple JSON format
  • Supports both git and bzr
$ juju bootstrap
$ juju deploy opengrok
$ juju expose opengrok

Thursday, November 1, 2012

My first juju charm: OpenGrok

From the project page:

" OpenGrok is a fast and usable source code search and cross reference engine. It helps you search, cross-reference and navigate your source tree. It can understand various program file formats and version control histories like Mercurial, Git, SCCS, RCS, CVS, Subversion, Teamware, ClearCase, Perforce, Monotone and Bazaar. In other words it lets you grok (profoundly understand) source code and is developed in the open, hence the name OpenGrok. It is written in Java."

To get started:
$ juju deploy cs:~peter-petrakis/precise/opengrok
$ juju expose opengrok
and the icing, you can add and index new projects by simply:
juju set opengrok og-content=lp:juju
Currently it only will do this with lp urls but later I intend to expand to general bzr urls and of course git. Automatic source code updating and indexing is also in the works. It's currently in the charm store submission stage but is ready for trial use. Remember, you can use LXC containers with juju so it's trivial to deploy complex services locally without a cloud.