Skip to content

Commit

Permalink
Remove pack200 API
Browse files Browse the repository at this point in the history
It's tracked in #238 .
This is first iteration removing the already non-functional API.
  • Loading branch information
akurtakov committed Mar 30, 2023
1 parent 92caba8 commit 5e14005
Show file tree
Hide file tree
Showing 37 changed files with 406 additions and 995 deletions.
Expand Up @@ -9,7 +9,6 @@ Bundle-Localization: plugin
Export-Package: org.eclipse.equinox.internal.p2.artifact.processing;x-friends:="org.eclipse.equinox.p2.artifact.processors,org.eclipse.equinox.p2.artifact.optimizers",
org.eclipse.equinox.internal.p2.artifact.processors.checksum;x-friends:="org.eclipse.equinox.p2.publisher",
org.eclipse.equinox.internal.p2.artifact.processors.md5;x-internal:=true,
org.eclipse.equinox.internal.p2.artifact.processors.pack200;x-friends:="org.eclipse.equinox.p2.artifact.processors,org.eclipse.equinox.p2.artifact.optimizers",
org.eclipse.equinox.internal.p2.artifact.processors.pgp;x-friends:="org.eclipse.equinox.p2.engine,org.eclipse.equinox.p2.ui.sdk,org.eclipse.equinox.p2.ui",
org.eclipse.equinox.internal.p2.artifact.repository;
x-friends:="org.eclipse.equinox.p2.publisher,
Expand Down
6 changes: 0 additions & 6 deletions bundles/org.eclipse.equinox.p2.artifact.repository/plugin.xml
Expand Up @@ -6,12 +6,6 @@
<extension-point id="artifactComparators" name="Artifact Comparators" schema="schema/artifactComparators.exsd"/>
<extension-point id="artifactChecksums" name="Artifact Checksum support" schema="schema/artifactChecksums.exsd"/>

<extension
point="org.eclipse.equinox.p2.artifact.repository.processingSteps"
id="org.eclipse.equinox.p2.processing.Pack200Unpacker">
<step class="org.eclipse.equinox.internal.p2.artifact.processors.pack200.Pack200ProcessorStep"/>
</extension>

<extension id="XZedRepository" point="org.eclipse.equinox.p2.artifact.repository.artifactRepositories">
<filter suffix="artifacts.xml.xz"/>
<factory class="org.eclipse.equinox.internal.p2.artifact.repository.simple.XZedSimpleArtifactRepositoryFactory"/>
Expand Down

This file was deleted.

Expand Up @@ -19,20 +19,48 @@
*******************************************************************************/
package org.eclipse.equinox.internal.p2.artifact.repository.simple;

import java.io.*;
import java.io.BufferedOutputStream;
import java.io.File;
import java.io.FileInputStream;
import java.io.FileOutputStream;
import java.io.IOException;
import java.io.OutputStream;
import java.net.URI;
import java.net.URISyntaxException;
import java.util.*;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collection;
import java.util.Collections;
import java.util.HashMap;
import java.util.HashSet;
import java.util.Iterator;
import java.util.LinkedList;
import java.util.List;
import java.util.Map;
import java.util.Map.Entry;
import java.util.Set;
import java.util.jar.JarEntry;
import java.util.jar.JarOutputStream;
import org.eclipse.core.runtime.*;

