summaryrefslogtreecommitdiffstats
path: root/freed-ora/current/f22/scripts
diff options
context:
space:
mode:
Diffstat (limited to 'freed-ora/current/f22/scripts')
-rwxr-xr-xfreed-ora/current/f22/scripts/allarchconfig.sh16
-rwxr-xr-xfreed-ora/current/f22/scripts/bumpspecfile.py76
-rwxr-xr-xfreed-ora/current/f22/scripts/check-TODO.sh27
-rw-r--r--freed-ora/current/f22/scripts/check-configs.pl83
-rwxr-xr-xfreed-ora/current/f22/scripts/combine.sh34
-rw-r--r--freed-ora/current/f22/scripts/configcommon.pl82
-rw-r--r--freed-ora/current/f22/scripts/configdiff.pl76
-rwxr-xr-xfreed-ora/current/f22/scripts/generate-git-snapshot.sh25
-rwxr-xr-xfreed-ora/current/f22/scripts/grab-logs.sh16
-rwxr-xr-xfreed-ora/current/f22/scripts/newpatch.sh21
-rw-r--r--freed-ora/current/f22/scripts/rediffall.pl64
-rwxr-xr-xfreed-ora/current/f22/scripts/sort-config226
12 files changed, 746 insertions, 0 deletions
diff --git a/freed-ora/current/f22/scripts/allarchconfig.sh b/freed-ora/current/f22/scripts/allarchconfig.sh
new file mode 100755
index 000000000..f80c23197
--- /dev/null
+++ b/freed-ora/current/f22/scripts/allarchconfig.sh
@@ -0,0 +1,16 @@
+#!/bin/sh
+# Run from within a source tree.
+
+for i in configs/kernel-*.config
+do
+ cp -f $i .config
+ Arch=`head -1 .config | cut -b 3-`
+ echo $Arch \($i\)
+ make ARCH=$Arch listnewconfig | grep -E '^CONFIG_' >.newoptions || true;
+ if [ -s .newoptions ]; then
+ cat .newoptions;
+ exit 1;
+ fi;
+ rm -f .newoptions;
+done
+
diff --git a/freed-ora/current/f22/scripts/bumpspecfile.py b/freed-ora/current/f22/scripts/bumpspecfile.py
new file mode 100755
index 000000000..bc02ab300
--- /dev/null
+++ b/freed-ora/current/f22/scripts/bumpspecfile.py
@@ -0,0 +1,76 @@
+#!/usr/bin/python
+#
+# Uses git config options user.name and user.email, falls
+# back to env vars $GIT_COMMITTER_NAME and $GIT_COMMITTER_EMAIL
+#
+import re
+import sys
+import time
+import os
+import string
+
+class Specfile:
+ def __init__(self,filename):
+ file=open(filename,"r")
+ self.lines=file.readlines()
+ self.vr=""
+
+ def getNextVR(self,aspec):
+ # Get VR for changelog entry.
+ (ver,rel) = os.popen("LC_ALL=C rpm --specfile -q --qf '%%{version} %%{release}\n' --define 'dist %%{nil}' %s | head -1" % aspec).read().strip().split(' ')
+ pos = 0
+ # general released kernel case, bump 1st field
+ fedora_build = rel.split('.')[pos]
+ if fedora_build == "0":
+ # this is a devel kernel, bump 2nd field
+ pos = 1
+ elif rel.split('.')[-1] != fedora_build:
+ # this is a branch, must bump 3rd field
+ pos = 2
+ fedora_build = rel.split('.')[pos]
+ if pos == 1 and len(rel.split('.')) > 4:
+ # uh... what? devel kernel in a branch? private build? just do no VR in clog...
+ print "Warning: not adding any VR to changelog, couldn't tell for sure which field to bump"
+ pos = -1
+ next_fedora_build = int(fedora_build) + 1
+ if pos == 0:
+ nextrel = str(next_fedora_build)
+ elif pos == 1:
+ nextrel = "0." + str(next_fedora_build)
+ elif pos == 2:
+ nextrel = rel.split('.')[0] + "." + rel.split('.')[1] + "." + str(next_fedora_build)
+ if pos >= 0:
+ for s in rel.split('.')[pos + 1:]:
+ nextrel = nextrel + "." + s
+ self.vr = " "+ver+'-'+nextrel
+
+ def addChangelogEntry(self,entry):
+ user = os.popen("git config --get user.name").read().rstrip()
+ if (user == ""):
+ user = os.environ.get("GIT_COMMITTER_NAME","Unknown")
+ email = os.popen("git config --get user.email").read().rstrip()
+ if (email == ""):
+ email = os.environ.get("GIT_COMMITTER_EMAIL","unknown")
+ if (email == "unknown"):
+ email = os.environ.get("USER","unknown")+"@fedoraproject.org"
+ changematch=re.compile(r"^%changelog")
+ date=time.strftime("%a %b %d %Y", time.localtime(time.time()))
+ newchangelogentry="%changelog\n* "+date+" "+user+" <"+email+">"+self.vr+"\n"+entry+"\n\n"
+ for i in range(len(self.lines)):
+ if(changematch.match(self.lines[i])):
+ self.lines[i]=newchangelogentry
+ break
+
+ def writeFile(self,filename):
+ file=open(filename,"w")
+ file.writelines(self.lines)
+ file.close()
+
+if __name__=="__main__":
+ aspec=(sys.argv[1])
+ s=Specfile(aspec)
+ entry=(sys.argv[2])
+ s.getNextVR(aspec)
+ s.addChangelogEntry(entry)
+ s.writeFile(aspec)
+
diff --git a/freed-ora/current/f22/scripts/check-TODO.sh b/freed-ora/current/f22/scripts/check-TODO.sh
new file mode 100755
index 000000000..7067f0b44
--- /dev/null
+++ b/freed-ora/current/f22/scripts/check-TODO.sh
@@ -0,0 +1,27 @@
+#!/bin/sh
+
+for i in `grep ^* TODO | awk '{ print $2 }'`
+do
+ if [ ! -f $i ]; then
+ echo "$i referenced in the TODO, but isn't in CVS!"
+ fi;
+done
+
+# sometimes dead stuff lingers in cvs, even though it's not in the specfile.
+for i in *.patch
+do
+ for j in $(grep $i kernel.spec | grep Apply.*Patch | awk '{ print $2 }' | wc -l)
+ do
+ if [ "$j" = "0" ]; then
+ echo $i is in CVS, but not applied in spec file.
+ grep $i TODO | awk '{ print $2 " is also still in the TODO" }'
+ fi
+ done
+done
+
+#for i in `grep ApplyPatch kernel.spec | awk '{ print $2 }'`
+#do
+# R=$(grep $i TODO)
+# echo "$i is in CVS, but not mentioned in the TODO!"
+#done
+
diff --git a/freed-ora/current/f22/scripts/check-configs.pl b/freed-ora/current/f22/scripts/check-configs.pl
new file mode 100644
index 000000000..10282aa74
--- /dev/null
+++ b/freed-ora/current/f22/scripts/check-configs.pl
@@ -0,0 +1,83 @@
+# By Paul Bolle October 2014.
+#
+# Contributed to the public domain by its author.
+
+use 5.016;
+use warnings;
+use autodie;
+
+use File::Find;
+
+my @Kconfigs;
+
+my $Kconfigre = qr/Kconfig.*/;
+my $configre = qr/^\s*(menu)?config\s+(?<config>(\w+))$/;
+my $CONFIG_re = qr/\bCONFIG_(?<CONFIG_>(\w+))/;
+
+sub match {
+ push( @Kconfigs, $File::Find::name ) if ($_ =~ $Kconfigre);
+}
+
+sub parse_kconfig {
+ my ($path) = @_;
+
+ my @ret;
+
+ open( my $kconfig, "<", $path );
+ my $slurp = do { local $/ = undef; <$kconfig> };
+ close( $kconfig );
+ my @lines = split ( /\n/, $slurp );
+ foreach my $line (@lines) {
+ if ($line =~ /$configre/) {
+ push( @ret, $+{config} );
+ }
+ }
+
+ @ret;
+}
+
+sub parse_shipped {
+ my ($path) = @_;
+
+ my @ret;
+
+ open( my $shipped, "<", $path );
+ my $slurp = do { local $/ = undef; <$shipped> };
+ close( $shipped );
+ my @lines = split ( /\n/, $slurp );
+ my $i = 1;
+ foreach my $line (@lines) {
+ if ($line =~ /$CONFIG_re/) {
+ push( @ret, [$i, $+{CONFIG_}] );
+ }
+ $i++;
+ }
+
+ @ret;
+}
+
+exit main ( @ARGV );
+
+sub main {
+ my %configs;
+
+ find( \&match, @_ );
+
+ foreach my $Kconfig (@Kconfigs) {
+ my (@tmp) = parse_kconfig( $Kconfig );
+ foreach my $config ( @tmp ) {
+ $configs{ $config }++;
+ }
+ }
+
+ foreach my $shipped (glob("config-*")) {
+ my (@tmp) = parse_shipped( $shipped );
+ foreach my $ref ( @tmp ) {
+ say( STDERR "$shipped:$ref->[0]: No Kconfig symbol matches 'CONFIG_$ref->[1]'" )
+ unless (grep( /$ref->[1]/, keys( %configs )));
+ }
+ }
+
+ 0;
+}
+
diff --git a/freed-ora/current/f22/scripts/combine.sh b/freed-ora/current/f22/scripts/combine.sh
new file mode 100755
index 000000000..86a68d302
--- /dev/null
+++ b/freed-ora/current/f22/scripts/combine.sh
@@ -0,0 +1,34 @@
+#! /bin/sh
+
+# combine a set of quilt patches
+
+# $1 : base dir (source tree)
+# $2 : quilt dir (patches to apply)
+# $3 : pre-patch to apply first (optional)
+
+# e.g.:
+# combine.sh /home/user/fedora/trunk/kernel/F-11/kernel-2.6.30/vanilla-2.6.30 \
+# /home/user/git/stable-queue/queue-2.6.30 \
+# /home/user/fedora/trunk/kernel/F-11/patch-2.6.30.5.bz2
+
+if [ $# -lt 2 ] ; then
+ exit 1
+fi
+
+TD="combine_temp.d"
+
+cd $1 || exit 1
+cd ..
+[ -d $TD ] && rm -Rf $TD
+mkdir $TD || exit 1
+cd $TD
+
+cp -al ../$(basename $1) work.d
+cd work.d
+[ "$3" ] && bzcat $3 | patch -p1 -s
+ln -s $2 patches
+[ -h patches ] || exit 1
+quilt snapshot
+quilt upgrade
+quilt push -a -q
+quilt diff --snapshot >../combined.patch
diff --git a/freed-ora/current/f22/scripts/configcommon.pl b/freed-ora/current/f22/scripts/configcommon.pl
new file mode 100644
index 000000000..38bbe80dc
--- /dev/null
+++ b/freed-ora/current/f22/scripts/configcommon.pl
@@ -0,0 +1,82 @@
+#! /usr/bin/perl
+
+my @args=@ARGV;
+my @configoptions;
+my @configvalues;
+my @common;
+my $configcounter = 0;
+
+# first, read the 1st file
+
+open (FILE,"$args[0]") || die "Could not open $args[0]";
+while (<FILE>) {
+ my $str = $_;
+ if (/\# ([\w]+) is not set/) {
+ $configoptions[$configcounter] = $1;
+ $configvalues[$configcounter] = $str;
+ $common[$configcounter] = 1;
+ $configcounter ++;
+ } else {
+ if (/([\w]+)=/) {
+ $configoptions[$configcounter] = $1;
+ $configvalues[$configcounter] = $str;
+ $common[$configcounter] = 1;
+ $configcounter ++;
+ } else {
+ $configoptions[$configcounter] = "foobarbar";
+ $configvalues[$configcounter] = $str;
+ $common[$configcounter] = 1;
+ $configcounter ++;
+ }
+ }
+};
+
+# now, read all configfiles and see of the options match the initial one.
+# if not, mark it not common
+my $cntr=1;
+
+
+while ($cntr < @ARGV) {
+ open (FILE,$args[$cntr]) || die "Could not open $args[$cntr]";
+ while (<FILE>) {
+ my $nooutput;
+ my $counter;
+ my $configname;
+
+ if (/\# ([\w]+) is not set/) {
+ $configname = $1;
+ } else {
+ if (/([\w]+)=/) {
+ $configname = $1;
+ }
+ }
+
+ $counter = 0;
+ $nooutput = 0;
+ while ($counter < $configcounter) {
+ if ("$configname" eq "$configoptions[$counter]") {
+ if ("$_" eq "$configvalues[$counter]") {
+ 1;
+ } else {
+ $common[$counter] = 0;
+ }
+ }
+ $counter++;
+ }
+ }
+
+ $cntr++;
+}
+
+# now print the common values
+my $counter = 0;
+
+while ($counter < $configcounter) {
+ if ($common[$counter]!=0) {
+ print "$configvalues[$counter]";
+ }
+ $counter++;
+}
+
+1;
+
diff --git a/freed-ora/current/f22/scripts/configdiff.pl b/freed-ora/current/f22/scripts/configdiff.pl
new file mode 100644
index 000000000..848d8df0f
--- /dev/null
+++ b/freed-ora/current/f22/scripts/configdiff.pl
@@ -0,0 +1,76 @@
+#! /usr/bin/perl
+
+my @args=@ARGV;
+my @configoptions;
+my @configvalues;
+my @alreadyprinted;
+my $configcounter = 0;
+
+# first, read the override file
+
+open (FILE,"$args[0]") || die "Could not open $args[0]";
+while (<FILE>) {
+ my $str = $_;
+ if (/\# ([\w]+) is not set/) {
+ $configoptions[$configcounter] = $1;
+ $configvalues[$configcounter] = $str;
+ $alreadprinted[$configcounter] = 0;
+ $configcounter ++;
+ } else {
+ if (/([\w]+)=/) {
+ $configoptions[$configcounter] = $1;
+ $configvalues[$configcounter] = $str;
+ $alreadprinted[$configcounter] = 0;
+ $configcounter ++;
+ } else {
+ $configoptions[$configcounter] = "$_";
+ $configvalues[$configcounter] = $str;
+ $alreadprinted[$configcounter] = 0;
+ $configcounter ++;
+ }
+ }
+};
+
+# now, read and output the entire configfile, except for the overridden
+# parts... for those the new value is printed.
+# O(N^2) algorithm so if this is slow I need to look at it later
+
+open (FILE2,"$args[1]") || die "Could not open $args[1]";
+while (<FILE2>) {
+ my $nooutput;
+ my $counter;
+ my $configname="$_";
+ my $match;
+
+ if (/\# ([\w]+) is not set/) {
+ $configname = $1;
+ } else {
+ if (/([\w]+)=/) {
+ $configname = $1;
+ }
+ }
+
+ $counter = 0;
+ $nooutput = 0;
+ $match = 0;
+# print "C : $configname";
+ while ($counter < $configcounter) {
+ if ("$configname" eq "$configoptions[$counter]") {
+ if ( ("$_" eq "$configvalues[$counter]") || ("$configname" eq "") ) {
+ $match = 1;
+ } else {
+ $alreadyprinted[$configcounter] = 1;
+ print "$_";
+ $match = 1;
+ }
+ }
+ $counter++;
+ }
+ if ($match == 0) {
+ print "$_";
+ }
+
+}
+
+
+1;
diff --git a/freed-ora/current/f22/scripts/generate-git-snapshot.sh b/freed-ora/current/f22/scripts/generate-git-snapshot.sh
new file mode 100755
index 000000000..b6fe0d6c1
--- /dev/null
+++ b/freed-ora/current/f22/scripts/generate-git-snapshot.sh
@@ -0,0 +1,25 @@
+#!/bin/sh
+#
+# Set LINUX_GIT to point to an upstream Linux git tree in your .bashrc or wherever.
+
+[ ! -d "$LINUX_GIT" ] && echo "error: set \$LINUX_GIT to point at upstream git tree" && exit 1
+
+VER=$(grep patch sources | head -n1 | awk '{ print $2 }' | sed s/patch-// | sed s/-git.*// | sed s/.xz//)
+
+OLDGIT=$(grep gitrev kernel.spec | head -n1 | sed s/%define\ gitrev\ //)
+export NEWGIT=$(($OLDGIT+1))
+
+pushd $LINUX_GIT
+
+git diff v$VER.. > /tmp/patch-$VER-git$NEWGIT
+xz -9 /tmp/patch-$VER-git$NEWGIT
+DESC=$(git describe)
+popd
+
+mv /tmp/patch-$VER-git$NEWGIT.xz .
+
+perl -p -i -e 's|%global baserelease.*|%global baserelease 0|' kernel.spec
+
+perl -p -i -e 's|%define gitrev.*|%define gitrev $ENV{'NEWGIT'}|' kernel.spec
+
+rpmdev-bumpspec -c "Linux $DESC" kernel.spec
diff --git a/freed-ora/current/f22/scripts/grab-logs.sh b/freed-ora/current/f22/scripts/grab-logs.sh
new file mode 100755
index 000000000..5df573571
--- /dev/null
+++ b/freed-ora/current/f22/scripts/grab-logs.sh
@@ -0,0 +1,16 @@
+#!/bin/sh
+
+VER=$(fedpkg verrel)
+ver=$(echo $VER | sed -e 's/-/ /g' | awk '{print $2}')
+rev=$(echo $VER | sed -e 's/-/ /g' | awk '{print $3}')
+
+if [ -d logs ]; then
+ DIR=logs/
+else
+ DIR=./
+fi
+
+wget -O $DIR/build-$VER-i686.log http://kojipkgs.fedoraproject.org/packages/kernel/$ver/$rev/data/logs/i686/build.log
+wget -O $DIR/build-$VER-x86-64.log http://kojipkgs.fedoraproject.org/packages/kernel/$ver/$rev/data/logs/x86_64/build.log
+wget -O $DIR/build-$VER-noarch.log http://kojipkgs.fedoraproject.org/packages/kernel/$ver/$rev/data/logs/noarch/build.log
+
diff --git a/freed-ora/current/f22/scripts/newpatch.sh b/freed-ora/current/f22/scripts/newpatch.sh
new file mode 100755
index 000000000..0dc2e837c
--- /dev/null
+++ b/freed-ora/current/f22/scripts/newpatch.sh
@@ -0,0 +1,21 @@
+#!/bin/sh
+# Easy application of new patches.
+# Always adds to the very end. (Bumps last patch nr by 100)
+# Parameters:
+# $1 - patch filename
+# $2 - description
+
+OLD=$(grep ^Patch kernel.spec | tail -n1 | awk '{ print $1 }' | sed s/Patch// | sed s/://)
+NEW=$(($OLD/100*100+100))
+
+sed -i "/^Patch$OLD:\ /a#\ $2\nPatch$NEW:\ $1" kernel.spec
+
+LAST=$(grep ^ApplyPatch kernel.spec | tail -n1 | awk '{ print $2 }')
+
+sed -i "/^ApplyPatch $LAST/aApplyPatch $1" kernel.spec
+
+cvs add $1
+
+scripts/bumpspecfile.py kernel.spec "- $2"
+make clog
+
diff --git a/freed-ora/current/f22/scripts/rediffall.pl b/freed-ora/current/f22/scripts/rediffall.pl
new file mode 100644
index 000000000..29f12beb9
--- /dev/null
+++ b/freed-ora/current/f22/scripts/rediffall.pl
@@ -0,0 +1,64 @@
+#!/usr/bin/perl -w
+#
+# Script to rediff all patches in the spec
+# Usage: perl -w rediffall.pl < kernel-2.4.spec
+#
+# $workdir is where the new rediff'ed patches are created
+# $origdir is where the original patches and tarball are located
+#
+# Note that both $workdir and $origdir must be absolute path names.
+# Suggestion: create a /kernel symbolic link to the top of your CVS tree.
+
+my $workdir = "/dev/shm/redifftree";
+my $origdir = "/home/davej/devel";
+my $kernver = "linux-2.6.17";
+my $datestrip = "s/^\\(\\(+++\\|---\\) [^[:blank:]]\\+\\)[[:blank:]].*/\\1/";
+my $patchindex = 0;
+my @patchlist;
+
+# phase 1: create a tree
+print "Extracting pristine source..\n";
+system("mkdir -p $workdir");
+system("rm -rf $workdir/*");
+chdir("$workdir");
+system("tar -jxvf $origdir/$kernver.tar.bz2 > /dev/null");
+system("cp -al $kernver linux-$patchindex");
+
+# phase 2: read the spec from stdin and store all patches
+print "Reading specfile..\n";
+
+while (<>) {
+ my $line = $_;
+ if ($line =~ /^Patch([0-9]+)\: ([a-zA-Z0-9\-\_\.\+]+\.patch)/) {
+ $patchlist[$1] = $2;
+ } else {
+ if ($line =~ /^Patch([0-9]+)\: ([a-zA-Z0-9\-\_\.]+\.bz2)/) {
+ $patchlist[$1] = $2;
+ }
+ }
+
+ if ($line =~ /^%patch([0-9]+) -p1/) {
+ # copy the tree, apply the patch, diff and remove the old tree
+ my $oldindex = $patchindex;
+ $patchindex = $1;
+
+ print "rediffing patch number $patchindex: $patchlist[$patchindex]\n";
+
+ system("cp -al linux-$oldindex linux-$patchindex");
+ chdir("linux-$patchindex");
+ if ($patchlist[$patchindex] =~ /bz2/) {
+ system("bzcat $origdir/$patchlist[$patchindex] | patch -p1 &>/dev/null");
+ } else {
+ system("cat $origdir/$patchlist[$patchindex] | patch -p1 &>/dev/null");
+ }
+ chdir("$workdir");
+ system("rm -f `find -name \"*orig\"`");
+ if ($patchlist[$patchindex] =~ /bz2/) {
+ } else {
+ system("diff -urNp --exclude-from=/home/davej/.exclude linux-$oldindex linux-$patchindex | sed '$datestrip' > $patchlist[$patchindex]");
+ }
+ system("rm -rf linux-$oldindex");
+ }
+};
+
+1;
diff --git a/freed-ora/current/f22/scripts/sort-config b/freed-ora/current/f22/scripts/sort-config
new file mode 100755
index 000000000..399709f18
--- /dev/null
+++ b/freed-ora/current/f22/scripts/sort-config
@@ -0,0 +1,226 @@
+#!/bin/bash
+
+FC=($(fedpkg verrel | awk -F. '{print $NF}'))
+
+SRC=($(ls config-* 2>/dev/null))
+
+TGT=($(ls kernel-*.$FC/linux-*.$2/configs/kernel-*-*.config \
+ kernel-*.$FC/linux-*.$2/configs/kernel-*-*-debug.config 2>/dev/null))
+TGT1=(${TGT[*]#kernel-*.$FC/linux-*.$2/configs/kernel-*-})
+
+ALL_OPTS="cdfimn"
+
+if [ $# -lt 2 ] ; then
+ echo -e "Usage:\n $(basename $0) [-$ALL_OPTS] input target\n"
+ echo -e " Sort input config file into the same order as the target\n"
+ echo -e " -c: insert comments about non-matching/impossible items"
+ echo -e " -d: show raw unsorted output with extra debug text"
+ echo -e " -f: force output to match what is in the target config,"
+ echo -e " and/or remove impossible config items"
+ echo -e " -i: find impossible config items"
+ echo -e " -m: find changed config items"
+ echo -e " -n: do not sort output\n"
+ echo -e " input: source config file" ' [' "${SRC[*]#config-}" ']\n'
+ echo -e " target: output arch name" ' [' "${TGT1[*]%.config}" ']\n'
+ exit 1
+fi
+
+while getopts "$ALL_OPTS" OPTION ; do
+case $OPTION in
+c)
+ ADDCOMMENT=1 ;;
+d)
+ DEBUG=1 ;;
+f)
+ FORCE=1 ;;
+i)
+ FIND_IMPOSS=1 ;;
+m)
+ FIND_CHANGED=1 ;;
+n)
+ NOSORT=1 ;;
+\?)
+ exit 2 ;;
+esac
+done
+
+if [ "$FORCE" -a "$ADDCOMMENT" ] ; then
+ echo "-f and -c options cannot be used together"
+ exit 2
+fi
+
+shift $((OPTIND-1))
+
+TEMPFILES="xx00 xx01 xx98 xx99"
+TEMPLEFT=
+for FILE in $TEMPFILES ; do
+ [ -f "$FILE" ] && TEMPLEFT="Y"
+done
+if [ "$TEMPLEFT" ] ; then
+ echo "WARNING! Output files named xx?? already exist." >&2
+ read -p "Press <Enter> to erase files, or Ctrl-C to exit..."
+ echo >&2
+fi
+rm -f $TEMPFILES
+
+SRCFILE=config-$1
+[ ! -f $SRCFILE ] && echo "Input file" $SRCFILE "missing" && exit 2
+
+TGTFILE=kernel-*.$FC/linux-*.$2/configs/kernel-*-$2.config
+[ ! -f $TGTFILE ] && echo "No target file matching" $TGTFILE "exists" && exit 2
+
+[ "$FIND_IMPOSS" ] && \
+ find kernel-*.$FC/*.$2 -name Kconfig\* -type f \
+ | xargs egrep -s -h '^[[:space:]]*(menu)?config[[:space:]]+' \
+ | sed -r 's/^[[:space:]]*(menu)?config[[:space:]]+/CONFIG_/' \
+ | sort | uniq >xx98
+
+extract_optname() {
+ # extract the option name from $TEXT, setting $OPTNAME
+ OPTNAME=
+ if [ "${TEXT:0:7}" = "CONFIG_" ] ; then
+ OPTNAME=${TEXT%%=*}
+ elif [ "${TEXT:0:9}" = "# CONFIG_" ] ; then
+ OPTNAME=${TEXT%" is not set"}
+ OPTNAME=${OPTNAME#\# }
+ fi
+}
+
+print_saved_comments() {
+ if [ $IX -gt 0 ] ; then
+ [ "$DEBUG" ] && echo " ->" $IX "comments were saved"
+ (( IX-- ))
+ for IX in $(seq 0 $IX) ; do
+ echo "$LINE":"${SAVECOMMENT[$IX]}"
+ done
+ unset SAVECOMMENT
+ IX=0
+ fi
+}
+
+assign_line_number() {
+ # use input line numbers if not sorting
+ [ "$NOSORT" ] && LINE=$IN
+ # make sure it has a line number
+ [ -z "$LINE" ] && LINE=999999
+}
+
+IX=0
+IN=0
+declare -a SAVECOMMENT
+
+cat ${SRCFILE} | {
+while read TEXT ; do
+
+ LINE=
+ COMMENT=
+
+ # replace empty lines
+ [ -z "$TEXT" ] && TEXT='//'
+
+ if [ "${TEXT:0:7}" = "CONFIG_" -o "${TEXT:0:9}" = "# CONFIG_" ] ; then
+
+ LINE=$(grep -n "^$TEXT" $TGTFILE | head -1 | cut -f 1 -d ':')
+ if [ -z "$LINE" ] ; then
+ [ "$DEBUG" ] && echo "nofind ->" "$TEXT"
+
+ extract_optname
+ if [ "$OPTNAME" ] ; then
+
+ if [ "$FIND_CHANGED" ] ; then
+ for FINDTEXT in "^${OPTNAME}=" "^# ${OPTNAME} is not set" ; do
+ if [ -z "$LINE" ] ; then
+ [ "$DEBUG" ] && echo "looking for ->" "$FINDTEXT"
+ LINE=$(grep -n "$FINDTEXT" $TGTFILE | head -1 | cut -f 1 -d ':')
+ if [ "$LINE" ] ; then
+ CHANGED=$(grep "$FINDTEXT" $TGTFILE | head -1)
+ if [ "$FORCE" ] ; then
+ TEXT=$CHANGED
+ [ "$DEBUG" ] && echo 'forced ->' "$TEXT"
+ else
+ if [ "$ADDCOMMENT" ] ; then
+ if [ ${CHANGED:0:1} = '#' ] ; then
+ NEWOPT="not set"
+ else
+ NEWOPT=${CHANGED#$OPTNAME}
+ fi
+ COMMENT="# -- Next option changed to \"${NEWOPT}\" at target line $LINE --"
+ fi
+ fi
+ fi
+ fi
+ done
+ fi
+
+ if [ "$FIND_IMPOSS" -a -z "$LINE" -a -z "$COMMENT" ] ; then
+ POSSIBLE=$(grep -n "^$OPTNAME" xx98)
+ if [ -z "$POSSIBLE" ] ; then
+ if [ "$ADDCOMMENT" ] ; then
+ COMMENT="# -- Next option is impossible --"
+ elif [ "$FORCE" ] ; then
+ [ "$DEBUG" ] && echo 'impossible ->' "$TEXT"
+ TEXT=""
+ fi
+ fi
+ fi
+
+ fi
+
+ fi
+
+ else
+ # not a config variable
+ COMMENT="$TEXT"
+ TEXT=
+ fi
+
+ [ "$DEBUG" -a "$COMMENT" ] && echo "comment ->" "$LINE" "$COMMENT"
+ [ "$DEBUG" -a "$TEXT" ] && echo "text ->" "$LINE" "$TEXT"
+
+ if [ "$TEXT" ] ; then
+
+ assign_line_number
+
+ # print the saved comments first
+ print_saved_comments
+ # now print the latest comment and text
+ [ "$COMMENT" ] && echo "$LINE":"$COMMENT"
+ echo "$LINE":"$TEXT"
+
+ elif [ "$COMMENT" ] ; then
+
+ # no output yet, save the comment
+ SAVECOMMENT[$IX]="$COMMENT"
+ let IX++
+ [ "$DEBUG" ] && echo 'savecomment (#'${IX}')'
+
+ fi
+
+ let IN++
+
+done
+# flush the buffers
+assign_line_number
+print_saved_comments
+[ "$DEBUG" ] && echo "$IN lines read from input"
+} >xx99
+
+if [ "$DEBUG" ] ; then
+ # just show the raw output with debug info, then exit
+ cat xx99
+else
+
+ # split output into two files, for matched and unmatched items
+ cat xx99 | sort -s -t ":" -k 1g | csplit -k -s - /^999999/ 2>/dev/null
+
+ cat xx00 | cut -f 2- -d ':' | sed 's/^\/\/$//'
+ if [ -s xx01 ] ; then
+ echo
+ echo '# ------------ UNMATCHED OPTIONS ------------'
+ echo
+ cat xx01 | cut -f 2- -d ':' | sed 's/^\/\/$//'
+ fi
+
+fi
+
+rm -f $TEMPFILES
OpenPOWER on IntegriCloud