Changeset 191
- Timestamp:
- 07/13/15 21:14:26 (9 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/debbuild
r190 r191 142 142 # /etc/debian-version and/or version of base-files package 143 143 my %distmap = ( 144 "3.1.9ubuntu7.1" => "dapper", 145 "4ubuntu2" => "feisty", 144 # legacy Unbuntu 145 "3.1.9ubuntu" => "dapper", 146 "6.06" => "dapper", 147 "4ubuntu" => "feisty", 148 "7.04" => "fiesty", 149 "4.0.1ubuntu" => "hardy", 150 "8.04" => "hardy", 151 # Note we do NOT support identification of "subrelease" versions (ie semimajor updates 152 # to a given release). If your dependencies are really that tight, and you can't rely 153 # on the versions of the actual dependencies, you're already in over your head, and 154 # should probably only ship a tarballed installer. 155 # only supporting LTS releases 156 # base-files version doesn't map to the Ubuntu version the way Debian versions do, thus the doubled entries 157 # Ubuntu 12.04.5 LTS (Precise Pangolin) 158 "6.5ubuntu" => "precise", 159 "12.04" => "precise", 160 # Ubuntu 14.04.2 LTS (Trusty Tahr) 161 "7.2ubuntu" => "trusty", 162 "14.04" => "trusty", 163 # Debian releases 146 164 "3.0" => "woody", 147 165 "3.1" => "sarge", 148 166 "4" => "etch", 149 167 "5" => "lenny", 150 "6.0" => "squeeze", 151 "7.0" => "wheezy", 152 "8.0" => "jessie", 153 "99" => "sid"); 168 "6" => "squeeze", 169 "7" => "wheezy", 170 "8" => "jessie", 171 "9" => "stretch", 172 "99" => "sid", 173 ); 174 175 # Map Ubuntu base-files versions to the nominal public versions 176 177 my %ubnt_vermap = ( 178 "6.5ubuntu6" => "12.04", 179 "7.2ubuntu5" => "14.04", 180 ); 181 154 182 # Enh. There doesn't seem to be any better way to do this... :( 155 183 { … … 157 185 # my $releasever = qx { cat /etc/debian_version }; 158 186 # chomp $releasever; 187 my $basefiles; 159 188 my $basever; 160 161 if ( ! -e '/usr/bin/dpkg-query' ) { 189 my $baseos; 190 191 # Funny thing how files like this have become useful... 192 # Check for /etc/os-release. If that doesn't exist, try /etc/lsb-release. If that doesn't exist, 193 # check for existence of dpkg-query, and either call it Debian Woody (if missing), or fall through 194 # to guessing based on the version of the base-files package. 195 if (-e '/etc/os-release') { 196 open OSREL, "</etc/os-release"; 197 # Look for ID and VERSION_ID lines. 198 while (<OSREL>) { 199 $baseos = $1 if /^ID=(\w+)/; 200 $basever = $1 if /^VERSION_ID="?([\d.]+)/; 201 } 202 close OSREL; 203 204 } elsif (-e '/etc/lsb-release') { 205 open LSBREL, "</etc/lsb-release"; 206 # Look for DISTRIB_ID and DISTRIB_RELEASE lines. 207 # We could also theoretically extract the dist codename, but since we have to hand-map 208 # it in so many other cases there's little point. 209 while (<LSBREL>) { 210 $baseos = $1 if /^DISTRIB_ID=(\w+)/; 211 $basever = $1 if /^DISTRIB_RELEASE=([\d.]+)/; 212 } 213 close LSBREL; 214 215 } elsif ( ! -e '/usr/bin/dpkg-query' ) { 162 216 # call it woody, since sarge and newer have dpkg-query, and we don't much care about obsolete^n releases 163 217 $basever = "3.0"; 218 $baseos = 'debian'; 219 164 220 } else { 165 166 221 # *eyeroll* there *really* has to be a better way to go about this. You 167 222 # can't sanely build packages for multiple distro targets if you can't … … 171 226 # releases would be... exponentially more painful. 172 227 228 my $majver; 173 229 # for the lazy copy-paster: dpkg-query --showformat '${version}\n' -W base-files 174 230 # avoid shellisms … … 177 233 close BASEGETTER; 178 234 179 ($basever) = ($basever =~ /^(\d(?:\.\d)?)/); 180 } 181 235 if ($basever =~ /ubuntu/) { 236 # Ubuntu, at least until they upset their versioning scheme again 237 # note that we remap the basefiles version to the public release number, to match the 238 # behaviour for Debian, and to match the unofficial standard for RHEL/Centos etc and Fedora 239 ($basefiles,$basever) = ($basever =~ /^(([\d.]+)ubuntu)\d/); 240 $baseos = 'ubuntu'; 241 } else { 242 # Debian, or more "pure" derivative 243 $baseos = 'debian'; 244 ($basever,$majver) = ($basever =~ /^((\d+)(?:\.\d)?)/); 245 if ($majver > 3) { 246 $basever = $majver; 247 } 248 } 249 } 250 251 if (!$basever) { 252 # Your llama is on fire 253 $basever = '99'; 254 print "Warning: couldn't autodetect OS version, assuming sid/unstable\n"; 255 } 182 256 } # got dpkg-query? 183 257 258 # Set some legacy globals. 184 259 $specglobals{"debdist"} = $distmap{$basever}; 185 260 $specglobals{"debver"} = $basever; # this may have trouble with Ubuntu versions? 261 262 # Set the standard generic OS-class globals; 263 $baseos = lc($baseos); 264 $specglobals{"ubuntu"} = $basever if $baseos eq 'ubuntu'; 265 $specglobals{"debian"} = $basever if $baseos eq 'debian'; 266 267 # Default %{dist} to something marginally sane. Note this should be overrideable by --define. 268 # This has been chosen to most closely follow the usage in RHEL/CentOS and Fedora, ie "el5" or "fc20". 269 $specglobals{"dist"} = $baseos.$basever; 186 270 187 271 } # done trying to set debian dist/version … … 657 741 my $output = expandmacros($1, 'gp'); 658 742 print "$output"; 743 next LINE; 659 744 } 660 745
Note:
See TracChangeset
for help on using the changeset viewer.