Wednesday, July 23, 2014

creating rpms with a specfile from a repository

I was working with my varnish vmod today, attempting to package it into rpm. I found a useful tutorial here: https://fedoraproject.org/wiki/How_to_create_an_RPM_package

I tend to be a bit impatient though and I didn't read everything. I wanted to have my rpmbuild process checkout the code from a repo and then to ./configure && make but I ended up getting this odd error:

error: No "Source:" tag in the spec file

It took a little while to get to the bottom of things, but I eventually discovered by having the following macro in my .spec file 

%setup -q

caused rpmbuild to need a Source: line. Once I took that line out, all was good again. The spec files I built are for libmaxmindb, varnish cache and a varnish module. The code is here:

https://github.com/russellsimpkins/varnish-mmdb-vmod


Friday, July 18, 2014

Working with Grids

While working on a course of Algorithms and data structures I had the need to represent a grid of x/y in an array. After a bit of thought I realized that for any grid of size N, you can represent the grid as an N*N length array. To convert an array element into X/Y coordinates, you do the following:

x = p/N
y = p%n

To get the array position p from an x/y coordinate:

p = N*x+y