summaryrefslogtreecommitdiff
path: root/debian/scripts/misc
diff options
context:
space:
mode:
Diffstat (limited to 'debian/scripts/misc')
-rwxr-xr-xdebian/scripts/misc/getabis79
-rwxr-xr-xdebian/scripts/misc/git-ubuntu-log232
-rwxr-xr-xdebian/scripts/misc/insert-changes.pl36
-rwxr-xr-xdebian/scripts/misc/insert-ubuntu-changes58
-rwxr-xr-xdebian/scripts/misc/kernelconfig170
-rwxr-xr-xdebian/scripts/misc/retag34
-rwxr-xr-xdebian/scripts/misc/splitconfig.pl111
7 files changed, 720 insertions, 0 deletions
diff --git a/debian/scripts/misc/getabis b/debian/scripts/misc/getabis
new file mode 100755
index 00000000000..44602a963b0
--- /dev/null
+++ b/debian/scripts/misc/getabis
@@ -0,0 +1,79 @@
+#!/bin/bash
+
+. debian/debian.env
+
+if [ "$#" != "2" ]; then
+ echo "Usage: $0 <release> <revision>" 1>&2
+ exit 1
+fi
+
+ver=$1
+revision=$2
+abi=$(echo $revision | awk -F. '{print $1}')
+
+verabi=$ver-$abi
+verfull=$ver-$revision
+
+src_pkg_name=$(dpkg-parsechangelog -l${DEBIAN}/changelog|grep Source|sed 's/^.*Source: //')
+
+WGET="wget --quiet -c"
+
+abidir="`pwd`/$DEBIAN/abi/$verfull"
+tmpdir="`pwd`/abi-tmp-$verfull"
+origdir="`pwd`"
+
+test -d $tmpdir || mkdir $tmpdir
+
+getall() {
+ arch=$1
+ shift
+
+ mkdir -p $abidir/$arch
+
+ for sub in $@; do
+ if [ -f $abidir/$arch/$sub ]; then
+ echo "Exists: $sub"
+ continue
+ fi
+ echo -n "Fetching $sub..."
+ filename=linux-image-${verabi}-${sub}_${verfull}_${arch}.deb
+ cd $tmpdir
+ for r in "${repo_list[@]}"
+ do
+ url="`echo $r | sed 's/linux$/'${src_pkg_name}'/'`"
+ if ! [ -f $filename ]; then
+ $WGET $url/$filename
+ fi
+ done
+ if [ "$?" = "0" ]; then
+ echo -n "extracting..."
+ dpkg-deb --extract $filename tmp
+ if [ -f tmp/boot/abi-* ]; then
+ mv tmp/boot/abi-* $abidir/$arch/$sub
+ else
+ echo -n "NO ABI FILE..."
+ fi
+ (cd tmp; find lib/modules/$verabi-$sub/kernel -name '*.ko') | \
+ sed -e 's/.*\/\([^\/]*\)\.ko/\1/' | sort > \
+ $abidir/$arch/$sub.modules
+ rm -rf tmp $filename
+ echo "done."
+ else
+ echo "FAILED."
+ fi
+ cd $origdir
+ done
+}
+
+# MAIN
+
+# Setup abi directory
+mkdir -p $abidir
+echo $abi > $abidir/abiname
+
+# NOTE: The flavours are hardcoded, because they may have changed from the
+# current build.
+
+. $DEBIAN/etc/getabis
+
+rmdir $tmpdir
diff --git a/debian/scripts/misc/git-ubuntu-log b/debian/scripts/misc/git-ubuntu-log
new file mode 100755
index 00000000000..1a244cf0ba4
--- /dev/null
+++ b/debian/scripts/misc/git-ubuntu-log
@@ -0,0 +1,232 @@
+#!/usr/bin/perl -w
+
+use strict;
+use Text::Wrap;
+
+my $kernel_auth = "Upstream Kernel Changes";
+
+my (%map, @reverts);
+my $pstate = 1;
+my $no_kern_log = 0;
+my $print_shas = 0;
+my $first_print = 1;
+
+while (@ARGV) {
+ my $opt = $ARGV[0];
+ shift;
+ if ($opt eq "--no-kern-log") {
+ $no_kern_log = 1;
+ } elsif ($opt eq "--print-shas") {
+ $print_shas = 1;
+ } else {
+ print STDERR "Unknown options: $opt\n";
+ exit(1);
+ }
+}
+
+sub check_reverts($) {
+ my ($entry) = @_;
+ my ($check);
+
+ foreach $check (reverse @reverts) {
+ my $desc = "Revert \"" . $entry->{'desc'} . "\"";
+ if ($check->{'desc'} eq $desc) {
+ @reverts = grep($_->{'desc'} ne $desc, @reverts);
+ return 1;
+ }
+ }
+
+ return 0;
+}
+
+sub add_entry($) {
+ my ($entry) = @_;
+ my $key = $entry->{'author'};
+
+ # store description in array, in email->{desc list} map
+ if (exists $map{$key}) {
+ # grab ref
+ my $obj = $map{$key};
+
+ # add desc to array
+ push(@$obj, $entry);
+ } else {
+ # create new array, containing 1 item
+ my @arr = ($entry);
+
+ # store ref to array
+ $map{$key} = \@arr;
+ }
+}
+
+sub shortlog_entry($$$$$) {
+ my ($name, $desc, $bug, $cve, $commit) = @_;
+ my $entry;
+
+ $desc =~ s#/pub/scm/linux/kernel/git/#/.../#g;
+ $desc =~ s#\[PATCH\] ##g;
+
+ $desc =~ s#^\s*##g;
+ $desc =~ s# *UBUNTU: ##g;
+
+ $entry->{'desc'} = $desc;
+ if ($bug ne '') {
+ $entry->{'bugno'} = $bug;
+ }
+ $entry->{'cve'} = $cve;
+ $entry->{'commit'} = $commit;
+ $entry->{'author'} = $name;
+
+ if ($desc =~ /^Revert "/) {
+ push(@reverts, $entry);
+ return;
+ }
+
+ return if check_reverts($entry);
+
+ add_entry($entry);
+}
+
+# sort comparison function
+sub by_name($$) {
+ my ($a, $b) = @_;
+
+ uc($a) cmp uc($b);
+}
+
+sub shortlog_output {
+ my ($obj, $key, $entry);
+
+ foreach $key (sort by_name keys %map) {
+ next if $key eq $kernel_auth and $no_kern_log;
+
+ print "\n" unless $first_print;
+ $first_print = 0;
+
+ # output author
+ printf " [ %s ]\n\n", $key;
+
+ # output author's 1-line summaries
+ $obj = $map{$key};
+ foreach $entry (reverse @$obj) {
+ print wrap(" * ", " ", $entry->{'desc'}) . "\n";
+ # For non upstream changes, add other info.
+ if ($key ne $kernel_auth) {
+ if ($print_shas) {
+ print " - GIT-SHA " . $entry->{'commit'} .
+ "\n";
+ }
+ }
+ if (defined($entry->{'bugno'})) {
+ print " - LP: #" . $entry->{'bugno'} . "\n";
+ }
+ if (defined($entry->{'cve'})) {
+ print " - " . $entry->{'cve'} . "\n";
+ }
+ }
+ }
+}
+
+sub changelog_input {
+ my ($author, $desc, $commit, $entry, $cve);
+
+ while (<STDIN>) {
+ # get commit
+ if ($pstate == 1) {
+ next unless /^commit (.*)/;
+
+ $commit = $1;
+
+ $pstate++;
+ }
+
+ # get author and email
+ elsif ($pstate == 2) {
+ my ($email);
+
+ next unless /^[Aa]uthor:?\s*(.*?)\s*<(.*)>/;
+
+ $author = $1;
+ $email = $2;
+ $desc = undef;
+ $cve = undef;
+
+ # cset author fixups
+ if (!$author) {
+ $author = $email;
+ }
+ $pstate++;
+ }
+
+ # skip to blank line
+ elsif ($pstate == 3) {
+ next unless /^\s*$/;
+ $pstate++;
+ }
+
+ # skip to non-blank line
+ elsif ($pstate == 4) {
+ next unless /^\s*?(.*)/;
+ my $ignore = 0;
+ my $do_ignore = 0;
+ my $bug = undef;
+ my %bugz = ();
+ my $k;
+
+ # skip lines that are obviously not
+ # a 1-line cset description
+ next if /^\s*From: /;
+
+ chomp;
+ $desc = $1;
+
+ if ($desc =~ /^ *(Revert "|)UBUNTU:/) {
+ $do_ignore = 1;
+ } else {
+ $do_ignore = 0;
+ $author = $kernel_auth;
+ $ignore = 1 if $desc =~ /Merge /;
+ }
+ while (<STDIN>) {
+ $ignore = 1 if ($do_ignore && /^ *Ignore: yes/i);
+ if (/^ *Bug: *(#|)([0-9#,\s]*)\s*$/i) {
+ foreach $k (split('(,|\s)\s*(#|)', $2)) {
+ $bugz{$k} = 1 if (($k ne '') and ($k =~ /[0-9]+/));
+ }
+ }
+ elsif (/^ *BugLink: *http.*:\/\/.*\/([0-9]+)/i) {
+ $bugz{$1} = 1;
+ }
+ elsif (/^ *(CVE-.*)/) {
+ $cve = $1
+ }
+ last if /^commit /;
+ }
+
+ $bug = join(", #", sort keys(%bugz));
+ if (!$ignore) {
+ &shortlog_entry($author, $desc, $bug,
+ $cve, $commit, 0);
+ }
+
+ $pstate = 1;
+ if ($_ && /^commit (.*)/) {
+ $commit = $1;
+ $pstate++;
+ }
+ }
+
+ else {
+ die "invalid parse state $pstate";
+ }
+ }
+
+ foreach $entry (@reverts) {
+ add_entry($entry);
+ }
+}
+
+&changelog_input;
+&shortlog_output;
+
+exit(0);
diff --git a/debian/scripts/misc/insert-changes.pl b/debian/scripts/misc/insert-changes.pl
new file mode 100755
index 00000000000..1c18234727f
--- /dev/null
+++ b/debian/scripts/misc/insert-changes.pl
@@ -0,0 +1,36 @@
+#!/usr/bin/perl -w
+
+my $debian;
+$droot = $ARGV[0] if (defined $ARGV[0]);
+$droot = 'debian' if (!defined $droot);
+$debian = $ARGV[1] if (defined $ARGV[1]);
+$debian = 'debian.linaro' if (!defined $debian);
+
+system("make -s -f $droot/rules printchanges > $debian/changes");
+
+open(CHANGELOG, "< $debian/changelog") or die "Cannot open changelog";
+open(CHANGES, "< $debian/changes") or die "Cannot open new changes";
+open(NEW, "> $debian/changelog.new") or die "Cannot open new changelog";
+
+$printed = 0;
+
+while (<CHANGELOG>) {
+ if (/^ CHANGELOG: /) {
+ next if $printed;
+
+ while (<CHANGES>) {
+ print NEW;
+ }
+
+ $printed = 1;
+ } else {
+ print NEW;
+ }
+}
+
+close(NEW);
+close(CHANGES);
+close(CHANGELOG);
+
+rename("$debian/changelog.new", "$debian/changelog");
+unlink("$debian/changes");
diff --git a/debian/scripts/misc/insert-ubuntu-changes b/debian/scripts/misc/insert-ubuntu-changes
new file mode 100755
index 00000000000..61b1faec687
--- /dev/null
+++ b/debian/scripts/misc/insert-ubuntu-changes
@@ -0,0 +1,58 @@
+#!/usr/bin/perl
+
+if ($#ARGV != 2) {
+ die "Usage: $0 <changelog> <stop at> <start at>\n";
+}
+my ($changelog, $end, $start) = @ARGV;
+
+$end =~ s/.*\.//;
+$start =~ s/.*\.//;
+
+my @changes = ();
+my $output = 0;
+open(CHG, "<debian.linaro/changelog") ||
+ open(CHG, "<debian/changelog") ||
+ die "$0: debian/changelog: open failed - $!\n";
+while (<CHG>) {
+ if (/^\S+\s+\((.*\.(\d+))\)/) {
+ if ($2 <= $end) {
+ last;
+ }
+ if ($2 == $start) {
+ $output = 1;
+ }
+ if ($output) {
+ push(@changes, "\n [ Ubuntu: $1 ]\n\n");
+ next;
+ }
+ }
+ next if ($output == 0);
+
+ next if (/^\s*$/);
+ next if (/^\s--/);
+ next if (/^\s\s[^\*\s]/);
+
+ push(@changes, $_);
+}
+close(CHG);
+
+open(CHANGELOG, "< $changelog") or die "Cannot open changelog";
+open(NEW, "> $changelog.new") or die "Cannot open new changelog";
+
+$printed = 3;
+while (<CHANGELOG>) {
+ if (/^ CHANGELOG: /) {
+ $printed--;
+ print NEW;
+ if ($printed == 0) {
+ print NEW @changes;
+ }
+ next;
+ }
+ print NEW;
+}
+
+close(NEW);
+close(CHANGELOG);
+
+rename("$changelog.new", "$changelog");
diff --git a/debian/scripts/misc/kernelconfig b/debian/scripts/misc/kernelconfig
new file mode 100755
index 00000000000..aa74e20c180
--- /dev/null
+++ b/debian/scripts/misc/kernelconfig
@@ -0,0 +1,170 @@
+#!/bin/bash
+
+. debian/debian.env
+
+# Script to merge all configs and run 'make silentoldconfig' on it to wade out bad juju.
+# Then split the configs into distro-commmon and flavour-specific parts
+
+# We have to be in the top level kernel source directory
+if [ ! -f MAINTAINERS ] || [ ! -f Makefile ]; then
+ echo "This does not appear to be the kernel source directory." 1>&2
+ exit 1
+fi
+
+mode=${1:?"Usage: $0 [oldconfig|editconfig]"}
+case "$mode" in
+ oldconfig) ;; # All is good
+ defaultconfig) ;; # All is good
+ editconfig) ;; # All is good
+ genconfig) ;; # All is good
+ *) echo "$0 called with invalid mode" 1>&2
+ exit 1 ;;
+esac
+kerneldir="`pwd`"
+confdir="$kerneldir/${DEBIAN}/config"
+sharedconfdir="$kerneldir/debian.linaro/config"
+variant="$2"
+
+. $DEBIAN/etc/kernelconfig
+
+bindir="`pwd`/${DROOT}/scripts/misc"
+common_conf="$confdir/config.common.$family"
+tmpdir=`mktemp -d`
+mkdir "$tmpdir/CONFIGS"
+
+if [ "$mode" = "genconfig" ]; then
+ keep=1
+ mode="oldconfig"
+ test -d CONFIGS || mkdir CONFIGS
+fi
+
+for arch in $archs; do
+ rm -rf build
+ mkdir build
+
+ # Map debian archs to kernel archs
+ case "$arch" in
+ amd64) kernarch="x86_64" ;;
+ lpia) kernarch="x86" ;;
+ sparc) kernarch="sparc64" ;;
+ armel) kernarch="arm" ;;
+ *) kernarch="$arch" ;;
+ esac
+
+ archconfdir=$confdir/$arch
+ flavourconfigs=$(cd $archconfdir && ls config.flavour.*)
+
+ # Merge configs
+ # We merge config.common.ubuntu + config.common.<arch> +
+ # config.flavour.<flavour>
+
+ for config in $flavourconfigs; do
+ fullconf="$tmpdir/$arch-$config-full"
+ case $config in
+ *)
+ : >"$fullconf"
+ if [ -f $common_conf ]; then
+ cat $common_conf >> "$fullconf"
+ fi
+ if [ -f $archconfdir/config.common.$arch ]; then
+ cat $archconfdir/config.common.$arch >> "$fullconf"
+ fi
+ cat "$archconfdir/$config" >>"$fullconf"
+ if [ -f $confdir/OVERRIDES ]; then
+ cat $confdir/OVERRIDES >> "$fullconf"
+ fi
+ ;;
+ esac
+ done
+
+ for config in $flavourconfigs; do
+ if [ -f $archconfdir/$config ]; then
+ fullconf="$tmpdir/$arch-$config-full"
+ cat "$fullconf" > build/.config
+ # Call oldconfig or menuconfig
+ case "$mode" in
+ oldconfig)
+ # Weed out incorrect config parameters
+ echo "* Run silentoldconfig on $arch/$config ..."
+ make O=`pwd`/build ARCH=$kernarch silentoldconfig ;;
+ defaultconfig)
+ # Weed out incorrect config parameters
+ echo "* Run oldconfig on $arch/$config ..."
+ make O=`pwd`/build ARCH=$kernarch oldconfig ;;
+ editconfig)
+ # Interactively edit config parameters
+ while : ; do
+ echo -n "Do you want to edit config: $arch/$config? [Y/n] "
+ read choice
+
+ case "$choice" in
+ y* | Y* | "" )
+ make O=`pwd`/build ARCH=$kernarch menuconfig
+ break ;;
+ n* | N* )
+ break ;;
+ *)
+ echo "Entry not valid"
+ esac
+ done
+ ;;
+ *) # Bad!
+ exit 1 ;;
+ esac
+ cat build/.config > $archconfdir/$config
+ cat build/.config > "$tmpdir/CONFIGS/$arch-$config"
+ if [ "$keep" = "1" ]; then
+ cat build/.config > CONFIGS/$arch-$config
+ fi
+ else
+ echo "!! Config not found $archconfdir/$config..."
+ fi
+ done
+
+ echo "Running splitconfig.pl for $arch"
+ echo
+
+ # Can we make this more robust by avoiding $tmpdir completely?
+ # This approach was used for now because I didn't want to change
+ # splitconfig.pl
+ (cd $archconfdir; $bindir/splitconfig.pl; mv config.common \
+ config.common.$arch; cp config.common.$arch $tmpdir)
+done
+
+rm -f $common_conf
+
+# Now run splitconfig.pl on all the config.common.<arch> copied to
+# $tmpdir
+(cd $tmpdir; $bindir/splitconfig.pl)
+(
+ cd $confdir;
+ rm -f *-full
+ grep -v 'is UNMERGABLE' <$tmpdir/config.common >$common_conf
+ for arch in $archs; do
+ grep -v 'is UNMERGABLE' <$tmpdir/config.common.$arch \
+ >$arch/config.common.$arch
+ done
+)
+
+echo ""
+echo "Running config-check for all configurations ..."
+echo ""
+fail=0
+for arch in $archs; do
+ archconfdir=$confdir/$arch
+ flavourconfigs=$(cd $archconfdir && ls config.flavour.*)
+ for config in $flavourconfigs; do
+ if [ -f $archconfdir/$config ]; then
+ fullconf="$tmpdir/CONFIGS/$arch-$config"
+ "$bindir/../config-check" "$fullconf" "$arch" "$config" "$sharedconfdir" "0" || let "fail=$fail+1"
+ fi
+ done
+done
+
+if [ "$fail" != 0 ]; then
+ echo ""
+ echo "*** ERROR: $fail config-check failures detected"
+ echo ""
+fi
+
+rm -rf build
diff --git a/debian/scripts/misc/retag b/debian/scripts/misc/retag
new file mode 100755
index 00000000000..94cf169a076
--- /dev/null
+++ b/debian/scripts/misc/retag
@@ -0,0 +1,34 @@
+#!/usr/bin/perl -w
+
+open(TAGS, "git tag -l |") or die "Could not get list of tags";
+@tags = <TAGS>;
+close(TAGS);
+
+open(LOGS, "git log --pretty=short |") or die "ERROR: Calling git log";
+my $commit = "";
+
+while (<LOGS>) {
+ my $origtag;
+
+ if (m|^commit (.*)$|) {
+ $commit = $1;
+ next;
+ }
+
+ m|\s*UBUNTU: (Ubuntu-2\.6\..*)| or next;
+
+ $tag = $1;
+
+ ($origtag) = grep(/^$tag.orig$/, @tags);
+
+ if (!defined($origtag)) {
+ print "I: Adding original tag for $tag\n";
+ system("git tag -m $tag $tag.orig $tag");
+ }
+
+ print "I: Tagging $tag => $commit\n";
+
+ system("git tag -f -m $tag $tag $commit");
+}
+
+close(LOGS);
diff --git a/debian/scripts/misc/splitconfig.pl b/debian/scripts/misc/splitconfig.pl
new file mode 100755
index 00000000000..3dca468fca6
--- /dev/null
+++ b/debian/scripts/misc/splitconfig.pl
@@ -0,0 +1,111 @@
+#!/usr/bin/perl -w
+
+%allconfigs = ();
+%common = ();
+
+print "Reading config's ...\n";
+
+opendir(DIR, ".");
+
+while (defined($config = readdir(DIR))) {
+ # Only config.*
+ next if $config !~ /^config\..*/;
+ # Nothing that is disabled, or remnant
+ next if $config =~ /.*\.(default|disabled|stub)$/;
+
+ %{$allconfigs{$config}} = ();
+
+ print " processing $config ... ";
+
+ open(CONFIG, "< $config");
+
+ while (<CONFIG>) {
+ # Skip comments
+ /^#*\s*CONFIG_(\w+)[\s=](.*)$/ or next;
+
+ ${$allconfigs{$config}}{$1} = $2;
+
+ $common{$1} = $2;
+ }
+
+ close(CONFIG);
+
+ print "done.\n";
+}
+
+closedir(DIR);
+
+print "\n";
+
+print "Merging lists ... \n";
+
+# %options - pointer to flavour config inside the allconfigs array
+for $config (keys(%allconfigs)) {
+ my %options = %{$allconfigs{$config}};
+
+ print " processing $config ... ";
+
+ for $key (keys(%common)) {
+ next if not defined $common{$key};
+
+ # If we don't have the common option, then it isn't
+ # common. If we do have that option, it must have the same
+ # value. EXCEPT where this file does not have a value at all
+ # which may safely be merged with any other value; the value
+ # will be elided during recombination of the parts.
+ if (!defined($options{$key})) {
+ # Its ok really ... let it merge
+ } elsif (not defined($options{$key})) {
+ undef $common{$key};
+ } elsif ($common{$key} ne $options{$key}) {
+ undef $common{$key};
+ }
+ }
+
+ print "done.\n";
+}
+
+print "\n";
+
+print "Creating common config ... ";
+
+open(COMMON, "> config.common");
+print COMMON "#\n# Common config options automatically generated by splitconfig.pl\n#\n";
+
+for $key (sort(keys(%common))) {
+ if (not defined $common{$key}) {
+ print COMMON "# CONFIG_$key is UNMERGABLE\n";
+ } elsif ($common{$key} eq "is not set") {
+ print COMMON "# CONFIG_$key is not set\n";
+ } else {
+ print COMMON "CONFIG_$key=$common{$key}\n";
+ }
+}
+close(COMMON);
+
+print "done.\n\n";
+
+print "Creating stub configs ...\n";
+
+for $config (keys(%allconfigs)) {
+ my %options = %{$allconfigs{$config}};
+
+ print " processing $config ... ";
+
+ open(STUB, "> $config");
+ print STUB "#\n# Config options for $config automatically generated by splitconfig.pl\n#\n";
+
+ for $key (sort(keys(%options))) {
+ next if defined $common{$key};
+
+ if ($options{$key} =~ /^is /) {
+ print STUB "# CONFIG_$key $options{$key}\n";
+ } else {
+ print STUB "CONFIG_$key=$options{$key}\n";
+ }
+ }
+
+ close(STUB);
+
+ print "done.\n";
+}