[26737] trunk/base/src/package1.0

source_changes at macosforge.org source_changes at macosforge.org
Thu Jul 5 11:53:40 PDT 2007


Revision: 26737
          http://trac.macosforge.org/projects/macports/changeset/26737
Author:   afb at macports.org
Date:     2007-07-05 11:53:40 -0700 (Thu, 05 Jul 2007)

Log Message:
-----------
hard wrap the rpm %description

Modified Paths:
--------------
    trunk/base/src/package1.0/portrpm.tcl
    trunk/base/src/package1.0/portsrpm.tcl

Modified: trunk/base/src/package1.0/portrpm.tcl
===================================================================
--- trunk/base/src/package1.0/portrpm.tcl	2007-07-05 18:49:33 UTC (rev 26736)
+++ trunk/base/src/package1.0/portrpm.tcl	2007-07-05 18:53:40 UTC (rev 26737)
@@ -158,6 +158,36 @@
     return $result
 }
 
+proc word_wrap {orig Length} {
+    set pos 0
+    set line ""
+    set text ""
+
+    set words [split $orig]
+    set numWords [llength $words]
+    for {set cnt 0} {$cnt < $numWords} {incr cnt} {
+	set w [lindex $words $cnt]
+	set wLen [string length $w]
+
+	if {($pos+$wLen < $Length)} {
+	    # append word to current line
+	    if {$pos} {append line " "; incr pos}
+	    append line $w
+	    incr pos $wLen
+	} else {
+	    # line full => write buffer and  begin a new line
+	    if {[string length $text]} {append text "\n"}
+	    append text $line
+	    set line $w
+	    set pos $wLen
+	}
+    }
+
+    if {[string length $text]} {append text "\n"}
+    if {[string length $line]} {append text $line}
+    return $text
+}
+
 proc write_spec {specfile destroot filelist portname portversion portrevision description long_description homepage category license maintainer dependencies epoch} {
     set specfd [open ${specfile} w+]
     set origportname ${portname}
@@ -190,9 +220,10 @@
 	    puts $specfd "Requires: [regsub -all -- "\-" $require "_"]"
 	}
     }
+    set wrap_description [word_wrap ${long_description} 72]
     puts $specfd "
 %description
-${long_description}
+$wrap_description
 
 %prep
 %build

Modified: trunk/base/src/package1.0/portsrpm.tcl
===================================================================
--- trunk/base/src/package1.0/portsrpm.tcl	2007-07-05 18:49:33 UTC (rev 26736)
+++ trunk/base/src/package1.0/portsrpm.tcl	2007-07-05 18:53:40 UTC (rev 26737)
@@ -155,6 +155,36 @@
     return $result
 }
 
+proc word_wrap {orig Length} {
+    set pos 0
+    set line ""
+    set text ""
+
+    set words [split $orig]
+    set numWords [llength $words]
+    for {set cnt 0} {$cnt < $numWords} {incr cnt} {
+	set w [lindex $words $cnt]
+	set wLen [string length $w]
+
+	if {($pos+$wLen < $Length)} {
+	    # append word to current line
+	    if {$pos} {append line " "; incr pos}
+	    append line $w
+	    incr pos $wLen
+	} else {
+	    # line full => write buffer and  begin a new line
+	    if {[string length $text]} {append text "\n"}
+	    append text $line
+	    set line $w
+	    set pos $wLen
+	}
+    }
+
+    if {[string length $text]} {append text "\n"}
+    if {[string length $line]} {append text $line}
+    return $text
+}
+
 proc write_port_spec {specfile portname portversion portrevision description long_description homepage category license maintainer distfiles fetch_urls dependencies epoch src} {
     set specfd [open ${specfile} w+]
     set origportname ${portname}
@@ -206,9 +236,10 @@
 	    puts $specfd "BuildRequires: [regsub -all -- "\-" $require "_"]"
 	}
     }
+    set wrap_description [word_wrap ${long_description} 72]
     puts $specfd "
 %description
-${long_description}
+$wrap_description
 
 %prep
 %setup -c -a 1 -T

-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.macosforge.org/pipermail/macports-changes/attachments/20070705/f7083523/attachment.html


More information about the macports-changes mailing list