Complete Linux history in git
From: Gonsolo
Date: Wed Sep 19 2007 - 17:07:04 EST
I have written a small python script that fetches the
linux archive at
git://git.kernel.org/pub/scm/linux/kernel/git/nico/archive.git,
applies patches up to 2.4.0 and commits every patch to git
with a message and a tag.
>From there it should be easy to merge old-2.6-bkcvs and
the latest Linux git and have a git archive with the complete
history.
To run it you have to download some patches from
http://gonsolo.de/kernel_history/ and start the script
from the same directory.
It is not perfect, you have to press enter a few times when
patches do not apply. I would be happy to receive feedback
or patches.
After running the script there is a git repository at "kernel" which
is approximately 1GB! After running "git gc" (which takes a long time!)
the pack file is under 100MB, IIRC.
Next step would be to download old-2.6-bkcvs repository from
git.kernel.org and merge/rebase (don't know).
Gonsolo
#!/usr/bin/python
# Fetch the git repository for kernels up to 1.0.
# Apply all patches up to 2.4 and commit to the repository.
# From here old-2.6-bkcvs can be applied.
# Some fixes are necessary these have to be downloaded seperately.
import os, shutil, urllib
# The local git directory
local='kernel/'
# Where to fetch patches
remote='http://www.kernel.org/pub/linux/kernel/'
# This can be a local directory, too
#remote= 'file:///your_local_patch_dir/www.kernel.org/pub/linux/kernel/'
def apply( patch ):
os.system( 'bzcat ' + patch + ' | patch -s -p1 -d ' + local )
os.remove( patch )
def retrieve_apply( dir, patch ):
print 'apply ' + patch
urllib.urlretrieve( dir + patch, patch )
apply( patch )
def commit( msg ):
os.system( 'cd ' + local + ' && git add * && git commit -q -a -m' + msg )
os.system( 'cd ' + local + ' && git tag ' + msg )
def apply_patches(dir,begin,end,patchbase,commitbase):
for i in range(begin,end):
patch=patchbase + str(i) + '.bz2'
retrieve_apply( dir, patch )
commit( commitbase + str(i) )
def v10():
print 'v10'
dir=remote + 'v1.0/'
apply_patches(dir,1,7,'patch','v1.0.')
def v11():
print 'v11'
dir=remote + 'v1.1/'
patch='1.0.6-1.1.0.diff.bz2'
retrieve_apply( dir, patch )
commit( 'v1.1.0' )
apply_patches(dir,1,46,'patch','v1.1.')
# patch 45 forgets to remove files
os.system( 'cd ' + local + ' && cat ../fix.1 | patch -s -p1' )
commit( 'v1.1.45fix1' )
apply_patches(dir,46,54,'patch','v1.1.')
# patch54 is screwed
#os.remove( local + 'fs/binfmt_elf.c' )
apply_patches(dir,54,75,'patch','v1.1.')
# patch75 is screwed
os.remove( local + 'fs/msdos/mmap.c' )
commit( 'v1.1.74a: fixup' )
apply_patches(dir,75,77,'patch','v1.1.')
# patch77 is whitespaced damaged
os.system( 'cd ' + local + ' && cat ../fix.2 | patch -s -p1' )
commit( 'v1.1.76a: fixup' )
apply_patches(dir,77,96,'patch','v1.1.')
# 1.1 patches add '-N' to diff
os.system( 'cd ' + local + ' && cat ../fix.3 | patch -s -p1' )
commit( 'v1.1.95fix2' )
def v12():
print 'v12'
dir=remote + 'v1.2/'
patch='v1.1.95-1.2.0.patch.bz2'
retrieve_apply( dir, patch )
commit( 'v1.2.0' )
apply_patches(dir,1,11,'patch-1.2.','v1.2.')
def v13():
print 'v13'
dir=remote + 'v1.3/'
# found no patch for upgrade
os.system( 'cat 1.2.10-1.3.0 | patch -s -p1 -d ' + local )
commit( 'v1.3.0' )
apply_patches(dir,1,101,'patch-1.3.','v1.3.')
# Fix 1.3 patches
os.system( 'cd ' + local + ' && cat ../fix.4 | patch -s -p1' )
commit( 'v1.3.100fix3' )
apply_patches(dir,1,15,'patch-pre2.0.','pre2.0.')
# Fix pre2 patches
os.system( 'cd ' + local + ' && cat ../fix.5 | patch -s -p1' )
commit( 'v2.0fix4' )
def v20():
print 'v20'
dir=remote + 'v2.0/'
apply_patches(dir,1,41,'patch-2.0.','v2.0.')
def v21():
print 'v21'
dir=remote + 'v2.1/'
os.system( 'cd ' + local + ' && git checkout v2.0.21' )
retrieve_apply( dir, 'patch-2.0.21-2.1.0.bz2')
commit( 'v2.1.0' )
apply_patches(dir,1,133,'patch-2.1.','v2.1.')
apply_patches(dir,1,10,'patch-2.2.0-pre','v2.2.0-pre')
retrieve_apply( dir, 'patch-2.2.0-final.bz2')
commit( 'v2.2.0-final' )
def v22():
print 'v22'
dir=remote + 'v2.2/'
apply_patches(dir,1,27,'patch-2.2.','v2.2.')
def v23():
print 'v23'
dir=remote + 'v2.3/'
os.system( 'cd ' + local + ' && git checkout v2.2.8' )
retrieve_apply( dir, 'patch-2.2.8-to-2.3.0.bz2')
commit( 'v2.3.0' )
apply_patches(dir,1,52,'patch-2.3.','v2.3.')
apply_patches(dir,1,10,'patch-2.3.99-pre','v2.3.99-pre')
def v24():
print 'v24'
dir=remote + 'v2.4/old-test-kernels/'
apply_patches(dir,1,13,'patch-2.4.0-test','v2.4.0-test')
retrieve_apply( dir, 'patch-2.4.0-prerelease.bz2' )
commit( 'v2.4.0-prerelease' )
retrieve_apply( dir, 'prerelease-to-final.bz2' )
commit( 'v2.4.0' )
if os.path.exists( local ):
shutil.rmtree( local )
os.system( 'git clone git://git.kernel.org/pub/scm/linux/kernel/git/nico/archive.git ' + local )
v10()
v11()
v12()
v13()
v20()
v21()
v22()
v23()
v24()