Borrow some code from fonts-rpm-macros, to drop a dependant code to generate srpm
This commit is contained in:
		
							parent
							
								
									d8db67095e
								
							
						
					
					
						commit
						7aea53ad43
					
				| @ -514,8 +514,106 @@ local function genfcconf(table) | |||||||
|     _fcconfbuild = (_fcconfbuild ~= '' and _fcconfbuild .. "\n" or '') .. "cat<<_EOL_>" .. table.fcconf .. "\\\n" .. xml .. "\n_EOL_\\" |     _fcconfbuild = (_fcconfbuild ~= '' and _fcconfbuild .. "\n" or '') .. "cat<<_EOL_>" .. table.fcconf .. "\\\n" .. xml .. "\n_EOL_\\" | ||||||
| end | end | ||||||
| 
 | 
 | ||||||
|  | -- Borrowed from fonts-rpm-macros | ||||||
|  | -- koji doesn't sasisfy BR during generating srpm yet. | ||||||
|  | -- We can't add a dependant code to fonts-rpm-macros at this stage. | ||||||
|  | 
 | ||||||
|  | -- https://github.com/rpm-software-management/rpm/issues/566 | ||||||
|  | -- Reformat a text intended to be used used in a package description, removing | ||||||
|  | -- rpm macro generation artefacts. | ||||||
|  | -- – remove leading and ending empty lines | ||||||
|  | -- – trim intermediary empty lines to a single line | ||||||
|  | -- – fold on spaces | ||||||
|  | -- Should really be a %%{wordwrap:…} verb | ||||||
|  | local function wordwrap(text) | ||||||
|  |   text = rpm.expand(text .. "\n") | ||||||
|  |   text = string.gsub(text, "\t",              "  ") | ||||||
|  |   text = string.gsub(text, "\r",              "\n") | ||||||
|  |   text = string.gsub(text, " +\n",            "\n") | ||||||
|  |   text = string.gsub(text, "\n+\n",           "\n\n") | ||||||
|  |   text = string.gsub(text, "^\n",             "") | ||||||
|  |   text = string.gsub(text, "\n( *)[-*—][  ]+", "\n%1– ") | ||||||
|  |   output = "" | ||||||
|  |   for line in string.gmatch(text, "[^\n]*\n") do | ||||||
|  |     local pos = 0 | ||||||
|  |     local advance = "" | ||||||
|  |     for word in string.gmatch(line, "%s*[^%s]*\n?") do | ||||||
|  |       local wl, bad = utf8.len(word) | ||||||
|  |       if not wl then | ||||||
|  |         print("%{warn:Invalid UTF-8 sequence detected in:}" .. | ||||||
|  |               "%{warn:" .. word .. "}" .. | ||||||
|  |               "%{warn:It may produce unexpected results.}") | ||||||
|  |         wl = bad | ||||||
|  |       end | ||||||
|  |       if (pos == 0) then | ||||||
|  |         advance, n = string.gsub(word, "^(%s*– ).*", "%1") | ||||||
|  |         if (n == 0) then | ||||||
|  |           advance = string.gsub(word, "^(%s*).*", "%1") | ||||||
|  |         end | ||||||
|  |         advance = string.gsub(advance, "– ", "  ") | ||||||
|  |         pos = pos + wl | ||||||
|  |       elseif  (pos + wl  < 81) or | ||||||
|  |              ((pos + wl == 81) and string.match(word, "\n$")) then | ||||||
|  |         pos = pos + wl | ||||||
|  |       else | ||||||
|  |         word = advance .. string.gsub(word, "^%s*", "") | ||||||
|  |         output = output .. "\n" | ||||||
|  |         pos = utf8.len(word) | ||||||
|  |       end | ||||||
|  |       output = output .. word | ||||||
|  |       if pos > 80 then | ||||||
|  |         pos = 0 | ||||||
|  |         if not string.match(word, "\n$") then | ||||||
|  |           output = output .. "\n" | ||||||
|  |         end | ||||||
|  |       end | ||||||
|  |     end | ||||||
|  |   end | ||||||
|  |   output = string.gsub(output, "\n*$", "\n") | ||||||
|  |   return output | ||||||
|  | end | ||||||
|  | 
 | ||||||
