Method: Jamf::Utility#expand_min_os
- Defined in:
- lib/jamf/utility.rb
#expand_min_os(min_os) ⇒ Array
Converts an OS Version into an Array of equal or higher OS versions, up to some non-existant max, hopefully far in the future, currently 20.12.10
This array can then be joined with commas and used as the value of the os_requirements for Packages and Scripts.
It’s unlikely that this method, as written, will still be in use by the release of macOS 20.12.10, but currently thats the upper limit.
Hopefully well before then JAMF will implement a “minimum OS” in Jamf Pro itself, then we could avoid the inherant limitations in using a method like this.
When the highest maint. release of an OS version is not known, because its the currently released OS version or higher, then this method assumes ‘12’ e.g. ‘10.16.12’, ‘11.12’, ‘12.12’, etc.
Apple has never released more than 11 updates to a version of macOS (that being 10.4), so hopefully 12 is enough
Since Big Sur might report itself as either ‘10.16’ or ‘11.x.x’, this method will allow for both possibilities, and the array will contain whatever iterations needed for both version numbers
122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 |
# File 'lib/jamf/utility.rb', line 122 def (min_os) min_os = min_os.delete '>=' # split the version into major, minor and maintenance release numbers major, minor, maint = min_os.split('.') minor = 'x' if minor.nil? || minor == '0' maint = 'x' if maint.nil? || maint == '0' ok_oses = [] # Deal with 10.x.x up to 10.16 if major == '10' # In big sur with SYSTEM_VERSION_COMPAT # set, it will only ever report as `10.16` # So if major is 10 and minor is 16, ignore maint # and start explicitly at '10.16' if minor == '16' ok_oses << '10.16' # But for Catalina and below, we need to # expand things out else # e.g. 10.14.x # doesn't expand to anything if maint == 'x' ok_oses << "10.#{minor}.x" # e.g. 10.15.5 # expand to 10.15.5, 10.15.6, 10.15.7 else max_maint_for_minor = OS_TEN_MAXS[minor.to_i] (maint.to_i..max_maint_for_minor).each do |m| ok_oses << "#{major}.#{minor}.#{m}" end # each m end # if maint == x # now if we started below catalina, account for everything # up to 10.15.x ((minor.to_i + 1)..15).each { |v| ok_oses << "10.#{v}.x" } if minor.to_i < 15 # and add big sur with SYSTEM_VERSION_COMPAT ok_oses << '10.16' end # if minor == 16 # now reset these so we can go higher major = '11' minor = 'x' maint = 'x' end # if major == 10 # if the min os is 11.0.0 or equiv, and we aven't added 10.16 # for SYSTEM_VERSION_COMPAT, add it now ok_oses << '10.16' if ['11', '11.x', '11.x.x', '11.0', '11.0.0'].include?(min_os) && !ok_oses.include?('10.16') # e.g. 11.x, or 11.x.x # expand to 11.x, 12.x, 13.x, ... 20.x if minor == 'x' ((major.to_i)..20).each { |v| ok_oses << "#{v}.x" } # e.g. 11.2.x # expand to 11.2.x, 11.3.x, ... 11.12.x, # 12.x, 13.x, ... 20.x elsif maint == 'x' # first expand the minors out to their max # e.g. 11.2.x, 11.3.x, ... 11.12.x max_minor_for_major = MAC_OS_MAXS[major.to_i] ((minor.to_i)..max_minor_for_major).each do |m| ok_oses << "#{major}.#{m}.x" end # each m # then add the majors out to 20 ((major.to_i + 1)..20).each { |v| ok_oses << "#{v}.x" } # e.g. 11.2.3 # expand to 11.2.3, 11.2.4, ... 11.2.10, # 11.3.x, 11.4.x, ... 11.12.x, # 12.x, 13.x, ... 20.x else # first expand the maints out to 10 # e.g. 11.2.3, 11.2.4, ... 11.2.10 ((maint.to_i)..10).each { |mnt| ok_oses << "#{major}.#{minor}.#{mnt}" } # then expand the minors out to their max # e.g. 11.3.x, ... 11.12.x max_minor_for_major = MAC_OS_MAXS[major.to_i] ((minor.to_i + 1)..max_minor_for_major).each { |min| ok_oses << "#{major}.#{min}.x" } # then add the majors out to 20 ((major.to_i + 1)..20).each { |v| ok_oses << "#{v}.x" } end ok_oses end |