summaryrefslogtreecommitdiff
path: root/pkgbuild2mw
diff options
context:
space:
mode:
Diffstat (limited to 'pkgbuild2mw')
-rwxr-xr-xpkgbuild2mw49
1 files changed, 42 insertions, 7 deletions
diff --git a/pkgbuild2mw b/pkgbuild2mw
index b3a4a30..9ee7bff 100755
--- a/pkgbuild2mw
+++ b/pkgbuild2mw
@@ -24,10 +24,10 @@ class Pass0
end
def is_hd
- not /(.*)[^<]<<\s*([^<]\S+)/.match(@line).nil?
+ not /(.*[^<])<<\s*([^<]\S+)/.match(@line).nil?
end
def section_hd
- m = /(.*)[^<]<<\s*([^<]\S+)/.match(@line)
+ m = /(.*[^<])<<\s*([^<]\S+)/.match(@line)
return if m.nil?
prefix = m[1]
eot = m[2]
@@ -38,6 +38,26 @@ class Pass0
getline
end
getline
+ body = body.gsub(/\\(.)/, '\1')
+ $stdout.puts "\n\n{{hc|#{prefix}|<nowiki>#{body.chomp}</nowiki>}}\n\n"
+ end
+
+ def is_hs
+ not /(.*[^<])<<<\'(.*)/.match(@line).nil?
+ end
+ def section_hs
+ m = /(.*[^<])<<<\'(.*)/.match(@line)
+ return if m.nil?
+ prefix = m[1]
+ body = m[2] + "\n"
+ getline
+ while not @line.end_with? "'\n"
+ body += @line
+ getline
+ end
+ body += @line.sub(/'$/, '')
+ getline
+ body = body.gsub("'\\''", "'")
$stdout.puts "\n\n{{hc|#{prefix}|<nowiki>#{body.chomp}</nowiki>}}\n\n"
end
@@ -52,7 +72,11 @@ class Pass0
$stdout.puts "\n\n{{bc|<nowiki>#{section.chomp}</nowiki>}}\n\n" unless section.gsub("\n", '') == ""
section_hd
section = ""
- elsif @line == "}\n"
+ elsif is_hs
+ $stdout.puts "\n\n{{bc|<nowiki>#{section.chomp}</nowiki>}}\n\n" unless section.gsub("\n", '') == ""
+ section_hs
+ section = ""
+ elsif @line == "postamble\n"
$stdout.puts "\n\n{{bc|<nowiki>#{section.chomp}</nowiki>}}\n\n" unless section.gsub("\n", '') == ""
return
else
@@ -86,7 +110,18 @@ class Pass0
m = /^depends\+?=\((.*)\)/.match(@line)
if not m.nil?
m[1].split(/\s+/).each do |pkg|
- $stdout.puts "p* {{ic|#{pkg}}"
+ $stdout.puts "p* {{ic|#{pkg}}}"
+ end
+ getline
+ next
+ end
+ if @line == "depends+=(\n"
+ getline
+ while @line != ")\n"
+ @line.sub(/#.*/, '').split(/\s+/).find_all{|x|not x.empty?}.each do |pkg|
+ $stdout.puts "p* {{ic|#{pkg}}}"
+ end
+ getline
end
getline
next
@@ -104,7 +139,7 @@ class Pass0
end
def run
- while @line != "package() {\n"
+ while @line != "preamble\n"
getline
end
getline
@@ -117,8 +152,8 @@ end
def pass1
exec('sed', '-r',
- '-e', 's@^\{\{hc\|add-file ([^|]*)\|(.*)\}\}$@f* {{ic|/\1}}: {{ic|\2}}@',
- '-e', 's@^\{\{hc\|add-file ([^|]*)\|@f* {{ic|/\1}}\n&@',
+ '-e', 's@^\{\{hc\|add-file (-\S+ )*([^|]*)\|(.*)\}\}$@f* {{ic|/\2}}: {{ic|\3}}@',
+ '-e', 's@^\{\{hc\|add-file (-\S+ )*([^|]*)\|@f* {{ic|/\2}}\n&@',
:in=>$stdin, :out=>$stdout)
end