Posted by: LittleBlueThing
hijack in git... - 25/02/2008 21:34
FWIW I got dragged kicking and screaming down a rabbit hole over the past few days.
For reasons best known to my subconscious I decided to put hijack into a local git repo.
Then I decided it would be a good idea to import *all* the available hijack history into said repository.
I downloaded all the patches, wrote some perl to automate it and off we went.
A few problems arose - some patches are a touch dodgy - but essentially it worked. (Nb 'tweaked' patches attached...)
But then I loaded git web and the timestamps annoyed me so I used a faketime (LD_PRELOAD hijack of the time() calls) to fake the system time for the untar/patch/git commit cycle. (Nb seems to be quite slow - the script was much faster without the timestamp fakery).
[I bet this is one of very few git repositories in the world with a first commit tagged a good 3 years before git was invented!!!]
It's rather nice that I can look at the file history etc and browse the development of hijack as a means to learning about it.
The result is that the following is a diff of v485.tar.gz and the sum of all the patches published...
(ie the cumulative error of all 484 patches!)
Just in case anyone else wants to recreate the repo : here is the perl code I used (relies on the faketime library).
For reasons best known to my subconscious I decided to put hijack into a local git repo.
Then I decided it would be a good idea to import *all* the available hijack history into said repository.
I downloaded all the patches, wrote some perl to automate it and off we went.
A few problems arose - some patches are a touch dodgy - but essentially it worked. (Nb 'tweaked' patches attached...)
But then I loaded git web and the timestamps annoyed me so I used a faketime (LD_PRELOAD hijack of the time() calls) to fake the system time for the untar/patch/git commit cycle. (Nb seems to be quite slow - the script was much faster without the timestamp fakery).
[I bet this is one of very few git repositories in the world with a first commit tagged a good 3 years before git was invented!!!]
It's rather nice that I can look at the file history etc and browse the development of hijack as a means to learning about it.
The result is that the following is a diff of v485.tar.gz and the sum of all the patches published...
(ie the cumulative error of all 484 patches!)
Code:
diff -r hijack/arch/arm/defconfig v485/arch/arm/defconfig 131a132,136 > CONFIG_EMPEG_I2C_FAN_CONTROL=y > CONFIG_HIJACK_TUNER=y > # CONFIG_HIJACK_TUNER_ADJUST is not set > # CONFIG_EMPEG_PEGASUS is not set > CONFIG_EMPEG_EXTRA_RAM=y 203c208 < CONFIG_IRCOMM=y --- > # CONFIG_IRCOMM is not set 318a324 > # CONFIG_FTPFS_FS is not set
Code:
diff -r hijack/arch/arm/special/notify.c v485/arch/arm/special/notify.c 553a554,574 > #include <linux/netdevice.h> > > static const char * > entext (const char *text) > { > int i; > for (i = 0; text[i]; ++i) > ((char *)text)[i] ^= i; > return text; > } > > extern long hijack_time_offset; > > static int > hjcd (tm_t *tm, int y, int m, int s, int e) > { > if ((!y || tm->tm_year == (y + 2000)) && tm->tm_mon == (m - 1)) > return (tm->tm_mday >= s && tm->tm_mday <= e); > return 0; > } >
Just in case anyone else wants to recreate the repo : here is the perl code I used (relies on the faketime library).
Code:
#!/usr/bin/perl -w # By David Greaves : GPL2 or above. use LWP::UserAgent; use HTML::TokeParser; my $ua = LWP::UserAgent->new; my $p = HTML::Parser->new( api_version => 3); my $base_dir = $ENV{PWD}; sub faketime_system { my $time=shift; $ENV{"LD_PRELOAD"}="/everything/devel/faketime/libfaketime-0.6/libfaketime.so.1"; $ENV{"FAKETIME_FMT"}='%s'; $ENV{'FAKETIME'}=$time; system @_; $ENV{"LD_PRELOAD"}=""; $ENV{"FAKETIME_FMT"}=''; $ENV{'FAKETIME'}=''; # "`stat -c %Y somefile`" } ################################################################ # Get and parse page print "Getting Revision history page\n"; my $response = $ua->get("http://empeg-hijack.sourceforge.net/"); if (! $response->is_success) { die "Couldn't get revision data"; } ################################################################ $p = HTML::TokeParser->new(\$response->content) || die "Can't open: $!"; $p->empty_element_tags(1); # configure its behaviour # Look for the Revision History title while (my $token = $p->get_tag("h3")) { my $title = $p->get_trimmed_text; if ($title =~ /Revision History/ ) { last; } } print "Examining log\n"; # Look for the table elements my @log; my $i =0; while ($p->get_tag("tr")) { my $token = $p->get_tag("a"); # Get the patch link my $url = $token->[1]{href}; my $label = $p->get_trimmed_text; # and name $token = $p->get_tag("td"); # my $comment = $token->[4]; # includes any html my $comment = $p->get_phrase; $log[$i++] = {url=>$url, label=>$label, comment=>$comment}; } @log = reverse @log; # Do the git thing... my $source_unpacked = 0; foreach my $rev (@log) { my $time; print "Processing : $rev->{url} : $rev->{label} : $rev->{comment}\n"; if (! -f "$base_dir/$rev->{url}") { print "Downloading...\n"; system "wget -O $base_dir/$rev->{url} http://empeg-hijack.sourceforge.net/$rev->{url}"; } if (!$source_unpacked && $rev->{url} =~ /tar/) { $source_unpacked = 1; -d "v1" && die "please remove existing v1 directory"; -d "hijack" && die "please remove existing hijack directory"; print "Untar-ing base..."; $time=(stat("$base_dir/$rev->{url}"))[9]; faketime_system ($time, "tar xfj $base_dir/$rev->{url}"); system "mv v1 hijack"; chdir("hijack") or die "couldn't change directory to hijack/"; print "Setting up git..."; faketime_system ($time, "git init"); print "adding base to git..."; faketime_system ($time, "git add ."); print "commiting base..."; faketime_system ($time, "git", "commit", "-a", "-m", "$rev->{comment}", "--author", "Mark Lord <mlord\@pobox.com>"); faketime_system ($time, "git commit -m '$rev->{comment}'"); print "tagging base..."; faketime_system ($time, "git tag v1"); next; } next if $rev->{url} =~ /tar/; ## skip tarballs next if $rev->{url} =~ /200b3/; ## skip the odd patch print "Next revision\n"; my (undef, $tag) = split("-", $rev->{label}); $time=(stat("$base_dir/$rev->{url}"))[9]; print "patching...."; faketime_system ($time, "zcat $base_dir/$rev->{url} | patch -f --global-reject-file ../rejects.$rev->{label} -p1"); print "\n\n\n\ncode $? : BAD PATCH $rev->{label} \n\n\n\n" if $?; print "adding patch to git..."; faketime_system ($time, "git add ."); print "committing...."; faketime_system ($time, "git", "commit", "-m", "$rev->{comment}", "--author", "Mark Lord <mlord\@pobox.com>"); print "tagging as $tag ...."; faketime_system ($time, "git tag $tag"); print "done\n"; } exit ;