lib/rpm_manifestizer.rb in inqlude-0.0.4 vs lib/rpm_manifestizer.rb in inqlude-0.0.5
- old
+ new
@@ -24,46 +24,72 @@
@cut_off_exceptions = [ "qt4-x11" ]
@source_rpms = Hash.new
end
def create_manifest name, rpm_name
- filename = "#{@settings.manifest_dir}/#{name}.manifest"
- File.open( filename, "w") do |f2|
- source_rpm = `rpm -q --queryformat '%{SOURCERPM}' #{rpm_name}`
- @source_rpms[source_rpm] = Array.new
+ qf = 'version:%{VERSION}\n'
+ qf += 'summary:%{SUMMARY}\n'
+ qf += 'homepage:%{URL}\n'
+ qf += 'license:%{LICENSE}\n'
+ qf += 'sourcerpm:%{SOURCERPM}\n'
+ header = `rpm -q --queryformat '#{qf}' #{rpm_name}`
- raw = `rpm -q --queryformat '%{DESCRIPTION}' #{rpm_name}`
- parse_authors = false
- description = ""
- authors = Array.new
- raw.each_line do |line3|
- if line3 =~ /^Authors:/
- parse_authors = true
+ header_strings = header.split "\n"
+
+ headers = Hash.new
+ header_strings.each do |header_string|
+ header_string =~ /^(.*?):(.*)$/
+ headers[$1] = $2
+ end
+
+ source_rpm = headers["sourcerpm"]
+ @source_rpms[source_rpm] = Array.new
+
+ raw = `rpm -q --queryformat '%{DESCRIPTION}' #{rpm_name}`
+ parse_authors = false
+ description = ""
+ authors = Array.new
+ raw.each_line do |line3|
+ if line3 =~ /^Authors:/
+ parse_authors = true
+ next
+ end
+ if parse_authors
+ if line3 =~ /^---/
next
end
- if parse_authors
- if line3 =~ /^---/
- next
- end
- authors.push "\"#{line3.strip}\""
- else
- description += line3.chomp + "\\n"
- end
+ authors.push "\"#{line3.strip}\""
+ else
+ description += line3.chomp + "\\n"
end
- description.gsub! /"/, "\\\""
- description.strip!
+ end
+ description.gsub! /"/, "\\\""
+ description.strip!
+
+ release_date = Date.parse "1970-01-01"
- qf = ' "version": "%{VERSION}",\n'
- qf += ' "summary": "%{SUMMARY}",\n'
- qf += ' "homepage": "%{URL}",\n'
- qf += ' "license": "%{LICENSE}",\n'
- header = `rpm -q --queryformat '#{qf}' #{rpm_name}`
+ licenses = Array.new
+ headers["license"].split(";").each do |l|
+ licenses.push "\"#{l.strip}\""
+ end
+ licenses_string = licenses.join ","
+ manifest_path = "#{@settings.manifest_path}/#{name}"
+ if !File.exists? manifest_path
+ Dir.mkdir manifest_path
+ end
+ filename = "#{manifest_path}/#{name}.#{release_date}.manifest"
+
+ File.open( filename, "w") do |f2|
f2.puts '{';
f2.puts ' "schema_version": 1,'
f2.puts " \"name\": \"#{name}\","
- f2.puts header
+ f2.puts " \"release_date\": \"#{release_date}\","
+ [ "version", "summary", "homepage" ].each do |key|
+ f2.puts " \"#{key}\": \"#{headers[key]}\","
+ end
+ f2.puts " \"licenses\": [#{licenses_string}],"
f2.puts " \"description\": \"#{description}\","
f2.puts ' "authors": [' + authors.join(",") + '],'
f2.puts ' "maturity": "stable",'
f2.puts ' "packages": {'
f2.puts ' "openSUSE": {'
@@ -153,9 +179,16 @@
if !dry_run
create_manifest name, lib_rpm
end
end
end
+ end
+
+ if !dry_run
+ patch = @settings.data_path + "/manifest.patch"
+ cmd = "cd #{@settings.manifest_path}; patch -p1 <#{patch}";
+ puts "Patching manifests with #{patch}"
+ system cmd
end
end
def read_source_cache
if !File.exist? @settings.cache_dir + "/source.json"