[packages/adapter: 258/631] - adapter portions moved to adapter

glen glen at pld-linux.org
Mon Sep 12 19:56:05 CEST 2016


commit 115a3045d6fe8c8aa2ae4752848807c9160df71e
Author: Elan Ruusamäe <glen at pld-linux.org>
Date:   Wed Dec 14 12:51:41 2005 +0000

    - adapter portions moved to adapter
    
    Changed files:
        adapter.awk -> 1.248
        adapter.sh -> 1.13
        builder.sh -> 1.360

 adapter.awk |   9 +++--
 adapter.sh  | 124 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++-
 2 files changed, 129 insertions(+), 4 deletions(-)
---
diff --git a/adapter.awk b/adapter.awk
index 2d3742a..60eff7e 100644
--- a/adapter.awk
+++ b/adapter.awk
@@ -1,15 +1,18 @@
 #!/bin/awk -f
 #
-# This is adapter v0.27. Adapter adapts .spec files for PLD.
+# This is adapter v0.27. Adapter adapts .spec files for PLD Linux.
 #
-# Copyright (C) 1999-2003 PLD-Team <feedback at pld-linux.org>
+# Copyright (C) 1999-2005 PLD-Team <feedback at pld-linux.org>
 # Authors:
 # 	Micha� Kuratczyk <kura at pld.org.pl>
 # 	Sebastian Zagrodzki <s.zagrodzki at mimuw.edu.pl>
 # 	Tomasz K�oczko <kloczek at rudy.mif.pg.gda.pl>
 # 	Artur Frysiak <wiget at pld-linux.org>
 # 	Michal Kochanowicz <mkochano at pld.org.pl>
-# 	Elan Ruusam�e <glen at pld-linux.org>
+# 	Elan Ruusam�e <glen at pld-linux.org>
+#
+# See cvs log adapter{,.awk} for list of contributors
+#
 # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # #
 
 # TODO
diff --git a/adapter.sh b/adapter.sh
index 813e4c1..b6783ca 100644
--- a/adapter.sh
+++ b/adapter.sh
@@ -1,4 +1,19 @@
 #!/bin/sh
+#
+# This is adapter v0.27. Adapter adapts .spec files for PLD Linux.
+#
+# Copyright (C) 1999-2003 PLD-Team <feedback at pld-linux.org>
+# Authors:
+# 	Micha� Kuratczyk <kura at pld.org.pl>
+# 	Sebastian Zagrodzki <s.zagrodzki at mimuw.edu.pl>
+# 	Tomasz K�oczko <kloczek at rudy.mif.pg.gda.pl>
+# 	Artur Frysiak <wiget at pld-linux.org>
+# 	Michal Kochanowicz <mkochano at pld.org.pl>
+# 	Elan Ruusam�e <glen at pld-linux.org>
+#
+# See cvs log adapter{,.awk} for list of contributors
+#
+# # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # #
 
 self=$(basename "$0")
 usage="Usage: $self [FLAGS] SPECFILE
@@ -47,9 +62,116 @@ while true; do
 	shift
 done
 
+diffcol()
+{
+	 # vim like diff colourization
+	 sed -e '
+	 s,,^[,g;
+	 s,,^G,g;
+	 s,^\(Index:\|diff\|---\|+++\) .*$,&,;
+	 s,^@@ ,&,g;
+	 s,^-,&,;
+	 s,^+,&,;
+	 s,
,^M,g;
+	 s,	,    ,g;
+	 s,\([^[:space:]]\)\([[:space:]]\+\)$,\1\2,g;
+	 s,$,,
+	 ' "$@"
+}
+
+diff2hunks()
+{
+	 # diff2hunks orignally by dig
+	 perl -e '
+#! /usr/bin/perl -w
+
+use strict;
+
+for my $filename (@ARGV) {
+    my $counter = 1;
+    my $fh;
+    open $fh, "<", $filename or die "$filename: open for reading: $!";
+    my @lines = <$fh>;
+    my @hunks;
+    my @curheader;
+    for my $i (0 ... $#lines) {
+        next unless $lines[$i] =~ m/^\@\@ /;
+        if ($i >= 2 and $lines[$i - 2] =~ m/^--- / and $lines[$i - 1] =~ m/^\+\+\+ /) {
+            @curheader = @lines[$i - 2 ... $i - 1];
+        }
+        next unless @curheader;
+        my $j = $i + 1;
+        while ($j < @lines and $lines[$j] !~ m/^\@\@ /) {$j++}
+        $j -= 2
+            if $j >= 3 and $j < @lines
+                and $lines[$j - 2] =~ m/^--- /
+                and $lines[$j - 1] =~ m/^\+\+\+ /;
+        $j--;
+        $j-- until $lines[$j] =~ m/^[ @+-]/;
+        my $hunkfilename = $filename;
+        $hunkfilename =~ s/((\.(pat(ch)?|diff?))?)$/"-".sprintf("%03i",$counter++).$1/ei;
+        my $ofh;
+        open $ofh, ">", $hunkfilename or die "$hunkfilename: open for writing: $!";
+        print $ofh @curheader, @lines[$i ... $j];
+        close $ofh;
+    }
+}
+' "$@"
+}
+
+adapterize()
+{
+	 local tmpdir
+	 tmpdir=$(mktemp -d ${TMPDIR:-/tmp}/adapter-XXXXXX) || exit
+	 awk -f adapter.awk $SPECFILE > $tmpdir/$SPECFILE || exit
+
+	 if [ "`diff --brief $SPECFILE $tmpdir/$SPECFILE`" ] ; then
+		  diff -u $SPECFILE $tmpdir/$SPECFILE > $tmpdir/$SPECFILE.diff
+		  if [ -t 1 ]; then
+				diffcol $tmpdir/$SPECFILE.diff | less -r
+				while : ; do
+					 echo -n "Accept? (Yes, No, Confirm each chunk)? "
+					 read ans
+					 case "$ans" in
+					 [yYoO]) # y0 mama
+						  mv -f $tmpdir/$SPECFILE $SPECFILE
+						  echo "Ok, adapterized."
+						  break
+					 ;;
+					 [cC]) # confirm each chunk
+						  diff2hunks $tmpdir/$SPECFILE.diff
+						  for t in $(ls $tmpdir/$SPECFILE-*.diff); do
+								diffcol $t | less -r
+								echo -n "Accept? (Yes, [N]o)? "
+								read ans
+								case "$ans" in
+								[yYoO]) # y0 mama
+									patch < $t
+									;;
+								esac
+						  done
+						  break
+					 ;;
+					 [QqnNsS])
+						  echo "Ok, exiting."
+						  break
+					 ;;
+					 esac
+				done
+		  else
+				cat $tmpdir/$SPECFILE.diff
+		  fi
+	 else
+		  echo "The SPEC is perfect ;)"
+	 fi
+
+	 rm -rf $tmpdir
+}
+
 if [ $# -ne 1 -o ! -f "$1" ]; then
 	echo "$usage"
 	exit 1
 fi
 
-exec ./builder --adapter "$1"
+SPECFILE="$1"
+adapterize
================================================================

---- gitweb:

http://git.pld-linux.org/gitweb.cgi/packages/adapter.git/commitdiff/6ca0126d4d0c8c79feb7db10b0a0fade0f3b8885



More information about the pld-cvs-commit mailing list