From patchwork Thu Jul 28 15:54:24 2011 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: David Howells X-Patchwork-Id: 1016612 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by demeter1.kernel.org (8.14.4/8.14.4) with ESMTP id p6SFvSNo021948 for ; Thu, 28 Jul 2011 15:57:28 GMT Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1755977Ab1G1PzF (ORCPT ); Thu, 28 Jul 2011 11:55:05 -0400 Received: from mx1.redhat.com ([209.132.183.28]:57399 "EHLO mx1.redhat.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1755462Ab1G1PzC (ORCPT ); Thu, 28 Jul 2011 11:55:02 -0400 Received: from int-mx10.intmail.prod.int.phx2.redhat.com (int-mx10.intmail.prod.int.phx2.redhat.com [10.5.11.23]) by mx1.redhat.com (8.14.4/8.14.4) with ESMTP id p6SFsSU0002153 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK); Thu, 28 Jul 2011 11:54:29 -0400 Received: from warthog.procyon.org.uk ([10.3.112.8]) by int-mx10.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id p6SFsPeI017580; Thu, 28 Jul 2011 11:54:26 -0400 Organization: Red Hat UK Ltd. Registered Address: Red Hat UK Ltd, Amberley Place, 107-111 Peascod Street, Windsor, Berkshire, SI4 1TE, United Kingdom. Registered in England and Wales under Company Registration No. 3798903 From: David Howells Subject: [PATCH 32/40] UAPI: Add a script to create a commit to set up new UAPI dirs [ver #3] To: torvalds@osdl.org Cc: linux-kernel@vger.kernel.org, linux-kbuild@vger.kernel.org, David Howells Date: Thu, 28 Jul 2011 16:54:24 +0100 Message-ID: <20110728155424.16618.81588.stgit@warthog.procyon.org.uk> In-Reply-To: <20110728154920.16618.89358.stgit@warthog.procyon.org.uk> References: <20110728154920.16618.89358.stgit@warthog.procyon.org.uk> User-Agent: StGIT/0.14.3 MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.68 on 10.5.11.23 Sender: linux-kbuild-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kbuild@vger.kernel.org X-Greylist: IP, sender and recipient auto-whitelisted, not delayed by milter-greylist-4.2.6 (demeter1.kernel.org [140.211.167.41]); Thu, 28 Jul 2011 15:57:28 +0000 (UTC) Add a script to create and set up new UAPI dirs and then commit them to GIT or StGIT: scripts/uapi-disintegration/set-up-Kbuild.pl Signed-off-by: David Howells --- scripts/uapi-disintegration/set-up-Kbuild.pl | 107 ++++++++++++++++++++++++++ 1 files changed, 107 insertions(+), 0 deletions(-) create mode 100755 scripts/uapi-disintegration/set-up-Kbuild.pl -- To unsubscribe from this list: send the line "unsubscribe linux-kbuild" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html diff --git a/scripts/uapi-disintegration/set-up-Kbuild.pl b/scripts/uapi-disintegration/set-up-Kbuild.pl new file mode 100755 index 0000000..6e497fb --- /dev/null +++ b/scripts/uapi-disintegration/set-up-Kbuild.pl @@ -0,0 +1,107 @@ +#!/usr/bin/perl -w + +use File::Find; +use File::Path; +use strict; + +my @sys_header_dirs = ( + "include" + ); + +# +# Changes must be committed first +# +system("git diff --quiet") == 0 or die "Uncommitted changes; aborting\n"; + +# +# Delete the old patch under StGIT +# +system("stg delete uapi-set-up-Kbuild.diff"); + +# +# Set up the patch under StGIT +# +system("stg new -m '" . + "UAPI: Set up UAPI Kbuild files\n" . + "\n" . + "Set up empty UAPI Kbuild files to be populated by the header splitter using\n" . + "scripts/uapi-disintegrate/set-up-Kbuild.pl\n" . + "' --sign uapi-set-up-Kbuild.diff" + ) == 0 or die; + +# +# Find all the system header directories under arch +# +opendir DIR, "arch" or die; +push @sys_header_dirs, + map { "arch/$_/include"; } +sort grep { -d "arch/$_/include"; } +grep { $_ !~ /^[.]/ } +readdir DIR; +closedir DIR; + +# +# Find all the header files +# +my %kbuilds = (); +sub find_Kbuild() +{ + $kbuilds{$File::Find::name} = 1 if ($_ =~ /Kbuild$/); +} + +find(\&find_Kbuild, @sys_header_dirs); + +#print join("\n", sort keys %kbuilds), "\n"; + +foreach my $kbuild (sort grep { $_ !~ m@arch/um/@} keys %kbuilds) { + + my $uapi_kbuild = $kbuild; + $uapi_kbuild =~ s@include/@include/uapi/@; + + print "[[[ $uapi_kbuild ]]]\n"; + + open FD, '<', $kbuild or die "open $kbuild: $!\n"; + my @old = ; + close FD or die; + + my @new = (); + + if ($#old > -1) { + if ($old[0] =~ /^#/) { + for (my $l = 0; $l <= $#old; $l++) { + last if ($old[$l] !~ /^#/); + push @new, $old[$l]; + } + push @new, "\n"; + } + + push @new, map { + my $x = $_; + $x =~ s@include/@include/uapi/@; + $x; + } grep { $_ =~ m@^include@; } @old; + + push @new, "\n" if ($#new > -1); + + push @new, grep { $_ =~ m@header-y\s+[+]=\s+[a-z0-9A-Z-]+/\s*@; } @old; + } + + #print @new; + + my $uapidir = $uapi_kbuild; + $uapidir = $1 if ($uapidir =~ m!(.*)/!); + mkpath($uapidir) if (! -d $uapidir); + + open FD, '>', $uapi_kbuild or die "create $uapi_kbuild: $!\n"; + print FD "# UAPI Header export list\n" or die "write $uapi_kbuild: $!\n"; + print FD @new or die "write $uapi_kbuild: $!\n"; + close FD or die "close $uapi_kbuild: $!\n"; + system("stg add $uapi_kbuild") == 0 or die; +} + +# +# Commit the changes +# +system("stg ref") == 0 or die; + +exit 0;