//Make Root IU
String time = Long.toString(System.currentTimeMillis());
InstallableUnitDescription vmIU = new InstallableUnitDescription();
vmIU.setId("org.example.xenVM");
vmIU.setVersion(Version.createOSGi(1, 0, 0, time));
vmIU.setTouchpointType(PublisherHelper.TOUCHPOINT_NATIVE);
IProvidedCapability createSelfCapability = PublisherHelper.createSelfCapability(vmIU.getId(), vmIU.getVersion());
vmIU.setCapabilities(new IProvidedCapability[] {createSelfCapability});
InstallableUnitDescription xenRootIU = new InstallableUnitDescription();
xenRootIU.setId("org.example.xenRoot");
xenRootIU.setVersion(Version.createOSGi(1, 0, 0, time));
Map<String, String> touchpointData = new HashMap<String, String>(7);
touchpointData.put("collect", "collect();");
touchpointData.put("install",
"mkdir(path:${installFolder}/image);" +
"unzip(source:@artifact, target:${installFolder}/image, buildFile:${installFolder}/build.properties);" +
"mkdir(path:${installFolder}/mountpoint);" +
"mount(options:-o loop,targetDir:${installFolder}, mountpoint:mountpoint, targetFile:image/centos.5-3.x86.img, buildFile:${installFolder}/build.properties);" +
"mount(options:-t proc,targetDir:${installFolder}, mountpoint:mountpoint/proc, targetFile:proc, buildFile:${installFolder}/build.properties);" +
//"chrootExec(chroot:${installFolder}/mountpoint/, chrootExec:ls -l /);" +
"");
xenRootIU.setTouchpointType(PublisherHelper.TOUCHPOINT_NATIVE);
ITouchpointData tpd = MetadataFactory.createTouchpointData(touchpointData);
xenRootIU.addTouchpointData(tpd);
ArtifactKey xen_image = new ArtifactKey(PublisherHelper.BINARY_ARTIFACT_CLASSIFIER, filename, Version.create("1.0.0"));
xenRootIU.setArtifacts(new IArtifactKey[] {xen_image});
File f = new File(repofiles + filename);
IArtifactDescriptor ad = PublisherHelper.createArtifactDescriptor(xen_image, f);
publishArtifact(ad, f, publisherInfo);
createSelfCapability = PublisherHelper.createSelfCapability(xenRootIU.getId(), xenRootIU.getVersion());
xenRootIU.setCapabilities(new IProvidedCapability[] {createSelfCapability});
RequiredCapability vm = new RequiredCapability(PublisherHelper.IU_NAMESPACE, "org.example.xenVM", new VersionRange(Version.create("0.0.0"), true, Version.create("9.9.9"), true), "", false, false);
xenRootIU.setRequiredCapabilities(new IRequiredCapability[] {vm});
ITouchpointData vm_touchpoint = MetadataFactory.createTouchpointData(Collections.EMPTY_MAP);
xenRootIU.addTouchpointData(vm_touchpoint);
results.addIU(makeJVM(publisherInfo), IPublisherResult.NON_ROOT);
results.addIU(makeInstallYourApp(publisherInfo), IPublisherResult.NON_ROOT);
results.addIU(MetadataFactory.createInstallableUnit(vmIU), IPublisherResult.NON_ROOT);
results.addIU(MetadataFactory.createInstallableUnit(xenRootIU), IPublisherResult.ROOT);