import org.eclipse.core.runtime.IAdaptable;
import org.eclipse.core.runtime.IProgressMonitor;
import org.eclipse.core.runtime.IStatus;
import org.eclipse.core.runtime.MultiStatus;
import org.eclipse.core.runtime.NullProgressMonitor;
import org.eclipse.core.runtime.OperationCanceledException;
import org.eclipse.core.runtime.Path;
import org.eclipse.core.runtime.Status;
import org.eclipse.core.runtime.SubMonitor;
import org.eclipse.core.runtime.URIUtil;
import org.eclipse.core.runtime.jobs.Job;
import org.eclipse.equinox.internal.p2.artifact.processors.checksum.ChecksumUtilities;
import org.eclipse.equinox.internal.p2.artifact.processors.checksum.ChecksumVerifier;
import org.eclipse.equinox.internal.p2.artifact.processors.pgp.PGPSignatureVerifier;
import org.eclipse.equinox.internal.p2.artifact.repository.*;
import org.eclipse.equinox.internal.p2.artifact.repository.Activator;
import org.eclipse.equinox.internal.p2.artifact.repository.Messages;
import org.eclipse.equinox.internal.p2.artifact.repository.MirrorRequest;
import org.eclipse.equinox.internal.p2.artifact.repository.MirrorSelector;
import org.eclipse.equinox.internal.p2.artifact.repository.SignatureVerifier;
import org.eclipse.equinox.internal.p2.core.helpers.FileUtils;
import org.eclipse.equinox.internal.p2.core.helpers.LogHelper;
import org.eclipse.equinox.internal.p2.metadata.ArtifactKey;
Expand All @@ -41,17 +69,29 @@
import org.eclipse.equinox.internal.p2.repository.DownloadStatus;
import org.eclipse.equinox.internal.p2.repository.Transport;
import org.eclipse.equinox.internal.p2.repository.helpers.ChecksumHelper;
import org.eclipse.equinox.internal.provisional.p2.artifact.repository.processing.*;
import org.eclipse.equinox.internal.provisional.p2.artifact.repository.processing.ProcessingStep;
import org.eclipse.equinox.internal.provisional.p2.artifact.repository.processing.ProcessingStepHandler;
import org.eclipse.equinox.internal.provisional.p2.artifact.repository.processing.ZipVerifierStep;
import org.eclipse.equinox.internal.provisional.p2.repository.IStateful;
import org.eclipse.equinox.p2.core.IProvisioningAgent;
import org.eclipse.equinox.p2.core.ProvisionException;
import org.eclipse.equinox.p2.metadata.IArtifactKey;
import org.eclipse.equinox.p2.metadata.index.IIndex;
import org.eclipse.equinox.p2.metadata.index.IIndexProvider;
import org.eclipse.equinox.p2.query.*;
import org.eclipse.equinox.p2.repository.*;
import org.eclipse.equinox.p2.repository.artifact.*;
import org.eclipse.equinox.p2.repository.artifact.spi.*;
import org.eclipse.equinox.p2.query.IQuery;
import org.eclipse.equinox.p2.query.IQueryResult;
import org.eclipse.equinox.p2.query.IQueryable;
import org.eclipse.equinox.p2.repository.IRepository;
import org.eclipse.equinox.p2.repository.IRepositoryManager;
import org.eclipse.equinox.p2.repository.IRunnableWithProgress;
import org.eclipse.equinox.p2.repository.artifact.IArtifactDescriptor;
import org.eclipse.equinox.p2.repository.artifact.IArtifactRepository;
import org.eclipse.equinox.p2.repository.artifact.IArtifactRepositoryManager;
import org.eclipse.equinox.p2.repository.artifact.IArtifactRequest;
import org.eclipse.equinox.p2.repository.artifact.IFileArtifactRepository;
import org.eclipse.equinox.p2.repository.artifact.spi.AbstractArtifactRepository;
import org.eclipse.equinox.p2.repository.artifact.spi.ArtifactDescriptor;
import org.eclipse.equinox.p2.repository.artifact.spi.ProcessingStepDescriptor;
import org.eclipse.osgi.service.datalocation.Location;
import org.eclipse.osgi.util.NLS;

