File indexing completed on 2022-11-29 19:42:56

0001 module Debian
0002   # A debian patch series as seen in debian/patches/series
0003   class PatchSeries
0004     attr_reader :patches
0005 
0006     def initialize(package_path, filename = 'series')
0007       @package_path = package_path
0008       @filename = filename
0009       raise 'not a package path' unless Dir.exist?("#{package_path}/debian")
0010       @patches = []
0011       parse
0012     end
0013 
0014     def exist?
0015       @exist ||= false
0016     end
0017 
0018     private
0019 
0020     def parse
0021       path = "#{@package_path}/debian/patches/#{@filename}"
0022       return unless (@exist = File.exist?(path))
0023       data = File.read(path)
0024       data.split($/).each do |line|
0025         next if line.chop.strip.empty? || line.start_with?('#')
0026         # series names really shouldn't use paths, so strip by space. This
0027         # enforces the simple series format described in the dpkg-source manpage
0028         # which unlike quilt does not support additional arguments such as
0029         # -pN.
0030         @patches << line.split(' ').first
0031       end
0032     end
0033   end
0034 end