How to create a git repo with the SQLite amalgamation source

Suppose you use GIT for your source control and would like to include SQLite as a third-party component via `git submodule` or `git subtree`. How does one go about getting access to the SQLite amalgamation as a GIT repo? When I tried this I found one on github.com, but it wasn’t being maintained any longer. It occurred to me that I didn’t need to depend on anyone else — I could do this myself. These steps use the bash command line shell. I’ve tried it on Mac OS, but should also work on Linux or using a bash shell on Windows. SQLite source is kept in a source control management tool called Fossil (http://fossil-scm.org). (It’s written by the authors of SQLite and uses SQLite internally, naturally.) The authors courteously tag each major of release in Fossil. So it’s simply a matter of cloning the SQLite source, checking out each tag, running the makefile to produce the amalgamation and checking in the amalgamated code into a new git repo.

Setup:

  1. Install Fossil from http://www.fossil-scm.org/download.html
  2. Install dev tools necessary for building fossil’s amalgamation (make, etc..)
  3. Install git
  4. Clone the SQLite source repo using fossil:

    mkdir sqlite-fossil
    cd sqlite-fossil
    fossil clone http://www.sqlite.org/cgi/src sqlite.fossil
    fossil open sqlite.fossil
    cd ..
  5. Create a new git repo to hold the amalgamation:

    mkdir sqlite-amalgamation
    cd sqlite-amalgamation
    git init
  6. Optional: Create a README.md file with a copy of these instructions or a link to this page and commit it.

In the future you won’t need to clone from fossil fresh, nor create a new repo — you’ll still have them. To add new SQLite releases to your repo you will use `fossil update` and `git pull` to update the two repos.

Adding one release:

  1. Perform these steps, replacing $1 with the release name — OR just copy this into a file called build-sqlite.sh next to your two repos, make it executable using `chmod +x build-sqlite.sh` and invoke it with the name of the release.
    cd sqlite-fossil
    fossil update $1
    rm -rf ../sqlite_build
    mkdir ../sqlite-build
    cd ../sqlite-build/
    ../sqlite-fossil/configure
    make sqlite3.c
    cd ../sqlite-amalgamation/
    mv ../sqlite-build/sqlite3.c .
    mv ../sqlite-fossil/src/shell.c .
    mv ../sqlite-build/sqlite3.h .
    mv ../sqlite-fossil/src/sqlite3ext.h .
    git commit -a -m $1
    cd ..
  2. For example:


    ./build-sqlite.sh version-3.8.11.1

    Not sure what all the tags are? Use `fossil tags` to display all the tags. Search for the ones that start with 3. as the major releases. Warning: The releases do not sort in alphabetical order (e.g. 3.8.11 sorts before 3.8.9 but is a later release) so use care when picking which tags to build, otherwise your git repo could end up with the commits not in the correct order.

Böx Game

Do you have an iPhone or iPad? Try my new Box Game. It’s inspired by “Uncle Lester”, a magician from the early twentieth century who had a passion for puzzle boxes. My version has a few levels (4 or 5) and no instructions. It’s designed to entertain you for a few minutes and that’s all. Leave comments here if you have feedback.

If you like it: that makes me happy. If it gives you trouble or you don’t like it… well, at least it was free.

Winter words of Wisdom

No matter how tired you are of putting on your long johns and your flannel lined jeans and your down vest and your insulated snow pants and your wool scarf and hand-knit hat and thinsulate gloves and micro-fiber parka and felt-liner muck lucks … Put them on. It’s cold outside.

Use sips and python to create vector-based AppIcon for iOS and OSX

I was surprised to see that Xcode does not make it easy to build all the various icon files for AppIcons for Mac OS and IOS. A few tools have been whipped together, but I’m not a fan of needing to install a whole new GUI app just to solve a simple problem. I’m also not a huge proponent of python, but it’s one of the scripting languages that natively supports JSON — which is part of how Apple’s implemented .xcassets (look inside you’ll see a file called Contents.json). So here is my solution — you’ll need to customize it for your own project. This particular project has two different AppIcon.appiconset entries in the xcassets file.

Note that this script re-writes the Contents.json file, to normalize the file naming. By default if you drag-and-drop files into Xcode it just adds -1 and -2 etc.. to the name, which is lame.

Whenever you update the icon (hardcoded here as a file called ‘icon.pdf’) re-run this script and the icon for you Mac and/or iOS app will update!

import re
import json
from subprocess import call
from pprint import pprint

for iconset in ['Design Show Server/Images.xcassets/AppIcon.appiconset', 'Design Show/Images.xcassets/AppIcon.appiconset']:
	json_data=open(iconset + '/Contents.json')
	newdata = []

	data = json.load(json_data)
	for img in data["images"]:
		size = int(re.sub(r'x.+$','', img["size"]))
		filename='{idiom:s}_{size:d}_{scale}.png'.format(idiom=img["idiom"],scale=img["scale"],size=size)
		filepath='{iconset:s}/{filename:s}'.format(iconset=iconset,filename=filename)
		if img["scale"] == '2x':
			size = size * 2
		newdata.append({ "filename" : filename, "size" : img["size"], "idiom" : img["idiom"], "scale" :img["scale"] })
		print('{filename:s} {size:d}'.format(filename=filename,size=size))
		call(['sips', '-s', 'format', 'png', '-Z', str(size), '-o', filepath, 'icon.pdf'])
	json_data.close()
	contents_file = open(iconset + '/Contents.json', "w")
	contents_file.write( json.dumps({ "images" : newdata, "info" : { "version" : 1, "author" : "andy's python script" }}) )
	contents_file.close()

Here’s a gist:

How to move commits after git filter-branch

I’ve read that you’re supposed to be able to use git rebase to move commits from an old repo to a one after using git filter-branch. But I couldn’t get that to work.

The backstory: Our repo was bloated because we started by forking a different project, and then deleted unneeded parts. This was an easy way to get started, but we ended up with all the history of the old project. So I ran git filter-branch and some other tools to clean up the history and remove empty merge commits. While I was preparing that, the rest of the team kept working on the old repo.

So I had to move those commits the rest of the team made onto the new, filtered repo. I used git format-patch and git am. Like this (assuming cwd is the new repo):


( cd ../old-repo; git format-patch --stdout -k commit id on old-repo of last shared commit ) | git am -k

Puppies

A new phase in my life starts…

20140218-091613.jpg

Leo (short for Leonard, in honor of Leonard Nimoy) on the left, and Chester on the right.

20140218-091635.jpg

Me with Leo (Leo has the science-officer blue collar).

20140218-091656.jpg

These best buds comforted each other on the scary ride from the farm outside of New Ulm where they grew up.