Expand Down Expand Up @@ -268,11 +308,6 @@ public void write(int b) throws IOException {
private static final String ARTIFACT_FOLDER = "artifact.folder"; //$NON-NLS-1$
private static final String ARTIFACT_UUID = "artifact.uuid"; //$NON-NLS-1$
static final private String BLOBSTORE = ".blobstore/"; //$NON-NLS-1$
static final private String[][] PACKED_MAPPING_RULES = {{"(& (classifier=osgi.bundle) (format=packed))", "${repoUrl}/plugins/${id}_${version}.jar.pack.gz"}, //$NON-NLS-1$//$NON-NLS-2$
{"(& (classifier=osgi.bundle))", "${repoUrl}/plugins/${id}_${version}.jar"}, //$NON-NLS-1$//$NON-NLS-2$
{"(& (classifier=binary))", "${repoUrl}/binary/${id}_${version}"}, //$NON-NLS-1$ //$NON-NLS-2$
{"(& (classifier=org.eclipse.update.feature) (format=packed))", "${repoUrl}/features/${id}_${version}.jar.pack.gz"}, //$NON-NLS-1$//$NON-NLS-2$
{"(& (classifier=org.eclipse.update.feature))", "${repoUrl}/features/${id}_${version}.jar"}}; //$NON-NLS-1$//$NON-NLS-2$

static final private String[][] DEFAULT_MAPPING_RULES = {{"(& (classifier=osgi.bundle))", "${repoUrl}/plugins/${id}_${version}.jar"}, //$NON-NLS-1$//$NON-NLS-2$
{"(& (classifier=binary))", "${repoUrl}/binary/${id}_${version}"}, //$NON-NLS-1$ //$NON-NLS-2$
Expand All @@ -292,8 +327,6 @@ public void write(int b) throws IOException {
private KeyIndex keyIndex;
private boolean snapshotNeeded = false;

static final private String PUBLISH_PACK_FILES_AS_SIBLINGS = "publishPackFilesAsSiblings"; //$NON-NLS-1$

private static final int DEFAULT_MAX_THREADS = 4;

protected String[][] mappingRules = DEFAULT_MAPPING_RULES;
Expand Down Expand Up @@ -391,19 +424,6 @@ public SimpleArtifactRepository(IProvisioningAgent agent, String repositoryName,
}

initializeAfterLoad(location, false); // Don't update the timestamp, it will be done during save
if (properties != null) {
if (properties.containsKey(PUBLISH_PACK_FILES_AS_SIBLINGS)) {
synchronized (this) {
String newValue = properties.get(PUBLISH_PACK_FILES_AS_SIBLINGS);
if (Boolean.TRUE.toString().equals(newValue)) {
mappingRules = PACKED_MAPPING_RULES;
} else {
mappingRules = DEFAULT_MAPPING_RULES;
}
initializeMapper();
}
}
}
save();
} finally {
if (lockAcquired)
Expand Down Expand Up @@ -447,11 +467,6 @@ private SimpleArtifactDescriptor createInternalDescriptor(IArtifactDescriptor de
if (isFolderBased(descriptor))
internal.setRepositoryProperty(ARTIFACT_FOLDER, Boolean.TRUE.toString());

//clear out the UUID if we aren't using the blobstore.
if (flatButPackedEnabled(descriptor) && internal.getProperty(ARTIFACT_UUID) != null) {
internal.setProperty(ARTIFACT_UUID, null);
}

if (descriptor instanceof SimpleArtifactDescriptor) {
Map<String, String> repoProperties = ((SimpleArtifactDescriptor) descriptor).getRepositoryProperties();
for (Map.Entry<String, String> entry : repoProperties.entrySet()) {
Expand Down Expand Up @@ -584,9 +599,6 @@ public synchronized boolean contains(IArtifactKey key) {
}

public synchronized URI createLocation(ArtifactDescriptor descriptor) {
if (flatButPackedEnabled(descriptor)) {
return getLocationForPackedButFlatArtifacts(descriptor);
}
// if the descriptor is canonical, clear out any UUID that might be set and use the Mapper
if (descriptor.getProcessingSteps().length == 0) {
descriptor.setProperty(ARTIFACT_UUID, null);
Expand Down Expand Up @@ -934,36 +946,12 @@ public synchronized Set<SimpleArtifactDescriptor> getDescriptors() {
return artifactDescriptors;
}

/**
* Typically non-canonical forms of the artifact are stored in the blob store.
* However, we support having the pack200 files alongside the canonical artifact
* for compatibility with the format used in optimized update sites. We call
* this arrangement "flat but packed".
*/
@SuppressWarnings("removal")
private boolean flatButPackedEnabled(IArtifactDescriptor descriptor) {
return Boolean.TRUE.toString().equals(getProperties().get(PUBLISH_PACK_FILES_AS_SIBLINGS)) && IArtifactDescriptor.FORMAT_PACKED.equals(descriptor.getProperty(IArtifactDescriptor.FORMAT));
}

/**
* @see #flatButPackedEnabled(IArtifactDescriptor)
*/
private URI getLocationForPackedButFlatArtifacts(IArtifactDescriptor descriptor) {
IArtifactKey key = descriptor.getArtifactKey();
return mapper.map(getLocation(), key.getClassifier(), key.getId(), key.getVersion().toString(),
descriptor.getProperty(IArtifactDescriptor.FORMAT), descriptor.getProperties());
}

public synchronized URI getLocation(IArtifactDescriptor descriptor) {
// if the artifact has a uuid then use it
String uuid = descriptor.getProperty(ARTIFACT_UUID);
if (uuid != null)
return blobStore.fileFor(bytesFromHexString(uuid));

if (flatButPackedEnabled(descriptor)) {
return getLocationForPackedButFlatArtifacts(descriptor);
}

try {
// if the artifact is just a reference then return the reference location
if (descriptor instanceof SimpleArtifactDescriptor) {
Expand Down Expand Up @@ -1387,16 +1375,6 @@ private String doSetProperty(String key, String newValue, IProgressMonitor monit
String oldValue = super.setProperty(key, newValue, new NullProgressMonitor());
if (oldValue == newValue || (oldValue != null && oldValue.equals(newValue)))
return oldValue;
if (PUBLISH_PACK_FILES_AS_SIBLINGS.equals(key)) {
synchronized (this) {
if (Boolean.TRUE.toString().equals(newValue)) {
mappingRules = PACKED_MAPPING_RULES;
} else {
mappingRules = DEFAULT_MAPPING_RULES;
}
initializeMapper();
}
}
if (save)
save();
return oldValue;
Expand Down

0 comments on commit 5e14005

Please sign in to comment.