Skip to main content
summaryrefslogtreecommitdiffstats
blob: 54e0dd7f4ba088efb179fbbd345a2204b61ccc36 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
/*******************************************************************************
 *  Copyright (c) 2010 IBM Corporation and others.
 *  All rights reserved. This program and the accompanying materials
 *  are made available under the terms of the Eclipse Public License v1.0
 *  which accompanies this distribution, and is available at
 *  http://www.eclipse.org/legal/epl-v10.html
 * 
 *  Contributors:
 *     IBM Corporation - initial API and implementation
 *******************************************************************************/
package org.eclipse.equinox.p2.cudf.tools;

import java.io.File;
import java.util.*;
import org.eclipse.equinox.p2.cudf.Log;
import org.eclipse.equinox.p2.cudf.Parser;
import org.eclipse.equinox.p2.cudf.metadata.InstallableUnit;
import org.eclipse.equinox.p2.cudf.solver.ProfileChangeRequest;

//Print on standard output the set of installed packages from the stanza
public class ExtractInstalled {
	public static void main(String[] args) {
		ProfileChangeRequest pcr = new Parser().parse(new File(args[0]));
		List l = pcr.getInitialState().getList();
		Collections.sort(l);
		Log.println(("Solution contains:" + l.size()));
		for (Iterator iterator = l.iterator(); iterator.hasNext();) {
			InstallableUnit iu = (InstallableUnit) iterator.next();
			if (!iu.isInstalled())
				continue;
			System.out.println("package: " + iu.getId());
			System.out.println("version: " + iu.getVersion().getMajor());
			System.out.println("installed: true");
			System.out.println();
		}

	}
}

Back to the top