SHOW:
|
|
- or go back to the newest paste.
1 | - | if(version.StartsWith("Windows 9")) { /* 95 and 98 */ } else { |
1 | + | /* |
2 | * The MIT License | |
3 | * | |
4 | * Copyright (c) 2004-2009, Sun Microsystems, Inc., Kohsuke Kawaguchi, Stephen Connolly | |
5 | * Copyright (C) 2009 Robert Collins | |
6 | * | |
7 | * Permission is hereby granted, free of charge, to any person obtaining a copy | |
8 | * of this software and associated documentation files (the "Software"), to deal | |
9 | * in the Software without restriction, including without limitation the rights | |
10 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell | |
11 | * copies of the Software, and to permit persons to whom the Software is | |
12 | * furnished to do so, subject to the following conditions: | |
13 | * | |
14 | * The above copyright notice and this permission notice shall be included in | |
15 | * all copies or substantial portions of the Software. | |
16 | * | |
17 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR | |
18 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, | |
19 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE | |
20 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER | |
21 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, | |
22 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN | |
23 | * THE SOFTWARE. | |
24 | */ | |
25 | ||
26 | package org.jvnet.hudson.plugins.platformlabeler; | |
27 | ||
28 | import net.robertcollins.lsb.Release; | |
29 | ||
30 | import hudson.remoting.Callable; | |
31 | import java.util.HashSet; | |
32 | ||
33 | class PlatformDetailsTask implements Callable<HashSet<String>, Exception> { | |
34 | ||
35 | /** Performs computation and returns the result, or throws some exception. */ | |
36 | public HashSet<String> call() throws Exception { | |
37 | final String arch = System.getProperty("os.arch"); | |
38 | String name = System.getProperty("os.name").toLowerCase(); | |
39 | String version = System.getProperty("os.version"); | |
40 | if (name.equals("solaris") || name.equals("SunOS")) { | |
41 | name = "solaris"; | |
42 | } else if (name.startsWith("windows")) { | |
43 | name = "windows"; | |
44 | if (name.startsWith("windows 9")) { | |
45 | if (version.startsWith("4.0")) { | |
46 | version = "95"; | |
47 | } else if (version.startsWith("4.9")) { | |
48 | version = "me"; | |
49 | } else { | |
50 | assert version.startsWith("4.1"); | |
51 | version = "98"; | |
52 | } | |
53 | } else { | |
54 | if (version.startsWith("4.0")) { | |
55 | version = "nt4"; | |
56 | } else if (version.startsWith("5.0")) { | |
57 | version = "2000"; | |
58 | } else if (version.startsWith("5.1")) { | |
59 | version = "xp"; | |
60 | } else if (version.startsWith("5.2")) { | |
61 | version = "2003"; | |
62 | } | |
63 | } | |
64 | } else if (name.startsWith("linux")) { | |
65 | Release release = new Release(); | |
66 | name = release.distributorId(); | |
67 | version = release.release(); | |
68 | } else if (name.startsWith("mac")) { | |
69 | name = "mac"; | |
70 | } else { | |
71 | // Take the System.properties values verbatim. | |
72 | } | |
73 | HashSet<String> result = new HashSet<String>(); | |
74 | result.add(arch); | |
75 | result.add(name); | |
76 | result.add(version); | |
77 | result.add(arch + "-" + name); | |
78 | result.add(name + "-" + version); | |
79 | result.add(arch + "-" + name + "-" + version); | |
80 | return result; | |
81 | } | |
82 | } |