next up previous contents
Next: About this document ... Up: oneSIS v2.0.5: Administrator's Manual Previous: initramfs.conf Configuration Directives   Contents


System image revision control with git, HOWTO

First, a quick note about speed. Doing git commands on a repository the size of a oneSIS system image over NFS can be somewhat slow. If your NFS server is a regular linux box, it is highly recommended that you run all git commands directly on that box so that all access to the image is direct to local disk rather than over NFS.

Git is an extremely powerful revision control system. It is advisable to create and tinker with smaller repositories before jumping to a full system image. Once you have a system image and are ready to put it into git, you can follow this procedure.

Procedure 6   Prepare an image for use with git.
Git is included in most modern distributions, but there is still an extra script that is packaged with the git source that we need to use for managing a system image.
 $\bullet$ Download and install git

Directions can be found at http://git-scm.com/download
 $\bullet$ Download setgitperms.perl

From git source tree: https://raw.github.com/git/git/master/contrib/hooks/setgitperms.perl
 $\bullet$ Create a git repository in your system image

# cd /var/lib/oneSIS/images/oneSIS_image_dir
# git init
 $\bullet$ Create some hooks to enable tracking permissions/ownership

# rm -f .git/hooks/*
# cp setgitperms.perl .git/hooks
Create .git/hooks/pre-commit

  #$!$/bin/sh
  SUBDIRECTORY_OK=1 . git-sh-setup
  $GIT_DIR/hooks/setgitperms.perl -r

Create both .git/hooks/post-checkout and .git/hooks/post-merge

  #$!$/bin/sh
  SUBDIRECTORY_OK=1 . git-sh-setup
  $GIT_DIR/hooks/setgitperms.perl -w

 $\bullet$ Git does not track empty directories so make sure that none are empty

Put a .gitignore file in every empty directory
# find . -name .git -prune -o -type d -empty -exec touch {}/.gitignore $\backslash$;
 $\bullet$ Git does not track device files so create a tar archive for them

# find . $\backslash$( -type b -o -type c -o -type p $\backslash$) -exec tar rf dev/devs.tar {} $\backslash$;
 $\bullet$ Add all files into the git repository

This step may take some time. Be sure to add a useful comment to all commits.
# git add .
# git commit

Thats it! The system image is now under revision-control. It is now possible to detect any changes to the system image with a simple git status, commit changes with git add and git commit, and view the history with git log. Refer to git documentation for how to use branching, merging, and other git capabilities.

Note: When cloning a git repository, the .git/hooks directory is not cloned, so you will need to copy all the hooks over by hand and manually untar the device file tarball on any new clone.

Procedure 7   Cloning a system image repository.
 $\bullet$ Clone the repository

# git clone oneSIS_image_dir cloned_image_dir
 $\bullet$ Set up the hooks

# rm -rf cloned_image_dir/.git/hooks
# cp -a oneSIS_image_dir/.git/hooks cloned_image_dir/.git/
 $\bullet$ Manually adjust permissions/ownership to match the repository

# cd cloned_image_dir
# .git/hooks/setgitperms.perl -w
 $\bullet$ Unpack all device files

# tar xvf dev/devs.tar


next up previous contents
Next: About this document ... Up: oneSIS v2.0.5: Administrator's Manual Previous: initramfs.conf Configuration Directives   Contents
root 2017-02-23