[packages/adapter: 3/631] version 0.3 - added formating descriptions. There is small bug - if description is divided to para

glen glen at pld-linux.org
Mon Sep 12 19:34:43 CEST 2016


commit 3fdddc43c6a153fddf3d38eb9efb5726660a2a1a
Author: kura <kura at pld-linux.org>
Date:   Sat Nov 20 09:12:33 1999 +0000

    version 0.3
    - added formating descriptions. There is small bug - if description is
      divided to paragraphs adapter joins them, but there is double space in
      the place where was empty line.
    - added adding "%define date    %(echo `LC_ALL="C" date +"%a %b %d %Y"`)
      before changelog section
    
    Changed files:
        adapter.awk -> 1.3

 adapter.awk | 46 +++++++++++++++++++++++++++++++++++++++++++---
 1 file changed, 43 insertions(+), 3 deletions(-)
---
diff --git a/adapter.awk b/adapter.awk
index 637f767..d150da5 100644
--- a/adapter.awk
+++ b/adapter.awk
@@ -1,12 +1,13 @@
 #!/bin/awk -f
 #
-# This is adapter v0.2. Adapter adapts .spec files for PLD.
+# This is adapter v0.3. Adapter adapts .spec files for PLD.
 # Copyright (C) 1999 Micha� Kuratczyk <kura at pld.org.pl>
 
 BEGIN {
 	preamble = 1;
 	bof = 1;	# Beggining of file
 	boc = 2;	# Beggining of %changelog
+	tw = 77;	# Descriptions width
 }
 
 # There should be a comment with CVS keywords on the first line of file.
@@ -19,13 +20,42 @@ bof == 1 {
 # descriptions:
 /%description/, (/^%[a-z]+/ && !/%description/) {
 	preamble = 0;
-
+	
 	# Define _prefix and _mandir if it is X11 application
 	if (/^%description$/ && x11 == 1) {
 		print "%define\t\t_prefix\t\t/usr/X11R6";
 		print "%define\t\t_mandir\t\t%{_prefix}/man\n";
 		x11 == 2;
 	}
+
+	# Collect whole text of description
+	if (description == 1 && !/^%[a-z]+/ && !/%description/) {
+		description_text = description_text $0 " ";
+		noprint = 1;
+	}
+	
+	# Formt description to the length of tw (default == 77)
+	if (/^%[a-z]+/ && !/%description/) {
+		n = split(description_text, dt, / /);
+		for (i = 1; i <= n; i++) {
+			if (length(line) + length(dt[i]) + 1 < tw) {
+				line = line dt[i] " ";
+			} else {
+				print line;
+				line = "";
+				i--;
+			}
+		}
+		
+		print line "\n";
+		line = "";
+		delete dt;
+		description_text = "";
+
+		description = 0;
+	} else {
+		description = 1;
+	}
 }
 
 # %prep section:
@@ -82,6 +112,7 @@ bof == 1 {
 	
 	if (/%defattr/)
 		$0 = "%defattr(644,root,root,755)";
+
 }
 
 # %changelog section:
@@ -98,8 +129,12 @@ bof == 1 {
 		boc = 0;
 	}
 	
-	if (boc == 2)
+	# Define date macro.
+	if (boc == 2 && date == 0) {
+		printf "%%define date\t%%(echo `LC_ALL=\"C\"";
+	       	print " date +\"%a %b %d %Y\"`)"
 		boc--;
+	}
 }
 
 # preambles:
@@ -153,6 +188,11 @@ preamble == 1 {
 # but set the redundant_line to 0.
 {
 	preamble = 1;
+	
+	# Macro 'date' already defined.
+	if (/%define date/)
+		date = 1;
+	
 	if (noprint == 0)
 		print;
 	else
================================================================

---- gitweb:

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



More information about the pld-cvs-commit mailing list