lib/autobuild/importer.rb in autobuild-1.8.0 vs lib/autobuild/importer.rb in autobuild-1.8.1

- old
+ new

@@ -282,33 +282,33 @@ end def apply(package, path, patch_level = 0); call_patch(package, false, path, patch_level) end def unapply(package, path, patch_level = 0); call_patch(package, true, path, patch_level) end - def parse_patch_list(package, patches_file) + def parse_patch_list(patches_file) File.readlines(patches_file).map do |line| line = line.rstrip if line =~ /^(.*)\s+(\d+)$/ - path = File.expand_path($1, package.srcdir) + path = $1 level = Integer($2) else - path = File.expand_path(line, package.srcdir) + path = line level = 0 end [path, level, File.read(path)] end end def currently_applied_patches(package) patches_file = patchlist(package) if File.exists?(patches_file) - return parse_patch_list(package, patches_file) + return parse_patch_list(patches_file) end patches_file = File.join(package.importdir, "patches-autobuild-stamp") if File.exists?(patches_file) - cur_patches = parse_patch_list(package, patches_file) + cur_patches = parse_patch_list(patches_file) save_patch_state(package, cur_patches) FileUtils.rm_f patches_file return currently_applied_patches(package) end @@ -317,13 +317,11 @@ def patch(package, patches = self.patches) # Get the list of already applied patches cur_patches = currently_applied_patches(package) - cur_patches_state = cur_patches.map { |_, level, content| [level, content] } - patches_state = patches.map { |_, level, content| [level, content] } - if cur_patches_state == patches_state + if cur_patches.map(&:last) == patches.map(&:last) return false end # Do not be smart, remove all already applied patches # and then apply the new ones @@ -357,21 +355,17 @@ def save_patch_state(package, cur_patches) patch_dir = patchdir(package) FileUtils.mkdir_p patch_dir cur_patches = cur_patches.each_with_index.map do |(path, level, content), idx| - path = File.join(patch_dir, idx.to_s) - File.open(path, 'w') do |patch_io| - patch_io.write content - end - [path, level] + path = File.join(patch_dir, idx.to_s) + File.open(path, 'w') do |patch_io| + patch_io.write content end + [path, level] + end File.open(patchlist(package), 'w') do |f| - patch_state = cur_patches.map do |path, level| - path = Pathname.new(path).relative_path_from(package.srcdir).to_s - "#{path} #{level}" - end - f.write(patch_state.join("\n")) + f.write(cur_patches.map { |p, l| "#{p} #{l}" }.join("\n")) end end def supports_relocation?; false end end