Revision 42881

View differences:

trunk/org.gvsig.desktop/pom.xml
2588 2588

  
2589 2589
        <jython.artifactId>jython-standalone</jython.artifactId>
2590 2590
        <!-- External project versions -->
2591
        <gvsig.tools.version>3.0.89</gvsig.tools.version>
2591
        <gvsig.tools.version>3.0.90</gvsig.tools.version>
2592 2592
        <gvsig.proj.version>1.0.3</gvsig.proj.version>
2593 2593
        <gvsig.projection.api.version>2.0.22</gvsig.projection.api.version>
2594 2594

  
trunk/org.gvsig.desktop/org.gvsig.desktop.library/org.gvsig.installer/org.gvsig.installer.lib/org.gvsig.installer.lib.api/src/main/java/org/gvsig/installer/lib/api/InstallerManager.java
325 325
	 * @return os code of the system
326 326
	 */
327 327
	public String getOperatingSystem();
328

  
328
        public String getOperatingSystemFamily();
329
	public String getOperatingSystemName();
330
	public String getOperatingSystemVersion();
329 331
	/**
330 332
	 * Returns the Architecture code of the system
331 333
	 * 
trunk/org.gvsig.desktop/org.gvsig.desktop.library/org.gvsig.installer/org.gvsig.installer.lib/org.gvsig.installer.lib.impl/src/main/java/org/gvsig/installer/lib/impl/DefaultPackageInfo.java
36 36
import java.util.ArrayList;
37 37
import java.util.Iterator;
38 38
import java.util.List;
39
import org.apache.commons.lang3.StringUtils;
39 40

  
40 41
import org.gvsig.installer.lib.api.Dependencies;
41 42
import org.gvsig.installer.lib.api.InstallerLocator;
......
79 80
    private Boolean broken = false;
80 81

  
81 82
    private String state = STATE.DEVEL;
82
    private String operatingSystem = OS.ALL;
83
//    private String operatingSystem = OS.ALL;
84
    private String operatingSystemFamily = OS.ALL;
85
    private String operatingSystemName = null;
86
    private String operatingSystemVersion = null;
87
    
83 88
    private String architecture = ARCH.ALL;
84 89
    private String javaVM = JVM.J1_5;
85 90

  
......
239 244
        this.official = official;
240 245
    }
241 246

  
247
    @Override
242 248
    public String getOperatingSystem() {
243
        return operatingSystem;
249
        StringBuilder operatingSystem = new StringBuilder();
250
        operatingSystem.append(this.operatingSystemFamily);
251
        if( !StringUtils.isEmpty(this.operatingSystemName) ) {
252
            operatingSystem.append("_");
253
            operatingSystem.append(this.operatingSystemName);
254
            if( !StringUtils.isEmpty(this.operatingSystemVersion) ) {
255
                operatingSystem.append("_");
256
                operatingSystem.append(this.operatingSystemVersion);
257
            }
258
        }
259
        return operatingSystem.toString();
244 260
    }
245 261

  
262
    @Override
246 263
    public void setOperatingSystem(String operatingSystem) {
247
        this.operatingSystem = operatingSystem;
264
    	if( StringUtils.isEmpty(operatingSystem) ) {
265
    		this.operatingSystemFamily = OS.ALL;
266
    		this.operatingSystemName = null;
267
    		this.operatingSystemVersion = null;
268
    	} else {
269
            if( operatingSystem.contains("_") ) {
270
                String s[] = operatingSystem.split("_");
271
                switch(s.length) {
272
                    case 2:
273
                        this.operatingSystemFamily = s[0];
274
                        this.operatingSystemName = s[1];
275
                        break;
276
                    case 3:
277
                        this.operatingSystemFamily = s[0];
278
                        this.operatingSystemName = s[1];
279
                        this.operatingSystemVersion = s[2];
280
                        break;
281
                    default:
282
                        throw new IllegalArgumentException("Can't parse OS '"+operatingSystem+"'.");
283
                }
284
            } else {
285
                this.operatingSystemFamily = operatingSystem;
286
            }
287
    	}
248 288
    }
289
    
290
    @Override
291
    public String getOperatingSystemFamily() {
292
        return this.operatingSystemFamily;
293
    }
294
    
295
    @Override
296
    public String getOperatingSystemName() {
297
        return this.operatingSystemName;
298
    }
299
    
300
    @Override
301
    public String getOperatingSystemVersion() {
302
        return this.operatingSystemVersion;
303
    }
249 304

  
305
    public void setOperatingSystemFamily(String operatingSystemFamily) {
306
        this.operatingSystemFamily = operatingSystemFamily;
307
    }
308
    
309
    public void setOperatingSystemName(String operatingSystemName) {
310
        this.operatingSystemName = operatingSystemName;
311
    }
312
    
313
    public void setOperatingSystemVersion(String operatingSystemVersion) {
314
        this.operatingSystemVersion = operatingSystemVersion;
315
    }
316

  
250 317
    public String getArchitecture() {
251 318
        return architecture;
252 319
    }
......
408 475
            .format(
409 476
                "%1$-8.8s %2$-40s %3$-20.20s %4$-5.5s %5$-5.5s %6$-6.6s %7$-5.5s %8$s %8$s",
410 477
                this.type, this.code, this.version, this.state,
411
                this.operatingSystem, this.architecture, this.javaVM,
478
                this.getOperatingSystem(), this.architecture, this.javaVM,
412 479
                this.dependencies, this.getAliasAsString());
413 480
    }
414 481

  
......
560 627
        return delete.delete(folder);
561 628
    }
562 629

  
630
    @Override
563 631
    public boolean matchID(String string) {
632
        final int PART_CODE = 0;
633
        final int PART_VERSION = 1;
634
        final int PART_OS = 2;
635
        final int PART_ARCH = 3;
636
        
564 637
        String id = this.getID();
565
        String[] stringParts = string.split("#");
638
        String[] parts = string.split("#");
566 639

  
567
        switch (stringParts.length) {
640
        switch (parts.length) {
568 641
        case 1:
569
            if (stringParts[0].equals(this.getCode())) {
642
            if (parts[PART_CODE].equals(this.getCode())) {
570 643
                return true;
571 644
            } else {
572 645
                return false;
573 646
            }
574 647
        case 2:
575
            if (!stringParts[0].equals(this.getCode())) {
648
            if (!parts[PART_CODE].equals(this.getCode())) {
576 649
                return false;
577 650
            }
578 651
            Version version = new DefaultVersion();
579 652
            try {
580
                version.parse(stringParts[1]);
653
                version.parse(parts[PART_VERSION]);
581 654
            } catch (InvalidParameterException ex) {
582 655
                return false;
583 656
            }
......
587 660
            }
588 661
            return false;
589 662
        case 4: // id, version, os, arch
590
            if (!stringParts[0].equals(this.getCode())) {
663
            if (!parts[PART_CODE].equals(this.getCode())) {
591 664
                return false;
592 665
            }
593
            if( !"any".equalsIgnoreCase(stringParts[1]) ) {
666
            if( !"any".equalsIgnoreCase(parts[PART_VERSION]) ) {
594 667
                version = new org.gvsig.tools.packageutils.impl.DefaultVersion();
595 668
                try {
596
                    version.parse(stringParts[1]);
669
                    version.parse(parts[PART_VERSION]);
597 670
                } catch (InvalidParameterException ex) {
598 671
                    return false;
599 672
                }
......
602 675
                    return false;
603 676
                }
604 677
            }
605
            if( !"any".equalsIgnoreCase(stringParts[2]) ) {
606
                if( "current".equalsIgnoreCase(stringParts[2]) ) {
607
                    if( !this.getOperatingSystem().equalsIgnoreCase(this.getPackageManager().getOperatingSystem()) ) {
678
            if( !"any".equalsIgnoreCase(parts[PART_OS]) ) {
679
                if( "current".equalsIgnoreCase(parts[PART_OS]) ) {
680
                    if( !this.getOperatingSystemFamily().equalsIgnoreCase(this.getPackageManager().getOperatingSystemFamily()) ) {
608 681
                        return false;
609 682
                    }
610
                } else if( !this.getOperatingSystem().equalsIgnoreCase(stringParts[2]) ) {
683
                    if( !StringUtils.isEmpty(this.getOperatingSystemName())) {
684
                        if( !this.getOperatingSystemName().equalsIgnoreCase(this.getPackageManager().getOperatingSystemName()) ) {
685
                            return false;
686
                        }
687
                        if( !StringUtils.isEmpty(this.getOperatingSystemVersion())) {
688
                            if( !this.getOperatingSystemVersion().equalsIgnoreCase(this.getPackageManager().getOperatingSystemVersion()) ) {
689
                                return false;
690
                            }
691
                        }
692
                    }
693
                        
694
                } else if( !this.getOperatingSystem().equalsIgnoreCase(parts[PART_OS]) ) {
611 695
                    return false;
612 696
                }
613 697
            }
614
            if( !"any".equalsIgnoreCase(stringParts[3]) ) {
615
                if( "current".equalsIgnoreCase(stringParts[3]) ) {
698
            if( !"any".equalsIgnoreCase(parts[PART_ARCH]) ) {
699
                if( "current".equalsIgnoreCase(parts[PART_ARCH]) ) {
616 700
                    if( !this.getArchitecture().equalsIgnoreCase(this.getPackageManager().getArchitecture()) ) {
617 701
                        return false;
618 702
                    }
619
                } else if( !this.getArchitecture().equalsIgnoreCase(stringParts[3]) ) {
703
                } else if( !this.getArchitecture().equalsIgnoreCase(parts[3]) ) {
620 704
                    return false;
621 705
                }
622 706
            }
......
665 749
        if (!version.check("=", other.getVersion())) {
666 750
            return false;
667 751
        }
668
        if (!operatingSystem.equalsIgnoreCase(other.getOperatingSystem())) {
752
        if (!getOperatingSystem().equalsIgnoreCase(other.getOperatingSystem())) {
669 753
            return false;
670 754
        }
671 755
        if (!gvSIGVersion.equalsIgnoreCase(other.getGvSIGVersion())) {
trunk/org.gvsig.desktop/org.gvsig.desktop.library/org.gvsig.installer/org.gvsig.installer.lib/org.gvsig.installer.lib.impl/src/main/java/org/gvsig/installer/lib/impl/DefaultInstallerManager.java
37 37
import java.util.Iterator;
38 38
import java.util.List;
39 39
import java.util.Map;
40
import java.util.Properties;
40 41
import java.util.Set;
42
import org.apache.commons.io.IOUtils;
41 43
import org.apache.commons.lang3.StringUtils;
42 44

  
43 45
import org.gvsig.installer.lib.api.DependenciesCalculator;
......
61 63
import org.gvsig.tools.exception.BaseException;
62 64
import org.gvsig.tools.extensionpoint.ExtensionPoint;
63 65
import org.gvsig.tools.extensionpoint.ExtensionPointManager;
66
import org.gvsig.tools.packageutils.PackageManager;
64 67
import org.gvsig.tools.service.AbstractManager;
65 68
import org.gvsig.tools.service.Service;
66 69
import org.gvsig.tools.service.ServiceException;
......
189 192
    private List<LocalRepositoryLocation> localRepositoriesLocation = null;
190 193
    private Map<String,File> defaultRepositoryLocation = null;
191 194

  
195
    private String operatingSystemName;
196
    private String operatingSystemFamily;
197
    private String operatingSystemVersion;
198

  
192 199
    public DefaultInstallerManager() {
193 200
        super(new DefaultInstallerProviderManager());
194 201
        this.defaultRepositoryLocation = new HashMap<String,File>();
......
333 340
    public String getDefaultIndexSetFileExtension() {
334 341
        return "gvspki";
335 342
    }
343
	
344
    private void loadOperatingSystemInfo() {
345
        String osname = System.getProperty("os.name");
346
        String osversion = System.getProperty("os.version");
347
        if (osname.toLowerCase().startsWith("linux")) {
348
            this.operatingSystemFamily = PackageManager.OS.LINUX;
349
            FileInputStream fis = null;
350
            try {
351
                Properties p = new Properties();
352
                fis = new FileInputStream("/etc/os-release");
353
                p.load(fis);
354
                this.operatingSystemName = p.getProperty("ID", null);
355
                this.operatingSystemVersion = p.getProperty("VERSION_ID", null);
356
            } catch(Exception ex) {
336 357

  
358
            } finally {
359
                IOUtils.closeQuietly(fis);
360
            }
361

  
362
        } else if (osname.toLowerCase().startsWith("window")) {
363
            this.operatingSystemFamily = PackageManager.OS.WINDOWS;
364
            String s = osname.replace(" ", "");
365
            s = s.replace("_", "");
366
            s = s.replace("-", "");
367
            this.operatingSystemName = s;
368
            this.operatingSystemVersion = osversion;
369

  
370
        } else {
371
            String s = osname.replace(" ", "");
372
            s = s.replace("_", "");
373
            s = s.replace("-", "");
374
            this.operatingSystemFamily = s;
375
            this.operatingSystemName = null;
376
            this.operatingSystemVersion = osversion;
377
        }
378
    }
379

  
380
    @Override
337 381
    public String getOperatingSystem() {
338
        String osname = System.getProperty("os.name");
339
        if ( osname.toLowerCase().startsWith("linux") ) {
340
            return InstallerManager.OS.LINUX;
382
        if( this.operatingSystemFamily == null ) {
383
            loadOperatingSystemInfo();
341 384
        }
342
        if ( osname.toLowerCase().startsWith("window") ) {
343
            return InstallerManager.OS.WINDOWS;
385
        StringBuilder builder = new StringBuilder();
386
        builder.append(this.operatingSystemFamily);
387
        if( this.operatingSystemName!=null ) {
388
            builder.append("_");
389
            builder.append(this.operatingSystemName);
390
            if( this.operatingSystemVersion!=null ) {
391
                builder.append("_");
392
                builder.append(this.operatingSystemVersion);
393
            }
344 394
        }
345
        return osname;
395
        return builder.toString();
346 396
    }
347 397

  
398
    @Override
399
    public String getOperatingSystemFamily() {
400
        if( this.operatingSystemFamily == null ) {
401
            loadOperatingSystemInfo();
402
        }
403
        return this.operatingSystemFamily;
404
    }
405

  
406
    @Override
407
    public String getOperatingSystemName() {
408
        if( this.operatingSystemFamily == null ) {
409
            loadOperatingSystemInfo();
410
        }
411
        return this.operatingSystemName;
412
    }
413

  
414
    @Override
415
    public String getOperatingSystemVersion() {
416
        if( this.operatingSystemFamily == null ) {
417
            loadOperatingSystemInfo();
418
        }
419
        return this.operatingSystemVersion;
420
    }
421

  
422
    @Override
348 423
    public String getArchitecture() {
349 424
        String osarch = System.getProperty("os.arch");
350
        if ( osarch.toLowerCase().startsWith("i386") ) {
351
            return InstallerManager.ARCH.X86;
425
        if (osarch.toLowerCase().startsWith("i386")) {
426
                return ARCH.X86;
352 427
        }
353
        if ( osarch.toLowerCase().startsWith("x86") ) {
354
            return InstallerManager.ARCH.X86;
428
        if (osarch.toLowerCase().startsWith("i686")) {
429
                return ARCH.X86;
355 430
        }
356
        if ( osarch.toLowerCase().startsWith("amd64") ) {
357
            return InstallerManager.ARCH.X86_64;
431
        if (osarch.toLowerCase().startsWith("x86_64")) {
432
                return ARCH.X86_64;
358 433
        }
359
        return osarch;
434
        if (osarch.toLowerCase().startsWith("x86")) {
435
                return ARCH.X86;
436
        }
437
        if (osarch.toLowerCase().startsWith("amd64")) {
438
                return ARCH.X86_64;
439
        }
440
        return osarch;	
360 441
    }
361 442

  
362 443
    public Dependency createDependency(PackageInfo packageInfo) {
trunk/org.gvsig.desktop/org.gvsig.desktop.library/org.gvsig.installer/org.gvsig.installer.swing/org.gvsig.installer.swing.impl/src/main/java/org/gvsig/installer/swing/impl/execution/panel/renderers/OsAndArchitectureCellRenderer.java
31 31
import javax.swing.JLabel;
32 32
import javax.swing.JTable;
33 33
import javax.swing.table.DefaultTableCellRenderer;
34
import org.apache.commons.lang3.StringUtils;
34 35

  
35 36
import org.gvsig.installer.lib.api.InstallerManager;
36 37
import org.gvsig.installer.swing.impl.execution.panel.model.PackagesTableModel.PackageOsAndArchitecture;
......
57 58
		JLabel check = new JLabel();
58 59
		PackageOsAndArchitecture osArch = (PackageOsAndArchitecture) value;
59 60

  
60
		if( InstallerManager.OS.ALL.equalsIgnoreCase(osArch.os) ) {
61
		if( InstallerManager.OS.ALL.equalsIgnoreCase(osArch.osfamily) ) {
61 62
			return check;
62 63
		}  
63 64
                
64
                String oslabel = osArch.os;
65
		if( InstallerManager.OS.LINUX.equalsIgnoreCase(osArch.os) ) {
65
                String oslabel = osArch.osfamily;
66
		if( InstallerManager.OS.LINUX.equalsIgnoreCase(osArch.osfamily) ) {
66 67
                    oslabel = "Linux";
67
		} else if( InstallerManager.OS.WINDOWS.equalsIgnoreCase(osArch.os) ) {
68
                    if( !StringUtils.isEmpty(osArch.osname) ) {
69
                        oslabel = oslabel + " " + osArch.osname;
70
                        if( !StringUtils.isEmpty(osArch.osversion) ) {
71
                            oslabel = oslabel + " " + osArch.osversion;
72
                        }
73
                    }
74
		} else if( InstallerManager.OS.WINDOWS.equalsIgnoreCase(osArch.osfamily) ) {
68 75
                    oslabel = "Windows";
69 76
		}
70 77
                
......
79 86
                }
80 87

  
81 88
                try {
82
			resource = this.getClass().getResource("/images/platform_14x14_"+osArch.os+"_"+osArch.arch+".png");
89
                    String s;
90
                    if( StringUtils.isEmpty(osArch.osname) ) {
91
                        s = "/images/platform_14x14_"+osArch.osfamily+"_"+osArch.arch+".png";
92
                    } else {
93
                        s = "/images/platform_14x14_"+osArch.osfamily+"_"+osArch.osname+"_"+osArch.arch+".png";
94
                    }
95
			resource = this.getClass().getResource(s);
83 96
		} catch( Exception ex) {
84 97
			resource = null;
85 98
		}
trunk/org.gvsig.desktop/org.gvsig.desktop.library/org.gvsig.installer/org.gvsig.installer.swing/org.gvsig.installer.swing.impl/src/main/java/org/gvsig/installer/swing/impl/execution/panel/model/PackagesTableModel.java
40 40
import java.util.Set;
41 41

  
42 42
import javax.swing.table.AbstractTableModel;
43
import org.apache.commons.lang3.StringUtils;
43 44

  
44 45
import org.gvsig.installer.lib.api.InstallerLocator;
45 46
import org.gvsig.installer.lib.api.InstallerManager;
......
67 68
	}
68 69

  
69 70
	public class PackageOsAndArchitecture {
70
		public String os;
71
		public String osfamily;
72
		public String osname;
73
                public String osversion;
71 74
		public String arch;
75
                
76
                public String getOperatingSystemId() {
77
                    if( StringUtils.isEmpty(osname)) {
78
                        return osfamily;
79
                    }
80
                    return osfamily + "-" + osname;
81
                }
72 82
	}
73 83
	
74 84
//	
......
125 135
	}
126 136

  
127 137
	private boolean canSetAsDefault(List<String> defaultIDs, PackageInfo pkg) {
128
    	String system_os = installerManager.getOperatingSystem();
138
    	String system_osfamily = installerManager.getOperatingSystemFamily();
139
        String system_arch = installerManager.getArchitecture();
129 140
    	String pkg_os = pkg.getOperatingSystem(); 
130 141
    	String pkg_arch = pkg.getArchitecture();
131 142
        if (defaultIDs != null) {
132 143
            for (int j = 0; j < defaultIDs.size(); j++) {
133 144
            	String code = defaultIDs.get(j);
134 145
                if (pkg.matchID(code)) {
135
                    if (pkg_os.equals(system_os) || pkg_os.equals(PackageManager.OS.ALL)) {
136
                    	// De momento solo marcamos paquetes de arquitectura x86, 32bits
137
                		if( PackageManager.ARCH.ALL.equalsIgnoreCase(pkg_arch) ) {
138
                			return true;
139
                		} else if( PackageManager.ARCH.X86.equalsIgnoreCase(pkg_arch) ) {
140
                			return true;
141
                		}
146
                    if ( pkg.getOperatingSystemFamily().equals(system_osfamily) || pkg_os.equals(PackageManager.OS.ALL)) {
147
                        if( PackageManager.ARCH.ALL.equalsIgnoreCase(pkg_arch) ) {
148
                                return true;
149
                        } else if( system_arch.equalsIgnoreCase(pkg_arch) ) {
150
                                return true;
151
                        }
142 152
                    }
143 153
                }
144 154
            }
......
373 383
		PackageOsAndArchitecture oSArch = new PackageOsAndArchitecture();
374 384
		TablePackageInfo tableInfo = currentlyVisiblePackages[rowIndex];
375 385
		PackageInfo installerInfo = tableInfo.getPackageInfo();
376
		oSArch.os = installerInfo.getOperatingSystem();
386
		oSArch.osfamily = installerInfo.getOperatingSystemFamily();
387
		oSArch.osname = installerInfo.getOperatingSystemName();
388
		oSArch.osversion = installerInfo.getOperatingSystemVersion();
377 389
		oSArch.arch = installerInfo.getArchitecture();
378 390
		return oSArch;
379 391
	}

Also available in: Unified diff