Class to represent a line from Sun’s patchdiag.xref patch “database”. See the following Oracle support publication for format: support.oracle.com/CSP/main/article?cmd=show&type=NOT&doctype=REFERENCE&id=1019527.1
An array of architectures for this patch. Values are strings like “sparc”, “i386”.
The date of this patch (a Date object).
The operating system for this patch, a string like “2.4, ”10“, ”10_x86“ or ”Unbundled“.
An array of packages that pertain to this patch. Values are strings like “SUNWcsr”.
The recommended field from the patchdiag xref database. Should be either ‘R’ or the empty string. See also #recommended?
The security field from the patchdiag xref database. Should be either ‘S’ or the empty string. See also #security?
This synopsis of this patch from the patchdiag xref database. This is a free text field (string).
# File lib/solaris/patchdiag_entry.rb, line 59 def initialize(patchdiag_line) fields = patchdiag_line.split( '|', 11 ) major, minor, date, @recommended, @security, @obsolete, bad, @os, archs, pkgs, @synopsis = *fields @archs = archs.split( ';' ) if date == '' year, month, day = 1970, 1, 1 else month_s, day_s, year_s = *date.split( '/' ) year = ( year_s.to_i > 50 ? "19#{year_s}" : "20#{year_s}" ).to_i month = Date::ABBR_MONTHNAMES.index( month_s ) day = day_s.to_i end @bad = bad =~ %rB/ ? 'B' : ' ' @y2k = bad =~ %rY/ ? 'Y' : ' ' @date = Date.new( year, month, day ) @patch = Patch.new( major, minor ) @pkgs = pkgs.split( ';' ) @synopsis.chomp! end
Compare (by delegated comparison of patch versions, see Solaris::Patch#<=>).
# File lib/solaris/patchdiag_entry.rb, line 174 def <=>(other) self.patch <=> other.patch end
Boolean, returns true if this patch is marked as “bad” in the patchdiag xref database.
# File lib/solaris/patchdiag_entry.rb, line 81 def bad? ; @bad == 'B' end
Download this patch. For options hash see Solaris::Patch#download!.
# File lib/solaris/patchdiag_entry.rb, line 84 def download_patch!(opts={}) ; @patch.download_patch!( opts ) end
Download the README for this patch. For options hash see Solaris::Patch#download!.
# File lib/solaris/patchdiag_entry.rb, line 89 def download_readme!(opts={}) @patch.download_readme!( opts ) end
Returns this entries major patch number as an integer.
# File lib/solaris/patchdiag_entry.rb, line 94 def major ; @patch.major end
Returns this entries minor patch number as an integer.
# File lib/solaris/patchdiag_entry.rb, line 97 def minor ; @patch.minor end
Boolean, returns true if this patch is marked as “obsolete” in the patchdiag xref database.
# File lib/solaris/patchdiag_entry.rb, line 101 def obsolete? ; @obsolete == 'O' end
Boolean, returns true if this patch is marked as “recommended” in the patchdiag xref database.
# File lib/solaris/patchdiag_entry.rb, line 105 def recommended? ; @recommended == 'R' end
Boolean, returns true if this patch is marked as “security” in the patchdiag xref database.
# File lib/solaris/patchdiag_entry.rb, line 109 def security? ; @security == 'S' end
Return the Solaris::Patch by which this entry is obsoleted. Throws Solaris::Patch::NotObsolete if this entry is not obsolete. Throws Solaris::Patch::MultipleSuccessors if this entry has more than one successor. Throws Solaris::Patch::InvalidSuccessor if the “obsoleted by” entry cannot be understood.
# File lib/solaris/patchdiag_entry.rb, line 117 def successor # I <3 consistency: # Obsoleted by : XXXXXX-XX # Obsoleted by: XXXXXX-XX # OBSOLETED by: XXXXXX # Obsoleted by: XXXXXX-XX OBSOLETED by WITHDRAWN # OBSOLETED by WITHDRAWN # OBSOLETED by XXXXXX # OBSOLETED by XXXXXX and XXXXXX # we ignore this pattern, see below # Obsoleted by XXXXXX-XX: # OBSOLETED by XXXXXX-XX: # WITHDRAWN Obsoleted by: XXXXXX-XX # WITHDRAWN PATCH Obsolete by: # WITHDRAWN PATCH Obsoleted by: # WITHDRAWN PATCH Obsoleted by XXXXXX-XX: # Fail if this entry is not actually obsolete raise Solaris::Patch::NotObsolete, "Entry #{patch.inspect} not obsolete" unless obsolete? # Fail if this entry is obsoleted by two patches (currently 2011/05/04 # only 105716 and 105717) raise Solaris::Patch::MultipleSuccessors, "More than one successor for entry #{patch.inspect}" if synopsis =~ %robsolete(d?) by\s*(:?)\s*(\d+(-\d+)?)\s+and\s+(\d+(-\d+)?)/ # See if we can find a successor if synopsis =~ %robsolete(d?) by\s*(:?)\s*(\d+(-\d+)?)/ Patch.new( $3 ) else raise Solaris::Patch::InvalidSuccessor, "Failed to parse successor to obsolete patchdiag entry for patch #{patch.inspect}" end end
Output this patchdiag xref entry as a string, in format of Oracle’s database.
# File lib/solaris/patchdiag_entry.rb, line 153 def to_s [ patch.major, Patch.pad_minor( patch.minor ), date_s, @recommended, @security, @obsolete, @bad + @y2k, @os, join_semis( @archs ), join_semis( @pkgs ), @synopsis ].join('|') end
Boolean, returns true if this patch is marked as a year 2000 patch in the patchdiag xref database.
# File lib/solaris/patchdiag_entry.rb, line 171 def y2k? ; @y2k == 'Y' end
Convert the Date object to a date string as found in patchdiag.xref.
# File lib/solaris/patchdiag_entry.rb, line 181 def date_s [ Date::ABBR_MONTHNAMES[ @date.mon ], # month eg Jan @date.mday.to_s.rjust(2, '0'), # day of month @date.year % 100 # 2 digit year ].join('/') end
Join an array of items with semicolons and append a trailing semicolon if the array is non-empty, otherwise return the empty string. Used to format @archs and @pkgs for to_s.
# File lib/solaris/patchdiag_entry.rb, line 191 def join_semis(a) a.empty? ? '' : a.join(';') + ';' end