aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorNeil Guzman2013-12-10 16:37:39 (EST)
committerAlexander Kurtakov2013-12-12 09:10:06 (EST)
commitb1ebdf9dc39e31110ebf07b75806ee35b401369c (patch)
tree6e9b98277a727055797638f45764dfcada868517
parentbfd6650197bcaabdd6ae7453a10b2912997588c2 (diff)
downloadorg.eclipse.linuxtools-b1ebdf9dc39e31110ebf07b75806ee35b401369c.zip
org.eclipse.linuxtools-b1ebdf9dc39e31110ebf07b75806ee35b401369c.tar.gz
org.eclipse.linuxtools-b1ebdf9dc39e31110ebf07b75806ee35b401369c.tar.bz2
RPM: createrepo "oldpackagedirs" preferencerefs/changes/24/19624/3
Added support for the "oldpackagedirs" command switch. Change-Id: I51e96c55651d34d7c1f20ed18bccec3c14026c1e Signed-off-by: Neil Guzman <nguzman@redhat.com> Reviewed-on: https://git.eclipse.org/r/19624 Reviewed-by: Alexander Kurtakov <akurtako@redhat.com> IP-Clean: Alexander Kurtakov <akurtako@redhat.com> Tested-by: Alexander Kurtakov <akurtako@redhat.com>
-rw-r--r--rpm/org.eclipse.linuxtools.rpm.createrepo/src/org/eclipse/linuxtools/internal/rpm/createrepo/CreaterepoCommandCreator.java27
-rw-r--r--rpm/org.eclipse.linuxtools.rpm.createrepo/src/org/eclipse/linuxtools/internal/rpm/createrepo/Messages.java6
-rw-r--r--rpm/org.eclipse.linuxtools.rpm.createrepo/src/org/eclipse/linuxtools/internal/rpm/createrepo/messages.properties4
-rw-r--r--rpm/org.eclipse.linuxtools.rpm.createrepo/src/org/eclipse/linuxtools/internal/rpm/createrepo/preference/CreaterepoDeltaPropertyPage.java25
-rw-r--r--rpm/org.eclipse.linuxtools.rpm.createrepo/src/org/eclipse/linuxtools/internal/rpm/createrepo/preference/CreaterepoPathEditor.java64
-rw-r--r--rpm/org.eclipse.linuxtools.rpm.createrepo/src/org/eclipse/linuxtools/internal/rpm/createrepo/preference/CreaterepoPreferenceInitializer.java1
-rw-r--r--rpm/org.eclipse.linuxtools.rpm.createrepo/src/org/eclipse/linuxtools/rpm/createrepo/CreaterepoPreferenceConstants.java2
7 files changed, 126 insertions, 3 deletions
diff --git a/rpm/org.eclipse.linuxtools.rpm.createrepo/src/org/eclipse/linuxtools/internal/rpm/createrepo/CreaterepoCommandCreator.java b/rpm/org.eclipse.linuxtools.rpm.createrepo/src/org/eclipse/linuxtools/internal/rpm/createrepo/CreaterepoCommandCreator.java
index be393f8..71a29df 100644
--- a/rpm/org.eclipse.linuxtools.rpm.createrepo/src/org/eclipse/linuxtools/internal/rpm/createrepo/CreaterepoCommandCreator.java
+++ b/rpm/org.eclipse.linuxtools.rpm.createrepo/src/org/eclipse/linuxtools/internal/rpm/createrepo/CreaterepoCommandCreator.java
@@ -45,7 +45,12 @@ public class CreaterepoCommandCreator {
CreaterepoPreferenceConstants.PREF_REVISION,
CreaterepoPreferenceConstants.PREF_DISTRO_TAG,
CreaterepoPreferenceConstants.PREF_CONTENT_TAG,
- CreaterepoPreferenceConstants.PREF_REPO_TAG
+ CreaterepoPreferenceConstants.PREF_REPO_TAG,
+ };
+
+ private static final String[] STRING_DELTA_COMMANDS = {
+ // deltas
+ CreaterepoPreferenceConstants.PREF_OLD_PACKAGE_DIRS,
};
// commands that determine used state by int passed with it
@@ -150,6 +155,18 @@ public class CreaterepoCommandCreator {
}
}
}
+ if (delta) {
+ for (String arg : STRING_DELTA_COMMANDS) {
+ String value = projectPreferences.get(arg, preferenceStore.getDefaultString(arg));
+ arg = ICreaterepoConstants.DASH.concat(arg);
+ for (String dirs : value.split(ICreaterepoConstants.DELIMITER)) {
+ if (!dirs.isEmpty()) {
+ commands.add(arg);
+ commands.add(dirs);
+ }
+ }
+ }
+ }
return commands;
}
@@ -164,10 +181,14 @@ public class CreaterepoCommandCreator {
List<String> commands = new ArrayList<String>();
if (delta) {
for (String arg : INT_DELTA_COMMANDS) {
- int value = projectPreferences.getInt(arg, preferenceStore.getDefaultInt(arg));
+ long value = projectPreferences.getInt(arg, preferenceStore.getDefaultInt(arg));
+ if (arg.equals(CreaterepoPreferenceConstants.PREF_MAX_DELTA_SIZE)) {
+ // 1048576 = bytes in a megabyte
+ value *= 1048576;
+ }
arg = ICreaterepoConstants.DASH.concat(arg);
commands.add(arg);
- commands.add(Integer.toString(value));
+ commands.add(Long.toString(value));
}
} else {
for (String arg : INT_COMMANDS) {
diff --git a/rpm/org.eclipse.linuxtools.rpm.createrepo/src/org/eclipse/linuxtools/internal/rpm/createrepo/Messages.java b/rpm/org.eclipse.linuxtools.rpm.createrepo/src/org/eclipse/linuxtools/internal/rpm/createrepo/Messages.java
index 54097b3..cbe4ed1 100644
--- a/rpm/org.eclipse.linuxtools.rpm.createrepo/src/org/eclipse/linuxtools/internal/rpm/createrepo/Messages.java
+++ b/rpm/org.eclipse.linuxtools.rpm.createrepo/src/org/eclipse/linuxtools/internal/rpm/createrepo/Messages.java
@@ -175,6 +175,8 @@ public final class Messages {
/****/
public static String CreaterepoDeltaPropertyPage_groupLabel;
/****/
+ public static String CreaterepoDeltaPropertyPage_groupDirectoryLabel;
+ /****/
public static String CreaterepoDeltaPropertyPage_booleanEnableLabel;
/****/
public static String CreaterepoDeltaPropertyPage_maxNumberOfDeltas;
@@ -182,6 +184,10 @@ public final class Messages {
public static String CreaterepoDeltaPropertyPage_maxDeltaSize;
/****/
public static String CreaterepoDeltaPropertyPage_errorInvalidText;
+ /****/
+ public static String CreaterepoDeltaPropertyPage_directoryDescription;
+ /****/
+ public static String CreaterepoDeltaPropertyPage_directoryDialogLabel;
static {
// initialize resource bundle
diff --git a/rpm/org.eclipse.linuxtools.rpm.createrepo/src/org/eclipse/linuxtools/internal/rpm/createrepo/messages.properties b/rpm/org.eclipse.linuxtools.rpm.createrepo/src/org/eclipse/linuxtools/internal/rpm/createrepo/messages.properties
index 7d2a451..68480d5 100644
--- a/rpm/org.eclipse.linuxtools.rpm.createrepo/src/org/eclipse/linuxtools/internal/rpm/createrepo/messages.properties
+++ b/rpm/org.eclipse.linuxtools.rpm.createrepo/src/org/eclipse/linuxtools/internal/rpm/createrepo/messages.properties
@@ -109,7 +109,11 @@ CreaterepoGeneralPropertyPage_workspaceSettings=Configure Workspace Settings...
# CreaterepoDeltaPropertyPage
CreaterepoDeltaPropertyPage_description=Configure delta execution properties of createrepo.
CreaterepoDeltaPropertyPage_groupLabel=Delta options
+CreaterepoDeltaPropertyPage_groupDirectoryLabel=Directories
CreaterepoDeltaPropertyPage_booleanEnableLabel=Generate deltarpms and the delta metadata
CreaterepoDeltaPropertyPage_maxNumberOfDeltas=The number of older versions to make deltas against:
CreaterepoDeltaPropertyPage_maxDeltaSize=Max size of an rpm to run deltarpm against (MByte):
CreaterepoDeltaPropertyPage_errorInvalidText=Field must be an integer that is greater than 0 and lesser than {0}
+CreaterepoDeltaPropertyPage_directoryDescription=Paths to look for older packages to delta against. Can be \
+ specified multiple times.
+CreaterepoDeltaPropertyPage_directoryDialogLabel=Select a directory to delta against.
diff --git a/rpm/org.eclipse.linuxtools.rpm.createrepo/src/org/eclipse/linuxtools/internal/rpm/createrepo/preference/CreaterepoDeltaPropertyPage.java b/rpm/org.eclipse.linuxtools.rpm.createrepo/src/org/eclipse/linuxtools/internal/rpm/createrepo/preference/CreaterepoDeltaPropertyPage.java
index e88e1c5..83e9a2a 100644
--- a/rpm/org.eclipse.linuxtools.rpm.createrepo/src/org/eclipse/linuxtools/internal/rpm/createrepo/preference/CreaterepoDeltaPropertyPage.java
+++ b/rpm/org.eclipse.linuxtools.rpm.createrepo/src/org/eclipse/linuxtools/internal/rpm/createrepo/preference/CreaterepoDeltaPropertyPage.java
@@ -32,6 +32,9 @@ public class CreaterepoDeltaPropertyPage extends CreaterepoPropertyPage {
private IntegerFieldEditor ifeNumDeltas;
private IntegerFieldEditor ifeMaxSizeDeltas;
+ private Group dirGroup;
+ private CreaterepoPathEditor peDirectories;
+
/**
* Default Constructor. Sets the description of the property page.
*/
@@ -88,6 +91,25 @@ public class CreaterepoDeltaPropertyPage extends CreaterepoPropertyPage {
layout = (GridLayout) optionsGroup.getLayout();
layout.marginWidth = 5;
layout.marginHeight = 5;
+
+ // the group for directories to package against
+ dirGroup = new Group(composite, SWT.SHADOW_ETCHED_IN);
+ layout = new GridLayout(2, false);
+ dirGroup.setLayout(layout);
+ dirGroup.setText(Messages.CreaterepoDeltaPropertyPage_groupDirectoryLabel);
+ GridDataFactory.fillDefaults().align(SWT.FILL, SWT.CENTER)
+ .grab(true, false).applyTo(dirGroup);
+
+ peDirectories = new CreaterepoPathEditor(CreaterepoPreferenceConstants.PREF_OLD_PACKAGE_DIRS,
+ Messages.CreaterepoDeltaPropertyPage_directoryDescription,
+ Messages.CreaterepoDeltaPropertyPage_directoryDialogLabel, dirGroup);
+ peDirectories.setPreferenceStore(preferenceStore);
+ peDirectories.load();
+ peDirectories.setPropertyChangeListener(this);
+
+ layout = (GridLayout) dirGroup.getLayout();
+ layout.marginWidth = 5;
+ layout.marginHeight = 5;
toggleEnabled();
return composite;
}
@@ -102,6 +124,7 @@ public class CreaterepoDeltaPropertyPage extends CreaterepoPropertyPage {
bfeEnableDeltas.loadDefault();
ifeNumDeltas.loadDefault();
ifeMaxSizeDeltas.loadDefault();
+ peDirectories.loadDefault();
}
/*
@@ -116,6 +139,7 @@ public class CreaterepoDeltaPropertyPage extends CreaterepoPropertyPage {
ifeNumDeltas.getIntValue());
getPreferenceStore().setValue(CreaterepoPreferenceConstants.PREF_MAX_DELTA_SIZE,
ifeMaxSizeDeltas.getIntValue());
+ peDirectories.store();
return true;
}
@@ -145,6 +169,7 @@ public class CreaterepoDeltaPropertyPage extends CreaterepoPropertyPage {
boolean enabled = bfeEnableDeltas.getBooleanValue();
ifeNumDeltas.setEnabled(enabled, optionsGroup);
ifeMaxSizeDeltas.setEnabled(enabled, optionsGroup);
+ peDirectories.setEnabled(enabled, dirGroup);
}
}
diff --git a/rpm/org.eclipse.linuxtools.rpm.createrepo/src/org/eclipse/linuxtools/internal/rpm/createrepo/preference/CreaterepoPathEditor.java b/rpm/org.eclipse.linuxtools.rpm.createrepo/src/org/eclipse/linuxtools/internal/rpm/createrepo/preference/CreaterepoPathEditor.java
new file mode 100644
index 0000000..a87226c
--- /dev/null
+++ b/rpm/org.eclipse.linuxtools.rpm.createrepo/src/org/eclipse/linuxtools/internal/rpm/createrepo/preference/CreaterepoPathEditor.java
@@ -0,0 +1,64 @@
+/*******************************************************************************
+ * Copyright (c) 2013 Red Hat Inc. 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:
+ * Neil Guzman - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.linuxtools.internal.rpm.createrepo.preference;
+
+import org.eclipse.jface.preference.PathEditor;
+import org.eclipse.linuxtools.rpm.createrepo.ICreaterepoConstants;
+import org.eclipse.swt.widgets.Composite;
+
+/**
+ * Custom PathEditor to parse and store preferences the way
+ * createrepo plugin does.
+ */
+public class CreaterepoPathEditor extends PathEditor {
+
+ /**
+ * Default Constructor.
+ *
+ * @param name The name of the preference to save in.
+ * @param labelText The description label.
+ * @param dirChooserLabelText The label shown at the bottom of the directory dialog.
+ * @param parent The parent composite this PathEditor belongs to.
+ */
+ public CreaterepoPathEditor(String name, String labelText, String dirChooserLabelText, Composite parent) {
+ super(name, labelText, dirChooserLabelText, parent);
+ }
+
+ /*
+ * (non-Javadoc)
+ * @see org.eclipse.jface.preference.PathEditor#createList(java.lang.String[])
+ */
+ @Override
+ protected String createList(String[] items) {
+ String preferenceValue = ICreaterepoConstants.EMPTY_STRING;
+ if (items.length > 0) {
+ for (String str : items) {
+ preferenceValue = preferenceValue.concat(str + ICreaterepoConstants.DELIMITER);
+ }
+ // remove hanging delimiter
+ preferenceValue = preferenceValue.substring(0, preferenceValue.length()-1);
+ }
+ return preferenceValue;
+ }
+
+ /*
+ * (non-Javadoc)
+ * @see org.eclipse.jface.preference.PathEditor#parseString(java.lang.String)
+ */
+ @Override
+ protected String[] parseString(String stringList) {
+ if (!stringList.isEmpty()) {
+ return stringList.split(ICreaterepoConstants.DELIMITER);
+ }
+ return new String[]{};
+ }
+
+}
diff --git a/rpm/org.eclipse.linuxtools.rpm.createrepo/src/org/eclipse/linuxtools/internal/rpm/createrepo/preference/CreaterepoPreferenceInitializer.java b/rpm/org.eclipse.linuxtools.rpm.createrepo/src/org/eclipse/linuxtools/internal/rpm/createrepo/preference/CreaterepoPreferenceInitializer.java
index 09ce1fb..a58fbd0 100644
--- a/rpm/org.eclipse.linuxtools.rpm.createrepo/src/org/eclipse/linuxtools/internal/rpm/createrepo/preference/CreaterepoPreferenceInitializer.java
+++ b/rpm/org.eclipse.linuxtools.rpm.createrepo/src/org/eclipse/linuxtools/internal/rpm/createrepo/preference/CreaterepoPreferenceInitializer.java
@@ -62,6 +62,7 @@ public class CreaterepoPreferenceInitializer extends
prefStore.setDefault(CreaterepoPreferenceConstants.PREF_DELTA_ENABLE, CreaterepoPreferenceConstants.DEFAULT_DELTA_ENABLE);
prefStore.setDefault(CreaterepoPreferenceConstants.PREF_NUM_DELTAS, CreaterepoPreferenceConstants.DEFAULT_NUM_DELTAS);
prefStore.setDefault(CreaterepoPreferenceConstants.PREF_MAX_DELTA_SIZE, CreaterepoPreferenceConstants.DEFAULT_MAX_DELTA_SIZE);
+ prefStore.setDefault(CreaterepoPreferenceConstants.PREF_OLD_PACKAGE_DIRS, CreaterepoPreferenceConstants.DEFAULT_OLD_PACKAGE_DIR_LIST);
}
}
diff --git a/rpm/org.eclipse.linuxtools.rpm.createrepo/src/org/eclipse/linuxtools/rpm/createrepo/CreaterepoPreferenceConstants.java b/rpm/org.eclipse.linuxtools.rpm.createrepo/src/org/eclipse/linuxtools/rpm/createrepo/CreaterepoPreferenceConstants.java
index 59f5f0e..10041b1 100644
--- a/rpm/org.eclipse.linuxtools.rpm.createrepo/src/org/eclipse/linuxtools/rpm/createrepo/CreaterepoPreferenceConstants.java
+++ b/rpm/org.eclipse.linuxtools.rpm.createrepo/src/org/eclipse/linuxtools/rpm/createrepo/CreaterepoPreferenceConstants.java
@@ -42,6 +42,7 @@ public final class CreaterepoPreferenceConstants {
/****/ public static final String PREF_DELTA_ENABLE = "deltas"; //$NON-NLS-1$
/****/ public static final String PREF_NUM_DELTAS = "num-deltas"; //$NON-NLS-1$
/****/ public static final String PREF_MAX_DELTA_SIZE = "max-delta-rpm-size"; //$NON-NLS-1$
+ /****/ public static final String PREF_OLD_PACKAGE_DIRS = "oldpackagedirs"; //$NON-NLS-1$
// Defaults
/****/ public static final String PREF_VERBOSE = "verbose"; //$NON-NLS-1$
@@ -73,4 +74,5 @@ public final class CreaterepoPreferenceConstants {
/****/ public static final boolean DEFAULT_DELTA_ENABLE = false;
/****/ public static final int DEFAULT_NUM_DELTAS = 1;
/****/ public static final int DEFAULT_MAX_DELTA_SIZE = 10;
+ /****/ public static final String DEFAULT_OLD_PACKAGE_DIR_LIST = ICreaterepoConstants.EMPTY_STRING;
}