|  | -- Reformat some text into something that can be included in an AppStream | ||||||
|  | -- XML description | ||||||
|  | local function txt2xml(text) | ||||||
|  |   local        text = wordwrap(text) | ||||||
|  |   local      output = "" | ||||||
|  |   local     oldtag  = nil | ||||||
|  |   local oldadvance  = nil | ||||||
|  |   local      newtag = nil | ||||||
|  |   text = string.gsub(text, "^\n*", "") | ||||||
|  |   text = string.gsub(text, "\n*$", "\n") | ||||||
|  |   for line in string.gmatch(text, "[^\n]*\n") do | ||||||
|  |     local change = true | ||||||
|  |     local advance, n = string.gsub(line, "^(%s*– ).*", "%1") | ||||||
|  |     if (n == 1) then | ||||||
|  |       newtag = "li" | ||||||
|  |     else | ||||||
|  |       advance = string.gsub(line, "^(%s*).*", "%1") | ||||||
|  |       if (line == "\n") then | ||||||
|  |         newtag = nil | ||||||
|  |       elseif (advance ~= oldadvance) then | ||||||
|  |         newtag = "p" | ||||||
|  |       else | ||||||
|  |         change = false | ||||||
|  |       end | ||||||
|  |     end | ||||||
|  |     local result = "" | ||||||
|  |     if change then | ||||||
|  |       result     = string.gsub(line, "^" .. advance, switchtag(oldtag,newtag)) | ||||||
|  |       oldtag     = newtag | ||||||
|  |       oldadvance = string.gsub(advance, "– ", "  ") | ||||||
|  |     else | ||||||
|  |       result = string.gsub(line, "^" .. advance, " ") | ||||||
|  |     end | ||||||
|  |     result = string.gsub(result, "\n$", "") | ||||||
|  |     output = output .. result | ||||||
|  |   end | ||||||
|  |   output = output .. closetag(oldtag, nil) | ||||||
|  |   return output | ||||||
|  | end | ||||||
|  | 
 | ||||||
| local function genmetainfo(table) | local function genmetainfo(table) | ||||||
|     local fonts = require "fedora.rpm.fonts" |  | ||||||
|     local xmlfontname = '$(cmd=$(for f in %{buildroot}' .. table.filename .. '; do fc-scan "$f" -f "echo \\\\\"    <font>%{fullname[0]}</font>\\\\\";"; done); if test x"$cmd" != x; then echo "echo \\\\\"  <provides>\\\\\"; $cmd echo \\\\\"  </provides>\\\\\""|sh; fi|grep -v "font></font")' |     local xmlfontname = '$(cmd=$(for f in %{buildroot}' .. table.filename .. '; do fc-scan "$f" -f "echo \\\\\"    <font>%{fullname[0]}</font>\\\\\";"; done); if test x"$cmd" != x; then echo "echo \\\\\"  <provides>\\\\\"; $cmd echo \\\\\"  </provides>\\\\\""|sh; fi|grep -v "font></font")' | ||||||
|     local xmlfontlang = '$(cmd=$(for f in %{buildroot}' .. table.filename .. '; do fc-scan "$f" -f "%{[]lang{echo \\\\\"    <lang>%{lang}</lang>\\\\\";}}"; done); if test x"$cmd" != x; then echo "echo \\\\\"  <languages>\\\\\"; ($cmd)|sort -u; echo \\\\\"  </languages>\\\\\""|sh; fi)' |     local xmlfontlang = '$(cmd=$(for f in %{buildroot}' .. table.filename .. '; do fc-scan "$f" -f "%{[]lang{echo \\\\\"    <lang>%{lang}</lang>\\\\\";}}"; done); if test x"$cmd" != x; then echo "echo \\\\\"  <languages>\\\\\"; ($cmd)|sort -u; echo \\\\\"  </languages>\\\\\""|sh; fi)' | ||||||
|     local xml = [[ |     local xml = [[ | ||||||
| @ -528,7 +626,7 @@ local function genmetainfo(table) | |||||||
|   <name>Noto ]] .. table.family .. [[</name>\ |   <name>Noto ]] .. table.family .. [[</name>\ | ||||||
|   <summary><![CDATA[Noto ]] .. table.summary .. [[\]\]></summary>\ |   <summary><![CDATA[Noto ]] .. table.summary .. [[\]\]></summary>\ | ||||||
|   <description>\ |   <description>\ | ||||||
| ]] .. fonts.txt2xml(table.description) .. "\\\n" .. [[ | ]] .. txt2xml(table.description) .. "\\\n" .. [[ | ||||||
|   </description>\ |   </description>\ | ||||||
|   <updatecontact>]] .. rpm.expand("%{fontcontact}") .. [[</updatecontact>\ |   <updatecontact>]] .. rpm.expand("%{fontcontact}") .. [[</updatecontact>\ | ||||||
|   <url type=\"homepage\">]] .. rpm.expand("%{url}") .. [[</url>\ |   <url type=\"homepage\">]] .. rpm.expand("%{url}") .. [[</url>\ | ||||||
|  | |||||||
		Loading…
	
		Reference in New Issue
	
	Block a user