Index: build.properties
===================================================================
RCS file: /home/tools/org.eclipse.cdt-contrib/org.eclipse.cdt.rpm/org.eclipse.cdt.rpm.core/build.properties,v
retrieving revision 1.1
diff -u -r1.1 build.properties
--- build.properties 13 Oct 2004 02:31:16 -0000 1.1
+++ build.properties 18 May 2005 20:42:40 -0000
@@ -9,4 +9,13 @@
source.RPMCore.jar = src/
bin.includes = plugin.xml,\
*.jar,\
- RPMCore.jar
+ RPMCore.jar,\
+ about.html
+src.includes = .classpath,\
+ .project,\
+ .template,\
+ ChangeLog,\
+ about.html,\
+ build.properties,\
+ plugin.xml,\
+ src/
Index: plugin.xml
===================================================================
RCS file: /home/tools/org.eclipse.cdt-contrib/org.eclipse.cdt.rpm/org.eclipse.cdt.rpm.core/plugin.xml,v
retrieving revision 1.2
diff -u -r1.2 plugin.xml
--- plugin.xml 11 Nov 2004 15:00:14 -0000 1.2
+++ plugin.xml 18 May 2005 20:42:40 -0000
@@ -12,9 +12,6 @@
-
-
-
@@ -25,5 +22,13 @@
+
+
+
+
+
Index: src/org/eclipse/cdt/rpm/core/LinuxShellCmds.java
===================================================================
RCS file: src/org/eclipse/cdt/rpm/core/LinuxShellCmds.java
diff -N src/org/eclipse/cdt/rpm/core/LinuxShellCmds.java
--- src/org/eclipse/cdt/rpm/core/LinuxShellCmds.java 8 Nov 2004 21:30:12 -0000 1.2
+++ /dev/null 1 Jan 1970 00:00:00 -0000
@@ -1,387 +0,0 @@
-/*
- * (c) 2004 Red Hat, Inc.
- *
- * This program is open source software licensed under the
- * Eclipse Public License ver. 1
- */
-
-package org.eclipse.cdt.rpm.core;
-
-import org.eclipse.core.runtime.CoreException;
-import org.eclipse.core.runtime.IStatus;
-import org.eclipse.core.runtime.Status;
-
-import java.io.*;
-
-/**
- *This class is used to interface to Linux commands
- */
-public class LinuxShellCmds {
- private static final boolean debug = false;
- private static final String file_sep = System.getProperty("file.separator"); //$NON-NLS-1$
- private static final String line_sep = System.getProperty("line.separator"); //$NON-NLS-1$
- private static final String Error = Messages.getString("RPMCore.Error_1"); //$NON-NLS-1$
- /**
- * Method createLinuxShellScript.
- * This method is necessary because of problems trying to execute the
- * "rpmbuild -bb....." command directly from the executeRPMbuild method.
- * The command did not work the same as it did from the command line.
- * It appears that the java command line parser does not work very well
- * on very sophisticated or lengthy command lines. Hence, we build a shell
- * script to eliminate the java command line parser and all works fine.
- * @param shellString - string containing the command to be executed as a shell script
- * @param rpmbuild_logname - boolean variable which determines whether or
- * not the output of the shell script to be created should be placed in the
- * rpmbuild logfile; true means do not output to the logfile, false means output to the logfile
- * @param rpm_shell is the name of the shell to create
- * @return boolean - return true if successful, else throw CoreException
- */
- /******************************************************************************/
- public static boolean createLinuxShellScript(String shellString,
- String rpmbuild_logname, String rpm_shell)
- throws CoreException {
- if (debug) {
- System.out.println("--createLinuxShellScript: " + shellString); //$NON-NLS-1$
- }
-
- // if there was a parenthesis at the beginning of the script, put one at the end
- String tail;
- String first = shellString.substring(0, 1);
-
- if (first.equals("(")) { //$NON-NLS-1$
- tail = " 2>&1 )" + line_sep; //$NON-NLS-1$
- } else {
- tail = " 2>&1" + line_sep; //$NON-NLS-1$
- }
-
- String is = "#!/bin/sh" + line_sep + shellString + " >> " + rpmbuild_logname + //$NON-NLS-1$ //$NON-NLS-2$
- tail;
-
- byte[] buf = is.getBytes();
-
- /* Read the input stream and try to create the shell script to be used by
- * the rpmbuild process */
- try {
- BufferedOutputStream os = new BufferedOutputStream(new FileOutputStream(
- rpm_shell));
-
- for (int i = 0; i < buf.length; i++) {
- os.write(buf[i]);
- }
-
- os.close();
- } catch (Exception e) {
- String throw_message = Messages.getString(
- "RPMCore.Problem_creating_a_shell_script_--__342") + //$NON-NLS-1$
- rpm_shell +
- Messages.getString(
- "RPMCore._nThere_may_be_a_problem_in_the_M/makefile._343"); //$NON-NLS-1$
- IStatus error = new Status(IStatus.ERROR, Error, 1, throw_message,
- null);
- throw new CoreException(error);
- }
-
- /* Change the file attributes so it is exectable, there is no method that I can
- * find in java that performs this function */
- String usr_chmod_cmd = RPMCorePlugin.getDefault().getPreferenceStore().getString("IRpmConstants.CHMOD_CMD"); //$NON_NLS-1$
- String chmodcommand = usr_chmod_cmd + " 744 " + rpm_shell; //$NON-NLS-1$
-
- try {
- executeLinuxCommand(chmodcommand, 0);
- } catch (CoreException e) {
- String throw_message = Messages.getString(
- "RPMCore.Problem_running_this_command___346") + //$NON-NLS-1$
- chmodcommand +
- Messages.getString("RPMCore._nCheck_permissions._347"); //$NON-NLS-1$
- IStatus error = new Status(IStatus.ERROR, Error, 1, throw_message,
- null);
- throw new CoreException(error);
- }
-
- return true;
- }
-
- /**
- * Method executeLinuxCommand.
- * This method executes a Linux command passed to it from other methods. It executes
- * the command, reads the output from the command and passes back a status. This method
- * is used when several output lines is expected from a command. If one line or less is
- * expected and the developer wants the output of the command, use the getInfo method.
- * @param linux_command - a string containing a Linux command
- * @param status - what the successful status value from the command should be (normally 0)
- * @return - throws a CoreException if an error is encountered
- */
- /****************************************************************************/
- public static void executeLinuxCommand(String linux_command, int status)
- throws CoreException {
- if (debug) {
- System.out.println("--executeLinuxCommand: " + //$NON-NLS-1$
- linux_command);
- }
-
- Runtime r = Runtime.getRuntime();
- Process p = null;
- int result;
- String line = ""; //$NON-NLS-1$
- String line2 = ""; //$NON-NLS-1$
- // prepare buffers for process output and error streams
- StringBuffer err = new StringBuffer();
- StringBuffer out = new StringBuffer();
-
- try {
- p = r.exec(linux_command);
- // create thread for reading inputStream (process' stdout)
- StreamReaderThread outThread = new StreamReaderThread(p
- .getInputStream(), out);
- // create thread for reading errorStream (process' stderr)
- StreamReaderThread errThread = new StreamReaderThread(p
- .getErrorStream(), err);
- // start both threads
- outThread.start();
- errThread.start();
-
- //wait for process to end
- result = p.waitFor();
- //finish reading whatever's left in the buffers
- outThread.join();
- errThread.join();
-
- if (result != 0) {
- if (debug) {
- System.out.println(Messages.getString("LinuxShellCmds.1") //$NON-NLS-1$
- + result);
- System.out.println(Messages.getString("LinuxShellCmds.2") + out.toString()); //$NON-NLS-1$
- System.out.println(Messages.getString("LinuxShellCmds.3") + err.toString()); //$NON-NLS-1$
- }
- } else {
- if (debug) {
- System.out.println(Messages.getString("LinuxShellCmds.4")); //$NON-NLS-1$
- System.out.println(Messages.getString("LinuxShellCmds.5") + out.toString()); //$NON-NLS-1$
- System.out.println(Messages.getString("LinuxShellCmds.6") + err.toString()); //$NON-NLS-1$
- }
- }
- } catch (Exception e) {
- String throw_message = Messages
- .getString("RPMCore.Error_executing__97") + linux_command + //$NON-NLS-1$
- Messages.getString("LinuxShellCmds.7") + err.toString(); //$NON-NLS-1$
- IStatus error = new Status(IStatus.ERROR, Error, 1, throw_message,
- null);
- throw new CoreException(error);
- }
- }
-
- /**
- * Method checkCompression. This method takes a spec file path and parses it
- * to see what compression will be required to untar the source file. We
- * assume that the compression will either be gzip or bzip2 since those are
- * the only 2 currently used for RPM's that we have run into.
- *
- * @param path
- * to the spec file to be searched
- * @return return the tar file suffix of either ".gz" or ".bz2" if
- * successful, return "" if not.
- */
- public static String checkCompression(String path_to_specfile) throws CoreException {
- if (debug) {
- System.out.println("--parseSpecfile: " + path_to_specfile); //$NON-NLS-1$
- }
-
- boolean found_source_line = false;
-
- try {
- FileReader sp_file = new FileReader(path_to_specfile);
- StreamTokenizer st = new StreamTokenizer(sp_file);
-
- // Make sure numbers, colons and percent signs are considered valid
- st.wordChars('a','z');
- st.wordChars('A','Z');
- st.wordChars(':', ':');
- st.wordChars('0', '9');
- st.wordChars('%', '%');
- st.wordChars('{', '}');
- st.wordChars('-', '-');
- st.wordChars('/', '/');
- st.wordChars('=','=');
- st.wordChars('.','.');
- st.wordChars('_','_');
- st.eolIsSignificant(true);
-
- String new_word;
- boolean check_ifs = false;
- int if_ctr = 0;
- int token = st.nextToken();
- while (token != StreamTokenizer.TT_EOF) {
- token = st.nextToken();
-
- switch (token) {
- case StreamTokenizer.TT_EOL:
- break;
- case StreamTokenizer.TT_WORD:
- new_word = st.sval;
- // System.out.println("---- " + new_word + "\n line no = " + st.lineno());
-
- if (found_source_line) {
- if (new_word.endsWith(".gz")) { //$NON-NLS-1$
- return ".gz"; //$NON-NLS-1$
- } else {
- return ".bz2"; //$NON-NLS-1$
- }
- }
-
- // Record where the last line of the form "Sourcex:" is
- if (new_word.startsWith("Source") & //$NON-NLS-1$
- new_word.endsWith(":")) { //$NON-NLS-1$
- found_source_line = true;
- break;
- }
-
- default:
- break;
- }
- }
-
- sp_file.close();
- } catch (IOException e) {
- String throw_message = Messages.getString(
- "RPMCore.Error_parsing_the_spec_file_in_the_project_--_157") + //$NON-NLS-1$
- path_to_specfile;
- IStatus error = new Status(IStatus.ERROR, Error, 1, throw_message,
- null);
- throw new CoreException(error);
- }
- // If we got here, we could not determine the compression for the tar file
- return ""; //$NON-NLS-1$
- }
- /**
- * Method linuxCopy
- * This method takes two strings containing paths and uses the Linux cp
- * command to copy from the first string path to the second string path. The
- * reason we sue this instead of native Java techniques is that Java copies
- * do not preserve all of the file attributes, particularly the executable bit and
- * also does not preserve the modification date/time without special handling.
- * In the future when this is taken care of, we will replace this method.
- * @author Red Hat, Inc.
- *@param from_path is a string containing the from path
- *@param to_path is a string containing the to path
- *@return if successful, throw CoreException if not
- */
- public static void linuxCopy(String from_path, String to_path, String rpmbuild_logname,
- String rpm_shell) throws CoreException {
- // If we are doing a directory to directory copy, make sure the to_path
- // exists and is a directory
- File f = new File(to_path);
- File f1 = new File(from_path);
- if (f1.isDirectory()) {
- if (!f.exists()) {
- if (!f.mkdir()) {
- String throw_message = Messages.getString("LinuxShellCmds.Error_attempting_to_create___1") + to_path; //$NON-NLS-1$
- IStatus error = new Status(IStatus.ERROR, Error, 1, throw_message, null);
- throw new CoreException(error);
- }
- }
- if (f.exists() & !f.isDirectory()) {
- String throw_message = Messages.getString("LinuxShellCmds.Cannot_copy_a_directory___2") + from_path + //$NON-NLS-1$
- Messages.getString("LinuxShellCmds._to_a_file___3") + to_path; //$NON-NLS-1$
- IStatus error = new Status(IStatus.ERROR, Error, 1, throw_message, null);
- throw new CoreException(error);
- }
- }
- String usr_cp_cmd = RPMCorePlugin.getDefault().getPreferenceStore().getString("IRpmConstants.CP_CMD"); //$NON_NLS-1$
- String cp_cmd = "(cd " + from_path + line_sep + usr_cp_cmd + " -rp . " + to_path; //$NON-NLS-1$ //$NON-NLS-2$
- try {
- createLinuxShellScript(cp_cmd, rpmbuild_logname, rpm_shell);
- executeLinuxCommand(rpm_shell,0);
- } catch (CoreException e) {
- String throw_message = Messages.getString("LinuxShellCmds.Error_attempting_to_copy_source_from___4") + from_path + //$NON-NLS-1$
- Messages.getString("LinuxShellCmds._to__5") + to_path; //$NON-NLS-1$
- IStatus error = new Status(IStatus.ERROR, Error, 1, throw_message, null);
- throw new CoreException(error);
- }
- }
-
- /**
- * Method getInfo.
- * This method takes a Linux/shell command, executes it and passes the output line back
- * as the information string.
- * @param sh_command - a string containing the command to execute
- * @return String - the output of the executed command, maybe null if there is an error
- */
- /******************************************************************************/
- public static String getInfo(String sh_command) {
- if (debug) {
- System.out.println("getInfo: " + sh_command); //$NON-NLS-1$
- }
-
- Runtime r = Runtime.getRuntime();
- Process p = null;
- int result;
- String line = ""; //$NON-NLS-1$
- String line2 = ""; //$NON-NLS-1$
- int line_ctr = 0;
- // prepare buffers for process output and error streams
- StringBuffer err=new StringBuffer();
- StringBuffer out=new StringBuffer();
-
- try {
- p = r.exec(sh_command);
- //create thread for reading inputStream (process' stdout)
- StreamReaderThread outThread=new StreamReaderThread(p.getInputStream(),out);
- //create thread for reading errorStream (process' stderr)
- StreamReaderThread errThread=new StreamReaderThread(p.getErrorStream(),err);
- //start both threads
- outThread.start();
- errThread.start();
-
- // Set up and capture the stdout messages from the Linux/shell command
-
- //wait for process to end
- result=p.waitFor();
- //finish reading whatever's left in the buffers
- outThread.join();
- errThread.join();
-
- if (result!=0)
- {
- if (debug)
- {
- System.out.println(Messages.getString("LinuxShellCmds.9")+result); //$NON-NLS-1$
- System.out.println(Messages.getString("LinuxShellCmds.10")+out.toString()); //$NON-NLS-1$
- System.out.println(Messages.getString("LinuxShellCmds.11")+err.toString()); //$NON-NLS-1$
- }
- return err.toString();
- }
- else
- {
- if (debug)
- {
- System.out.println(Messages.getString("LinuxShellCmds.12")); //$NON-NLS-1$
- System.out.println(Messages.getString("LinuxShellCmds.13")+out.toString()); //$NON-NLS-1$
- System.out.println(Messages.getString("LinuxShellCmds.14")+err.toString()); //$NON-NLS-1$
- }
- return out.toString();
- }
- }
- catch (Exception e)
- {
- System.out.println(Messages.getString("LinuxShellCmds.15")); //$NON-NLS-1$
- e.printStackTrace();
- }
-
- return line2;
- }
-
- /**
- * Method checkForConfigure checks a project for the presence of a
- * "configure" script that creates various parts of a project including
- * "Makefile".
- * @return true if "configure" was found, false if not
- */
-
- public static boolean checkForConfigure(String proj_path) {
-// Check to see if there is a "configure" script for use when creating a spec file
- File f = new File(proj_path + file_sep + "configure"); //$NON-NLS-1$
-
- return f.exists();
- }
-
-}
Index: src/org/eclipse/cdt/rpm/core/Messages.java
===================================================================
RCS file: src/org/eclipse/cdt/rpm/core/Messages.java
diff -N src/org/eclipse/cdt/rpm/core/Messages.java
--- src/org/eclipse/cdt/rpm/core/Messages.java 13 Oct 2004 02:31:16 -0000 1.1
+++ /dev/null 1 Jan 1970 00:00:00 -0000
@@ -1,30 +0,0 @@
-/*
- * (c) 2004 Red Hat, Inc.
- *
- * This program is open source software licensed under the
- * Eclipse Public License ver. 1
- */
-
-package org.eclipse.cdt.rpm.core;
-
-import java.util.MissingResourceException;
-import java.util.ResourceBundle;
-
-public class Messages {
-
- private static final String BUNDLE_NAME = "org.eclipse.cdt.rpm.core.rpm_strings";
-
-
- private static final ResourceBundle RESOURCE_BUNDLE = ResourceBundle.getBundle(BUNDLE_NAME);
-
- private Messages() {
- }
-
- public static String getString(String key) {
- try {
- return RESOURCE_BUNDLE.getString(key);
- } catch (MissingResourceException e) {
- return '!' + key + '!';
- }
- }
-}
Index: src/org/eclipse/cdt/rpm/core/RPMCore.java
===================================================================
RCS file: src/org/eclipse/cdt/rpm/core/RPMCore.java
diff -N src/org/eclipse/cdt/rpm/core/RPMCore.java
--- src/org/eclipse/cdt/rpm/core/RPMCore.java 14 Dec 2004 20:17:36 -0000 1.3
+++ /dev/null 1 Jan 1970 00:00:00 -0000
@@ -1,2037 +0,0 @@
-/*
- * (c) 2004 Red Hat, Inc.
- *
- * This program is open source software licensed under the
- * Eclipse Public License ver. 1
- */
-
-package org.eclipse.cdt.rpm.core;
-
-import org.eclipse.core.runtime.CoreException;
-import org.eclipse.core.runtime.IStatus;
-import org.eclipse.core.runtime.Status;
-
-import java.io.*;
-import java.util.ArrayList;
-import java.text.SimpleDateFormat;
-import java.util.Date;
-
-/**
- *This class contains the core methods for manipulating rpm's. Most othe classes
- *extend this one to get to these classes.
- */
-public class RPMCore {
- // When debug is set to true, lots of debug statements are printed.
- private static final boolean debug = false;
- protected static final String file_sep = System.getProperty("file.separator"); //$NON-NLS-1$
- protected static final String line_sep = System.getProperty("line.separator"); //$NON-NLS-1$
- protected static final String Error = Messages.getString("RPMCore.Error_1"); //$NON-NLS-1$
-
- protected String spec_file_prefix = RPMCorePlugin.getDefault().getPreferenceStore()
- .getString("IRpmConstants.SPEC_FILE_PREFIX"); //$NON-NLS-1$
- protected String srpm_info_name = RPMCorePlugin.getDefault().getPreferenceStore()
- .getString("IRpmConstants.SRPM_INFO_FILE"); //$NON-NLS-1$
- protected String wksp_path = RPMCorePlugin.getDefault().getPreferenceStore()
- .getString("IRpmConstants.RPM_WORK_AREA"); //$NON-NLS-1$
- protected String rpmrc = RPMCorePlugin.getDefault().getPreferenceStore()
- .getString("IRpmConstants.RPM_RESOURCE_FILE"); //$NON-NLS-1$
- protected String rpm_macros = RPMCorePlugin.getDefault().getPreferenceStore()
- .getString("IRpmConstants.RPM_MACROS_FILE"); //$NON-NLS-1$
- protected String rpm_shell = RPMCorePlugin.getDefault().getPreferenceStore()
- .getString("IRpmConstants.RPM_SHELL_SCRIPT"); //$NON-NLS-1$
- protected String rpmbuild_logname = RPMCorePlugin.getDefault().getPreferenceStore()
- .getString("IRpmConstants.RPM_LOG_NAME"); //$NON-NLS-1$
- protected String usr_make_cmd = RPMCorePlugin.getDefault().getPreferenceStore()
- .getString("IRpmConstants.MAKE_CMD"); //$NON-NLS-1$
- protected String usr_rpm_cmd = RPMCorePlugin.getDefault().getPreferenceStore()
- .getString("IRpmConstants.RPM_CMD"); //$NON-NLS-1$
- protected String usr_rpmbuild_cmd = RPMCorePlugin.getDefault().getPreferenceStore()
- .getString("IRpmConstants.RPMBUILD_CMD"); //$NON-NLS-1$
- protected String usr_cp_cmd = RPMCorePlugin.getDefault().getPreferenceStore()
- .getString("IRpmConstants.CP_CMD"); //$NON-NLS-1$
- protected String usr_chmod_cmd = RPMCorePlugin.getDefault().getPreferenceStore()
- .getString("IRpmConstants.CHMOD_CMD"); //$NON-NLS-1$
- protected String usr_diff_cmd = RPMCorePlugin.getDefault().getPreferenceStore()
- .getString("IRpmConstants.DIFF_CMD"); //$NON-NLS-1$
-
- protected String proj_path;
- protected String path_to_rpm;
- protected String rpmdirs_path;
- protected String rpm_version = "1"; //$NON-NLS-1$
- protected String rpm_release = "0"; //$NON-NLS-1$
- protected String rpm_name;
- protected String path_to_specfile;
- protected String path_to_newspecfile;
- protected String spec_file_name;
- protected String proj_dir;
- protected String srpm_full_name;
- protected String ui_rel_no = ""; //$NON-NLS-1$
- protected String ui_ver_no = ""; //$NON-NLS-1$
- protected boolean chk_sum_diff = false;
-
- private boolean preserve = true;
- private boolean generate_patch;
- private String rpm_spec;
- private String checksum_string;
- private String diff_old_dir;
- private String diff_new_dir;
- private String copied_proj_path;
- private String orig_srpm_path;
- private String srpm_abbr_name;
-
-
- /**
- * Constructor #1 for RPMCore - used for the RPM import to Eclipse Project sequence
- * also used for exporting an Eclipse C/C++ project to Source RPM
- * This method is called when a source rpm is to be imported into an Eclipse C/C++ project
- * or exported from an Eclipse project. It extends LinuxShellCmds and is extended by
- * RPMExportCore and SRPMExport.
- * @param c_proj_path - is a string containing the full path to the workspace project of the form
- * /home/xxxx/workspace/cproject
- * @param c_path_to_rpm - is a string containing the path to the user-selected RPM
- * (only used if this is an import of a source RPM)
- * @return - throws a CoreException if it cannot get to the .sprminfo file if this was a
- * previously imported source RPM
- */
- public RPMCore(String c_proj_path, String c_path_to_rpm)
- throws CoreException {
- if (debug) {
- System.out.println(
- "RPMCore constructor**************************************************"); //$NON-NLS-1$
- }
-
- proj_path = c_proj_path;
- path_to_rpm = c_path_to_rpm;
-
- String user_wksp = wksp_path + file_sep + System.getProperty("user.name"); //$NON-NLS-1$ //$NON-NLS-2$
- rpmdirs_path = user_wksp + file_sep + "rpm_workarea"; //$NON-NLS-1$
- String srpm_abbr_name = ""; //$NON-NLS-1$
-
- int j = proj_path.lastIndexOf(file_sep); //$NON-NLS-1$
- if ( j == -1) {
- proj_dir = proj_path;
- } else {
- proj_dir = proj_path.substring( j + 1);
- }
- if (!firstSRPM(proj_path)) {
- long cksum;
- ArrayList srpminfo = new ArrayList();
- try {
- srpminfo = getSRPMexportinfo(proj_path);
- checkSrpmExists((String) srpminfo.get(0));
- cksum = generateChecksum(proj_path, 0);
- } catch (CoreException e) {
- String throw_message = e.getMessage();
- IStatus error = new Status(IStatus.ERROR, Error, 1, throw_message, null);
- throw new CoreException(error);
- }
-
- int i = spec_file_name.lastIndexOf(file_sep);
- if (i == -1) {
- path_to_specfile = proj_path + file_sep + spec_file_name;
- } else {
- path_to_specfile = spec_file_name;
- }
- if (Long.parseLong(checksum_string) != cksum) {
- chk_sum_diff = true;
- }
-
- if (!(path_to_rpm.equals(""))) { //$NON-NLS-1$
- j = path_to_rpm.lastIndexOf(file_sep);
- if (j != -1) {
- srpm_full_name = path_to_rpm.substring(j+1);
- }
- j = srpm_full_name.lastIndexOf(".src.rpm"); //$NON-NLS-1$
-
- // Strip off the ".src.rpm" part of the name to get the abbreviated name
- if (j!= -1) {
- srpm_abbr_name = srpm_full_name.substring(0, j);
- }
- // If this is the first time this project has been exported into RPM
- // format, use the Eclipse project directory name as the RPM name
- }
- } else {
- rpm_name = proj_dir;
- srpm_abbr_name = proj_dir;
- srpm_full_name = proj_dir;
- spec_file_name = proj_dir + ".spec"; //$NON-NLS-1$
- }
-
- rpm_spec = rpmdirs_path + file_sep + "SPECS" + file_sep + srpm_abbr_name + ".spec"; //$NON-NLS-1$ //$NON-NLS-2$
- rpm_shell = rpmdirs_path + file_sep + rpm_shell;
- rpm_macros = rpmdirs_path + file_sep + getRpm_macros();
- rpmrc = rpmdirs_path + file_sep + getRpmrc();
- }
-
- /**
- * Constructor #2 for RPMCore - used by the GUI to access information stored in the
- * project's .srpminfo file and the latest source RPM built from this project. The GUI
- * displays the RPM version/release info on the screen for the user to change if desired.
- * This method is called when a source rpm is to be imported into an Eclipse C/C++
- * project. It is called to instantiate this class so the GUI can call getSRPMinfo
- */
- public RPMCore() throws CoreException {
-
- }
-
- /**
- * Method checkMakefileForClean.
- * This method is used to check the M/makefile in the C/C++ project for a
- * particular string.
- * @param path - contains a string to the Makefile to be searched
- * @param srch_string - contains a string to search the Makefile for
- * @return boolean - return true if successful, false if not
- * @exception - throw a CoreException if we have problems reading the
- * Makefile
- */
- /******************************************************************************/
- public boolean checkMakefileForString(String path, String srch_string)
- throws CoreException {
- if (debug) {
- System.out.println("checkForMakefileClean: " + path); //$NON-NLS-1$
- }
- boolean makefile_found = false;
- boolean found_string = false;
- String sh_command;
- String line;
- String[] makefile_path = { "", "" }; //$NON-NLS-1$ //$NON-NLS-2$
-
- if (!path.equals("")) { //$NON-NLS-1$
- makefile_path[0] = path + file_sep + "Makefile"; //$NON-NLS-1$
- makefile_path[1] = path + file_sep + "makefile"; //$NON-NLS-1$
- }
-
- for (int i = 0; i < makefile_path.length; i++) {
- File f = new File(makefile_path[i]);
-
- // Now check for whether or not there are 'install:'/'clean:' sections in the Makefile/makefile
- if (f.exists()) {
- makefile_found = true;
-
- try {
- FileReader makefile = new FileReader(makefile_path[i]);
- StreamTokenizer st = new StreamTokenizer(makefile);
- st.wordChars(':', ':');
- st.wordChars('-', '-');
-
- int token = st.nextToken();
-
- while ((token != StreamTokenizer.TT_EOF) &
- (!found_string)) {
- token = st.nextToken();
-
- switch (token) {
- case StreamTokenizer.TT_WORD:
-
- String word = st.sval;
-
- if (word.equals(srch_string) | word.equals(srch_string + ":")) { //$NON-NLS-1$
- return true;
- }
-
- break;
-
- default:
- break;
- }
- }
-
- makefile.close();
- } catch (IOException e) {
- String throw_message = Messages.getString(
- "RPMCore.I/O_error_processing/reading_the_M/makefile__183") + //$NON-NLS-1$
- e;
- IStatus error = new Status(IStatus.ERROR, Error, 1,
- throw_message, null);
- throw new CoreException(error);
- }
- }
- }
- return false;
- }
- /**
- * Method checkForMakefile.
- * This method is used to check the C/C++ project to be made into an RPM has a
- * Makefile/makefile present in its top directory
- * @param path - contains a string with the path of where to check for the existence
- * of a Makefile or makefile (this last check for "makefile" may be removed at a later
- * date if deemed unnecessary)
- * @return boolean - return true if successful, throw CoreException if not
- */
- /******************************************************************************/
- public boolean checkForMakefile(String path) throws CoreException {
- if (debug) {
- System.out.println("checkMakefile: " + path); //$NON-NLS-1$
- }
- boolean makefile_found = false;
- String sh_command;
- String line;
- String[] makefile_path = { "", "" }; //$NON-NLS-1$ //$NON-NLS-2$
-
- if (!path.equals("")) { //$NON-NLS-1$
- makefile_path[0] = path + file_sep + "Makefile"; //$NON-NLS-1$
- makefile_path[1] = path + file_sep + "makefile"; //$NON-NLS-1$
- }
-
- for (int i = 0; i < makefile_path.length; i++) {
- File f = new File(makefile_path[i]);
-
- // Now check for whether or not there are 'install:'/'clean:' sections in the Makefile/makefile
- if (f.exists()) {
- return true;
- }
- }
- // If no M/makefile is found, throw an error.
- String throw_message = Messages.getString(
- "RPMCore.Failed_to_find_a_M/makefile_in_the_project.___THIS_IS_REQUIRED_!_!_!_185"); //$NON-NLS-1$
- IStatus error = new Status(IStatus.ERROR, Error, 1, throw_message,
- null);
- throw new CoreException(error);
-
- }
-
- /**
- * Method copyDirTree.
- * This method copies one directory tree to another.
- * @param dir - A file that points to the directory where the traversing
- * is to begin
- * @return - false if unsuccessful, true if successful
- * ***NOTE*** this method is not currectly used, we use the
- * Linux "cp" command right now since Java provides not way
- * to preserve file permissions, particularly the "execute" bit...
- * when this deficiency is corrected, we will replace those "cp"
- * commands with calls to this method
- */
- private boolean copyDirTree(String dirin, String dirout) {
- if (debug) {
- System.out.println("--copyDirTree" + //$NON-NLS-1$
- line_sep + "----dirin = " + dirin + //$NON-NLS-1$
- line_sep + "----dirout = " + dirout); //$NON-NLS-1$
- }
-
- int file_ctr;
- String infile;
- String outfile;
- File newdirin = new File(dirin);
- File newdirout = new File(dirout);
-
- if (newdirin.isDirectory()) {
- // If the directory to output to already exists,
- // skip trying to create it
- if (!newdirout.exists()) {
- if (!newdirout.mkdir()) {
- return false;
- }
- }
-
- // Get a list of all of the files in this directory
- String[] children = newdirin.list();
-
- // Walk the tree and copy files
- for (int i = 0; i < children.length; i++) {
- infile = dirin + file_sep + children[i];
- outfile = dirout + file_sep + children[i];
-
- File newfilein = new File(infile);
- File newfileout = new File(outfile);
- long modifiedTime = newfilein.lastModified();
-
- if (newfilein.isDirectory()) {
- copyDirTree(infile, outfile);
- } else {
- try {
- copyFile(infile, outfile);
- } catch (Exception e) {
- return false;
- }
-
- if (!newfileout.setLastModified(modifiedTime)) {
- return false;
- }
- }
- }
- }
-
- return true;
- }
-
- /**
- * Method getConfigOpts.
- * This method takes a spec file path and parses it to see if there are any options
- * that need to be passed to the "configure" script when conmfiguring an RPM.
- * @param path_to_specfile - contains a string with a path to the spec file to be
- * searched to see if the "configure" command has any options to be applied
- * @return a string containing the options to pass to configure if any were found
- */
- public String getConfigOpts(String path_to_specfile) throws CoreException {
- if (debug) {
- System.out.println("--getConfigOpts: " + path_to_specfile); //$NON-NLS-1$
- }
-
-
- boolean found_config = false;
- int lines = 0;
- int config_line = 0;
- String config_opts = ""; //$NON-NLS-1$
-
- try {
- FileReader sp_file = new FileReader(path_to_specfile);
- StreamTokenizer st = new StreamTokenizer(sp_file);
-// st.resetSyntax();
-
- // Make sure numbers, colons and percent signs are considered valid
- st.wordChars('a','z');
- st.wordChars('A','Z');
- st.wordChars(':', ':');
- st.wordChars('0', '9');
- st.wordChars('%', '%');
- st.wordChars('{', '}');
- st.wordChars('-', '-');
- st.wordChars('/','/');
- st.wordChars('=','=');
- st.wordChars('.','.');
- st.wordChars('_','_');
- st.eolIsSignificant(true);
-
- String new_word;
- int if_ctr = 0;
- int token = st.nextToken();
- while (token != StreamTokenizer.TT_EOF) {
- token = st.nextToken();
-
- switch (token) {
- case StreamTokenizer.TT_EOL:
- lines++;
- break;
- case StreamTokenizer.TT_WORD:
- new_word = st.sval;
- // System.out.println("---- " + new_word + line_sep + " line no = " + st.lineno());
-
- // If '%configure' was found, gather the options if there were any
- if (found_config & config_line == lines) {
- config_opts = config_opts + " --" + new_word; //$NON-NLS-1$
- break;
- }
- if (found_config & !(config_line == lines)) {
- found_config = false;
- break;
- }
-
- // See if there is a %configure section
- if (new_word.equals("%configure")) { //$NON-NLS-1$
- found_config = true;
- config_line = lines;
-
- break;
- }
- }
- }
-
- sp_file.close();
- } catch (IOException e) {
- String throw_message = Messages.getString(
- "RPMCore.Error_parsing_the_spec_file_in_the_project_--_157") + //$NON-NLS-1$
- path_to_specfile;
- IStatus error = new Status(IStatus.ERROR, Error, 1, throw_message,
- null);
- throw new CoreException(error);
- }
-
- return config_opts;
- }
-
-
- /**
- * Method executeProjConfigure.
- * See if there is a "configure" script to be run to set up the project with a properly
- * configured Makefile and if there is, run it.
- * @param orig_proj_path - contans a string with a path to the directory in which
- * to run the "configure" script
- * @return boolean - return true if successful, throw CoreException if not
- */
- /***************************************************************************/
- public void executeProjConfigure(String orig_proj_path) throws CoreException {
- if (debug) {
- System.out.println("executeProjConfigure"); //$NON-NLS-1$
- }
- String config_opts;
-
- // Check to see if there is indeed a "configure" script
- File config = new File(orig_proj_path + file_sep + "configure"); //$NON-NLS-1$
-
- if (config.exists()) {
-
- // We need to parse the spec file to see if there are any "configure" options
- File spec_path = new File(rpmdirs_path + file_sep + "SPECS" + file_sep); //$NON-NLS-1$
- String[] children = spec_path.list();
- String path_to_specfile = rpmdirs_path + file_sep + "SPECS" + file_sep + children[0]; //$NON-NLS-1$
- try {
- config_opts = getConfigOpts(path_to_specfile);
- } catch (Exception e) {
- String throw_message = Messages.getString("RPMCore.Error_parsing_spec_file_at__33") + path_to_specfile; //$NON-NLS-1$
- IStatus error = new Status(IStatus.ERROR, Error, 1,
- throw_message, null);
- throw new CoreException(error);
- }
- String conf_cmd = "cd " + orig_proj_path + line_sep + "." + file_sep + "configure " + //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
- config_opts + " >> " + rpmdirs_path + file_sep + "configure.log"; //$NON-NLS-1$ //$NON-NLS-2$
- try {
- LinuxShellCmds.createLinuxShellScript(conf_cmd, rpmbuild_logname, rpm_shell);
- LinuxShellCmds.executeLinuxCommand(rpm_shell, 0);
- } catch (Exception e) {
- String throw_message = e.getMessage();
- IStatus error = new Status(IStatus.ERROR, Error, 1,
- throw_message, null);
- throw new CoreException(error);
- }
- }
- }
- /**
- * Method getSRPMexportinfo.
- * This method is called to get the information from the .srpminfo
- * file in the Eclipse project where information about an imported
- * source RPM is kept.
- * @param String containing the path to the Eclipse project
- * @return ArrayList - contains the following if successful:
- * ArrayList[0] = previous source RPM used to create this Eclipse project
- * ArrayList[1] = version number
- * ArrayList[2] = release number
- * ArrayList[3] = rpm name
- * ArrayList[4] = date when SRPM was imported/exported
- * ArrayList[5] = spec file name
- * ArrayList[6] = String with the checksum
- *
- * or throws CoreException if unsuccessful
- */
- public ArrayList getSRPMexportinfo(String project_path)
- throws CoreException {
- if (debug) {
- System.out.println("getSRPMexportinfo -- " + project_path); //$NON-NLS-1$
- }
-
- String path_to_srpm_info_file = project_path + srpm_info_name; //$NON-NLS-1$
- String Error = Messages.getString("RPMCore.Error_1"); //$NON-NLS-1$
- boolean found_chksum = false;
-
- // See if the srpminfo file exists
- ArrayList srpm_info = new ArrayList();
-
- // Read the first line of the file in, it is a warning about not deleting the file
- try {
- BufferedReader in = new BufferedReader(new FileReader(
- path_to_srpm_info_file));
- String str;
-
- while ((str = in.readLine()) != null) {
- if (str.lastIndexOf(".src.rpm") != -1) { //$NON-NLS-1$
-
- path_to_rpm = project_path + file_sep + str; //$NON-NLS-1$
- srpm_info.add(0, path_to_rpm);
-
- // save the source rpm path for the installRPMsource() method
- // path_to_rpm = path;
- // Now get the version/release number from the RPM
- rpm_version = LinuxShellCmds.getInfo(
- usr_rpm_cmd + " --qf %{VERSION} -qp " + //$NON-NLS-1$
- path_to_rpm);
- rpm_release = LinuxShellCmds.getInfo(
- usr_rpm_cmd + " --qf %{RELEASE} -qp " + //$NON-NLS-1$
- path_to_rpm);
- rpm_name = LinuxShellCmds.getInfo(usr_rpm_cmd + " --qf %{NAME} -qp " + //$NON-NLS-1$
- path_to_rpm);
- srpm_info.add(1, rpm_version);
- srpm_info.add(2, rpm_release);
- srpm_info.add(3, rpm_name);
- }
-
- if (str.startsWith("Date:")) { //$NON-NLS-1$
-
- String date_temp = str.substring(6, str.length());
- srpm_info.add(4, date_temp);
- }
-
- if (str.startsWith("Specfile:")) { //$NON-NLS-1$
-
- spec_file_name = str.substring(10, str.length());
- srpm_info.add(5, spec_file_name);
- }
-
- if (str.startsWith("Checksum:")) { //$NON-NLS-1$
-
- checksum_string = str.substring(10, str.length());
- srpm_info.add(6, checksum_string);
- found_chksum = true;
- }
- }
-
- in.close();
- } catch (IOException e) {
- String throw_message = Messages.getString(
- "RPMCore.Error_getting_info_from__93") + //$NON-NLS-1$
- path_to_srpm_info_file;
- IStatus error = new Status(IStatus.ERROR, Error, 1, throw_message,
- null);
- throw new CoreException(error);
- }
-
- if (!found_chksum) {
- srpm_info.add(6, "-1"); //$NON-NLS-1$
- }
-
- return srpm_info;
- }
-
- /**
- * Method checkSrpmExists takes a path to the source rpm to be
- * checked and verifies that there is indeed still there.
- * If there is not, we cannot successfully export this project.
- * @param project - a string containing the path to the selected project
- * @throws CoreException if it does not exist
- */
- public void checkSrpmExists(String srpm_path) throws CoreException {
-
- File f = new File(srpm_path);
-// Make sure the source rpm is still where it was
-
- if (!f.exists()) {
- String throw_message = Messages.getString(
- "RPMCore.There_is_no_longer_a_source_RPM_at__86") + //$NON-NLS-1$
- srpm_path +
- Messages.getString("RPMCore._nThis_RPM_*must*_be_restored_before_exporting_can_occur._1"); //$NON-NLS-1$
- IStatus error = new Status(IStatus.ERROR, Messages.getString("RPMCore.Error_1"), 2, //$NON-NLS-1$
- throw_message, null);
- throw new CoreException(error);
- }
- return;
- }
-
- /**
- * Method copyFile with two file input strings
- * Takes two input strings containing pathnames, one input file path and
- * one output file path and does a copy
- * @param inName - a string containing a path to the input file
- * @param outName - a string containing a path to the output file
- * @return - throws any of three exceptions if an error occurs
- */
- public void copyFile(String inName, String outName)
- throws FileNotFoundException, IOException, CoreException {
- // if (debug) {
- // System.out.println("--copyFile - inName: " + inName + //$NON-NLS-1$
- // line _sep + " outName: " + outName); //$NON-NLS-1$
- // }
- BufferedInputStream is = new BufferedInputStream(new FileInputStream(
- inName));
- BufferedOutputStream os = new BufferedOutputStream(new FileOutputStream(
- outName));
-
- try {
- copyFile(is, os, true);
- } catch (Exception e) {
- String throw_message = e.getMessage();
- IStatus error = new Status(IStatus.ERROR, Messages.getString("RPMCore.Error_1"), 1, //$NON-NLS-1$
- throw_message, null);
- throw new CoreException(error);
- }
- }
-
- /**
- * Method copyFile which copies a file from an input stream to an output stream
- * @param is - a file InputStream
- * @param os - a file OutputStream
- * @param close - a boolean to tell if the OutputStream should be closed upon exit
- * @return if successful, throw Exception if not
- */
- public void copyFile(InputStream is, OutputStream os, boolean close)
- throws IOException, CoreException {
- int b;
-
- try {
- while ((b = is.read()) != -1) {
- os.write(b);
- }
-
- is.close();
-
- if (close) {
- os.close();
- }
- } catch (Exception e) {
- String throw_message = Messages.getString(
- "RPMCore.Error_trying_to_write_to__8") + os; //$NON-NLS-1$
- IStatus error = new Status(IStatus.ERROR, Messages.getString("RPMCore.Error_1"), 1, //$NON-NLS-1$
- throw_message, null);
- throw new CoreException(error);
- }
- }
-
- /**
- * Method getNameVerRel interrogates a spec file for the name, version and release
- * of the RPM
- * @param path_to_specfile contains a string pointing to the specfile to interrogate
- * @return if successful, throw Exception if not
- */
-
- public ArrayList getNameVerRel(String path_to_specfile)
- throws CoreException, FileNotFoundException {
- if (debug) {
- System.out.println("getNameVerRel"); //$NON-NLS-1$
- }
-
- ArrayList rpm_info = new ArrayList();
- ArrayList define_info = new ArrayList();
-
- // initialize version/release numbers to 0 in case none are found in the spec file
- rpm_info.add(0, "0"); //$NON-NLS-1$
- rpm_info.add(1, "0"); //$NON-NLS-1$
- rpm_info.add(2, " "); //$NON-NLS-1$
-
- boolean found_version = false;
- boolean found_release = false;
- boolean found_name = false;
- boolean found_ver_token = false;
- boolean found_rel_token = false;
- boolean found_name_token = false;
- boolean found_define = false;
- boolean found_define_name = false;
- int define_ctr = 0;
-
- File f = new File(path_to_specfile);
-
- if (!f.exists()) {
- String throw_message = "" + //$NON-NLS-1$
- path_to_specfile;
- IStatus error = new Status(IStatus.ERROR, Messages.getString("RPMCore.Error_1"), 1, //$NON-NLS-1$
- throw_message, null);
- throw new CoreException(error);
- }
-
- try {
- FileReader sp_file = new FileReader(path_to_specfile);
- StreamTokenizer st = new StreamTokenizer(sp_file);
-
- // Make sure numbers, colons and periods are considered valid characters
- st.resetSyntax();
- st.wordChars(':', ':');
- st.wordChars('0', '9');
- st.wordChars('.', '.');
- st.wordChars('A', 'z');
- st.wordChars('%','%');
- st.wordChars('{','{');
- st.wordChars('}','}');
-
- int token = 0;
- String new_word;
-outer:
- while (token != StreamTokenizer.TT_EOF) {
- token = st.nextToken();
-
- switch (token) {
- case StreamTokenizer.TT_WORD:
- new_word = st.sval;
-
- if (found_define) {
- found_define = false;
- define_info.add(define_ctr,new_word);
- define_ctr++;
- found_define_name = true;
- break;
- }
-
- if (found_define_name) {
- found_define_name = false;
- define_info.add(define_ctr,new_word);
- define_ctr++;
- break;
- }
-
- if (found_version & !found_ver_token) {
- found_ver_token = true;
- if (new_word.startsWith("%")) { //$NON-NLS-1$
- try {
- rpm_info.set(0,parseDefine(new_word, define_info));
- } catch (Exception e) {
- String throw_message = Messages.getString("RPMCore.Error_using_parseDefine_to_get_the_version_no._41") + //$NON-NLS-1$
- Messages.getString("RPMCore._from_the_spec_file_at___42") + path_to_specfile; //$NON-NLS-1$
- IStatus error = new Status(IStatus.ERROR, Messages.getString("RPMCore.Error_1"), 1, //$NON-NLS-1$
- throw_message, null);
- throw new CoreException(error);
- }
- } else {
- rpm_info.set(0, new_word);
- }
-
- // System.out.println("Found version = " + new_word);
- if (found_name_token & found_ver_token &
- found_rel_token) {
- break outer;
- }
-
- break;
- }
-
- if (found_release & !found_rel_token) {
- found_rel_token = true;
- if (new_word.startsWith("%")) { //$NON-NLS-1$
- try {
- rpm_info.set(1,parseDefine(new_word, define_info));
- } catch (Exception e) {
- String throw_message = Messages.getString("RPMCore.Error_using_parseDefine_to_get_the_release_no._44") + //$NON-NLS-1$
- Messages.getString("RPMCore._from_the_spec_file_at___45") + path_to_specfile; //$NON-NLS-1$
- IStatus error = new Status(IStatus.ERROR, Messages.getString("RPMCore.Error_1"), 1, //$NON-NLS-1$
- throw_message, null);
- throw new CoreException(error);
- }
- break;
- } else {
- rpm_info.set(1, new_word);
- }
-
- // System.out.println("Found release = " + new_word);
- if (found_name_token & found_ver_token &
- found_rel_token) {
- break outer;
- }
-
- break;
- }
-
- if (found_name & !found_name_token) {
- found_name_token = true;
- rpm_info.set(2, new_word);
-
- // System.out.println("Found name = " + new_word);
- if (found_name_token & found_ver_token &
- found_rel_token) {
- break outer;
- }
-
- break;
- }
-
- // See if this is a "Version:" tag
- if (new_word.equals("Version:")) { //$NON-NLS-1$
- found_version = true;
- break;
- }
-
- // See if this is a "Release:" tag
- if (new_word.equals("Release:")) { //$NON-NLS-1$
- found_release = true;
- break;
- }
-
- // See if this is a "Name:" tag
- if (new_word.equals("Name:")) { //$NON-NLS-1$
- found_name = true;
- break;
- }
-
- // See if this a "%define" statement
- // the version and release can sometimes be in a define stmt
- if (new_word.equals("%define")) { //$NON-NLS-1$
- found_define = true;
- break;
- }
-
- default:
- break;
- }
- }
- } catch (IOException e) {
- String throw_message = Messages.getString(
- "RPMCore.Error_parsing_the_spec_file_at") + //$NON-NLS-1$
- path_to_specfile;
- IStatus error = new Status(IStatus.ERROR, Messages.getString("RPMCore.Error_1"), 1, //$NON-NLS-1$
- throw_message, null);
- throw new CoreException(error);
- }
-
- return rpm_info;
- }
-
- /**
- * Method parseDefine accepts a token from the parser and
- * searches the ArrayList passed to it for the value of the
- * token name. This is crude at this point since this does not
- * happen very often.
- * @param token is a string containing the name found after the
- * "Version:" or "Release:" fields of a spec file and the
- * begining character is a "%"
- * @param token_value ia an ArrayList containing the names and
- * values found in the "%define" statements usually found
- * at the top of the spec file
- * @return a string with the correct version or release number
- * else throw a CoreException
- */
- public String parseDefine(String token, ArrayList token_value)
- throws CoreException {
- if (debug) {
- System.out.println("parseDefine - token = " + token); //$NON-NLS-1$
- }
- // See if there in anything in the ArrayList
- if (token_value.isEmpty()) {
- String throw_message = Messages.getString("RPMCore.No___%defines___were_found_in_the_spec_file_38"); //$NON-NLS-1$
- IStatus error = new Status(IStatus.ERROR, Messages.getString("RPMCore.Error_1"), 1, //$NON-NLS-1$
- throw_message, null);
- throw new CoreException(error);
- }
- // A token usually looks this: %{name}
- String token_name = token.substring(2,token.length()-1);
- int i = token_value.indexOf(token_name);
- return (String) token_value.get(i+1);
- }
-
-
- /**
- * Method generateChecksum is used to calculate the size of the source
- * files in a project. This can then be used by the GUI to see if any files
- * have changed since the last time this project was exported.
- * @param project_path is a string containing the path to the project
- * @param a long containing the initial value to begin with (since this is
- * a recursive function, the value is always passed into the function)
- * @return long integer with total file size
- */
- public long generateChecksum(String project_path, long proj_checksum)
- throws CoreException {
-// if (debug) {
-// System.out.println("generateChecksum"); //$NON-NLS-1$
-// }
-
- File dir = new File(project_path);
-
- if (dir.isDirectory()) {
- String[] children = dir.list();
-
- for (int i = 0; i < children.length; i++) {
-
- File temp = new File(project_path + file_sep + children[i]);
-
- if (temp.isDirectory()) {
- proj_checksum = generateChecksum(project_path
- + file_sep + children[i], proj_checksum);
- /**
- * Here is a list of files to include for the checksum and a
- * couple to exclude. We want to only include source files
- * that are not generated or modified in some way by the
- * "configure" script.
- */
- } else {
- if ((children[i].endsWith(".c") | //$NON-NLS-1$
- children[i].endsWith(".cpp") | //$NON-NLS-1$
- children[i].endsWith(".h") | //$NON-NLS-1$
- children[i].endsWith(".in") | //$NON-NLS-1$
- children[i].endsWith(".pl") | //$NON-NLS-1$
- children[i].endsWith(".s") | //$NON-NLS-1$
- children[i].endsWith(".log") | //$NON-NLS-1$
- children[i].endsWith(".m4") | //$NON-NLS-1$
- children[i].endsWith("-sh") | //$NON-NLS-1$
- children[i].endsWith(".mo") | //$NON-NLS-1$
- children[i].endsWith(".po") | //$NON-NLS-1$
- children[i].endsWith(".pot") | //$NON-NLS-1$
- children[i].endsWith(".sh")) & //$NON-NLS-1$
- (!children[i].equals("config.log") & //$NON-NLS-1$
- !children[i].equals("config.h"))) { //$NON-NLS-1$
- try {
- proj_checksum += fileCheckSum(temp);
- } catch (Exception e) {
- String throw_message = Messages.getString("RPMCore.0") + //$NON-NLS-1$
- temp.toString();
- IStatus error = new Status(IStatus.ERROR, Error, 1,
- throw_message, null);
- throw new CoreException(error);
- }
- }
- if (children[i].equals("Makefile") & !LinuxShellCmds.checkForConfigure(project_path)) { //$NON-NLS-1$
- try {
- proj_checksum += fileCheckSum(temp);
- } catch (Exception e) {
- // Auto-generated catch block
- e.printStackTrace();
- }
- }
- }
- }
- }
-
- return proj_checksum;
- }
-
- /**
- * Method fileCheckSum.
- * Generate a checksum for the file passed to this method.
- *
- * @param File
- * to parse
- * @return long containing the checksum of the file
- * @throws CoreException
- */
- public long fileCheckSum(File input) throws Exception {
- if (debug) {
- System.out.println("fileCheckSum file = " + input); //$NON-NLS-1$
- }
- String input_line;
- long chksum = 0;
- BufferedReader br = new BufferedReader(new FileReader(input.toString()));
- while ((input_line = br.readLine()) != null) {
- for (int i=0; i file_length) {
- continue;
- }
-
- String file_ext = subfiles[i].substring(file_length -
- ext_length);
-
- if (!file_ext.equals(files_to_del[j])) {
- continue;
- }
-
- boolean del_file = f.delete();
-
- if (!del_file) {
- String throw_message = Messages.getString(
- "RPMCore.Error_deleting_files_in_deleteSRPMextrafiles_498"); //$NON-NLS-1$
- IStatus error = new Status(IStatus.ERROR, Error, 1,
- throw_message, null);
- throw new CoreException(error);
- }
- }
- }
- }
- return true;
- }
-
- /**
- * Method deleteEclipseFiles will delete the files added to an SRPM that
- * was imported by Eclipse and the import process.
- * @param String containing the path where to start deleting
- * @return true if successful, false if not
- */
- public boolean deleteEclipseFiles(String path_to_delete, String rpm_name)
- throws CoreException {
- if (debug) {
- System.out.println("--deleteEclipseFiles"); //$NON-NLS-1$
- }
-
- // Remove the .srpminfo file used to store info about the SRPM
- String[] eclipse_files = {
- srpm_info_name, file_sep + ".project", file_sep + ".cdtproject", file_sep + ".cdtbuild", //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
- file_sep + spec_file_prefix + rpm_name + ".spec", //$NON-NLS-1$
- file_sep + spec_file_prefix + rpm_name +
- ".spec.new" + file_sep + //$NON-NLS-1$
- "Binaries" //$NON-NLS-1$
-
- };
-
- for (int i = 0; i < eclipse_files.length; i++) {
- File f = new File(path_to_delete + eclipse_files[i]);
-
- if (f.exists()) {
- if (!f.delete()) {
- String throw_message = ""; //$NON-NLS-1$
- IStatus error = new Status(IStatus.ERROR, Error, 1,
- throw_message, null);
- throw new CoreException(error);
- }
- }
- }
-
- return true;
- }
-
- /**
- * Method createRPMdirectories creates the directories in the "path" passed to
- * it necessary for the "rpm/rpmbuild" command to execute.
- * @param path contains a string to the path of where to create the directories
- * @return boolean - true is the operation was successful,
- * throw CoreException if not
- */
- /******************************************************************************/
-
- // Create RPM Directories used for the rpmbuild process
- public boolean createRPMdirectories(String path) throws CoreException {
- if (debug) {
- System.out.println("createRPMdirectories: path = " + //$NON-NLS-1$
- path);
- }
-
- boolean cmd_stat;
- File f = new File(path);
-
- // If an old environment exists remove it
- if (f.exists()) {
- deleteRPMworkarea(f);
- }
-
- // Create the rpm temporary work area
- if (!f.mkdirs()) {
- String throw_message = Messages.getString(
- "RPMCore.Failed_to_create_RPM_directories,_check_file_permissions_in__195") + //$NON-NLS-1$
- wksp_path;
- IStatus error = new Status(IStatus.ERROR, Error, 1, throw_message,
- null);
- throw new CoreException(error);
- }
-
- // Create the directories required by rpm/rpmbuild to perform their work
- String[] rpm_dirs = { "BUILD", "RPMS", "SOURCES", "SPECS", "SRPMS" }; //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$ //$NON-NLS-5$
-
- for (int i = 0; i < rpm_dirs.length; i++) {
- File f1 = new File(rpmdirs_path + file_sep + rpm_dirs[i]);
-
- if (!f1.mkdir()) {
- String throw_message = Messages.getString(
- "RPMCore.Failed_to_create_RPM_directories_in__203") + //$NON-NLS-1$
- f1 +
- Messages.getString(
- "RPMCore._--_check_file_permissions._204"); //$NON-NLS-1$
- IStatus error = new Status(IStatus.ERROR, Error, 1,
- throw_message, null);
- throw new CoreException(error);
- }
- }
-
- // Set the permissions of the work area so only the owner can access for
- String chmodcommand = usr_chmod_cmd + " -R 744 " + rpmdirs_path + file_sep; //$NON-NLS-1$
-
- try {
- LinuxShellCmds.executeLinuxCommand(chmodcommand, 0);
- } catch (CoreException e) {
- String throw_message = e.getMessage();
- IStatus error = new Status(IStatus.ERROR, Error, 1, throw_message,
- null);
- throw new CoreException(error);
- }
- return true;
- }
- /**
- * Method createRPMLogFile.
- * Create the file where the name of the logfile resides for this run.
- * @return throw CoreException if unsuccessful
- */
- public void createRPMLogFile() throws CoreException {
- if (debug) {
- System.out.println("createRPMLogFile: " + rpmbuild_logname); //$NON-NLS-1$
- }
-
- String logfilename = wksp_path + file_sep +
- RPMCorePlugin.getDefault().getPreferenceStore().
- getString("IRpmConstants.RPM_DISPLAYED_LOG_NAME"); //$NON-NLS-1$
- byte[] buf = rpmbuild_logname.getBytes();
- try {
- BufferedOutputStream os = new BufferedOutputStream(new FileOutputStream(
- logfilename));
-
- for (int i = 0; i " + rpmdirs_path + //$NON-NLS-1$ //$NON-NLS-2$
- file_sep + "SOURCES" + file_sep + patch_name + " )" + line_sep; //$NON-NLS-1$ //$NON-NLS-2$
- File f = new File(rpmdirs_path + file_sep + "SOURCES" + file_sep + patch_name); //$NON-NLS-1$
- // Execute the diff_cmd shell script to create a patch file
- try {
- LinuxShellCmds.createLinuxShellScript(diff_cmd, rpmbuild_logname, rpm_shell);
- LinuxShellCmds.executeLinuxCommand(rpm_shell, 1);
- } catch (CoreException e) {
-
- if (!f.exists() | f.length() == 0) {
- return 0;
- } else {
- return -1;}
- }
- return f.length();
- }
-
- /**
- * This small class implements the FilenameFilter method. It is
- * used to return all files ending with ".spec" from the SPECS
- * directory
- */
- public class OnlyExt implements FilenameFilter {
- String ext;
-
- /**
- * Method OnlyExt.
- * This method accepts a string to be used as a filter. Only files with names ending
- * in .'ext' will be returned.
- * @param ext - string containing the file extension to use as a filter
- */
- public OnlyExt(String ext) {
- this.ext = "." + ext; //$NON-NLS-1$
- }
-
- /**
- * @see java.io.FilenameFilter#accept(File, String)
- */
- public boolean accept(File dir, String name) {
- return (name.endsWith(ext));
- }
- }
-
- /**
- * @return
- */
- public static String getError() {
- return Error;
- }
-
- /**
- * @return
- */
- public boolean isGenerate_patch() {
- return generate_patch;
- }
-
- /**
- * @return
- */
- public String getPath_to_rpm() {
- return path_to_rpm;
- }
-
- /**
- * @return
- */
- public String getPath_to_specfile() {
- return path_to_specfile;
- }
-
- /**
- * @return
- */
- public String getProj_dir() {
- return proj_dir;
- }
-
- /**
- * @return
- */
- public String getProj_path() {
- return proj_path;
- }
-
- /**
- * @return
- */
- public String getRpm_macros() {
- return rpm_macros;
- }
-
- /**
- * @return
- */
- public String getRpm_name() {
- return rpm_name;
- }
-
- /**
- * @return
- */
- public String getRpm_release() {
- return rpm_release;
- }
-
- /**
- * @return
- */
- public String getRpm_spec() {
- return rpm_spec;
- }
-
- /**
- * @return
- */
- public String getRpm_version() {
- return rpm_version;
- }
-
- /**
- * @return
- */
- public String getRpmbuild_logname() {
- return rpmbuild_logname;
- }
-
- /**
- * @return
- */
- public String getRpmdirs_path() {
- return rpmdirs_path;
- }
-
- /**
- * @return
- */
- public String getRpmrc() {
- return rpmrc;
- }
-
- /**
- * @return
- */
- public String getSpec_file_name() {
- return spec_file_name;
- }
-
- /**
- * @return
- */
- public String getSpec_file_prefix() {
- return spec_file_prefix;
- }
-
- /**
- * @return
- */
- public String getSrpm_info_name() {
- return srpm_info_name;
- }
-
- /**
- * @return
- */
- public String getWksp_path() {
- return wksp_path;
- }
-
- /**
- * @param string
- */
- public void setRpm_release(String string) {
- rpm_release = string;
- }
-
- /**
- * @param string
- */
- public void setRpm_version(String string) {
- rpm_version = string;
- }
-
- /**
- * @param string
- */
- public void setSpec_file_name(String string) {
- spec_file_name = string;
- }
-
- /**
- * @return
- */
- public boolean isChk_sum_diff() {
- return chk_sum_diff;
- }
-
- /**
- * @return
- */
- public String getRpm_shell() {
- return rpm_shell;
- }
-
- /**
- * @param string
- */
- public void setPath_to_specfile(String string) {
- path_to_specfile = string;
- }
-
- /**
- * @param string
- */
- public void setUi_rel_no(String string) {
- ui_rel_no = string;
- }
-
- /**
- * @param string
- */
- public void setUi_ver_no(String string) {
- ui_ver_no = string;
- }
-
-}
Index: src/org/eclipse/cdt/rpm/core/RPMCorePlugin.java
===================================================================
RCS file: /home/tools/org.eclipse.cdt-contrib/org.eclipse.cdt.rpm/org.eclipse.cdt.rpm.core/src/org/eclipse/cdt/rpm/core/RPMCorePlugin.java,v
retrieving revision 1.2
diff -u -r1.2 RPMCorePlugin.java
--- src/org/eclipse/cdt/rpm/core/RPMCorePlugin.java 8 Nov 2004 21:30:12 -0000 1.2
+++ src/org/eclipse/cdt/rpm/core/RPMCorePlugin.java 18 May 2005 20:42:40 -0000
@@ -1,5 +1,5 @@
/*
- * (c) 2004 Red Hat, Inc.
+ * (c) 2004, 2005 Red Hat, Inc.
*
* This program is open source software licensed under the
* Eclipse Public License ver. 1
@@ -7,13 +7,19 @@
package org.eclipse.cdt.rpm.core;
-import org.eclipse.ui.plugin.AbstractUIPlugin;
-import org.eclipse.core.resources.IWorkspace;
-import org.eclipse.jface.preference.IPreferenceStore;
-
+import java.io.File;
+import java.io.IOException;
import java.net.UnknownHostException;
-import java.util.ResourceBundle;
import java.util.MissingResourceException;
+import java.util.ResourceBundle;
+
+import org.eclipse.cdt.rpm.core.internal.Messages;
+import org.eclipse.core.resources.IWorkspace;
+import org.eclipse.core.runtime.CoreException;
+import org.eclipse.core.runtime.IStatus;
+import org.eclipse.core.runtime.Status;
+import org.eclipse.jface.preference.IPreferenceStore;
+import org.eclipse.ui.plugin.AbstractUIPlugin;
import org.osgi.framework.BundleContext;
/**
@@ -24,8 +30,13 @@
private static RPMCorePlugin plugin;
//Resource bundle.
private ResourceBundle resourceBundle;
+ //Shell script shared by all external operations
+ private File shellScriptFile;
+ //Log file shared by all external operations
+ private File externalLogFile;
+
+ public static final String ID = "org.eclipse.cdt.rpm.core";
- static final String file_sep = System.getProperty("file.separator"); //$NON-NLS-1$
/**
* The constructor.
@@ -88,27 +99,50 @@
protected void initializeDefaultPreferences(IPreferenceStore store)
{
String user_name = System.getProperty("user.name");
- store.setDefault("IRpmConstants.RPM_WORK_AREA","/var/tmp");
- store.setDefault("IRpmConstants.USER_WORK_AREA",file_sep + "rpm_workarea");
- store.setDefault("IRpmConstants.RPM_DISPLAYED_LOG_NAME",".logfilename_"
+ store.setDefault(IRPMConstants.RPM_DISPLAYED_LOG_NAME, ".logfilename_" //$NON-NLS-1$
+ user_name);
- store.setDefault("IRpmConstants.SPEC_FILE_PREFIX","eclipse_");
- store.setDefault("IRpmConstants.SRPM_INFO_FILE",file_sep+".srpminfo");
- store.setDefault("IRpmConstants.RPM_SHELL_SCRIPT","rpmshell.sh");
- store.setDefault("IRpmConstants.RPM_LOG_NAME","rpmbuild.log");
- store.setDefault("IRpmConstants.RPM_RESOURCE_FILE",".rpmrc");
- store.setDefault("IRpmConstants.RPM_MACROS_FILE",".rpm_macros");
- store.setDefault("IRpmConstants.AUTHOR_NAME",user_name); //$NON-NLS-1$ //$NON-NLS-2$
- store.setDefault("IRpmConstants.AUTHOR_EMAIL",user_name +"@" + getHostName()); //$NON-NLS-1$ //$NON-NLS-2$
-
- store.setDefault("IRpmConstants.MAKE_CMD", "/usr/bin/make"); //$NON-NLS-1$ //$NON-NLS-2$
- store.setDefault("IRpmConstants.RPM_CMD", "/bin/rpm"); //$NON-NLS-1$ //$NON-NLS-2$
- store.setDefault("IRpmConstants.RPMBUILD_CMD", "/usr/bin/rpmbuild"); //$NON-NLS-1$ //$NON-NLS-2$
- store.setDefault("IRpmConstants.CHMOD_CMD", "/bin/chmod"); //$NON-NLS-1$ //$NON-NLS-2$
- store.setDefault("IRpmConstants.CP_CMD", "/bin/cp"); //$NON-NLS-1$ //$NON-NLS-2$
- store.setDefault("IRpmConstants.DIFF_CMD", "/usr/bin/diff"); //$NON-NLS-1$ //$NON-NLS-2$
- store.setDefault("IRpmConstants.TAR_CMD", "/bin/tar"); //$NON-NLS-1$ //$NON-NLS-2$
+ store.setDefault(IRPMConstants.RPM_LOG_NAME, "rpmbuild.log"); //$NON-NLS-1$
+ store.setDefault(IRPMConstants.AUTHOR_NAME, user_name);
+ store.setDefault(IRPMConstants.AUTHOR_EMAIL, user_name + "@" + getHostName()); //$NON-NLS-1$
+
+ store.setDefault(IRPMConstants.RPM_CMD, "/bin/rpm"); //$NON-NLS-1$
+ store.setDefault(IRPMConstants.RPMBUILD_CMD, "/usr/bin/rpmbuild"); //$NON-NLS-1$
+ store.setDefault(IRPMConstants.DIFF_CMD, "/usr/bin/diff"); //$NON-NLS-1$
}
+
+
+ //Note this method is not thread-safe
+ public File getShellScriptFile() throws CoreException {
+ if(shellScriptFile == null) {
+ try {
+ shellScriptFile = File.createTempFile(RPMCorePlugin.ID, ".sh"); //$NON-NLS-1$
+ } catch(IOException e) {
+ String throw_message = Messages.getString("RPMCore.Error_creating__1") + //$NON-NLS-1$
+ shellScriptFile.getAbsolutePath();
+ IStatus error = new Status(IStatus.ERROR, IRPMConstants.ERROR, 1,
+ throw_message, null);
+ throw new CoreException(error);
+ }
+ }
+ return shellScriptFile;
+ }
+
+ //Note this method is not thread-safe
+ public File getExternalLogFile() throws CoreException {
+ if(externalLogFile == null) {
+ try {
+ externalLogFile = File.createTempFile(RPMCorePlugin.ID, ".log"); //$NON-NLS-1$
+ } catch(IOException e) {
+ String throw_message = Messages.getString("RPMCore.Error_creating__1") + //$NON-NLS-1$
+ externalLogFile.getAbsolutePath();
+ IStatus error = new Status(IStatus.ERROR, IRPMConstants.ERROR, 1,
+ throw_message, null);
+ throw new CoreException(error);
+ }
+ }
+ return externalLogFile;
+ }
+
/**
* Method getHostName gets the name of the host to use as part of the
* e-mail address for the changelog entry in the spec file.
@@ -138,4 +172,5 @@
}
return hosttemp.substring(1);
}
+
}
Index: src/org/eclipse/cdt/rpm/core/RPMExport.java
===================================================================
RCS file: src/org/eclipse/cdt/rpm/core/RPMExport.java
diff -N src/org/eclipse/cdt/rpm/core/RPMExport.java
--- src/org/eclipse/cdt/rpm/core/RPMExport.java 13 Oct 2004 02:31:16 -0000 1.1
+++ /dev/null 1 Jan 1970 00:00:00 -0000
@@ -1,35 +0,0 @@
-/*
- * (c) 2004 Red Hat, Inc.
- *
- * This program is open source software licensed under the
- * Eclipse Public License ver. 1
- */
-
-package org.eclipse.cdt.rpm.core;
-
-import org.eclipse.core.runtime.CoreException;
-import org.eclipse.core.runtime.IStatus;
-import org.eclipse.core.runtime.Status;
-
-/**
- *This class is used to manipulate RPM files for Linux systems
- */
-public class RPMExport extends RPMExportCore {
-
- private static final boolean debug = false;
-
- public RPMExport(String c_proj_path)
- throws CoreException {
- super(c_proj_path, "-bb"); //$NON-NLS-1$
- }
-
- public void run() throws CoreException {
- try {
- super.run();
- } catch (Exception e) {
- String throw_message = e.getMessage();
- IStatus error = new Status(IStatus.ERROR, Error, 1, throw_message, null);
- throw new CoreException(error);
- }
- }
-}
\ No newline at end of file
Index: src/org/eclipse/cdt/rpm/core/RPMExportCore.java
===================================================================
RCS file: src/org/eclipse/cdt/rpm/core/RPMExportCore.java
diff -N src/org/eclipse/cdt/rpm/core/RPMExportCore.java
--- src/org/eclipse/cdt/rpm/core/RPMExportCore.java 13 Oct 2004 02:31:16 -0000 1.1
+++ /dev/null 1 Jan 1970 00:00:00 -0000
@@ -1,472 +0,0 @@
-/*
- * (c) 2004 Red Hat, Inc.
- *
- * This program is open source software licensed under the
- * Eclipse Public License ver. 1
- */
-
-package org.eclipse.cdt.rpm.core;
-
-import org.eclipse.core.runtime.CoreException;
-import org.eclipse.core.runtime.IStatus;
-import org.eclipse.core.runtime.Status;
-import java.io.File;
-import java.io.FileNotFoundException;
-import java.io.IOException;
-
-/**
- *This class is the core class that is extended by RPMExport and SRPMExport.
- * It conatins the main methods for exporting either a binary or source RPM.
- */
-public class RPMExportCore extends RPMCore {
-
- protected String ui_spec_file = ""; //$NON-NLS-1$
- protected String patch_name;
- protected String patch_tag;
- protected String changelog_entry;
-
- private String which_rpm;
- private SpecFileOps specfileops;
-
- private static final String src_exp = "-bs"; //$NON-NLS-1$
- private static final String bin_exp = "-bb"; //$NON-NLS-1$
- private static final boolean debug = false;
-
- /**
- * This is the constructor called to instantiate this class.
- * @param c_proj_path is the path to the Eclipse project to be exported.
- * @param c_which_rpm is which rpm to export; "-bs" = source, "-bb" = binary
- * @throws CoreException
- */
-
- public RPMExportCore (String c_proj_path, String c_which_rpm)
- throws CoreException {
- super(c_proj_path, ""); //$NON-NLS-1$
-
- which_rpm = c_which_rpm;
-
- int j = proj_path.lastIndexOf(file_sep);
- proj_dir = proj_path.substring(j + 1);
- }
-
- /**
- * Method run will call the proper methods in the proper sequence
- * to create the appropriate RPM. This is called from the GUI to
- * segregate the implementation from the user interface.
- * @return if successful, throws CoreException if not
- */
- public void run() throws CoreException {
- if (debug) {
- System.out.println("*************** RPMExportCore run **********************"); //$NON-NLS-1$
- }
- // Create the work area for rpm to do its thing
- try {
- setRpmbuild_logname();
- createRPMdirectories(rpmdirs_path);
- createRPMmacros(rpm_macros);
- createRPMrpmrc(rpmrc);
- createRPMLogFile();
- } catch (Exception e) {
- String throw_message = e.getMessage();
- IStatus error = new Status(IStatus.ERROR, Error, 1, throw_message, null);
- throw new CoreException(error);
- }
- // If we are exporting a binary RPM and the source RPM is already built and contains
- // the same version/release numbers and the checksums are the same
- // just build the RPM from the source
- if (ui_ver_no.equals(getRpm_version()) & ui_rel_no.equals(getRpm_release()) &
- patch_tag == null & which_rpm.equals("-bb") & !isChk_sum_diff()) { //$NON-NLS-1$
- try {
- buildBinaryFromSourceRpm();
- } catch (Exception e) {
- String throw_message = e.getMessage();
- IStatus error = new Status(IStatus.ERROR, Error, 1, throw_message, null);
- throw new CoreException(error);
- }
- return;
- }
- // Was this project previously exported (does a .srpminfo file exist)
- if (firstSRPM(proj_path)) {
- // if this is the first time this project has been exported, branch off to another method
- try {
- createSRPM();
- } catch (CoreException e) {
- String throw_message = e.getMessage();
- IStatus error = new Status(IStatus.ERROR, Error, 1, throw_message, null);
- throw new CoreException(error);
- }
- return;
- }
- String path_to_newspecfile;
- /** During an export we install the source rpm this project was imported from
- * and then copy the Eclipse project itself over to the to allow us to create patches
- * by executing the "diff" command. In the future we should change this behaviour
- * to only occur when a source RPM is being exported, but for now we do it the same
- * for both exports.
- */
- // Install the source into the rpm workarea
- try {
- installRPMsource(getPath_to_rpm()); // "rpm -i ...." command
- executeRPMbuildprep(); // "rpmbuild -bp ...." command
- // If the user specfied a spec file, use it instead of modifying the one in the project
- if (ui_spec_file.startsWith(spec_file_prefix)) {
- specfileops = new SpecFileOps(proj_path, rpmdirs_path, wksp_path, proj_dir);
- path_to_newspecfile =
- specfileops.changeRPMspecfile(ui_ver_no, ui_rel_no, rpm_version,
- rpm_release,patch_tag,changelog_entry,rpm_name,getPath_to_specfile());
- // Now generate patches by doing a diff between the old source RPM and
- // the current project directory
- generateSRPMpatch(ui_ver_no, patch_tag);
- } else {
- path_to_newspecfile = ui_spec_file;
- }
- /* If the version number changed, we must change the tarball name if we are exporting
- * a source rpm export, the source tarball name format is:
- * rpmname-version.tar.zz where zz is usually either bz2 or gz
- */
- if (which_rpm.equals(src_exp) & !ui_ver_no.equals(getRpm_version())) {
- TarOps tarops = new TarOps(proj_path, rpmdirs_path);
- try {
- tarops.renameRPMtarfile(getRpm_name(), getRpmbuild_logname(),
- getRpm_shell(), ui_ver_no, getRpm_version());
- } catch (Exception e) {
- String throw_message = e.getMessage();
- IStatus error = new Status(IStatus.ERROR, Error, 1, throw_message, null);
- throw new CoreException(error);
- }
- }
- // Replace the spec file in the work area with the new one we just created
- String spec_path = replaceSpecFile(path_to_newspecfile);
- // Now build us an RPM....which_rpm governs which one
- executeRpmBuild(which_rpm, spec_path);
- // Now copy the newly created RPM(s) back to the Eclipse project
- String new_src_rpm = copyRpms(which_rpm);
- // Only create a new spec file/.srpminfo file if a source RPM was exported
- if (which_rpm.equals("-bs")) { //$NON-NLS-1$
- String newspecpath = renameSpecFile(path_to_newspecfile, spec_path);
- int j = new_src_rpm.lastIndexOf(file_sep);
- String srpm_full_name = new_src_rpm.substring(j + 1);
- createSRPMinfo(newspecpath, srpm_full_name);
- // Delete the newly created spec file if we exported a binary RPM
- } else {
- try {
- File f = new File(path_to_newspecfile);
- f.delete();
- } catch (Exception e) {
- String throw_message = "Error trying to delete newly created spec file at: " //$NON-NLS-1$
- + path_to_newspecfile;
- IStatus error = new Status(IStatus.ERROR, Error, 1, throw_message, null);
- throw new CoreException(error);
- }
- }
-
- deleteRPMresources(rpmdirs_path);
- } catch (Exception e) {
- String throw_message = e.getMessage();
- IStatus error = new Status(IStatus.ERROR, Error, 1, throw_message, null);
- throw new CoreException(error);
- }
- return;
- }
-
- /**
- * Method renameSpecFile will delete the previous "eclipse_...spec"
- * and the new "eclipse_...spec.new" files from the project and copy the
- * spec file that was used to perform the building of the source rpm from
- * the work area to the project renaming it to "eclipse_...spec"
- * @param path is a String containing the path to the spec file either created
- * by changeRPMspec which was created from the original spec file but has
- * the version and/or release numbers changed along with the addition of
- * Patch:/%patch/Changelog statements or is a user-specified spec file
- * @param path2 is a String containing the path to the spec file in the rpm
- * workarea so we can copy it back to the project for future use
- * @return the path to the new spec file so this information can be included
- * in the .srpminfo file so the next time we export we'll know which spec file
- * to use; throws CoreException if there is an error
- */
- public String renameSpecFile(String path, String path2) throws CoreException {
- if (debug) {
- System.out.println("renameSpecFile" + line_sep + " path = " + path + //$NON-NLS-1$ //$NON-NLS-2$
- line_sep + " path2 = " + path2); //$NON-NLS-1$
- }
- int j = path2.lastIndexOf(file_sep);
- String spec_name;
- if (j != -1) {
- spec_name = path2.substring(j+1);
- } else {
- spec_name = path2;
- }
- // Only delete the spec file is the user did not specify their own spec file
- if (ui_spec_file.startsWith(spec_file_prefix)) {
- File f = new File(path);
- File f1 = new File(getPath_to_specfile());
- if (!f.delete() | !f1.delete()) {
- String throw_message = "Error trying to delete " + f + " or " + f1; //$NON-NLS-1$ //$NON-NLS-2$
- IStatus error = new Status(IStatus.ERROR, Error, 1, throw_message, null);
- throw new CoreException(error);
- }
- }
-
- try {
- copyFile(path2, proj_path + file_sep + getSpec_file_prefix() + spec_name);
- } catch (FileNotFoundException e) {
-
- e.printStackTrace();
- } catch (IOException e) {
-
- e.printStackTrace();
- } catch (CoreException e) {
-
- e.printStackTrace();
- }
- return proj_path + file_sep + spec_name;
- }
-
- /**
- * Method replaceSpecFile takes the new spec file created by changeRPMspec
- * with the new information and copies it to the rpm workarea replacing the spec
- * file that was a part of original source RPM.
- * @param contains a String with is the path to the newly created spec file
- * which resides in the project for now.
- * @return if successful, throws CoreException if not
- */
-
- public String replaceSpecFile(String path) throws CoreException {
- if (debug) {
- System.out.println("replaceSpecFile"); //$NON-NLS-1$
- }
- String temp = rpmdirs_path + file_sep + "SPECS" + file_sep; //$NON-NLS-1$
- File f = new File(temp);
- String[] subdir = f.list();
- if (subdir.length != 1) {
- String throw_message = Messages.getString("RPMExportCore.Too_many_spec_files_in__4") + temp; //$NON-NLS-1$
- IStatus error = new Status(IStatus.ERROR, Error, 1, throw_message, null);
- throw new CoreException(error);
- }
- File f1 = new File(temp + subdir[0]);
- if (!f1.delete()) {
- String throw_message = Messages.getString("RPMExportCore.Error_trying_to_delete__5") + f1; //$NON-NLS-1$
- IStatus error = new Status(IStatus.ERROR, Error, 1, throw_message, null);
- throw new CoreException(error);
- }
- try {
- copyFile(path, temp + subdir[0]);
- } catch (FileNotFoundException e) {
- e.printStackTrace();
- } catch (IOException e) {
- e.printStackTrace();
- } catch (CoreException e) {
- e.printStackTrace();
- }
- return temp + subdir[0];
- }
-
- /**
- * Method createSRPM is called when a project has never been
- * exported as a project before.
- * @return if successful, throws CoreException if not
- */
- public void createSRPM() throws CoreException {
- if (debug) {
- System.out.println("createSRPM"); //$NON-NLS-1$
- }
- String spec_dir = file_sep + "SPECS" + file_sep;
- // Since this is the first time this project has been exported as an RPM,
- // use the version/release number entered by the user
- rpm_version = ui_ver_no;
- rpm_release = ui_rel_no;
- // Copy the project to the work area to preserve the Eclipse project
- String proj_work_dir = rpmdirs_path + file_sep + "BUILD" + file_sep + proj_dir; //$NON-NLS-1$
- // Copy the project to the rpm workarea so we can work on it
- try {
- LinuxShellCmds.linuxCopy(proj_path, proj_work_dir, getRpmbuild_logname(),
- getRpm_shell());
- } catch (Exception e) {
- String throw_message = e.getMessage();
- IStatus error = new Status(IStatus.ERROR, Error, 1, throw_message, null);
- throw new CoreException(error);
- }
- String spec_file_name = ui_spec_file;
- String spec_file_path = ui_spec_file;
- // Invoke the specfile ops class to create a new spec file if the user has not specified one
- // If the user chose a spec file inside the Eclipse project, there will not be any
- // '/'s in the name, if there are '/'s, figure out the name
- if (!ui_spec_file.equals("")) { //$NON-NLS-1$
- int i = ui_spec_file.lastIndexOf(file_sep);
- if (i != -1) {
- spec_file_name = ui_spec_file.substring(i+1);
- spec_file_path = ui_spec_file;
- }
- } else {
- spec_file_name = proj_dir + ".spec"; //$NON-NLS-1$
- spec_file_path = rpmdirs_path + spec_dir + spec_file_name;
- SpecFileOps specfileops = new SpecFileOps(proj_path, rpmdirs_path, wksp_path,
- proj_dir);
- specfileops.createRPMspec(getRpm_shell(), getRpmbuild_logname(),
- proj_work_dir, rpm_version, rpm_release, rpmdirs_path + spec_dir +
- spec_file_name,
- rpm_name);
- }
-
- // Now create a tarball for the source if the user has indicated that a source RPM be built
- if (which_rpm.equals("-bs")) { //$NON-NLS-1$
- // Clean up after the spec file creation is done in preparation for creating a tarball
- try {
- executeMakeClean(proj_work_dir);
- } catch (Exception e) {
- String throw_message = e.getMessage();
- IStatus error = new Status(IStatus.ERROR, Error, 1, throw_message, null);
- throw new CoreException(error);
- }
- }
- try {
- TarOps tarops = new TarOps(proj_path, rpmdirs_path);
- tarops.createRPMtarfile(rpm_name, rpm_version, spec_file_path);
- } catch (Exception e) {
- String throw_message = e.getMessage();
- IStatus error = new Status(IStatus.ERROR, Error, 1, throw_message, null);
- throw new CoreException(error);
- }
- // Copy the spec file to be used by rpmbuild to the work area if it isn't already there
- if (!spec_file_path.equals(rpmdirs_path + spec_dir + spec_file_name)) {
- try {
- copyFile(spec_file_path, rpmdirs_path + spec_dir + spec_file_name);
- } catch (Exception e) {
- String throw_message = e.getMessage();
- IStatus error = new Status(IStatus.ERROR, Error, 1, throw_message, null);
- throw new CoreException(error);
- }
- }
- // Now, build the RPM's and copy them to the project
- try {
- executeRpmBuild(which_rpm, spec_file_path);
- String path_to_src_rpm = copyRpms(which_rpm);
- copyFile(rpmdirs_path + spec_dir + spec_file_name, proj_path + file_sep +
- getSpec_file_prefix() + spec_file_name);
- if (which_rpm.equals("-bs")){ //$NON-NLS-1$
- int j = path_to_src_rpm.lastIndexOf(file_sep);
- String src_name = path_to_src_rpm.substring(j+1);
- createSRPMinfo(getSpec_file_prefix() + spec_file_name, src_name);
- }
- } catch (Exception e) {
- String throw_message = e.getMessage();
- IStatus error = new Status(IStatus.ERROR, Error, 1, throw_message, null);
- throw new CoreException(error);
- }
- // Now clean up the work area
- try {
- deleteRPMresources(rpmdirs_path);
- } catch (Exception e) {
- String throw_message = e.getMessage();
- IStatus error = new Status(IStatus.ERROR, Error, 1, throw_message, null);
- throw new CoreException(error);
- }
- }
-
- /**
- * Method createSRPMinfo is used as an interface to the same method
- * inthe RPMCore class. We just put try/catch around it
- * @param file1 is a string containing the Eclipce spec file name in the Eclipse project
- * @param file2 is a string containing the name of the new source rpm that resides
- * in the project
- * @return if successful, throws CoreException if not
- */
- public void createSRPMinfo(String specfile, String src_name)
- throws CoreException {
- int j = specfile.lastIndexOf(file_sep);
- if (j != -1) {
- specfile = getSpec_file_prefix() + specfile.substring(j+1);
- }
- // Now, recreate the .srpminfo file in the project to point to the new source RPM
- try {
- super.createSRPMinfo(specfile, src_name);
- } catch (Exception e) {
- String throw_message = e.getMessage();
- IStatus error = new Status(IStatus.ERROR, Error, 1,
- throw_message, null);
- throw new CoreException(error);
- }
- }
-
- /**
- * Method buildBinaryFromSource builds a binary RPM from a source RPM
- * that has previously been created in the project.
- * @return if successful, throws CoreException if not
- */
- public void buildBinaryFromSourceRpm() throws CoreException {
- if (debug) {
- System.out.println("buildBinaryFromSourceRpm"); //$NON-NLS-1$
- }
- try {
- installRPMsource(getPath_to_rpm()); // "rpm -i ...." command
- // Now build us an RPM....which_rpm governs which one
- String spec_path = findSpecFileName();
- executeRpmBuild(which_rpm, spec_path);
- copyRpms(which_rpm);
- deleteRPMresources(rpmdirs_path);
- } catch (Exception e) {
- String throw_message = e.getMessage();
- IStatus error = new Status(IStatus.ERROR, Error, 1,
- throw_message, null);
- throw new CoreException(error);
- }
- return;
- }
-
- /**
- * Method findSpecFileName will return the name of the spec file in the
- * SPECS directory of the RPM work area.
- * @return if successful, throws CoreException if not
- */
- public String findSpecFileName() throws CoreException {
- if (debug) {
- System.out.println("findSpecFileName"); //$NON-NLS-1$
- }
- File f = new File(rpmdirs_path + file_sep + "SPECS" + file_sep); //$NON-NLS-1$
- String[] subdir = f.list();
- if (subdir.length != 1) {
- String throw_message = "Error in spec file directory:" + f; //$NON-NLS-1$
- IStatus error = new Status(IStatus.ERROR, Error, 1, throw_message, null);
- throw new CoreException(error);
- }
- return rpmdirs_path + file_sep + "SPECS" + file_sep + subdir[0]; //$NON-NLS-1$
- }
-
- /**
- * @param string
- */
- public void setPatch_name(String string) {
- patch_name = string;
- }
-
- /**
- * @param string
- */
- public void setPatch_tag(String string) {
- patch_tag = string;
- }
-
- /**
- * @param string containing the changelog entry the user entered
- * from the GUI
- */
- public void setChangelog_entry(String string) {
- changelog_entry = string;
- }
-
- /**
- * @param string
- */
- public void setUi_spec_file(String string) {
- ui_spec_file = string;
- if (!string.equals("") & string != null) { //$NON-NLS-1$
- int i = spec_file_name.lastIndexOf(file_sep);
- if (i == -1) {
- setPath_to_specfile(proj_path + file_sep + ui_spec_file);
- } else {
- setPath_to_specfile(ui_spec_file);
- }
- }
- }
-
-}
Index: src/org/eclipse/cdt/rpm/core/SRPMExport.java
===================================================================
RCS file: src/org/eclipse/cdt/rpm/core/SRPMExport.java
diff -N src/org/eclipse/cdt/rpm/core/SRPMExport.java
--- src/org/eclipse/cdt/rpm/core/SRPMExport.java 13 Oct 2004 02:31:16 -0000 1.1
+++ /dev/null 1 Jan 1970 00:00:00 -0000
@@ -1,46 +0,0 @@
-/*
- * (c) 2004 Red Hat, Inc.
- *
- * This program is open source software licensed under the
- * Eclipse Public License ver. 1
- */
-package org.eclipse.cdt.rpm.core;
-
-import org.eclipse.core.runtime.CoreException;
-import org.eclipse.core.runtime.IStatus;
-import org.eclipse.core.runtime.Status;
-
-
-/**
- *This class is called from the GUI when a source RPM is to be created.
- */
-public class SRPMExport extends RPMExportCore {
-
- private static final boolean debug = false;
-
- /**
- * This is the constructor called by the GUI to instantiate this class.
- * @param c_proj_path is the path to the Eclipse project to be exported
- * @param c_wksp_path is the path to the temporary work area to be used by rpm
- * @throws CoreException
- */
-
- public SRPMExport(String c_proj_path) throws CoreException {
- super(c_proj_path, "-bs"); //$NON-NLS-1$
- }
-
- /**
- * This run method is called by the GUI to run the methods to create a source RPM.
- * @return if successful, throw CoreException if not
- * @throws CoreException
- */
- public void run() throws CoreException {
- try {
- super.run();
- } catch (Exception e) {
- String throw_message = e.getMessage();
- IStatus error = new Status(IStatus.ERROR, Error, 1, throw_message, null);
- throw new CoreException(error);
- }
- }
-}
\ No newline at end of file
Index: src/org/eclipse/cdt/rpm/core/SRPMImport.java
===================================================================
RCS file: src/org/eclipse/cdt/rpm/core/SRPMImport.java
diff -N src/org/eclipse/cdt/rpm/core/SRPMImport.java
--- src/org/eclipse/cdt/rpm/core/SRPMImport.java 8 Nov 2004 21:30:12 -0000 1.2
+++ /dev/null 1 Jan 1970 00:00:00 -0000
@@ -1,297 +0,0 @@
-/*
- * (c) 2004 Red Hat, Inc.
- *
- * This program is open source software licensed under the
- * Eclipse Public License ver. 1
- */
-package org.eclipse.cdt.rpm.core;
-
-import org.eclipse.core.runtime.CoreException;
-import org.eclipse.core.runtime.IStatus;
-import org.eclipse.core.runtime.Status;
-
-import java.io.*;
-
-/**
- *This class is used to import source RPMs into Eclipse projects.
- *It is called by the GUI to invoke the run method which does the import.
- */
-public class SRPMImport extends RPMCore {
-
- private boolean doAutoconf = true;
- private boolean doPatches = true;
-
- // When debug is set to true, lots of debug statements are printed.
- private static final boolean debug = false;
- /*
- * Constructor to create data for the RPMCore class.
- */
- public SRPMImport(String c_proj_path, String c_path_to_rpm)
- throws CoreException {
- super(c_proj_path, c_path_to_rpm);
-
- int j = path_to_rpm.lastIndexOf(file_sep);
- if (j == -1) {
- srpm_full_name = path_to_rpm;
- } else {
- srpm_full_name = path_to_rpm.substring(j+1);
- }
- }
-
- /**
- * Method setupSRPMworkarea.
- * This method is called by the GUI to setup the RPM workarea specified
- * in the "rpmdirs_bld" path. The directories that rpm will use to install and
- * setup the source rpm before importing it into the Eclipse project.
- * @return return if successful, throw CoreException if failed
- */
- public void run() throws CoreException {
- if (debug) {
- System.out.println("******************Import run*****************"); //$NON-NLS-1$
- }
- setRpmbuild_logname();
- rpmbuild_logname = getRpmbuild_logname();
- try {
- createRPMdirectories(rpmdirs_path);
- createRPMmacros(rpm_macros);
- createRPMrpmrc(rpmrc);
- createRPMLogFile();
- } catch (Exception e) {
- String throw_message = e.getMessage();
- IStatus error = new Status(IStatus.ERROR, Error, 1, throw_message, null);
- throw new CoreException(error);
- }
- String orig_proj_path;
- try {
- orig_proj_path = getSourceCode();
- } catch (Exception e) {
- String throw_message = e.getMessage();
- IStatus error = new Status(IStatus.ERROR, Error, 1, throw_message, null);
- throw new CoreException(error);
- }
-
- // Now see if 'configure' should be run, but only if we applied patches
- if (doAutoconf & doPatches) {
- executeProjConfigure(orig_proj_path);
- }
- // We are now ready to copy the files from the work area to the Eclipse project
-
- try {
- LinuxShellCmds.linuxCopy(orig_proj_path, proj_path, rpmbuild_logname, rpm_shell);
- } catch (CoreException e) {
- String throw_message = e.getMessage();
- IStatus error = new Status(IStatus.ERROR, Error, 1, throw_message, null);
- throw new CoreException(error);
- }
- String spec_dir = file_sep + "SPECS" + file_sep; //$NON-NLS-1$
- // Copy the spec file and source RPM to the project for safekeeping
- File f = new File(rpmdirs_path + spec_dir);
- String[] subdir = f.list();
- if (subdir == null | subdir.length > 1) {
- String throw_message = "There should only be one file in: " + rpmdirs_path + spec_dir; //$NON-NLS-1$
- IStatus error = new Status(IStatus.ERROR, Error, 1, throw_message, null);
- throw new CoreException(error);
- }
- String from_file = rpmdirs_path + spec_dir + subdir[0];
- try {
- super.copyFile(from_file, proj_path + file_sep + spec_file_prefix + subdir[0]);
- super.copyFile(path_to_rpm, proj_path + file_sep + srpm_full_name);
- } catch (Exception e) {
- String throw_message = e.getMessage();
- IStatus error = new Status(IStatus.ERROR, Error, 1, throw_message, null);
- throw new CoreException(error);
- }
- // Now, create a file that resides in the project that contains information
- int j = path_to_rpm.lastIndexOf(file_sep);
- String srpm_full_name = path_to_rpm.substring(j + 1);
- createSRPMinfo(spec_file_prefix + subdir[0], srpm_full_name);
- // Now clean up the RPM work area
- deleteRPMresources(rpmdirs_path);
- }
-
- /**
- * Method getSourceCode.
- * This method is called to install the source code and then depending
- * on whether or not patches are to be applied either run the rpmbuild
- * command or untar the source tarball.
- * @return return path to the source if successful, return "" or
- * throw CoreException if failed
- */
- public String getSourceCode() throws CoreException {
- if (debug) {
- System.out.println("getSourceCode"); //$NON-NLS-1$
- }
- try {
- installRPMsource(path_to_rpm);
- } catch (CoreException e) {
- String throw_message = e.getMessage();
- IStatus error = new Status(IStatus.ERROR, Error, 1, throw_message, null);
- throw new CoreException(error);
- }
- // If the doPatches switch is set run the "rpmbuild -bp" command to install the
- // source with patches
- if (doPatches) {
- try {
- executeRPMbuildprep();
- } catch (CoreException e) {
- String throw_message = e.getMessage();
- IStatus error = new Status(IStatus.ERROR, Error, 1, throw_message, null);
- throw new CoreException(error);
- }
- // Figure out what the path to the installed sources is
- File f = new File(rpmdirs_path + file_sep + "BUILD"); //$NON-NLS-1$
- String subdir[] = f.list();
- if (subdir == null | subdir.length != 1) {
- String throw_message = Messages.getString("SRPMImport.Error_occurred_during_the_source_install._n_1") + //$NON-NLS-1$
- Messages.getString("SRPMImport.There_are_either_too_many_or_0_directories_under__2") + f; //$NON-NLS-1$
- IStatus error = new Status(IStatus.ERROR, Error, 1, throw_message, null);
- throw new CoreException(error);
- }
- return rpmdirs_path + file_sep + "BUILD" + file_sep + subdir[0]; //$NON-NLS-1$
- // If doPatches is not set, untar the source myself
- } else {
- String tarball_path = findTarBallPath(rpmdirs_path + file_sep + "SOURCES"); //$NON-NLS-1$
- if (tarball_path != "") { //$NON-NLS-1$
- TarOps tarOps = new TarOps(proj_path, rpmdirs_path);
- try {
- tarOps.untarSource(tarball_path, rpmbuild_logname, rpm_shell);
- } catch (CoreException e) {
- String throw_message =e.getMessage();
- IStatus error = new Status(IStatus.ERROR, Error, 1, throw_message, null);
- throw new CoreException(error);
- }
- } else {
- String throw_message = Messages.getString("SRPMImport.Cannot_find_a_tarball_to_untar_in___3") + tarball_path; //$NON-NLS-1$
- IStatus error = new Status(IStatus.ERROR, Error, 1, throw_message, null);
- throw new CoreException(error);
- }
- }
- // Figure out where the source code is, there *should* be only one directory
- // in the 'rpmdirs_path/SOURCES/' directory
- String src_path = rpmdirs_path + file_sep + "SOURCES" + file_sep; //$NON-NLS-1$
- File f = new File(src_path);
- String[] subdir = f.list();
- for (int i =0; i 8) {
- if (input_line.startsWith("Version")) { //$NON-NLS-1$
- input_line = new_version_line;
- } else if (input_line.startsWith("Release")) { //$NON-NLS-1$
- input_line = new_release_line;
- }
- }
-
- fw.write(input_line + line_sep);
-
- // See if this was the "%changelog" line just written, if it was, write out the new entry
- if (input_line.length() == 10 && !patch_name.equals("")) { //$NON-NLS-1$
- if (input_line.startsWith("%changelog")) { //$NON-NLS-1$
- fw.write(changelog_entry);
- found_changelog = true;
- }
- }
-
- line_ctr++;
-
- // Check to see if this is one of the lines I should add something after
- if (!patch_name.equals("")) { //$NON-NLS-1$
- if (line_ctr == line_ptr[line_indx]) {
- fw.write(add_line[line_indx]);
- line_indx++;
- }
- }
- }
-
- // if there was not a "%changelog" section, make one
- if (!found_changelog && !patch_name.equals("")) { //$NON-NLS-1$
- fw.write("%changelog" + line_sep + changelog_entry); //$NON-NLS-1$
- }
-
- fw.close();
- } catch (IOException e) {
- String throw_message = Messages.getString(
- "RPMCore.Error_trying_to_modify__132") + //$NON-NLS-1$
- path_to_specfile;
- IStatus error = new Status(IStatus.ERROR, Error, 1, throw_message,
- null);
- throw new CoreException(error);
- }
-
- return path_to_newspecfile;
- }
-
- /**
- * Method parseSpecfile.
- * This method takes a spec file path and parses it for various information.
- * @param String containing the path to the spec file to be parsed
- * @return simply return if successful, throw CoreEception if not
- */
- public void parseSpecfile(String path_to_specfile) throws CoreException {
- if (debug) {
- System.out.println("--parseSpecfile: " + path_to_specfile); //$NON-NLS-1$
- }
- for (int i = 0; i < line_ptr.length; i++) {
- line_ptr[i] = 0;
- }
- /* The following logic determines where in the spec file the "Patchx:" and
- * %patchx -p1" lines will need to be added to accomodate the patch we
- * are fixing to generate. If this is the first patch to ever be added to this
- * source RPM then the "Patchx: statement will have to be added after the
- * last "Sourcex:" statement and the "%patch -p1" statement will need to be
- * added after the "%setup" statement. If this is not the first patch for this
- * source rpm, the "Patchx:" statement will be added after the last "Patchx:"
- * statement and the "%patchx -p1" will be added after the last "%patch -p1"
- * statement. So, we keep track of where the line numbers for all of these
- * eventualities are so when we mod the file we will know where to insert
- * the necessary new lines.
- */
- ArrayList patchlist = new ArrayList();
- boolean found_source_line = false;
- boolean found_patch = false;
- boolean found_define = false;
- boolean found_define_name = false;
- boolean found_version = false;
- boolean found_release = false;
- int define_ctr = 0;
- int define_line_ctr = 0;
- int lines = 1;
-
- try {
- FileReader sp_file = new FileReader(path_to_specfile);
- StreamTokenizer st = new StreamTokenizer(sp_file);
-
- // Make sure numbers, colons and percent signs are considered valid
- st.wordChars('a','z');
- st.wordChars('A','Z');
- st.wordChars(':', ':');
- st.wordChars('0', '9');
- st.wordChars('%', '%');
- st.wordChars('{', '}');
- st.wordChars('-', '-');
- st.wordChars('/', '/');
- st.wordChars('=','=');
- st.wordChars('.','.');
- st.wordChars('_','_');
- st.eolIsSignificant(true);
-
- String new_word;
- boolean check_ifs = false;
- int if_ctr = 0;
- int token = st.nextToken();
- while (token != StreamTokenizer.TT_EOF) {
- token = st.nextToken();
-
- switch (token) {
- case StreamTokenizer.TT_EOL:
- lines++;
- break;
- case StreamTokenizer.TT_WORD:
- new_word = st.sval;
-
-/* The following commented out logic addresses bugzilla 110452 where the version and
- * release numbers for spec files are stored in "%define" variables at the top of the file. It
- * has been decided to put this change on hold until it can be determined how pervasive
- * the use of this practice is. The code is incomplete for the time being and may be deleted
- * entirely in future releases.
- */
-/* if (found_version) {
- found_version = false;
- if (new_word.startsWith("%{")) { //$NON-NLS-1$
- version_param = true;
- define_info.add(0,new_word.substring(2,new_word.length()-1));
- }
- break;
- }
-
- if (found_release) {
- found_release = false;
- if (new_word.startsWith("%{")) { //$NON-NLS-1$
-// release_param = true;
- define_info.add(1,new_word.substring(2,new_word.length()-1));
- }
- break;
- } */
-
- // See if we have found the Version: line
- if (new_word.equals("Version:")) { //$NON-NLS-1$
- found_version = true;
- break;
- }
-
- // See if we have found the Release: line
- if (new_word.equals("Release:")) { //$NON-NLS-1$
- found_release = true;
- break;
- }
-
- // Record where the last line of the form "Sourcex:" is
- if (new_word.startsWith("Source") & //$NON-NLS-1$
- new_word.endsWith(":")) { //$NON-NLS-1$
- line_ptr[0] = lines;
- found_source_line = true;
- break;
- }
-
- /* Record where the last line of the form "Patchx:" is and count how many there were.
- * Also, record the statement so when we generate our new "Patchx:" statement
- * we don't duplicate a "Patch" statement. This has to be done because a lot of
- * spec files have "Patchx:" statements that are non-sequential
- */
- if (new_word.startsWith("Patch") & //$NON-NLS-1$
- new_word.endsWith(":")) { //$NON-NLS-1$
- line_ptr[1] = lines;
- pat_ctr++;
- patchlist.add(new_word);
-
- break;
- }
-
- // Record where the "%setup line is
- if (new_word.equals("%setup")) { //$NON-NLS-1$
-
- // set the "check for if" constructs switch
- check_ifs = true;
- line_ptr[2] = lines;
-
- break;
- }
-
- if (new_word.equals("%build")) { //$NON-NLS-1$
- check_ifs = false;
-
- break;
- }
-
- // Record where the last (if any) "%patchx" line is
- if (new_word.startsWith("%patch")) { //$NON-NLS-1$
- line_ptr[3] = lines;
- found_patch = true;
-
- break;
- }
-
- // See if we have found a %define statement, if so save it as some
- // source RPMs use %define statements to "define" version/release #'s
-/* See the comment several lines above regarding bugzilla 110452 as it also pertains to this code */
-/* if (new_word.equals("%define")) { //$NON-NLS-1$
- found_define = true;
- define_line_ptr[define_line_ctr] = lines;
- define_line_ctr++;
-
- break;
- } */
-
- if (found_define) {
- found_define = false;
-// define_info.add(define_ctr,new_word);
- define_ctr++;
- found_define_name = true;
- break;
- }
-
- if (found_define_name) {
- found_define_name = false;
-// define_info.add(define_ctr,new_word);
- define_ctr++;
- break;
- }
-
- // Set the found %if/%ifarch/%ifnarch/%ifos/%ifnos switch
- if (check_ifs) {
- if (new_word.startsWith("%if")) { //$NON-NLS-1$
- if_ctr++;
-
- break;
- }
-
- // Reset the found %if/%ifarch switch
- if (new_word.equals("%endif")) { //$NON-NLS-1$
-
- if ((if_ctr > 0) & found_patch) {
- if_ctr--;
- line_ptr[3] = lines;
- found_patch = false;
-
- break;
- }
- }
-
- break;
- }
-
- break;
-
- default:
- break;
- }
- }
-
- sp_file.close();
- } catch (IOException e) {
- String throw_message = Messages.getString(
- "RPMCore.Error_parsing_the_spec_file_in_the_project_--_157") + //$NON-NLS-1$
- path_to_specfile;
- IStatus error = new Status(IStatus.ERROR, Error, 1, throw_message,
- null);
- throw new CoreException(error);
- }
-
- if (pat_ctr > 1) {
- int patch_num = parsePatchArray(patchlist, pat_ctr);
- pat_ctr = patch_num;
- }
-
- return;
- }
-
- /**
- * Method checkPatch is used to check for the existence of a previous
- * patch name in the "SOURCES" directory.
- * @param patch name formed from the patch tag from the GUI
- * @return true if the name unique, false if name already exists
- */
- private boolean checkPatch(String patch_name) {
- if (debug) {
- System.out.println("--checkPatch"); //$NON-NLS-1$
- }
-
- File f = new File(rpmdirs_path + file_sep + "SOURCES" + file_sep + patch_name); //$NON-NLS-1$
-
- if (f.exists()) {
- return false;
- }
-
- return true;
- }
-
- /**
- * Method parseArrayList is used to peruse a list of the "Patchx:"
- * statements gleaned from a spec file and determine what would
- * be unique "Patchx:"/"%patchx" statements to add to the spec file.
- * @param patchlist is an ArrayList containing the "Patchx:" statements
- * in the spec file
- * @param patch_ctr is the number of "Patchx:" statements found in the spec file
- * @return a number to replace "x" in "Patchx:" and "%patchx" which
- * is unique for this spec file
- *
- */
- private static int parsePatchArray(ArrayList patchlist, int patch_ctr) {
- if (debug) {
- System.out.println("--parsePatchArrayList"); //$NON-NLS-1$
- }
-
- int patch_array_size = patchlist.size();
- String num_string;
- int patch_num;
- String last_patch = (String) patchlist.get(patch_array_size - 1);
- int indx = 5;
-
- while (last_patch.charAt(indx) != ':') {
- indx++;
- }
-
- // Allow for the fact that there could only be one patch statement of the
- // form "Patch:", that is, there is no number
- if (indx == 5) {
- return 0;
- }
-
- String num = last_patch.substring(5, indx);
-
- try {
- patch_num = Integer.parseInt(num, 10);
- } catch (NumberFormatException e) {
- return -1;
- }
-
- return patch_num + 1;
- }
-
- /**
- * Method createRPMspec.
- * Create a *very* generic spec file since no spec file was specfified and
- * this is the first time this project has been exported.
- * @param rpm_shell is the name to use when creating a shell script
- * @param rpmbuild_logname is the name of the file to send log errors to
- * @param tar_path is the path to the tarball to be used in this specfile
- * @param rpm_version is the verison number to be placed in the spec file
- * @param rpm_release is the release number to be placed in the spec file
- * @param path_to_specfile is the path to write the new spec file to
- * @param proj_dir is the name of the Eclipse project directory, it will be used
- * to create the name of the tarball along with the version number
- * @return - true if successful, throw CoreException if not
- */
- /******************************************************************************/
- public boolean createRPMspec(String rpm_shell, String rpmbuild_logname,
- String tar_path, String rpm_version, String rpm_release, String path_to_specfile,
- String proj_dir)
- throws CoreException {
- if (debug) {
- System.out.println("createRPMspec "); //$NON-NLS-1$
- System.out.println(rpm_shell + " " + rpmbuild_logname + " " + tar_path + line_sep + //$NON-NLS-1$
- rpm_version + " " + rpm_release + " " + path_to_specfile + line_sep + //$NON-NLS-1$ //$NON-NLS-2$
- proj_dir);
- }
- String author_name = RPMCorePlugin.getDefault().getPreferenceStore()
- .getString("IRpmConstants.AUTHOR_NAME"); //$NON-NLS-1$
- String author_email = RPMCorePlugin.getDefault().getPreferenceStore()
- .getString("IRpmConstants.AUTHOR_EMAIL"); //$NON-NLS-1$
- String user_name = System.getProperty("user.name"); //$NON-NLS-1$
- String user_wksp = wksp_path + file_sep + user_name;
- ArrayList file_list = new ArrayList();
- String mkdir_cmds = "make install" + line_sep; //$NON-NLS-1$
-
- String make_cmd = "(cd " + tar_path + line_sep + usr_make_cmd + line_sep; //$NON-NLS-1$
-
- // Build the project to generate the binaries
- try {
- LinuxShellCmds.createLinuxShellScript(make_cmd, rpmbuild_logname, rpm_shell);
- LinuxShellCmds.executeLinuxCommand(rpm_shell, 0);
- } catch (CoreException e) {
- String throw_message = Messages.getString(
- "RPMCore.Problem_running_the___make___file_to_create_the_executables._nView_the_log_file_at__249") + //$NON-NLS-1$
- rpmbuild_logname;
- IStatus error = new Status(IStatus.ERROR, Error, 1, throw_message,
- null);
- throw new CoreException(error);
- }
- String user_work_area = RPMCorePlugin.getDefault().getPreferenceStore()
- .getString("IRpmConstants.USER_WORK_AREA"); //$NON_NLS-1$
- String build_root_path = user_wksp + user_work_area + file_sep +
- proj_dir + "-root"; //$NON-NLS-1$
-
- /* Now run the 'make install' to install the files into the directory structure
- * so we can get a list of them and the directories they go into.
- */
-
- String make_inst_cmd = "export RPM_BUILD_ROOT=" + //$NON-NLS-1$
- build_root_path + line_sep + mkdir_cmds;
-
- try {
- LinuxShellCmds.createLinuxShellScript("cd " + tar_path + line_sep + make_inst_cmd, rpmbuild_logname, //$NON-NLS-1$
- rpm_shell);
- LinuxShellCmds.executeLinuxCommand(rpm_shell, 0);
- } catch (CoreException e) {
- String throw_message = Messages.getString(
- "RPMCore.Problem_running_the___make_install___shell_script_--__273") + //$NON-NLS-1$
- rpm_shell +
- Messages.getString(
- "RPMCore._nThere_may_be_a_problem_in_the_M/makefile._274"); //$NON-NLS-1$
- IStatus error = new Status(IStatus.ERROR, Error, 1, throw_message,
- null);
- throw new CoreException(error);
- }
-
- /* Now traverse the "build root" directory to find all of the files installed by
- * the "make install" above. This file list will be used to populate the "%files"
- * section of the spec file.
- */
- traverse(new File(build_root_path), build_root_path, file_list);
-
- /* See if there are any files in file_lst, if not, we probably have an error in the install: section
- * of the Makefile/makefile.
- */
- if (file_list.size() == 0) {
- String throw_message = Messages.getString(
- "RPMCore.No_files_were_found_under_build_root_--__276") + //$NON-NLS-1$
- build_root_path +
- Messages.getString(
- "RPMCore._n_--_Problem_with_the___install____section_of_the_spec_file__277"); //$NON-NLS-1$
- IStatus error = new Status(IStatus.ERROR, Error, 1, throw_message,
- null);
- throw new CoreException(error);
- }
-
- // If there is a configure script, put in a %configure
- String configure = ""; //$NON-NLS-1$
-
- if (LinuxShellCmds.checkForConfigure(proj_path)) {
- configure = "%configure" + line_sep; //$NON-NLS-1$
- }
-
- // Set up date for "%changelog" entry
- SimpleDateFormat df = new SimpleDateFormat("E MMM dd yyyy"); //$NON-NLS-1$
-
- // PatchChangeLogStamp.setText("* " + df.format(today)+ " -- YourName" +" ");
- // Now set up to build the RPM spec file
- String is =
- "%define _unpackaged_files_terminate_build 0" + line_sep + //$NON-NLS-1$
- "Summary: None - Eclipse-generated spec file" + line_sep + "Name: " + //$NON-NLS-1$ //$NON-NLS-2$
- proj_dir + "" + line_sep + "Version: " + rpm_version + "" + line_sep + "Release: " + //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$
- rpm_release + "" + line_sep + "License: GPL" + line_sep + //$NON-NLS-1$ //$NON-NLS-2$
- "Group: Applications/Internet" + line_sep + "Source: " + proj_dir + "-" + //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
- "%{version}.tar.bz2" + line_sep + "Requires: tar" + line_sep + "BuildRoot: " + //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
- "%{_tmppath}/%{name}-root" + line_sep + //$NON-NLS-1$
- "%description" + line_sep + line_sep + //$NON-NLS-1$
- "Basic spec file for rpm build in Eclipse for " + proj_dir + //$NON-NLS-1$
- line_sep + line_sep + "%prep" + line_sep + "%setup -q" + line_sep + "%build" + line_sep + line_sep + configure + //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
- "make" + line_sep + line_sep + "%install rm -rf $RPM_BUILD_ROOT" + line_sep +
- "%makeinstall RPM_BUILD_ROOT=$RPM_BUILD_ROOT" + line_sep + "%clean" + line_sep + //$NON-NLS-1$ //$NON-NLS-2$
- "rm -rf $RPM_BUILD_ROOT" + line_sep + "%files" + line_sep + //$NON-NLS-1$ //$NON-NLS-2$
- "%defattr(-,root,root)" + line_sep; //$NON-NLS-1$
-
- // Convert the ArrayList file_list to an array of strings and append to the spec file
- String[] lines = new String[file_list.size()];
- file_list.toArray(lines);
-
- for (int i = 0; i < lines.length; i++) {
- /* The following marked code is a hack to get around a problem of the ".gz" being
- * dropped from some document file names that belong in /usr/share/man. I'm not sure
- * why docs whose names are of the form "xxxx.8.gz" are returned from the "traverse
- * method as "xxxx.8". Is there a problem with having two periods in the name with java
- * for some reason? Using the find command from a shell returns the correct names.
- * When the exact same find command is embedded in java code and fired off as a shell
- * script, again the ".gz" gets lost. I was hoping to solve the problem with the "traverse"
- * method, but it has the same problem which leads me to believe it is a java-related
- * problem. I must move on now, but this hack can be removed if this mystery is solved.
- *
- * ************* Beginning of hack ************************************/
- int k = lines[i].length() - 2;
- char last_char = lines[i].charAt(k);
-
- if (Character.isDigit(last_char) &
- (lines[i].lastIndexOf(file_sep + "man" + file_sep) != -1)) { //$NON-NLS-1$
- lines[i] = lines[i].substring(0, k + 1) + ".gz" + line_sep; //$NON-NLS-1$
- }
-
- /* ************ End of hack *****************************************/
- is = is + lines[i];
- }
- Date today = new Date();
- is = is + "%changelog" + line_sep + "* " + returnDate() +
- " " + author_name + " <" + //$NON-NLS-1$ //$NON-NLS-2$
- author_email + ">" + line_sep + "- Original" + line_sep; //$NON-NLS-1$ //$NON-NLS-2$
-
- byte[] buf = is.getBytes();
-
- /* Read the input stream and try to create the spec file to be used by
- * the rpmbuild process */
- try {
- BufferedOutputStream os =
- new BufferedOutputStream(new FileOutputStream(path_to_specfile));
-
- for (int i = 0; i < buf.length; i++) {
- os.write(buf[i]);
- }
-
- os.close();
- } catch (Exception e) {
- String throw_message = Messages.getString(
- "RPMCore.Problem_creating_spec_file.__Check_permissions_in__324") + //$NON-NLS-1$
- rpmdirs_path;
- IStatus error = new Status(IStatus.ERROR, Error, 1, throw_message,
- null);
- throw new CoreException(error);
- }
-
- return true;
- }
-
- /**
- * Method traverse.
- * This method traverses a directory tree beginning at the path passed
- * to it and builds an array of file names contained in that tree. This list
- * of files is used to populate the "%files" section of the spec file.
- * @param dir - A file that points to the directory where the traversing
- * is to begin
- * @param build_root_path is the path to the rpm build root directory
- * @param file_list is an ArrayList of strings containing paths to what files were
- * installed by the "make install" command
- * @return - If the file_lst[[] array is empty upon return there is a problem
- * probably in the "install" section of the M/makefile
- */
- private void traverse(File dir, String build_root_path, ArrayList file_list) {
- if (debug) {
- System.out.println("--traverse"); //$NON-NLS-1$
- }
-
- int file_ctr;
-
- if (dir.isDirectory()) {
- String[] children = dir.list();
-
- for (int i = 0; i < children.length; i++) {
- File temp = new File(dir, children[i]);
-
- if (temp.isDirectory()) {
- traverse(temp, build_root_path, file_list);
- } else {
- String tmp_name = temp.getAbsolutePath();
- file_list.add(tmp_name.substring(build_root_path.length()) + line_sep);
-
- if (debug) {
- file_ctr = file_list.size() - 1;
- System.out.println(" file_lst[" + file_ctr + "] = " + //$NON-NLS-1$ //$NON-NLS-2$
- file_list.get(file_ctr));
- }
- }
- }
- }
- }
-
- /**
- * Method getHostName gets the name of the host to use as part of the
- * e-mail address for the chnagelog.
- * @return String containing the name of the host, "" if error
- */
- private String getHostName()
- {
- String hostname;
- try {
- hostname = java.net.InetAddress.getLocalHost().getHostName();
- } catch (UnknownHostException e) {
- return "";
- }
- // Trim off superflous stuff from the hostname
- int firstdot = hostname.indexOf(".");
- int lastdot = hostname.lastIndexOf(".");
- // If the two are equal, no need to trim name
- if (firstdot == lastdot) {
- return hostname;
- }
- String hosttemp = "";
- String hosttemp2 = hostname;
- while (firstdot != lastdot) {
- hosttemp = hosttemp2.substring(lastdot) + hosttemp;
- hosttemp2 = hostname.substring(0,lastdot);
- lastdot = hosttemp2.lastIndexOf(".");
- }
- return hosttemp.substring(1);
- }
-
- /**
- * Method returnDate returns the type of date requested by the user.
- * @return String containing the date in the requested format
- */
- private String returnDate() {
- SimpleDateFormat date_Format;
- date_Format = new SimpleDateFormat("E MMM dd yyyy"); //$NON-NLS-1$
- return date_Format.format(new Date());
- }
-
-
-}
Index: src/org/eclipse/cdt/rpm/core/StreamReaderThread.java
===================================================================
RCS file: src/org/eclipse/cdt/rpm/core/StreamReaderThread.java
diff -N src/org/eclipse/cdt/rpm/core/StreamReaderThread.java
--- src/org/eclipse/cdt/rpm/core/StreamReaderThread.java 8 Nov 2004 21:30:12 -0000 1.1
+++ /dev/null 1 Jan 1970 00:00:00 -0000
@@ -1,29 +0,0 @@
-package org.eclipse.cdt.rpm.core;
-
-import java.io.InputStreamReader;
-import java.io.InputStream;
-
-public class StreamReaderThread extends Thread
-{
- StringBuffer mOut;
- InputStreamReader mIn;
-
- public StreamReaderThread(InputStream in, StringBuffer out)
- {
- mOut=out;
- mIn=new InputStreamReader(in);
- }
-
- public void run()
- {
- int ch;
- try {
- while(-1 != (ch=mIn.read()))
- mOut.append((char)ch);
- }
- catch (Exception e)
- {
- mOut.append("\nRead error:"+e.getMessage());
- }
- }
-}
Index: src/org/eclipse/cdt/rpm/core/TarOps.java
===================================================================
RCS file: src/org/eclipse/cdt/rpm/core/TarOps.java
diff -N src/org/eclipse/cdt/rpm/core/TarOps.java
--- src/org/eclipse/cdt/rpm/core/TarOps.java 8 Nov 2004 21:30:12 -0000 1.2
+++ /dev/null 1 Jan 1970 00:00:00 -0000
@@ -1,292 +0,0 @@
-/*
- * (c) 2004 Red Hat, Inc.
- *
- * This program is open source software licensed under the
- * Eclipse Public License ver. 1
- */
-package org.eclipse.cdt.rpm.core;
-
-import org.eclipse.core.runtime.CoreException;
-import org.eclipse.core.runtime.IStatus;
-import org.eclipse.core.runtime.Status;
-
-import java.io.*;
-/**
- *This class is used to interface with the Linux "tar" command when
- *manipulating rpm's
- */
-public class TarOps {
-
-// When debug is set to true, lots of debug statements are printed.
- private static final boolean debug = false;
- private static final String Error = Messages.getString("RPMCore.Error_1"); //$NON-NLS-1$
- private static final String file_sep = System.getProperty("file.separator"); //$NON-NLS-1$
- private static final String line_sep = System.getProperty("line.separator"); //$NON-NLS-1$
-
- private String usr_tar_cmd = RPMCorePlugin.getDefault().getPreferenceStore().getString("IRpmConstants.TAR_CMD"); //$NON_NLS-1$
- private String rpmdirs_path;
- private String proj_path;
-
- public TarOps (String c_proj_path, String c_rpmdirs_path)
- throws CoreException {
-
- proj_path = c_proj_path;
- rpmdirs_path = c_rpmdirs_path;
-
- }
-
- /**
- * Method untarSource.
- * This method is called when the source RPM being imported and the developer does
- * not want patches applied to the source code.
- * @return void if OK, throws CoreException if error occurs
- * @throws CoreException
- */
- public boolean untarSource(String tarball_path, String rpmbuild_logname,
- String rpm_shell) throws CoreException {
- if (debug) {
- System.out.println("untarSource"); //$NON-NLS-1$
- }
-
- String tarball_type = null;
- String from_path;
-
- // Get a list of files in the SOURCES directory
- File tarball = new File(tarball_path);
-
- // See what the tarball ends with to see which compression we need
- if (tarball_path.endsWith(".gz")) { //$NON-NLS-1$
- tarball_type = "z"; //$NON-NLS-1$
- } else if (tarball_path.endsWith(".bz2")) { //$NON-NLS-1$
- tarball_type = "j"; //$NON-NLS-1$
- } else if (tarball_path.endsWith(".tar")) { //$NON-NLS-1$
- tarball_type = ""; //$NON-NLS-1$
- } else {
- return false;
- }
-
- // change to the directory and untar it, first get the path to the tarball
- int j = tarball_path.lastIndexOf(file_sep);
- String tar_path = tarball_path.substring(0,j);
- // now get the name of the tarball
- String tarball_name = tarball_path.substring(j+1);
- String tar_cmd = "cd " + tar_path + line_sep + usr_tar_cmd + " x" + //$NON-NLS-1$ //$NON-NLS-2$
- tarball_type + "f " + tarball_name; //$NON-NLS-1$
-
- try {
- LinuxShellCmds.createLinuxShellScript(tar_cmd, rpmbuild_logname, rpm_shell);
- LinuxShellCmds.executeLinuxCommand(rpm_shell, 0);
- } catch (CoreException e) {
- String throw_message = e.getMessage();
- IStatus error = new Status(IStatus.ERROR, Error, 1,
- throw_message, null);
- throw new CoreException(error);
- }
-
- return true;
- }
-
- /**
- * The method takes care of renaming the source tarball in the SOURCES
- * directory of the temporary RPM work area. Usually the source tarball
- * is named of the form: packagename-version#.tar.gz/bz2. When the
- * version number changes both the name of the tarball needs to change
- * and the directory it creates (which is also usually of the format
- * packagename-version). The problem is that sometimes the
- * "make clean/make dist-clean/make maintainer-clean does not totally
- * remove files created by the auto* tools. To get around this we use the
- * original tarball from the source RPM. We untar it, rename the directory
- * it creates and then re-tar it with the new name.
- * @param rpm_name - contains a string with the rpm name
- * @param rpmbuild_logname - string pointing to the file where errors are being logged
- * @param rpm_shell - string to use for creating a Linux shell script
- * @param rpm_version - string containing the version of the rpm
- * @param prev_ver_no - string with the previous version number of the rpm
- * @return true if successful, throw CoreException if not
- * @throws CoreException
- */
- public boolean renameRPMtarfile(String rpm_name, String rpmbuild_logname,
- String rpm_shell, String rpm_version, String prev_ver_no) throws CoreException {
- if (debug) {
- System.out.println("renameRPMtarfile"); //$NON-NLS-1$
- }
-
- String source_dir = rpmdirs_path + file_sep +"SOURCES" + file_sep; //$NON-NLS-1$
- String tarball_name = ""; //$NON-NLS-1$
- String tar_cmd_opt = ""; //$NON-NLS-1$
- String tar_extension = ""; //$NON-NLS-1$
- File f = new File(source_dir);
- String[] dirlist = f.list();
-
-
-// Get the name of the current tarball
-loop:
- for (int i = 0; i < dirlist.length; i++) {
- if (dirlist[i].length() > rpm_name.length()) {
- String temp = dirlist[i].substring(0, rpm_name.length());
-
- if (temp.equals(rpm_name)) {
- if (dirlist[i].endsWith(".tar.bz2")) { //$NON-NLS-1$
- tarball_name = dirlist[i];
- tar_cmd_opt = "j"; //$NON-NLS-1$
- tar_extension = ".tar.bz2"; //$NON-NLS-1$
-
- break loop;
- } else if (dirlist[i].endsWith(".tar.gz")) { //$NON-NLS-1$
- tarball_name = dirlist[i];
- tar_cmd_opt = "z"; //$NON-NLS-1$
- tar_extension = ".tar.gz"; //$NON-NLS-1$
-
- break loop;
- }
- }
- }
- }
-
- // If tar_cmd_opt did not get set, we did not find a tarball
- if (tar_cmd_opt.equals("")) { //$NON-NLS-1$
-
- String throw_message = Messages.getString(
- "RPMCore.Cannot_find_source_tarball_in__644") + //$NON-NLS-1$
- source_dir;
- IStatus error = new Status(IStatus.ERROR, Error, 1, throw_message,
- null);
- throw new CoreException(error);
- }
-
- // Set up to untar the source tarball
- String tar_cmd = "cd " + source_dir + line_sep + usr_tar_cmd + " -x" + tar_cmd_opt + //$NON-NLS-1$ //$NON-NLS-2$
- "f " + tarball_name; //$NON-NLS-1$
-
- try {
- LinuxShellCmds.createLinuxShellScript(tar_cmd, rpmbuild_logname, rpm_shell);
- LinuxShellCmds.executeLinuxCommand(rpm_shell, 0);
- } catch (CoreException e) {
- String throw_message = Messages.getString(
- "RPMCore.Error_trying_to_extract_the_source_tarball_using_this_command_--__652") + //$NON-NLS-1$
- tar_cmd;
- IStatus error = new Status(IStatus.ERROR, Error, 1, throw_message,
- null);
- throw new CoreException(error);
- }
-
- File f1 = new File(source_dir + rpm_name + "-" + prev_ver_no); //$NON-NLS-1$
-
- if (f1.exists() & f1.isDirectory()) {
- File f2 = new File(source_dir + rpm_name + "-" + rpm_version); //$NON-NLS-1$
-
- if (!f2.exists()) {
- if (!f1.renameTo(f2)) {
- String throw_message = Messages.getString(
- "RPMCore.Error_trying_to_rename_directory__656") + //$NON-NLS-1$
- f1 + Messages.getString("RPMCore._to__") + f2; //$NON-NLS-1$
- IStatus error = new Status(IStatus.ERROR, Error, 1,
- throw_message, null);
- throw new CoreException(error);
- } else {
- tar_cmd = usr_tar_cmd + " -C " + source_dir + " -c" + //$NON-NLS-1$ //$NON-NLS-2$
- tar_cmd_opt + "f " + source_dir + rpm_name + "-" + //$NON-NLS-1$ //$NON-NLS-2$
- rpm_version + tar_extension + " ." + file_sep + rpm_name + //$NON-NLS-1$
- "-" + rpm_version; //$NON-NLS-1$
-
- try {
- LinuxShellCmds.executeLinuxCommand(tar_cmd, 0);
- } catch (CoreException e) {
- String throw_message = Messages.getString(
- "RPMCore.Error_trying_to_create_a_new_source_tarball_using_this_command_--__665") + //$NON-NLS-1$
- tar_cmd;
- IStatus error = new Status(IStatus.ERROR, Error, 1,
- throw_message, null);
- throw new CoreException(error);
- }
- }
- }
- }
-
- return true;
- }
-
- /**
- * Method createRPMtarfile
- * This method creates a tar file from a source directory in the RPM work area
- * under the "/BUILD" directory and puts it in the "/SOURCES" directory for use
- * by the "rpmbuild" command when it creates either a source or binary RPM.
- * @param rpm_name - string with the name of the rpm
- * @param rpm_version - string with the rpm verison number
- * @param path_to_specfile - string with a path to the specfile
- * @return returns true if successful, else it throws a CoreException
- * @throws CoreException
- */
- public boolean createRPMtarfile(String rpm_name, String rpm_version,
- String path_to_specfile)
- throws CoreException {
- if (debug) {
- System.out.println("createRPMtarfile"); //$NON-NLS-1$
- }
-
- String tar_compression;
- String tar_suffix;
- String rpm_new_name = rpm_name + "-" + rpm_version; //$NON-NLS-1$
- // Figure out what the directory name is under "/BUILD" in the workarea is
- File f = new File(rpmdirs_path + file_sep + "BUILD"); //$NON-NLS-1$
- String[] dirlist = f.list();
- if (dirlist.length != 1) {
- String throw_message = Messages.getString(
- "RPMCore.There_are_too_many_directories_in__432") + //$NON-NLS-1$
- rpmdirs_path + file_sep + "BUILD"; //$NON-NLS-1$
- IStatus error = new Status(IStatus.ERROR,
- Error, 1, throw_message, null);
- throw new CoreException(error);
- }
-
- if (!dirlist[0].equals(rpm_new_name)) {
- File f1 = new File(rpmdirs_path + file_sep + "BUILD" + file_sep + dirlist[0]); //$NON-NLS-1$
-
- if (!f1.renameTo(new File(rpmdirs_path + file_sep + "BUILD" + file_sep + rpm_new_name))) { //$NON-NLS-1$
-
- String throw_message = Messages.getString(
- "RPMCore.Error_trying_to_rename_directory_in__438") + //$NON-NLS-1$
- rpmdirs_path + file_sep + "BUILD" + line_sep + //$NON-NLS-1$
- Messages.getString(
- "RPMCore.Permissions_problem__440"); //$NON-NLS-1$
- IStatus error = new Status(IStatus.ERROR, Error, 1,
- throw_message, null);
- throw new CoreException(error);
- }
- }
-
- // compression we need for the tar file, gzip or bzip2
- try {
- tar_suffix = LinuxShellCmds.checkCompression(path_to_specfile);
- } catch (CoreException e) {
- String throw_message = e.getMessage();
- IStatus error = new Status(IStatus.ERROR, Error, 1,
- throw_message, null);
- throw new CoreException(error);
- }
-
- if (tar_suffix.equals(".bz2")) { //$NON-NLS-1$
- tar_compression = "j"; //$NON-NLS-1$
- } else {
- tar_compression = "z"; //$NON-NLS-1$
- }
-
- String tar_cmd = usr_tar_cmd + " -C " + rpmdirs_path + file_sep + "BUILD" + " -c" + //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
- tar_compression + "f " + rpmdirs_path + file_sep + "SOURCES" + file_sep + rpm_new_name + //$NON-NLS-1$ //$NON-NLS-2$
- ".tar" + tar_suffix + " ." + file_sep + rpm_new_name; //$NON-NLS-1$ //$NON-NLS-2$
-
- try {
- LinuxShellCmds.executeLinuxCommand(tar_cmd, 0);
- } catch (CoreException e) {
- String throw_message = Messages.getString(
- "RPMCore.Error_trying_to_create_a_tarball_of_the_source_using_this_command_--__454") + //$NON-NLS-1$
- tar_cmd;
- IStatus error = new Status(IStatus.ERROR, Error, 1, throw_message,
- null);
- throw new CoreException(error);
- }
-
- return true;
- }
-
-}
Index: src/org/eclipse/cdt/rpm/core/rpm_strings.properties
===================================================================
RCS file: src/org/eclipse/cdt/rpm/core/rpm_strings.properties
diff -N src/org/eclipse/cdt/rpm/core/rpm_strings.properties
--- src/org/eclipse/cdt/rpm/core/rpm_strings.properties 14 Dec 2004 20:17:36 -0000 1.3
+++ /dev/null 1 Jan 1970 00:00:00 -0000
@@ -1,216 +0,0 @@
-###############################################################################
-# (c) 2004 Red Hat, Inc.
-#
-# This program is open source software licensed under the
-# Eclipse Public License ver. 1
-#
-###############################################################################
-
-RPMCore.Error=Error
-RPMCore.Error_trying_to_copy__=Error trying to copy
-RPMCore._to__=\ to
-RPMCore.--executeRPMlinux_command__95=--executeRPMlinux_command:
-RPMCore.Error_executing__97=Error executing
-RPMCore.Error_waiting_for__99=Error waiting for
-RPMCore._to_complete._100=\ to complete.
-RPMCore.Command__102=Command
-RPMCore._was_interrupted._103=\ was interrupted.
-RPMCore.The_patch_name__109=The patch name
-RPMCore._is_not_unique._110=\ is not unique.
-RPMCore._nPlease_modify_the___Patch_tag___field_and_try_again._111=\nPlease modify the \'Patch tag\' field and try again.
-RPMCore.Error_trying_to_parse_spec_file_113=Error trying to parse spec file\nMaybe a character encoding error?
-RPMCore._nIs_there_a_spec_file_at___114=\nIs there a spec file at:
-RPMCore.Failed_to_open_the_output_spec_file_at__123=Failed to open the output spec file at
-RPMCore.Error_trying_to_modify__132=Error trying to modify
-RPMCore.Error_parsing_the_spec_file_in_the_project_--_157=Error parsing the spec file in the project --
-RPMCore.Failed_to_find_a___install__or___clean____section_in_the__180=Failed to find a \'install: or \'clean:\' section in the
-RPMCore.project__s_M/makefile.__THIS_IS_REQUIRED_!_!_!_181=project\'s M/makefile. THIS IS REQUIRED\!\!\!
-RPMCore.I/O_error_processing/reading_the_M/makefile__183=I/O error processing/reading the M/makefile
-RPMCore.Failed_to_find_a_M/makefile_in_the_project.___THIS_IS_REQUIRED_!_!_!_185=Failed to find a M/makefile in the project. THIS IS REQUIRED\!\!\!
-RPMCore.Failed_to_create_RPM_directories,_check_file_permissions_in__195=Failed to create RPM directories, check file permissions in
-RPMCore.Failed_to_create_RPM_directories_in__203=Failed to create RPM directories in
-RPMCore._--_check_file_permissions._204=\ -- check file permissions.
-RPMCore.Error_executing__208=Error executing
-RPMCore.command._nSomething_is_wrong_with_file_permissions._209=command.\nSomething is wrong with file permissions.
-RPMCore.Problem_creating_the_.rpmrc_file.__Check_file_permissions_in__217=Problem creating the .rpmrc file. Check file permissions in
-RPMCore.Problem_creating_the_.rpmmacros_file._nCheck_file_permissions_in__226=Problem creating the .rpmmacros file.\nCheck file permissions in
-RPMCore.Problem_creating_the_.rpmmacros_file._nCheck_file_permissions_in__228=Problem creating the .rpmmacros file.\nCheck file permissions in
-RPMCore.Problem_creating_the_rpm_spec_file._nCheck_file_permissions_in__247=Problem creating the rpm spec file.\nCheck file permissions in
-RPMCore.Problem_running_the___make___file_to_create_the_executables._nView_the_log_file_at__249=Problem running the \'make\' file to create the executables.\nView the log file at
-RPMCore.Problem_creating_the___make_install___shell_script_--___rpmbuild.sh__.___270=Problem creating the \'make install\' shell script -- \'rpmbuild.sh\'.
-RPMCore._nCheck_file_permissions_in__271=\nCheck file permissions in
-RPMCore.Problem_running_the___make_install___shell_script_--__273=Problem running the \'make install\' shell script --
-RPMCore._nThere_may_be_a_problem_in_the_M/makefile._274=\nThere may be a problem in the M/makefile.
-RPMCore.No_files_were_found_under_build_root_--__276=No files were found under build root --
-RPMCore._n_--_Problem_with_the___install____section_of_the_spec_file__277=\n -- Problem with the \'install:\' section of the spec file?
-RPMCore.Problem_creating_spec_file.__Check_permissions_in__324=Problem creating spec file. Check permissions in
-RPMCore.Problem_creating_spec_file.__Check_permissions_in__326=Problem creating spec file. Check permissions in
-RPMCore.source_328=source
-RPMCore.Error_executing___make_clean___in__329=Error executing \'make clean\' in
-RPMCore.Problem_creating_a_shell_script_--__342=Problem creating a shell script --
-RPMCore._nThere_may_be_a_problem_in_the_M/makefile._343=\nThere may be a problem in the M/makefile.
-RPMCore.Problem_running_this_command___346=Problem running this command:
-RPMCore._nCheck_permissions._347=\nCheck permissions.
-RPMCore.Error_trying_to_create_shell_script_to_install__352=Error trying to create shell script to install
-RPMCore.the_source_rpm._nCheck_the_file_permissions_in__353=the source rpm.\nCheck the file permissions in
-RPMCore.Error_trying_to_install_the_source_with_this_command__355=Error trying to install the source with this command
-RPMCore._nCheck_the_log_at__356=\nCheck the log at
-RPMCore./SPECS/_359=/SPECS/
-RPMCore.There_is_not_a__360=There is not a
-RPMCore._directory._nCheck_permissions_in_the_path_directories._361=\ directory.\nCheck permissions in the path directories.
-RPMCore.An_error_in_the__364=An error in the
-RPMCore.directory._nEither_there_is_either_no_spec_file_or_more_than_one._365=directory.\nEither there is either no spec file or more than one.
-RPMCore.There_are_either_no_directories_or_too_many_directories_under__369=There are either no directories or too many directories under
-RPMCore.An_error_occurred_trying_to_rename__373=An error occurred trying to rename
-RPMCore.Error_creating_shell_script_for_the__381=Error creating shell script for the
-RPMCore._nCheck_file_permissions._382=\nCheck file permissions.
-RPMCore.Error_executing_the_command_to_build_prep_the_rpm_-__384=Error executing the command to build prep the rpm -
-RPMCore._nCheck_the_log_at__385=\nCheck the log at
-RPMCore.There_should_be_only_one_directory_under__391=There should be only one directory under
-RPMCore._at_this_point_392=\ at this point
-RPMCore.This_file_already_exists___396=This file already exists:
-RPMCore.Error_trying_to_create_.srpminfo_file._401=Error trying to create .srpminfo file.
-RPMCore.Problem_copying_source_rpm_info_file._nCheck_permissions_in__409=Problem copying source rpm info file.\nCheck permissions in
-RPMCore.Problem_copying_source_rpm_info_file._nCheck_permissions_in__411=Problem copying source rpm info file.\nCheck permissions in
-RPMCore.Error_trying_to_copy_the_target_project_directory_tree_with_this_command_--__417=Error trying to copy the target project directory tree with this command --
-RPMCore._nFile_permissions_problem__418=\nFile permissions problem?
-RPMCore.Error_trying_to_check_for_Makefile_in__421=Error trying to check for Makefile in
-RPMCore.Error_--_the_M/makefile_does_not_have_either_an___install____or___clean_____423=Error -- the M/makefile does not have either an \'install:\' or \'clean:\'
-RPMCore.section._nLook_in_this_directory_____424=section.\nLook in this directory:
-RPMCore.Error_running___make_clean___in__426=Error running \'make clean\' in
-RPMCore.Error_either_creating_or_executing_the___make_clean___command_in__428=Error either creating or executing the \'make clean\' command in
-RPMCore.There_are_too_many_directories_in__432=There are too many directories in
-RPMCore.Error_trying_to_rename_directory_in__438=Error trying to rename directory in
-RPMCore.Permissions_problem__440=Permissions problem?
-RPMCore.Error_trying_to_parse_spec_file_442=Error trying to parse spec file
-RPMCore._nIs_there_a_spec_file_at___443=\nIs there a spec file at:
-RPMCore.Error_trying_to_create_a_tarball_of_the_source_using_this_command_--__454=Error trying to create a tarball of the source using this command --
-RPMCore.A_problem_occurred_creating_the_rpmbuild_shell_script.___461=A problem occurred creating the rpmbuild shell script.
-RPMCore._nPlease_check_the_file_permissions_in_/var/tmp__462=\nPlease check the file permissions in /var/tmp
-RPMCore.A_problem_occurred_running_this_command.___464=A problem occurred running this command.
-RPMCore.__nPlease_review_the_log_at__465=\ \nPlease review the log at\nWindows->Show View->Other...->RPM Plugin Log File->RPM Plugin Log Viewer
-RPMCore.There_should_be_only_one_directory_under__467=There should be only one directory under
-RPMCore.__nCheck_the_directories_there.__The_RPM_work_area_in_/var/tmp_will_be_preserved._468=\ \nCheck the directories there. The RPM work area in /var/tmp will be preserved.
-RPMCore.Error_trying_to_delete__477=Error trying to delete
-RPMCore._nCheck_permissions._478=\nCheck permissions.
-RPMCore.Error_deleting_resources.__Check_file_permissions_in__483=Error deleting resources. Check file permissions in
-RPMCore.Problem_deleting_the_log_file_at__486=Problem deleting the log file at
-RPMCore.__Check_the_permissions._487=\ \ Check the permissions.
-RPMCore.Error_deleting_files_in_deleteSRPMextrafiles_496=Error deleting files in deleteSRPMextrafiles
-RPMCore.Error_deleting_files_in_deleteSRPMextrafiles_498=Error deleting files in deleteSRPMextrafiles
-RPMCore.executeProjConfigure_500=executeProjConfigure
-RPMCore./bin/chmod_-R_u+r__501=/bin/chmod -R u+r
-RPMCore./_502=/
-RPMCore.Error_executing_the_command__503=Error executing the command
-RPMCore.__Check_permissions_of__504=\ \ Check permissions of
-RPMCore.Problem_creating_the___make_clean/distclean/maintainer-clean___shell_script_--__515=Problem creating the \'make clean/distclean/maintainer-clean\' shell script --
-RPMCore._nThere_may_be_a_problem_in_the_M/makefile._516=\nThere may be a problem in the M/makefile.
-RPMCore.Problem_running_the___make_install___shell_script_--__518=Problem running the \'make install\' shell script --
-RPMCore._nThere_may_be_a_problem_in_the_M/makefile._519=\nThere may be a problem in the M/makefile.
-RPMCore.Problem_deleting_extra_files_from_project_in_deleteSRPMextrafiles_521=Problem deleting extra files from project in deleteSRPMextrafiles
-RPMCore.Problem_deleting_extra_files_in_the_project_in_deleteEclipseiles._523=Problem deleting extra files in the project in deleteEclipseiles.
-RPMCore.There_should_only_be_two_directories_in__531=There should only be two directories in
-RPMCore.Error_executing_the_command__538=Error executing the command
-RPMCore.__Check_permissions_of__539=\ \ Check permissions of
-RPMCore.Error_in_the_Makefile_in__541=Error in the Makefile in
-RPMCore._nMake_sure_there_is_a_clean_/distclean_/realclean_section__542=\nMake sure there is a clean:/distclean:/realclean section:
-RPMCore.Error_running_the___make_distclean/realclean/mainainer-clean____544=Error running the \'make distclean/realclean/maintainer-clean\'
-RPMCore.command_on_the_previous_source_RPM_545=command on the previous source RPM
-RPMCore.Error_creating_shell_script_for_the__553=Error creating shell script for the
-RPMCore._nCheck_file_permissions._554=\nCheck file permissions.
-RPMCore.Error_executing_the_command_to_create_the_patch_file_-__558=Error executing the command to create the patch file -
-RPMCore._nAre_you_sure_there_were_changes_made_to_the_project__559=\nAre you sure there were changes made to the project?
-RPMCore.rpm_spec_should_not_be_null_here_in__567=rpm_spec should not be null here in
-RPMCore.A_problem_occurred_creating_the_rpmbuild_shell_script.___571=A problem occurred creating the rpmbuild shell script.
-RPMCore._nPlease_check_the_file_permissions_in_/var/tmp__572=\nPlease check the file permissions in /var/tmp
-RPMCore.A_problem_occurred_running_this_command.___574=A problem occurred running this command.
-RPMCore._nPlease_review_the_log_at__575=\nPlease review the log at\nWindows->Show View->Other...->RPM Plugin Log File->RPM Plugin Log Viewer
-RPMCore.There_are_too_many_directories_in__577=There are too many directories in
-RPMCore.Unable_to_delete_file__582=Unable to delete file
-RPMCore._nCheck_permissions_in_the_project._583=\nCheck permissions in the project.
-RPMCore.Error_returned_from_firstSRPM_trying__588=Error returned from firstSRPM() trying
-RPMCore.to_copy_the_spec_file_from_the_work_area_to_the_project_589=to copy the spec file from the work area to the project
-RPMCore.Error_trying_to_rename__591=Error trying to rename
-RPMCore.Error_trying_to_create_.srpminfo_file._594=Error trying to create .srpminfo file.
-RPMCore.Error_trying_to_copy_spec_file_from_work__598=Error trying to copy spec file from work
-RPMCore.area_to_Eclipse_project_directory_599=area to Eclipse project directory
-RPMCore.Error_copying_directories_in__1=Error copying directories in
-RPMCore.Error_trying_to_copy_project_directory(_3=Error trying to copy project directory(
-RPMCore.)_to_the_work_area(_4=) to the work area(
-RPMCore.Error_trying_to_write_to__8=Error trying to write to
-RPMCore.Error_1=Error
-RPMCore.Error_6=Error
-RPMCore.Error_8=Error
-RPMCore.Error_creating_directory___18=Error creating directory:
-RPMCore._nCheck_permissions__19=\nCheck permissions?
-RPMCore.Error_copying_project_source_from__20=Error copying project source from
-RPMCore._to__21=\ to
-RPMCore.Error_creating_the_shell_script_to_untar_or__22=Error creating the shell script to untar or
-RPMCore.executing_the_shell_script_to_untar_the_source._Command____23=executing the shell script to untar the source. Command =
-RPMCore.Error_copying_source_from__24=Error copying source from
-RPMCore._to__25=\ to
-RPMCore.__26=\
-RPMCore.0=generateChecksum: Error trying to access file:
-RPMCore.Error_trying_to_copy_file__27=Error trying to copy file
-RPMCore._to__28=\ to
-RPMCore.Error_trying_to_set_up_rpm__29=Error trying to set up rpm
-RPMCore.in__30=in
-RPMCore._to_create_patches_31=\ to create patches
-RPMCore.Checksum___32=Checksum:
-RPMCore.Error_parsing_spec_file_at__33=Error parsing spec file at
-RPMCore.Error_either_creating_or_running_configure_script_34=Error either creating or running configure script
-RPMCore.RPMCore._to__7_35=RPMCore._to__7
-RPMCore.Error_36=Error
-RPMCore.Error_37=Error
-RPMCore.Error_39=Error
-RPMCore.Error_40=Error
-RPMCore.Error_47=Error
-RPMCore.An_error_occurred_either_creating_the_shell_script_containing_2=An error occurred either creating the shell script containing
-RPMCore.this_command____3=this command:\n
-RPMCore._nor_trying_to_execute_it._nView_the_log_at___4=\nor trying to execute it.\nView the log at:
-RPMCore._for_more_details_5=\ for more details
-RPMCore.Error_1=Error
-RPMCore.There_is_not_a_.srpminfo_file_in__7=There is not a .srpminfo file in
-RPMCore.There_is_no_longer_a_source_RPM_at__86=There is no longer a source RPM at
-RPMCore.Error_getting_info_from__93=Error getting info from
-RPMCore.Error_during__191=Error during
-RPMCore._execution..error____192=\ execution..error =
-RPMCore.Error_trying_to_copy__6=Error trying to copy
-RPMCore._to__7=\ to
-RPMCore.Error_trying_to_write_to__8=Error trying to write to
-RPMCore.No___%defines___were_found_in_the_spec_file_38=No \'%defines\' were found in the spec file
-RPMCore.Failed_to_find_a_spec_file_at=Failed to find a spec file at
-RPMCore.Error_using_parseDefine_to_get_the_version_no._41=Error using parseDefine to get the version no.
-RPMCore._from_the_spec_file_at___42=\ from the spec file at:
-RPMCore.Error_using_parseDefine_to_get_the_release_no._44=Error using parseDefine to get the release no.
-RPMCore._from_the_spec_file_at___45=\ from the spec file at:
-RPMCore.Error_parsing_the_spec_file_at=Error parsing the spec file at
-RPMCore.Error_creating_srpminfo_file_in_the_project._9=Error creating srpminfo file in the project.
-RPMCore._nCheck_permissions_in__10=\nCheck permissions in
-RPMExportCore.Too_many_spec_files_in__4=Too many spec files in
-RPMExportCore.Error_trying_to_delete__5=Error trying to delete
-ImportSRPM.Error_occurred_during_the_source_install._n_1=Error occurred during the source install.\n
-ImportSRPM.There_are_either_too_many_or_0_directories_under__2=There are either too many or 0 directories under
-ImportSRPM.Cannot_find_a_tarball_to_untar_in___3=Cannot find a tarball to untar in:
-LinuxShellCmds.Error_attempting_to_create___1=Error attempting to create:
-LinuxShellCmds.Cannot_copy_a_directory___2=Cannot copy a directory:
-LinuxShellCmds._to_a_file___3=\ to a file:
-LinuxShellCmds.Error_attempting_to_copy_source_from___4=Error attempting to copy source from:
-LinuxShellCmds._to__5=\ to
-LinuxShellCmds.1=Process returned non-zero value:
-LinuxShellCmds.2=Process output:\n
-LinuxShellCmds.3=Process error:\n
-LinuxShellCmds.4=Process executed successfully
-LinuxShellCmds.5=Process output:\n
-LinuxShellCmds.6=Process error:\n
-LinuxShellCmds.7=\n Error output from command:\n
-LinuxShellCmds.9=Process returned non-zero value:
-LinuxShellCmds.10=Process output:\n
-LinuxShellCmds.11=Process error:\n
-LinuxShellCmds.12=Process executed successfully
-LinuxShellCmds.13=Process output:\n
-LinuxShellCmds.14=Process error:\n
-LinuxShellCmds.15=Error executing
-RPMCore._nThis_RPM_*must*_be_restored_before_exporting_can_occur._1=\nThis RPM *must* be restored before exporting can occur.
-RPMCore.Error_creating__1=Error creating
-RPMCore._nCheck_permissions__2=\nCheck permissions?
Index: src/org/eclipse/cdt/rpm/core/IPatch.java
===================================================================
RCS file: src/org/eclipse/cdt/rpm/core/IPatch.java
diff -N src/org/eclipse/cdt/rpm/core/IPatch.java
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ src/org/eclipse/cdt/rpm/core/IPatch.java 1 Jan 1970 00:00:00 -0000
@@ -0,0 +1,57 @@
+/*
+ * (c) 2005 Red Hat, Inc.
+ *
+ * This program is open source software licensed under the
+ * Eclipse Public License ver. 1
+ */
+
+package org.eclipse.cdt.rpm.core;
+
+import org.eclipse.core.resources.IFile;
+
+/**
+ * Represents a patch to a source RPM.
+ */
+public interface IPatch {
+
+ /**
+ * Returns the spec file ChangeLog entry associated with this patch.
+ * @return the ChangeLog entry, or null
if not set
+ */
+ public String getChangelogEntry();
+
+ /**
+ * Sets the spec file ChangeLog entry associated with this patch.
+ * @param changelogEntry the ChangeLog entry
+ */
+ public void setChangelogEntry(String changelogEntry);
+
+ /**
+ * Returns the workspace patch file that contains the source code diffs
+ * associated with this patch.
+ * @return the patch file, or null
if not set
+ */
+ public IFile getFile();
+
+ /**
+ * Sets the workspace patch file that contains the source code diffs
+ * associated with this patch.
+ * @param file the patch file
+ */
+ public void setFile(IFile file);
+
+ /**
+ * Returns the name of the patch file.
+ * @return the patch file name, or null
if not set.
+ */
+ public String getPatchName();
+
+ /**
+ * Sets the name of the patch file. Note that if the workspace patch file has
+ * already been set using setFile
, this method will not modify the
+ * name of the patch file on disk.
+ * @param patchName the name of the patch file
+ */
+ public void setPatchName(String patchName);
+
+}
Index: src/org/eclipse/cdt/rpm/core/IRPMConfiguration.java
===================================================================
RCS file: src/org/eclipse/cdt/rpm/core/IRPMConfiguration.java
diff -N src/org/eclipse/cdt/rpm/core/IRPMConfiguration.java
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ src/org/eclipse/cdt/rpm/core/IRPMConfiguration.java 1 Jan 1970 00:00:00 -0000
@@ -0,0 +1,50 @@
+/*
+ * (c) 2005 Red Hat, Inc.
+ *
+ * This program is open source software licensed under the
+ * Eclipse Public License ver. 1
+ */
+
+package org.eclipse.cdt.rpm.core;
+
+import org.eclipse.core.resources.IFolder;
+
+/**
+ * Represents an RPM configuration associated with an RPM project.
+ * An RPM configuration contains information about RPM folder locations
+ * and other RPM macro definitions.
+ *
+ */
+public interface IRPMConfiguration {
+
+ /**
+ * Returns the workspace folder containing RPM build artifacts.
+ * @return the build folder
+ */
+ public IFolder getBuildFolder();
+
+ /**
+ * Returns the workspace folder containing binary RPMs.
+ * @return the RPMs folder
+ */
+ public IFolder getRpmsFolder();
+
+ /**
+ * Returns the workspace folder containing RPM sources artifacts.
+ * @return the sources folder
+ */
+ public IFolder getSourcesFolder();
+
+ /**
+ * Returns the workspace folder containing RPM spec files.
+ * @return the spec files folder
+ */
+ public IFolder getSpecsFolder();
+
+ /**
+ * Returns the workspace folder containing source RPMs.
+ * @return the source RPMs folder
+ */
+ public IFolder getSrpmsFolder();
+
+}
Index: src/org/eclipse/cdt/rpm/core/IRPMConstants.java
===================================================================
RCS file: src/org/eclipse/cdt/rpm/core/IRPMConstants.java
diff -N src/org/eclipse/cdt/rpm/core/IRPMConstants.java
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ src/org/eclipse/cdt/rpm/core/IRPMConstants.java 1 Jan 1970 00:00:00 -0000
@@ -0,0 +1,114 @@
+/*
+ * (c) 2005 Red Hat, Inc.
+ *
+ * This program is open source software licensed under the
+ * Eclipse Public License ver. 1
+ */
+
+package org.eclipse.cdt.rpm.core;
+
+import org.eclipse.cdt.rpm.core.internal.Messages;
+
+public interface IRPMConstants {
+
+ /**
+ * Contains the name of the preference store key for storing and retrieving
+ * the path to the system's rpm
binary.
+ */
+ public static final String RPM_CMD = "RPM_CMD"; //$NON-NLS-1$
+
+ /**
+ * Contains the name of the preference store key for storing and retrieving
+ * the path to the system's rpmbuild
binary.
+ */
+ public static final String RPMBUILD_CMD = "RPMBUILD_CMD"; //$NON-NLS-1$
+
+ /**
+ * Contains the name of the preference store key for storing and retrieving
+ * the path to the system's diff
binary.
+ */
+ public static final String DIFF_CMD = "DIFF_CMD"; //$NON-NLS-1$
+
+ /**
+ * Contains the name of the preference store key for storing and retrieving
+ * the author's name.
+ */
+ public static final String AUTHOR_NAME = "AUTHOR_NAME"; //$NON-NLS-1$
+
+ /**
+ * Contains the name of the preference store key for storing and retrieving
+ * the author's email address.
+ */
+ public static final String AUTHOR_EMAIL = "AUTHOR_EMAIL"; //$NON-NLS-1$
+
+ /**
+ * Contains the name of the preference store key for storing and retrieving
+ * the name of the RPM log viewer.
+ */
+ public static final String RPM_DISPLAYED_LOG_NAME = "RPM_DISPLAYED_LOG_NAME"; //$NON-NLS-1$
+
+ /**
+ * Contains the name of the preference store key for storing and retrieving
+ * the name of the RPM log.
+ */
+ public static final String RPM_LOG_NAME = "RPM_LOG_NAME"; //$NON-NLS-1$
+
+ /**
+ * Contains the name of the default RPMS folder in an RPM project.
+ */
+ public static final String RPMS_FOLDER = "RPMS"; //$NON-NLS-1$
+
+ /**
+ * Contains the name of the default SRPMS folder in an RPM project.
+ */
+ public static final String SRPMS_FOLDER = "SRPMS"; //$NON-NLS-1$
+
+ /**
+ * Contains the name of the default SPECS folder in an RPM project.
+ */
+ public static final String SPECS_FOLDER = "SPECS"; //$NON-NLS-1$
+
+ /**
+ * Contains the name of the default SOURCES folder in an RPM project.
+ */
+ public static final String SOURCES_FOLDER = "SOURCES"; //$NON-NLS-1$
+
+ /**
+ * Contains the name of the default BUILD folder in an RPM project.
+ */
+ public static final String BUILD_FOLDER = "BUILD"; //$NON-NLS-1$
+
+ /**
+ * Contains the name of the project property used to store the project-relative
+ * path of an RPM project's source RPM.
+ */
+ public static final String SRPM_PROPERTY = "SRPM_PROPERTY"; //$NON-NLS-1$
+
+ /**
+ * Contains the name of the project property used to store the project-relative
+ * path of an RPM project's spec file.
+ */
+ public static final String SPEC_FILE_PROPERTY = "SPEC_FILE_PROPERTY"; //$NON-NLS-1$
+
+ /**
+ * Contains the name of the project property used to store an RPM project's
+ * checksum value.
+ */
+ public static final String CHECKSUM_PROPERTY = "CHECKSUM_PROPERTY"; //$NON-NLS-1$
+
+ /**
+ * Contains the system's file separator.
+ */
+ public static final String FILE_SEP = System.getProperty("file.separator"); //$NON-NLS-1$
+
+ /**
+ * Contains the system's line separator.
+ */
+ public static final String LINE_SEP = System.getProperty("line.separator"); //$NON-NLS-1$
+
+ /**
+ * Contains the plug-ins default error message.
+ */
+ public static final String ERROR = Messages.getString("RPMCore.Error_1"); //$NON-NLS-1$
+
+}
Index: src/org/eclipse/cdt/rpm/core/IRPMProject.java
===================================================================
RCS file: src/org/eclipse/cdt/rpm/core/IRPMProject.java
diff -N src/org/eclipse/cdt/rpm/core/IRPMProject.java
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ src/org/eclipse/cdt/rpm/core/IRPMProject.java 1 Jan 1970 00:00:00 -0000
@@ -0,0 +1,157 @@
+/*
+ * (c) 2005 Red Hat, Inc.
+ *
+ * This program is open source software licensed under the
+ * Eclipse Public License ver. 1
+ */
+package org.eclipse.cdt.rpm.core;
+
+import java.io.File;
+
+import org.eclipse.core.resources.IProject;
+import org.eclipse.core.runtime.CoreException;
+
+/**
+ * Represents an RPM project.
+ *
+ */
+public interface IRPMProject {
+
+ /**
+ * Prepares the sources for the RPM project according to the directives
+ * in the project's spec file. This method deposits prepared sources
+ * in the project's BUILD directory. This method is the equivalent of
+ * executing rpmbuild -bp /path/to/specfile.spec
on the
+ * command line.
+ * @throws CoreException if:
+ *
+ * - The project's BUILD directory cannot be refreshed
+ * rpmbuild
execution fails
+ * - The project is not an RPM project (a source RPM has not been imported)
+ *
+ */
+ public void buildPrep() throws CoreException;
+
+ /**
+ * Builds both a source RPM and a binary RPM according to the directives
+ * in the project's spec file. This method deposits the binary and source
+ * RPMs into the project's RPMS and SRPMS directories, respectively.
+ * This method will modify the project model and project spec file according
+ * to the given export deltas. This method will also refresh the project
+ * sources with the new project model when the export operation is complete.
+ * @param export the deltas associated with the export operation
+ * @throws CoreException if:
+ *
+ * - Updating the RPM project model fails
+ * rpmbuild
execution fails
+ * - Refreshing project sources fails
+ * - The project is not an RPM project (a source RPM has not been imported)
+ *
+ */
+ public void buildAll(RPMExportDelta export) throws CoreException;
+
+ /**
+ * Builds a binary RPM according to the directives in the project's spec file.
+ * This method deposits the binary RPM(s) into the project's RPMS directory.
+ * This method will modify the project model and project spec file according
+ * to the given export deltas. This method will also refresh the project
+ * sources with the new project model when the export operation is complete.
+ * @param export the deltas associated with the export operation
+ * @throws CoreException if:
+ *
+ * - Updating the RPM project model fails
+ * rpmbuild
execution failse
+ * - Refreshing project sources fails
+ * - The project is not an RPM project (a source RPM has not been imported)
+ *
+ */
+ public void buildBinaryRPM(RPMExportDelta export) throws CoreException;
+
+ /**
+ * Builds a source RPM according to the directives in the project's spec file.
+ * This method deposits the source RPM into the project's RPMS directory.
+ * This method will modify the project model and project spec file according
+ * to the given export deltas. This method will also refresh the project
+ * sources with the new project model when the export operation is complete.
+ * @param export the deltas associated with the export operation
+ * @throws CoreException if:
+ *
+ * - Updating the RPM project model fails
+ * rpmbuild
execution failse
+ * - Refreshing project sources fails
+ * - The project is not an RPM project (a source RPM has not been imported)
+ *
+ */
+ public void buildSourceRPM(RPMExportDelta export) throws CoreException;
+
+ /**
+ * Imports an external source RPM into the project and installs project
+ * sources. This method also adds an RPM nature to the project.
+ * @param externalFile the external source RPM
+ * @throws CoreException if:
+ *
+ * - The external source RPM cannot be accessed
+ * - Source installation fails
+ * - Spec file parsing error occurs
+ * - Calculating project checksum fails
+ *
+ */
+ public void importSourceRPM(File externalFile) throws CoreException;
+
+ /**
+ * Returns whether the project has been modified since it has been imported.
+ * @return true if the project has been modified, false if it has not
+ * @throws CoreException if:
+ *
+ * - Calculating project checksum fails
+ *
+ */
+ public boolean isChanged() throws CoreException;
+
+ /**
+ * Returns the project handle associated with the RPM project.
+ * @return the project handle
+ */
+ public IProject getProject();
+
+ /**
+ * Returns the RPM configuration associated with the RPM project.
+ * @return the RPM configuration
+ */
+ public IRPMConfiguration getConfiguration();
+
+ /**
+ * Returns the source RPM associated with the RPM project.
+ * @return the source RPM, or null
if no source RPM
+ * has been imported
+ */
+ public ISourceRPM getSourceRPM();
+
+ /**
+ * Sets the source RPM associated with the RPM project.
+ * @param sourceRPM the source RPM
+ * @throws CoreException if:
+ *
+ * - Setting the project property associated with the source RPM fails
+ *
+ */
+ public void setSourceRPM(ISourceRPM sourceRPM) throws CoreException;
+
+ /**
+ * Returns the spec file associated with the RPM project.
+ * @return the spec file, or null
if no source RPM
+ * has been imported
+ */
+ public ISpecFile getSpecFile();
+
+ /**
+ * Sets the spec file associated with the RPM project.
+ * @param specFile the spec file
+ * @throws CoreException if:
+ *
+ * - Setting the project property associated with the spec file fails
+ *
+ */
+ public void setSpecFile(ISpecFile specFile) throws CoreException;
+
+}
Index: src/org/eclipse/cdt/rpm/core/ISourceRPM.java
===================================================================
RCS file: src/org/eclipse/cdt/rpm/core/ISourceRPM.java
diff -N src/org/eclipse/cdt/rpm/core/ISourceRPM.java
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ src/org/eclipse/cdt/rpm/core/ISourceRPM.java 1 Jan 1970 00:00:00 -0000
@@ -0,0 +1,43 @@
+/*
+ * (c) 2005 Red Hat, Inc.
+ *
+ * This program is open source software licensed under the
+ * Eclipse Public License ver. 1
+ */
+package org.eclipse.cdt.rpm.core;
+
+import org.eclipse.core.resources.IFile;
+import org.eclipse.core.resources.IFolder;
+
+/**
+ * Represents a source RPM in an RPM project.
+ *
+ */
+public interface ISourceRPM {
+
+ /**
+ * Returns the workspace file associated with the source RPM.
+ * @return the source RPM file
+ */
+ public IFile getFile();
+
+ /**
+ * Returns the folder contained within the RPM BUILD directory
+ * that contains the project sources. Typically, this is the
+ * directory that is installed in the BUILD directory after unpacking
+ * the project sources during source preparation.
+ * @return the source RPM sources folder, or null
if
+ * none exists
+ */
+ public IFolder getSourcesFolder();
+
+ /**
+ * Sets the folder contained within the RPM BUILD directory that
+ * contains the project sources. Typically, this is the directory
+ * that is installed in the BUILD directory after unpacking the
+ * project sources during source preparation.
+ * @param folder the source RPM sources folder
+ */
+ public void setSourcesFolder(IFolder folder);
+
+}
Index: src/org/eclipse/cdt/rpm/core/ISpecFile.java
===================================================================
RCS file: src/org/eclipse/cdt/rpm/core/ISpecFile.java
diff -N src/org/eclipse/cdt/rpm/core/ISpecFile.java
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ src/org/eclipse/cdt/rpm/core/ISpecFile.java 1 Jan 1970 00:00:00 -0000
@@ -0,0 +1,92 @@
+/*
+ * (c) 2005 Red Hat, Inc.
+ *
+ * This program is open source software licensed under the
+ * Eclipse Public License ver. 1
+ */
+package org.eclipse.cdt.rpm.core;
+
+import org.eclipse.core.resources.IFile;
+import org.eclipse.core.runtime.CoreException;
+
+/**
+ * Represents a spec file in an RPM project.
+ *
+ */
+public interface ISpecFile {
+
+ /**
+ * Adds a patch to the spec file. Changes to the spec file are not
+ * reflected on-disk until the write method is called.
+ * @param patch the patch to add
+ */
+ public void addPatch(IPatch patch);
+
+ /**
+ * Returns the workspace file handle for the spec file.
+ * @return the spec file handle
+ */
+ public IFile getFile();
+
+ /**
+ * Returns the spec file's configure arguments. For projects that
+ * contain a configure
script, the spec file typically
+ * contains a %configure
directive followed by a list
+ * of arguments. Not all spec files contain this directive.
+ * @return the configure arguments, or null
if none present
+ */
+ public String getConfigureArgs();
+
+ /**
+ * Returns the name of the RPM project according to the spec file's
+ * directives.
+ * @return the RPM project name
+ */
+ public String getName();
+
+ /**
+ * Sets the name of the RPM project. Changes to the spec file are
+ * not reflected on-disk until the write method is called.
+ * @param name the RPM project name
+ */
+ public void setName(String name);
+
+ /**
+ * Returns the version of the RPM project according to the spec file's
+ * directives.
+ * @return the RPM project version
+ */
+ public String getVersion();
+
+ /**
+ * Sets the version of the RPM project. Changes to the spec file
+ * are not reflected on-disk until the write method is called.
+ * @param version the RPM project version
+ */
+ public void setVersion(String version);
+
+ /**
+ * Returns the release of the RPM project according to the spec
+ * file's directives.
+ * @return the RPM project release
+ */
+ public String getRelease();
+
+ /**
+ * Sets the release of the RPM proejct. Changes to the spec file
+ * are not reflected on-disk until the write method is called.
+ * @param release the RPM project release
+ */
+ public void setRelease(String release);
+
+ /**
+ * Writes the current spec file model to disk.
+ * @throws CoreException if:
+ *
+ * - Parsing the spec file fails
+ * - Writing to the spec file fails
+ *
+ */
+ public void write() throws CoreException;
+
+}
Index: src/org/eclipse/cdt/rpm/core/RPMExportDelta.java
===================================================================
RCS file: src/org/eclipse/cdt/rpm/core/RPMExportDelta.java
diff -N src/org/eclipse/cdt/rpm/core/RPMExportDelta.java
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ src/org/eclipse/cdt/rpm/core/RPMExportDelta.java 1 Jan 1970 00:00:00 -0000
@@ -0,0 +1,107 @@
+/*
+ * (c) 2005 Red Hat, Inc.
+ *
+ * This program is open source software licensed under the
+ * Eclipse Public License ver. 1
+ */
+
+package org.eclipse.cdt.rpm.core;
+
+import org.eclipse.core.resources.IFile;
+
+/**
+ * Represents a set of changes (delta) to be made to the RPM project
+ * model during export.
+ *
+ */
+public class RPMExportDelta {
+
+ private IFile specFile;
+ private String version;
+ private String release;
+ private String patchName;
+ private String changelogEntry;
+
+ /**
+ * Returns the ChangeLog entry associated with the export delta.
+ * @return the ChangeLog entry, or null
if none set
+ */
+ public String getChangelogEntry() {
+ return changelogEntry;
+ }
+
+ /**
+ * Sets the ChangeLog entry associated with the export delta.
+ * @param changelogEntry the ChangeLog entry
+ */
+ public void setChangelogEntry(String changelogEntry) {
+ this.changelogEntry = changelogEntry;
+ }
+
+ /**
+ * Returns the name of the patch file associated with the export delta.
+ * @return the patch file name, or null
if none set
+ */
+ public String getPatchName() {
+ return patchName;
+ }
+
+ /**
+ * Sets the name of the patch file associated with the export delta.
+ * @param patchName the patch file name
+ */
+ public void setPatchName(String patchName) {
+ this.patchName = patchName;
+ }
+
+ /**
+ * Returns the release associated with the export delta.
+ * @return the release
+ */
+ public String getRelease() {
+ return release;
+ }
+
+ /**
+ * Sets the release associated with the export delta.
+ * @param release the release
+ */
+ public void setRelease(String release) {
+ this.release = release;
+ }
+
+ /**
+ * Returns the workspace file handle for the spec file associated
+ * with this export delta.
+ * @return the spec file handle
+ */
+ public IFile getSpecFile() {
+ return specFile;
+ }
+
+ /**
+ * Sets the workspace file handle for the spec file associated
+ * with this export delta.
+ * @param specFile the spec file handle
+ */
+ public void setSpecFile(IFile specFile) {
+ this.specFile = specFile;
+ }
+
+ /**
+ * Returns the the version associated with the export delta.
+ * @return the version
+ */
+ public String getVersion() {
+ return version;
+ }
+
+ /**
+ * Sets the version associated with the export delta.
+ * @param version the version
+ */
+ public void setVersion(String version) {
+ this.version = version;
+ }
+
+}
Index: src/org/eclipse/cdt/rpm/core/RPMProjectFactory.java
===================================================================
RCS file: src/org/eclipse/cdt/rpm/core/RPMProjectFactory.java
diff -N src/org/eclipse/cdt/rpm/core/RPMProjectFactory.java
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ src/org/eclipse/cdt/rpm/core/RPMProjectFactory.java 1 Jan 1970 00:00:00 -0000
@@ -0,0 +1,83 @@
+/*
+ * (c) 2005 Red Hat, Inc.
+ *
+ * This program is open source software licensed under the
+ * Eclipse Public License ver. 1
+ */
+
+package org.eclipse.cdt.rpm.core;
+
+import org.eclipse.cdt.rpm.core.internal.Messages;
+import org.eclipse.cdt.rpm.core.internal.RPMProject;
+import org.eclipse.cdt.rpm.core.internal.SourceRPM;
+import org.eclipse.cdt.rpm.core.internal.SpecFile;
+import org.eclipse.core.resources.IFolder;
+import org.eclipse.core.resources.IProject;
+import org.eclipse.core.runtime.CoreException;
+import org.eclipse.core.runtime.IStatus;
+import org.eclipse.core.runtime.QualifiedName;
+import org.eclipse.core.runtime.Status;
+
+/**
+ * Factory class for obtaining an instance of an RPM project.
+ *
+ */
+public class RPMProjectFactory {
+
+ private RPMProjectFactory() {
+ }
+
+ /**
+ * Returns an instance of an RPM project given a workspace project.
+ * If the given project has an RPM nature (a source RPM was previously
+ * imported), the RPM project model will be reconstructed. Otherwise,
+ * the given project will be initialized with the default properties of a
+ * new RPM project. Note that an RPM project is not given an RPM nature
+ * until an import operation has been completed.
+ * @param project the workspace project to use in constructing an RPM project
+ * @return an RPM project
+ * @throws CoreException if:
+ *
+ * - Initializing the RPM project configuration fails
+ * - Reconstructing the existing RPM project model fails
+ *
+ */
+ public static IRPMProject getRPMProject(IProject project) throws CoreException {
+ IRPMProject rpmProject = new RPMProject(project);
+
+ if(project.hasNature(RPMProjectNature.RPM_NATURE_ID)) {
+ // Construct the project's source RPM object
+ String sourceRPMName =
+ project.getPersistentProperty(new QualifiedName(RPMCorePlugin.ID, IRPMConstants.SRPM_PROPERTY));
+ if(sourceRPMName != null) {
+ IFolder srpmsFolder = rpmProject.getConfiguration().getSrpmsFolder();
+ ISourceRPM sourceRPM = new SourceRPM(srpmsFolder.getFile(sourceRPMName));
+ rpmProject.setSourceRPM(sourceRPM);
+ }
+ else {
+ String throw_message = Messages.getString("RPMCore.RPMProjectFactory.0"); //$NON-NLS-1$
+ IStatus error = new Status(IStatus.ERROR, IRPMConstants.ERROR, 1,
+ throw_message, null);
+ throw new CoreException(error);
+ }
+
+ // Construct the project's spec file object
+ String specFileName =
+ project.getPersistentProperty(new QualifiedName(RPMCorePlugin.ID, IRPMConstants.SPEC_FILE_PROPERTY));
+ if(specFileName != null) {
+ ISpecFile specFile =
+ new SpecFile(rpmProject.getConfiguration().getSpecsFolder().getFile(specFileName));
+ rpmProject.setSpecFile(specFile);
+ }
+ else {
+ String throw_message = Messages.getString("RPMCore.RPMProjectFactory.1"); //$NON-NLS-1$
+ IStatus error = new Status(IStatus.ERROR, IRPMConstants.ERROR, 1,
+ throw_message, null);
+ throw new CoreException(error);
+ }
+ }
+
+ return rpmProject;
+ }
+
+}
Index: src/org/eclipse/cdt/rpm/core/RPMProjectNature.java
===================================================================
RCS file: src/org/eclipse/cdt/rpm/core/RPMProjectNature.java
diff -N src/org/eclipse/cdt/rpm/core/RPMProjectNature.java
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ src/org/eclipse/cdt/rpm/core/RPMProjectNature.java 1 Jan 1970 00:00:00 -0000
@@ -0,0 +1,121 @@
+/*
+ * (c) 2005 Red Hat, Inc.
+ *
+ * This program is open source software licensed under the
+ * Eclipse Public License ver. 1
+ */
+
+package org.eclipse.cdt.rpm.core;
+
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.List;
+
+import org.eclipse.core.resources.IProject;
+import org.eclipse.core.resources.IProjectDescription;
+import org.eclipse.core.resources.IProjectNature;
+import org.eclipse.core.runtime.CoreException;
+import org.eclipse.core.runtime.IProgressMonitor;
+
+/**
+ * The RPM project nature.
+ *
+ */
+public class RPMProjectNature implements IProjectNature {
+
+ /**
+ * The unique nature ID associated with the RPM project nature.
+ */
+ public static final String RPM_NATURE_ID = RPMCorePlugin.ID + ".rpmnature"; //$NON-NLS-1$
+
+ IProject project;
+
+ public RPMProjectNature() {
+ }
+
+ public RPMProjectNature(IProject project) {
+ this.project = project;
+ }
+
+ /**
+ * Adds the RPM project nature to a given workspace project.
+ * @param project the project
+ * @param mon a progress monitor, or null
if progress monitoring
+ * is not desired
+ * @throws CoreException if adding the RPM project nature fails
+ */
+ public static void addRPMNature(IProject project, IProgressMonitor mon) throws CoreException {
+ addNature(project, RPM_NATURE_ID, mon);
+ }
+
+ /**
+ * Removes the RPM project nature from a given workspace project.
+ * @param project the project
+ * @param mon a progress monitor, or null
if progress monitoring
+ * is not desired
+ * @throws CoreException if removing the RPM project nature fails
+ */
+ public static void removeRPMNature(IProject project, IProgressMonitor mon) throws CoreException {
+ removeNature(project, RPM_NATURE_ID, mon);
+ }
+
+ /**
+ * Utility method for adding a nature to a project.
+ *
+ * @param proj
+ * the project to add the nature
+ * @param natureId
+ * the id of the nature to assign to the project
+ * @param monitor
+ * a progress monitor to indicate the duration of the operation,
+ * or null
if progress reporting is not required.
+ *
+ */
+ private static void addNature(IProject project, String natureId, IProgressMonitor monitor) throws CoreException {
+ if(project.hasNature(natureId)) {
+ return;
+ }
+ IProjectDescription description = project.getDescription();
+ String[] prevNatures = description.getNatureIds();
+ String[] newNatures = new String[prevNatures.length + 1];
+ System.arraycopy(prevNatures, 0, newNatures, 0, prevNatures.length);
+ newNatures[prevNatures.length] = natureId;
+ description.setNatureIds(newNatures);
+ project.setDescription(description, monitor);
+ }
+
+ /**
+ * Utility method for removing a project nature from a project.
+ *
+ * @param proj
+ * the project to remove the nature from
+ * @param natureId
+ * the nature id to remove
+ * @param monitor
+ * a progress monitor to indicate the duration of the operation,
+ * or null
if progress reporting is not required.
+ */
+ private static void removeNature(IProject project, String natureId, IProgressMonitor monitor) throws CoreException {
+ IProjectDescription description = project.getDescription();
+ String[] prevNatures = description.getNatureIds();
+ List newNatures = new ArrayList(Arrays.asList(prevNatures));
+ newNatures.remove(natureId);
+ description.setNatureIds((String[]) newNatures.toArray(new String[newNatures.size()]));
+ project.setDescription(description, monitor);
+ }
+
+ public void configure() throws CoreException {
+ }
+
+ public void deconfigure() throws CoreException {
+ }
+
+ public IProject getProject() {
+ return project;
+ }
+
+ public void setProject(IProject project) {
+ this.project = project;
+ }
+
+}
Index: src/org/eclipse/cdt/rpm/core/internal/Messages.java
===================================================================
RCS file: src/org/eclipse/cdt/rpm/core/internal/Messages.java
diff -N src/org/eclipse/cdt/rpm/core/internal/Messages.java
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ src/org/eclipse/cdt/rpm/core/internal/Messages.java 1 Jan 1970 00:00:00 -0000
@@ -0,0 +1,28 @@
+/*
+ * (c) 2004, 2005 Red Hat, Inc.
+ *
+ * This program is open source software licensed under the
+ * Eclipse Public License ver. 1
+ */
+
+package org.eclipse.cdt.rpm.core.internal;
+
+import java.util.MissingResourceException;
+import java.util.ResourceBundle;
+
+public class Messages {
+ private static final String BUNDLE_NAME = "org.eclipse.cdt.rpm.core.internal.rpm_strings"; //$NON-NLS-1$
+
+ private static final ResourceBundle RESOURCE_BUNDLE = ResourceBundle.getBundle(BUNDLE_NAME);
+
+ private Messages() {
+ }
+
+ public static String getString(String key) {
+ try {
+ return RESOURCE_BUNDLE.getString(key);
+ } catch (MissingResourceException e) {
+ return '!' + key + '!';
+ }
+ }
+}
Index: src/org/eclipse/cdt/rpm/core/internal/Patch.java
===================================================================
RCS file: src/org/eclipse/cdt/rpm/core/internal/Patch.java
diff -N src/org/eclipse/cdt/rpm/core/internal/Patch.java
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ src/org/eclipse/cdt/rpm/core/internal/Patch.java 1 Jan 1970 00:00:00 -0000
@@ -0,0 +1,38 @@
+/*
+ * (c) 2005 Red Hat, Inc.
+ *
+ * This program is open source software licensed under the
+ * Eclipse Public License ver. 1
+ */
+
+package org.eclipse.cdt.rpm.core.internal;
+
+import org.eclipse.cdt.rpm.core.IPatch;
+import org.eclipse.core.resources.IFile;
+
+public class Patch implements IPatch {
+
+ private String changelogEntry;
+ private String patchName;
+ private IFile file;
+
+ public String getChangelogEntry() {
+ return changelogEntry;
+ }
+ public void setChangelogEntry(String changelogEntry) {
+ this.changelogEntry = changelogEntry;
+ }
+ public IFile getFile() {
+ return file;
+ }
+ public void setFile(IFile file) {
+ this.file = file;
+ }
+ public String getPatchName() {
+ return patchName;
+ }
+ public void setPatchName(String patchName) {
+ this.patchName = patchName;
+ }
+
+}
Index: src/org/eclipse/cdt/rpm/core/internal/RPMConfiguration.java
===================================================================
RCS file: src/org/eclipse/cdt/rpm/core/internal/RPMConfiguration.java
diff -N src/org/eclipse/cdt/rpm/core/internal/RPMConfiguration.java
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ src/org/eclipse/cdt/rpm/core/internal/RPMConfiguration.java 1 Jan 1970 00:00:00 -0000
@@ -0,0 +1,143 @@
+/*
+ * (c) 2005 Red Hat, Inc.
+ *
+ * This program is open source software licensed under the
+ * Eclipse Public License ver. 1
+ */
+
+package org.eclipse.cdt.rpm.core.internal;
+
+import org.eclipse.cdt.rpm.core.IRPMConfiguration;
+import org.eclipse.cdt.rpm.core.IRPMConstants;
+import org.eclipse.cdt.rpm.core.RPMCorePlugin;
+import org.eclipse.core.resources.IFolder;
+import org.eclipse.core.resources.IProject;
+import org.eclipse.core.runtime.CoreException;
+import org.eclipse.core.runtime.QualifiedName;
+
+public class RPMConfiguration implements IRPMConfiguration {
+
+ private IProject project;
+
+ private IFolder rpmsFolder;
+ private IFolder srpmsFolder;
+ private IFolder specsFolder;
+ private IFolder sourcesFolder;
+ private IFolder buildFolder;
+
+ public RPMConfiguration(IProject project) throws CoreException {
+ this.project = project;
+ initialize();
+ }
+
+ /**
+ * Sets the internal folder fields according to stored properties
+ * in the workspace project, or according to the default properties
+ * if no stored properties are found. If the folders do not exist,
+ * they are created.
+ * @throws CoreException if:
+ *
+ * - Getting or setting project properties fails
+ * Creating project folders fails
+ *
+ */
+ private void initialize() throws CoreException {
+ String pluginID = RPMCorePlugin.ID;
+
+ String sourcesPath =
+ project.getPersistentProperty(new QualifiedName(pluginID, IRPMConstants.SOURCES_FOLDER));
+ if(sourcesPath == null) {
+ sourcesFolder = project.getFolder(IRPMConstants.SOURCES_FOLDER);
+ sourcesFolder.create(false, true, null);
+ sourcesFolder.setDerived(true);
+ project.setPersistentProperty(new QualifiedName(pluginID, IRPMConstants.SOURCES_FOLDER),
+ sourcesFolder.getName());
+ } else {
+ sourcesFolder = project.getFolder(sourcesPath);
+ if(!sourcesFolder.exists()) {
+ sourcesFolder.create(false, true, null);
+ }
+ }
+
+ String srcRpmPath =
+ project.getPersistentProperty(new QualifiedName(pluginID, IRPMConstants.SRPMS_FOLDER));
+ if(srcRpmPath == null) {
+ srpmsFolder = project.getFolder(IRPMConstants.SRPMS_FOLDER);
+ srpmsFolder.create(false, true, null);
+ srpmsFolder.setDerived(true);
+ project.setPersistentProperty(new QualifiedName(pluginID, IRPMConstants.SRPMS_FOLDER),
+ srpmsFolder.getName());
+ } else {
+ srpmsFolder = project.getFolder(srcRpmPath);
+ if(!srpmsFolder.exists()) {
+ srpmsFolder.create(false, true, null);
+ }
+ }
+
+ String buildPath =
+ project.getPersistentProperty(new QualifiedName(pluginID, IRPMConstants.BUILD_FOLDER));
+ if(buildPath == null) {
+ buildFolder = project.getFolder(IRPMConstants.BUILD_FOLDER);
+ buildFolder.create(false, true, null);
+ buildFolder.setDerived(true);
+ project.setPersistentProperty(new QualifiedName(pluginID, IRPMConstants.BUILD_FOLDER),
+ buildFolder.getName());
+ } else {
+ buildFolder = project.getFolder(buildPath);
+ if(!buildFolder.exists()) {
+ buildFolder.create(false, true, null);
+ }
+ }
+
+ String rpmPath =
+ project.getPersistentProperty(new QualifiedName(pluginID, IRPMConstants.RPMS_FOLDER));
+ if(rpmPath == null) {
+ rpmsFolder = project.getFolder(IRPMConstants.RPMS_FOLDER);
+ rpmsFolder.create(false, true, null);
+ rpmsFolder.setDerived(true);
+ project.setPersistentProperty(new QualifiedName(pluginID, IRPMConstants.RPMS_FOLDER),
+ rpmsFolder.getName());
+ } else {
+ rpmsFolder = project.getFolder(rpmPath);
+ if(!rpmsFolder.exists()) {
+ rpmsFolder.create(false, true, null);
+ }
+ }
+
+ String specPath =
+ project.getPersistentProperty(new QualifiedName(pluginID, IRPMConstants.SPECS_FOLDER));
+ if(specPath == null) {
+ specsFolder = project.getFolder(IRPMConstants.SPECS_FOLDER);
+ specsFolder.create(false, true, null);
+ specsFolder.setDerived(true);
+ project.setPersistentProperty(new QualifiedName(pluginID, IRPMConstants.SPECS_FOLDER),
+ specsFolder.getName());
+ } else {
+ specsFolder = project.getFolder(specPath);
+ if(!specsFolder.exists()) {
+ specsFolder.create(false, true, null);
+ }
+ }
+ }
+
+ public IFolder getBuildFolder() {
+ return buildFolder;
+ }
+
+ public IFolder getRpmsFolder() {
+ return rpmsFolder;
+ }
+
+ public IFolder getSourcesFolder() {
+ return sourcesFolder;
+ }
+
+ public IFolder getSpecsFolder() {
+ return specsFolder;
+ }
+
+ public IFolder getSrpmsFolder() {
+ return srpmsFolder;
+ }
+
+}
Index: src/org/eclipse/cdt/rpm/core/internal/RPMProject.java
===================================================================
RCS file: src/org/eclipse/cdt/rpm/core/internal/RPMProject.java
diff -N src/org/eclipse/cdt/rpm/core/internal/RPMProject.java
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ src/org/eclipse/cdt/rpm/core/internal/RPMProject.java 1 Jan 1970 00:00:00 -0000
@@ -0,0 +1,419 @@
+/*
+ * (c) 2005 Red Hat, Inc.
+ *
+ * This program is open source software licensed under the
+ * Eclipse Public License ver. 1
+ */
+package org.eclipse.cdt.rpm.core.internal;
+
+import java.io.BufferedReader;
+import java.io.File;
+import java.io.FileInputStream;
+import java.io.FileNotFoundException;
+import java.io.FileReader;
+import java.io.IOException;
+import java.util.Vector;
+
+import org.eclipse.cdt.rpm.core.IPatch;
+import org.eclipse.cdt.rpm.core.IRPMConfiguration;
+import org.eclipse.cdt.rpm.core.IRPMConstants;
+import org.eclipse.cdt.rpm.core.IRPMProject;
+import org.eclipse.cdt.rpm.core.ISourceRPM;
+import org.eclipse.cdt.rpm.core.ISpecFile;
+import org.eclipse.cdt.rpm.core.RPMCorePlugin;
+import org.eclipse.cdt.rpm.core.RPMExportDelta;
+import org.eclipse.cdt.rpm.core.RPMProjectNature;
+import org.eclipse.cdt.rpm.core.utils.Diff;
+import org.eclipse.cdt.rpm.core.utils.RPM;
+import org.eclipse.cdt.rpm.core.utils.RPMBuild;
+import org.eclipse.core.resources.IFile;
+import org.eclipse.core.resources.IFolder;
+import org.eclipse.core.resources.IProject;
+import org.eclipse.core.resources.IResource;
+import org.eclipse.core.runtime.CoreException;
+import org.eclipse.core.runtime.IPath;
+import org.eclipse.core.runtime.IStatus;
+import org.eclipse.core.runtime.Path;
+import org.eclipse.core.runtime.QualifiedName;
+import org.eclipse.core.runtime.Status;
+
+public class RPMProject implements IRPMProject {
+
+ private IProject project;
+ private ISourceRPM sourceRPM;
+ private ISpecFile specFile;
+ private IRPMConfiguration rpmConfig;
+
+ public RPMProject(IProject project) throws CoreException {
+ this.project = project;
+ rpmConfig = new RPMConfiguration(this.project);
+ }
+
+ public IProject getProject() {
+ return project;
+ }
+
+ public ISourceRPM getSourceRPM() {
+ return sourceRPM;
+ }
+
+ public void setSourceRPM(ISourceRPM sourceRPM) throws CoreException {
+ this.sourceRPM = sourceRPM;
+ getProject().setPersistentProperty(new QualifiedName(RPMCorePlugin.ID,
+ IRPMConstants.SRPM_PROPERTY), sourceRPM.getFile().getName());
+ }
+
+ public IRPMConfiguration getConfiguration() {
+ return rpmConfig;
+ }
+
+ public ISpecFile getSpecFile() {
+ return specFile;
+ }
+
+ public void setSpecFile(ISpecFile specFile) throws CoreException {
+ this.specFile = specFile;
+ getProject().setPersistentProperty(new QualifiedName(RPMCorePlugin.ID,
+ IRPMConstants.SPEC_FILE_PROPERTY), specFile.getFile().getName());
+ }
+
+ public void importSourceRPM(File externalFile) throws CoreException {
+ // Copy original SRPM to workspace
+ IFile srpmFile = getConfiguration().getSrpmsFolder().getFile(externalFile.getName());
+ try {
+ srpmFile.create(new FileInputStream(externalFile), false, null);
+ } catch(FileNotFoundException e) {
+ String throw_message = Messages.getString("RPMCore.Error_trying_to_copy__") + //$NON-NLS-1$
+ rpmConfig.getSpecsFolder().getLocation().toOSString();
+ IStatus error = new Status(IStatus.ERROR, IRPMConstants.ERROR, 1, throw_message, null);
+ throw new CoreException(error);
+ }
+ setSourceRPM(new SourceRPM(srpmFile));
+
+ // Install the SRPM
+ RPM rpm = new RPM(getConfiguration());
+ rpm.install(getSourceRPM().getFile());
+ getProject().refreshLocal(IResource.DEPTH_INFINITE, null);
+
+ // Set the spec file
+ IResource[] installedSpecs = {};
+ installedSpecs = getConfiguration().getSpecsFolder().members();
+ if (installedSpecs.length != 1) {
+ String throw_message = Messages.getString("RPMCore.spec_file_ambiguous") + //$NON-NLS-1$
+ rpmConfig.getSpecsFolder().getLocation().toOSString();
+ IStatus error = new Status(IStatus.ERROR, IRPMConstants.ERROR, 1, throw_message, null);
+ throw new CoreException(error);
+ }
+ setSpecFile(new SpecFile(getConfiguration().getSpecsFolder().getFile(installedSpecs[0].getName())));
+
+ // Prepare the sources
+ buildPrep();
+ getProject().refreshLocal(IResource.DEPTH_INFINITE, null);
+
+ // Copy sources from build root
+ copySources();
+
+ // Set the project nature
+ RPMProjectNature.addRPMNature(getProject(), null);
+
+ // Generate and store project checksum
+ long checksum = generateProjectChecksum(getProject().getLocation().toOSString(), 0);
+ getProject().setPersistentProperty(new QualifiedName(RPMCorePlugin.ID,
+ IRPMConstants.CHECKSUM_PROPERTY), new Long(checksum).toString());
+ }
+
+ public void buildAll(RPMExportDelta exportOp) throws CoreException {
+ prepareExport(exportOp);
+ RPMBuild rpmbuild = new RPMBuild(getConfiguration());
+ rpmbuild.buildAll(getSpecFile().getFile());
+
+ getConfiguration().getBuildFolder().refreshLocal(IResource.DEPTH_INFINITE, null);
+ getConfiguration().getRpmsFolder().refreshLocal(IResource.DEPTH_INFINITE, null);
+ getConfiguration().getSrpmsFolder().refreshLocal(IResource.DEPTH_INFINITE, null);
+ buildPrep();
+ copySources();
+ }
+
+ public void buildBinaryRPM(RPMExportDelta exportOp) throws CoreException {
+ prepareExport(exportOp);
+ RPMBuild rpmbuild = new RPMBuild(getConfiguration());
+ rpmbuild.buildBinary(getSpecFile().getFile());
+
+ getConfiguration().getBuildFolder().refreshLocal(IResource.DEPTH_INFINITE, null);
+ getConfiguration().getRpmsFolder().refreshLocal(IResource.DEPTH_INFINITE, null);
+ }
+
+ public void buildSourceRPM(RPMExportDelta exportOp) throws CoreException {
+ prepareExport(exportOp);
+ RPMBuild rpmbuild = new RPMBuild(getConfiguration());
+ rpmbuild.buildSource(getSpecFile().getFile());
+
+ getConfiguration().getBuildFolder().refreshLocal(IResource.DEPTH_INFINITE, null);
+ getConfiguration().getSrpmsFolder().refreshLocal(IResource.DEPTH_INFINITE, null);
+ buildPrep();
+ copySources();
+ }
+
+ public void buildPrep() throws CoreException {
+ RPMBuild rpmbuild = new RPMBuild(getConfiguration());
+ rpmbuild.buildPrep(getSpecFile().getFile());
+ getConfiguration().getBuildFolder().refreshLocal(IResource.DEPTH_INFINITE, null);
+ IResource[] sources = getConfiguration().getBuildFolder().members();
+ // If there is one folder, assume it contains all the sources
+ if(sources.length == 1 && sources[0].getType() == IResource.FOLDER) {
+ IFolder foo = getProject().getFolder(sources[0].getProjectRelativePath());
+ getSourceRPM().setSourcesFolder(foo);
+ }
+ }
+
+ public boolean isChanged() throws CoreException {
+ getProject().refreshLocal(IResource.DEPTH_INFINITE, null);
+ String originalSumStr = getProject().getPersistentProperty(new QualifiedName(RPMCorePlugin.ID,
+ IRPMConstants.CHECKSUM_PROPERTY));
+ long currSum = generateProjectChecksum(getProject().getLocation().toOSString(), 0);
+ return (new Long(originalSumStr).longValue()) != currSum;
+ }
+
+ /**
+ * Copies sources from the project's BUILD directory to the project root.
+ * @throws CoreException if copying fails
+ */
+ private void copySources() throws CoreException {
+ //Copy all sources to the project root
+ IResource[] sources = null;
+ if(getSourceRPM().getSourcesFolder() != null) {
+ sources = getSourceRPM().getSourcesFolder().members();
+ } else {
+ getConfiguration().getBuildFolder().members();
+ }
+ for(int i=0; i < sources.length; i++) {
+ IPath path = getProject().getFullPath().addTrailingSeparator();
+ path = path.append(sources[i].getName());
+ if(sources[i].getType() == IResource.FILE) {
+ IFile oldFile = getProject().getParent().getFile(path);
+ IFile newFile =
+ getProject().getFile(sources[i].getProjectRelativePath());
+ if(oldFile.exists()) {
+ oldFile.setContents(newFile.getContents(), false, true, null);
+ } else {
+ sources[i].copy(path, false, null);
+ }
+ } else if(sources[i].getType() == IResource.FOLDER) {
+ IFolder oldDir = getProject().getParent().getFolder(path);
+ if(oldDir.exists()) {
+ oldDir.delete(false, true, null);
+ }
+ sources[i].copy(path, false, null);
+ }
+ }
+ getProject().refreshLocal(IResource.DEPTH_INFINITE, null);
+ }
+
+ /**
+ * Prepares for project export. This method updates the project model with
+ * the given RPM project export delta by:
+ *
+ * - Parsing the given spec file and updating the model accordingly
+ * - Updating the spec file model and writing it to disk
+ * - Determining if a patch is needed and generating a patch
+ *
+ * @param exportOp the export delta
+ * @throws CoreException if:
+ *
+ * - The project does not have an RPM nature
+ * - Parsing the spec file fails
+ * - Patch generation fails
+ * - Writing the spec file fails
+ *
+ */
+ private void prepareExport(RPMExportDelta exportOp) throws CoreException {
+ /* Don't support exporting projects that have not been imported as SRPMs */
+ if (!getProject().hasNature(RPMProjectNature.RPM_NATURE_ID)) {
+ String throw_message = Messages.getString("RPMCore.RPMProject.prepareExport") + //$NON-NLS-1$
+ getProject().getName();
+ IStatus error = new Status(IStatus.ERROR, IRPMConstants.ERROR, 1, throw_message, null);
+ throw new CoreException(error);
+ }
+
+ // We need to reset the spec file (which may be user-defined)
+ if(exportOp.getSpecFile() != null &&
+ !getSpecFile().getFile().getProjectRelativePath().equals(exportOp.getSpecFile().getProjectRelativePath())) {
+ setSpecFile(new SpecFile(exportOp.getSpecFile()));
+ }
+ else {
+ setSpecFile(new SpecFile(getSpecFile().getFile()));
+ }
+
+ boolean patchNeeded = isChanged();
+ if (exportOp.getVersion().equals(getSpecFile().getVersion()) &&
+ exportOp.getRelease().equals(getSpecFile().getRelease()) && !patchNeeded) {
+ return;
+ }
+
+ getSpecFile().setVersion(exportOp.getVersion());
+ getSpecFile().setRelease(exportOp.getRelease());
+ if(patchNeeded) {
+ //Do a buildPrep again to make sure the BUILD folder is pristine
+ buildPrep();
+ getSpecFile().addPatch(generatePatch(exportOp));
+ //Generate and store new project checksum
+ long checksum = generateProjectChecksum(getProject().getLocation().toOSString(), 0);
+ getProject().setPersistentProperty(new QualifiedName(RPMCorePlugin.ID,
+ IRPMConstants.CHECKSUM_PROPERTY), new Long(checksum).toString());
+ }
+ // write changes to spec file on disk
+ getSpecFile().write();
+
+ getConfiguration().getSourcesFolder().refreshLocal(IResource.DEPTH_INFINITE, null);
+ getConfiguration().getSpecsFolder().refreshLocal(IResource.DEPTH_INFINITE, null);
+ }
+
+ /**
+ * Generates a patch given a project's export delta.
+ * @param exportOp the export delta
+ * @return the patch
+ * @throws CoreException if:
+ *
+ * - The supplied patch name already exists
+ * - Patch generation fails
+ *
+ */
+ private IPatch generatePatch(RPMExportDelta exportOp) throws CoreException {
+ // Make sure patch name is unique
+ String patch_name = exportOp.getPatchName();
+ IFile patchFile = getConfiguration().getSourcesFolder().getFile(patch_name);
+ if(patchFile.exists()) {
+ String throw_message = Messages.getString(
+ "RPMCore.The_patch_name__109") + patch_name + //$NON-NLS-1$
+ Messages.getString("RPMCore._is_not_unique._110") + //$NON-NLS-1$
+ Messages.getString(
+ "RPMCore._nPlease_modify_the___Patch_tag___field_and_try_again._111"); //$NON-NLS-1$
+ IStatus error = new Status(IStatus.ERROR, IRPMConstants.ERROR, 1, throw_message,
+ null);
+ throw new CoreException(error);
+ }
+
+ String diff_old_dir = null;
+ if(getSourceRPM().getSourcesFolder() != null) {
+ diff_old_dir = getSourceRPM().getSourcesFolder().getLocation().toOSString();
+ }
+ else {
+ diff_old_dir = getConfiguration().getBuildFolder().getLocation().toOSString();
+ }
+ String diff_new_dir = getProject().getName();
+
+ // Figure out what resources to exclude from the diff
+ String[] excludes = findExcludedFiles();
+
+ // Do the diff
+ Diff diff = new Diff(getProject().getParent().getLocation().toOSString(),
+ diff_old_dir, diff_new_dir, excludes, patchFile.getLocation().toOSString());
+ diff.exec();
+
+ // Construct a new patch
+ IPatch patch = new Patch();
+ patch.setChangelogEntry(exportOp.getChangelogEntry());
+ patch.setFile(patchFile);
+ patch.setPatchName(patch_name);
+ return patch;
+ }
+
+ /**
+ * Finds a list of files to exclude from patch generation. By default,
+ * all resources that are marked as derived are excluded from patch
+ * generation.
+ * @return an array of project-relative paths of excluded files
+ * @throws CoreException if the operation fails
+ */
+ private String[] findExcludedFiles() throws CoreException {
+ Vector excludes = new Vector();
+ IResource[] resources = getProject().members();
+ for(int i=0; i < resources.length; i++) {
+ find(resources[i], excludes);
+ }
+
+ String[] excludesArr = new String[excludes.size()];
+ for(int i=0; i < excludes.size(); i++) {
+ excludesArr[i] = (String) excludes.get(i);
+ }
+ return excludesArr;
+ }
+
+ private void find(IResource resource, Vector excludes) throws CoreException {
+ if(resource.isDerived()) {
+ excludes.add(resource.getName());
+ }
+ else if(resource.getType() == IResource.FOLDER) {
+ IFolder folder = getProject().getFolder(resource.getProjectRelativePath());
+ IResource[] members = folder.members();
+ for(int i=0; i < members.length; i++) {
+ find(members[i], excludes);
+ }
+ }
+ }
+
+ /**
+ * Generates the checksum for a given project path.
+ * @param project_path the absolute path of the project
+ * @param proj_checksum input 0
+ * @return
+ * @throws CoreException if the operation fails
+ */
+ private long generateProjectChecksum(String project_path, long proj_checksum)
+ throws CoreException {
+ File dir = new File(project_path);
+
+ if (dir.isDirectory()) {
+ String[] children = dir.list();
+
+ for (int i = 0; i < children.length; i++) {
+
+ File temp = new File(project_path + IRPMConstants.FILE_SEP + children[i]);
+
+ if (temp.isDirectory()) {
+ IFolder folder = getProject().getFolder(new Path(children[i]));
+ if(!folder.isDerived()) {
+ proj_checksum = generateProjectChecksum(project_path
+ + IRPMConstants.FILE_SEP + children[i], proj_checksum);
+ }
+ } else {
+ IFile file = getProject().getFile(new Path(children[i]));
+ if(!file.isDerived() || file.getProjectRelativePath().equals(getSpecFile().getFile().getProjectRelativePath())) {
+ proj_checksum += generateFileCheckSum(temp);
+ }
+ if (children[i].equals("Makefile") & !getProject().getFile("configure").exists()) { //$NON-NLS-1$ //$NON-//$NON-NLS-2$
+ proj_checksum += generateFileCheckSum(temp);
+ }
+ }
+ }
+ }
+
+ return proj_checksum;
+ }
+
+ private long generateFileCheckSum(File input) throws CoreException {
+ String input_line;
+ long chksum = 0;
+ try {
+ BufferedReader br = new BufferedReader(new FileReader(input.toString()));
+ while ((input_line = br.readLine()) != null) {
+ for (int i=0; i 8) {
+ if (input_line.startsWith("Version")) { //$NON-NLS-1$
+ input_line = new_version_line;
+ } else if (input_line.startsWith("Release")) { //$NON-NLS-1$
+ input_line = new_release_line;
+ }
+ }
+
+ fw.write(input_line + IRPMConstants.LINE_SEP);
+
+ // See if this was the "%changelog" line just written, if it was, write out the new entry
+ if (input_line.length() == 10 && patch != null) { //$NON-NLS-1$
+ if (input_line.startsWith("%changelog")) { //$NON-NLS-1$
+ fw.write(patch.getChangelogEntry());
+ found_changelog = true;
+ }
+ }
+
+ line_ctr++;
+
+ // Check to see if this is one of the lines I should add something after
+ if(patch != null) { //$NON-NLS-1$
+ if(line_ctr == lastPatchLine) {
+ fw.write(patchLine);
+ }
+ else if(line_ctr == lastPatchMacroLine) {
+ fw.write(patchMacroLine);
+ }
+ }
+ }
+
+ // if there was not a "%changelog" section, make one
+ if (!found_changelog && patch != null) { //$NON-NLS-1$
+ fw.write("%changelog" + IRPMConstants.LINE_SEP + patch.getChangelogEntry()); //$NON-NLS-1$
+ }
+
+ fw.close();
+ } catch (IOException e) {
+ String throw_message = Messages.getString(
+ "RPMCore.Error_trying_to_modify__132") + //$NON-NLS-1$
+ getFile().getLocation().toOSString();
+ IStatus error = new Status(IStatus.ERROR, IRPMConstants.ERROR, 1, throw_message,
+ null);
+ throw new CoreException(error);
+ }
+
+ newSpecFile.refreshLocal(IResource.DEPTH_INFINITE, null);
+ getFile().delete(false, true, null);
+ newSpecFile.move(getFile().getFullPath(), false, false, null);
+ getFile().refreshLocal(IResource.DEPTH_INFINITE, null);
+ }
+
+ public IFile getFile() {
+ return specFile;
+ }
+
+ public String getConfigureArgs() {
+ return configureArgs;
+ }
+
+ public String getName() {
+ return name;
+ }
+
+ public void setName(String name) {
+ this.name = name;
+ }
+
+ public String getVersion() {
+ return version;
+ }
+
+ public void setVersion(String version) {
+ this.version = version;
+ }
+
+ public String getRelease() {
+ return release;
+ }
+
+ public void setRelease(String release) {
+ this.release = release;
+ }
+}
Index: src/org/eclipse/cdt/rpm/core/internal/SpecFileParser.java
===================================================================
RCS file: src/org/eclipse/cdt/rpm/core/internal/SpecFileParser.java
diff -N src/org/eclipse/cdt/rpm/core/internal/SpecFileParser.java
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ src/org/eclipse/cdt/rpm/core/internal/SpecFileParser.java 1 Jan 1970 00:00:00 -0000
@@ -0,0 +1,657 @@
+/*
+ * (c) 2005 Red Hat, Inc.
+ *
+ * This program is open source software licensed under the
+ * Eclipse Public License ver. 1
+ */
+package org.eclipse.cdt.rpm.core.internal;
+
+import java.io.File;
+import java.io.FileReader;
+import java.io.IOException;
+import java.io.StreamTokenizer;
+import java.util.ArrayList;
+
+import org.eclipse.cdt.rpm.core.IRPMConstants;
+import org.eclipse.core.resources.IFile;
+import org.eclipse.core.runtime.CoreException;
+import org.eclipse.core.runtime.IStatus;
+import org.eclipse.core.runtime.Status;
+
+/**
+ * A spec file parser.
+ *
+ */
+public class SpecFileParser {
+
+ private int lastSourceLine = 0;
+ private int lastPatchLine = 0;
+ private int setupLine = 0;
+ private int lastPatchMacroLine = 0;
+ private int numPatches = 0;
+
+ private IFile specFile;
+ private String configureArgs;
+ private String name;
+ private String version;
+ private String release;
+
+ /**
+ * Constructs a new parser.
+ * @param specFile a handle to the workspace spec file
+ */
+ public SpecFileParser(IFile specFile) {
+ this.specFile = specFile;
+ }
+
+ /**
+ * Parses the spec file.
+ * @throws CoreException if parsing fails
+ */
+ public void parse() throws CoreException {
+ /* The following logic determines where in the spec file the "Patchx:" and
+ * %patchx -p1" lines will need to be added to accomodate the patch we
+ * are fixing to generate. If this is the first patch to ever be added to this
+ * source RPM then the "Patchx: statement will have to be added after the
+ * last "Sourcex:" statement and the "%patch -p1" statement will need to be
+ * added after the "%setup" statement. If this is not the first patch for this
+ * source rpm, the "Patchx:" statement will be added after the last "Patchx:"
+ * statement and the "%patchx -p1" will be added after the last "%patch -p1"
+ * statement. So, we keep track of where the line numbers for all of these
+ * eventualities are so when we mod the file we will know where to insert
+ * the necessary new lines.
+ */
+ ArrayList patchlist = new ArrayList();
+ boolean found_source_line = false;
+ boolean found_patch = false;
+ boolean found_define = false;
+ boolean found_define_name = false;
+ boolean found_version = false;
+ boolean found_release = false;
+ int define_ctr = 0;
+ int define_line_ctr = 0;
+ int lines = 1;
+
+ try {
+ FileReader sp_file = new FileReader(specFile.getLocation().toOSString());
+ StreamTokenizer st = new StreamTokenizer(sp_file);
+
+ // Make sure numbers, colons and percent signs are considered valid
+ st.wordChars('a','z');
+ st.wordChars('A','Z');
+ st.wordChars(':', ':');
+ st.wordChars('0', '9');
+ st.wordChars('%', '%');
+ st.wordChars('{', '}');
+ st.wordChars('-', '-');
+ st.wordChars('/', '/');
+ st.wordChars('=','=');
+ st.wordChars('.','.');
+ st.wordChars('_','_');
+ st.eolIsSignificant(true);
+
+ String new_word;
+ boolean check_ifs = false;
+ int if_ctr = 0;
+ int token = st.nextToken();
+ while (token != StreamTokenizer.TT_EOF) {
+ token = st.nextToken();
+
+ switch (token) {
+ case StreamTokenizer.TT_EOL:
+ lines++;
+ break;
+ case StreamTokenizer.TT_WORD:
+ new_word = st.sval;
+
+/* The following commented out logic addresses bugzilla 110452 where the version and
+ * release numbers for spec files are stored in "%define" variables at the top of the file. It
+ * has been decided to put this change on hold until it can be determined how pervasive
+ * the use of this practice is. The code is incomplete for the time being and may be deleted
+ * entirely in future releases.
+ */
+/* if (found_version) {
+ found_version = false;
+ if (new_word.startsWith("%{")) { //$NON-NLS-1$
+ version_param = true;
+ define_info.add(0,new_word.substring(2,new_word.length()-1));
+ }
+ break;
+ }
+
+ if (found_release) {
+ found_release = false;
+ if (new_word.startsWith("%{")) { //$NON-NLS-1$
+// release_param = true;
+ define_info.add(1,new_word.substring(2,new_word.length()-1));
+ }
+ break;
+ } */
+
+ // See if we have found the Version: line
+ if (new_word.equals("Version:")) { //$NON-NLS-1$
+ found_version = true;
+ break;
+ }
+
+ // See if we have found the Release: line
+ if (new_word.equals("Release:")) { //$NON-NLS-1$
+ found_release = true;
+ break;
+ }
+
+ // Record where the last line of the form "Sourcex:" is
+ if (new_word.startsWith("Source") & //$NON-NLS-1$
+ new_word.endsWith(":")) { //$NON-NLS-1$
+ lastSourceLine = lines;
+ found_source_line = true;
+ break;
+ }
+
+ /* Record where the last line of the form "Patchx:" is and count how many there were.
+ * Also, record the statement so when we generate our new "Patchx:" statement
+ * we don't duplicate a "Patch" statement. This has to be done because a lot of
+ * spec files have "Patchx:" statements that are non-sequential
+ */
+ if (new_word.startsWith("Patch") & //$NON-NLS-1$
+ new_word.endsWith(":")) { //$NON-NLS-1$
+ lastPatchLine = lines;
+ numPatches++;
+ patchlist.add(new_word);
+
+ break;
+ }
+
+ // Record where the "%setup line is
+ if (new_word.equals("%setup")) { //$NON-NLS-1$
+
+ // set the "check for if" constructs switch
+ check_ifs = true;
+ setupLine = lines;
+
+ break;
+ }
+
+ if (new_word.equals("%build")) { //$NON-NLS-1$
+ check_ifs = false;
+
+ break;
+ }
+
+ // Record where the last (if any) "%patchx" line is
+ if (new_word.startsWith("%patch")) { //$NON-NLS-1$
+ lastPatchMacroLine = lines;
+ found_patch = true;
+
+ break;
+ }
+
+ // See if we have found a %define statement, if so save it as some
+ // source RPMs use %define statements to "define" version/release #'s
+/* See the comment several lines above regarding bugzilla 110452 as it also pertains to this code */
+/* if (new_word.equals("%define")) { //$NON-NLS-1$
+ found_define = true;
+ define_line_ptr[define_line_ctr] = lines;
+ define_line_ctr++;
+
+ break;
+ } */
+
+ if (found_define) {
+ found_define = false;
+// define_info.add(define_ctr,new_word);
+ define_ctr++;
+ found_define_name = true;
+ break;
+ }
+
+ if (found_define_name) {
+ found_define_name = false;
+// define_info.add(define_ctr,new_word);
+ define_ctr++;
+ break;
+ }
+
+ // Set the found %if/%ifarch/%ifnarch/%ifos/%ifnos switch
+ if (check_ifs) {
+ if (new_word.startsWith("%if")) { //$NON-NLS-1$
+ if_ctr++;
+
+ break;
+ }
+
+ // Reset the found %if/%ifarch switch
+ if (new_word.equals("%endif")) { //$NON-NLS-1$
+
+ if ((if_ctr > 0) & found_patch) {
+ if_ctr--;
+ lastPatchMacroLine = lines;
+ found_patch = false;
+
+ break;
+ }
+ }
+
+ break;
+ }
+
+ break;
+
+ default:
+ break;
+ }
+ }
+
+ sp_file.close();
+ } catch (IOException e) {
+ e.printStackTrace();
+ String throw_message = Messages.getString(
+ "RPMCore.Error_parsing_the_spec_file_in_the_project_--_157") + //$NON-NLS-1$
+ specFile.getLocation().toOSString();
+ IStatus error = new Status(IStatus.ERROR, IRPMConstants.ERROR, 1, throw_message,
+ null);
+ throw new CoreException(error);
+ }
+
+ if (numPatches > 1) {
+ int patch_num = getUniquePatchId(patchlist, numPatches);
+ numPatches = patch_num;
+ }
+ setConfigureArgs(parseConfigureArgs());
+ parseNameVerRel();
+ }
+
+ /**
+ * Method parseConfigureArgs.
+ * This method takes a spec file path and parses it to see if there are any options
+ * that need to be passed to the "configure" script when conmfiguring an RPM.
+ * @param path_to_specfile - contains a string with a path to the spec file to be
+ * searched to see if the "configure" command has any options to be applied
+ * @return a string containing the options to pass to configure if any were found
+ */
+ private String parseConfigureArgs() throws CoreException {
+ String path_to_specfile = specFile.getLocation().toOSString();
+
+ boolean found_config = false;
+ int lines = 0;
+ int config_line = 0;
+ String config_opts = ""; //$NON-NLS-1$
+
+ try {
+ FileReader sp_file = new FileReader(path_to_specfile);
+ StreamTokenizer st = new StreamTokenizer(sp_file);
+// st.resetSyntax();
+
+ // Make sure numbers, colons and percent signs are considered valid
+ st.wordChars('a','z');
+ st.wordChars('A','Z');
+ st.wordChars(':', ':');
+ st.wordChars('0', '9');
+ st.wordChars('%', '%');
+ st.wordChars('{', '}');
+ st.wordChars('-', '-');
+ st.wordChars('/','/');
+ st.wordChars('=','=');
+ st.wordChars('.','.');
+ st.wordChars('_','_');
+ st.eolIsSignificant(true);
+
+ String new_word;
+ int if_ctr = 0;
+ int token = st.nextToken();
+ while (token != StreamTokenizer.TT_EOF) {
+ token = st.nextToken();
+
+ switch (token) {
+ case StreamTokenizer.TT_EOL:
+ lines++;
+ break;
+ case StreamTokenizer.TT_WORD:
+ new_word = st.sval;
+ // System.out.println("---- " + new_word + line_sep + " line no = " + st.lineno());
+
+ // If '%configure' was found, gather the options if there were any
+ if (found_config & config_line == lines) {
+ config_opts = config_opts + " --" + new_word; //$NON-NLS-1$
+ break;
+ }
+ if (found_config & !(config_line == lines)) {
+ found_config = false;
+ break;
+ }
+
+ // See if there is a %configure section
+ if (new_word.equals("%configure")) { //$NON-NLS-1$
+ found_config = true;
+ config_line = lines;
+
+ break;
+ }
+ }
+ }
+
+ sp_file.close();
+ } catch (IOException e) {
+ String throw_message = Messages.getString(
+ "RPMCore.Error_parsing_the_spec_file_in_the_project_--_157") + //$NON-NLS-1$
+ path_to_specfile;
+ IStatus error = new Status(IStatus.ERROR, IRPMConstants.ERROR, 1, throw_message,
+ null);
+ throw new CoreException(error);
+ }
+
+ if(!found_config) {
+ return null;
+ }
+ return config_opts;
+ }
+
+ /**
+ * Method parseNameVerRel interrogates a spec file for the name, version and release
+ * of the RPM
+ * @param path_to_specfile contains a string pointing to the specfile to interrogate
+ * @return if successful, throw Exception if not
+ */
+
+ private void parseNameVerRel() throws CoreException {
+ String path_to_specfile = specFile.getLocation().toOSString();
+ ArrayList rpm_info = new ArrayList();
+ ArrayList define_info = new ArrayList();
+
+ // initialize version/release numbers to 0 in case none are found in the spec file
+ rpm_info.add(0, "0"); //$NON-NLS-1$
+ rpm_info.add(1, "0"); //$NON-NLS-1$
+ rpm_info.add(2, " "); //$NON-NLS-1$
+
+ boolean found_version = false;
+ boolean found_release = false;
+ boolean found_name = false;
+ boolean found_ver_token = false;
+ boolean found_rel_token = false;
+ boolean found_name_token = false;
+ boolean found_define = false;
+ boolean found_define_name = false;
+ int define_ctr = 0;
+
+ File f = new File(path_to_specfile);
+
+ if (!f.exists()) {
+ String throw_message = "" + //$NON-NLS-1$
+ path_to_specfile;
+ IStatus error = new Status(IStatus.ERROR, Messages.getString("RPMCore.Error_1"), 1, //$NON-NLS-1$
+ throw_message, null);
+ throw new CoreException(error);
+ }
+
+ try {
+ FileReader sp_file = new FileReader(path_to_specfile);
+ StreamTokenizer st = new StreamTokenizer(sp_file);
+
+ // Make sure numbers, colons and periods are considered valid characters
+ st.resetSyntax();
+ st.wordChars(':', ':');
+ st.wordChars('0', '9');
+ st.wordChars('.', '.');
+ st.wordChars('A', 'z');
+ st.wordChars('%','%');
+ st.wordChars('{','{');
+ st.wordChars('}','}');
+
+ int token = 0;
+ String new_word;
+outer:
+ while (token != StreamTokenizer.TT_EOF) {
+ token = st.nextToken();
+
+ switch (token) {
+ case StreamTokenizer.TT_WORD:
+ new_word = st.sval;
+
+ if (found_define) {
+ found_define = false;
+ define_info.add(define_ctr,new_word);
+ define_ctr++;
+ found_define_name = true;
+ break;
+ }
+
+ if (found_define_name) {
+ found_define_name = false;
+ define_info.add(define_ctr,new_word);
+ define_ctr++;
+ break;
+ }
+
+ if (found_version & !found_ver_token) {
+ found_ver_token = true;
+ if (new_word.startsWith("%")) { //$NON-NLS-1$
+ try {
+ rpm_info.set(0,parseDefine(new_word, define_info));
+ } catch (Exception e) {
+ String throw_message = Messages.getString("RPMCore.Error_using_parseDefine_to_get_the_version_no._41") + //$NON-NLS-1$
+ Messages.getString("RPMCore._from_the_spec_file_at___42") + path_to_specfile; //$NON-NLS-1$
+ IStatus error = new Status(IStatus.ERROR, Messages.getString("RPMCore.Error_1"), 1, //$NON-NLS-1$
+ throw_message, null);
+ throw new CoreException(error);
+ }
+ } else {
+ rpm_info.set(0, new_word);
+ }
+
+ // System.out.println("Found version = " + new_word);
+ if (found_name_token & found_ver_token &
+ found_rel_token) {
+ break outer;
+ }
+
+ break;
+ }
+
+ if (found_release & !found_rel_token) {
+ found_rel_token = true;
+ if (new_word.startsWith("%")) { //$NON-NLS-1$
+ try {
+ rpm_info.set(1,parseDefine(new_word, define_info));
+ } catch (Exception e) {
+ String throw_message = Messages.getString("RPMCore.Error_using_parseDefine_to_get_the_release_no._44") + //$NON-NLS-1$
+ Messages.getString("RPMCore._from_the_spec_file_at___45") + path_to_specfile; //$NON-NLS-1$
+ IStatus error = new Status(IStatus.ERROR, Messages.getString("RPMCore.Error_1"), 1, //$NON-NLS-1$
+ throw_message, null);
+ throw new CoreException(error);
+ }
+ break;
+ } else {
+ rpm_info.set(1, new_word);
+ }
+
+ // System.out.println("Found release = " + new_word);
+ if (found_name_token & found_ver_token &
+ found_rel_token) {
+ break outer;
+ }
+
+ break;
+ }
+
+ if (found_name & !found_name_token) {
+ found_name_token = true;
+ rpm_info.set(2, new_word);
+
+ // System.out.println("Found name = " + new_word);
+ if (found_name_token & found_ver_token &
+ found_rel_token) {
+ break outer;
+ }
+
+ break;
+ }
+
+ // See if this is a "Version:" tag
+ if (new_word.equals("Version:")) { //$NON-NLS-1$
+ found_version = true;
+ break;
+ }
+
+ // See if this is a "Release:" tag
+ if (new_word.equals("Release:")) { //$NON-NLS-1$
+ found_release = true;
+ break;
+ }
+
+ // See if this is a "Name:" tag
+ if (new_word.equals("Name:")) { //$NON-NLS-1$
+ found_name = true;
+ break;
+ }
+
+ // See if this a "%define" statement
+ // the version and release can sometimes be in a define stmt
+ if (new_word.equals("%define")) { //$NON-NLS-1$
+ found_define = true;
+ break;
+ }
+
+ default:
+ break;
+ }
+ }
+ } catch (IOException e) {
+ String throw_message = Messages.getString(
+ "RPMCore.Error_parsing_the_spec_file_at") + //$NON-NLS-1$
+ path_to_specfile;
+ IStatus error = new Status(IStatus.ERROR, Messages.getString("RPMCore.Error_1"), 1, //$NON-NLS-1$
+ throw_message, null);
+ throw new CoreException(error);
+ }
+
+ /* Ugly: In rpm_info ArrayList:
+ * [0] = Version
+ * [1] = Release
+ * [2] = Name
+ */
+ setVersion((String) rpm_info.get(0));
+ setRelease((String) rpm_info.get(1));
+ setName((String) rpm_info.get(2));
+ }
+
+ /**
+ * Method parseDefine accepts a token from the parser and
+ * searches the ArrayList passed to it for the value of the
+ * token name. This is crude at this point since this does not
+ * happen very often.
+ * @param token is a string containing the name found after the
+ * "Version:" or "Release:" fields of a spec file and the
+ * begining character is a "%"
+ * @param token_value ia an ArrayList containing the names and
+ * values found in the "%define" statements usually found
+ * at the top of the spec file
+ * @return a string with the correct version or release number
+ * else throw a CoreException
+ */
+ private String parseDefine(String token, ArrayList token_value)
+ throws CoreException {
+ // See if there in anything in the ArrayList
+ if (token_value.isEmpty()) {
+ String throw_message = Messages.getString("RPMCore.No___%defines___were_found_in_the_spec_file_38"); //$NON-NLS-1$
+ IStatus error = new Status(IStatus.ERROR, Messages.getString("RPMCore.Error_1"), 1, //$NON-NLS-1$
+ throw_message, null);
+ throw new CoreException(error);
+ }
+ // A token usually looks this: %{name}
+ String token_name = token.substring(2,token.length()-1);
+ int i = token_value.indexOf(token_name);
+ return (String) token_value.get(i+1);
+ }
+
+ private int getUniquePatchId(ArrayList patchlist, int patch_ctr) {
+ int patch_array_size = patchlist.size();
+ String num_string;
+ int patch_num;
+ String last_patch = (String) patchlist.get(patch_array_size - 1);
+ int indx = 5;
+
+ while (last_patch.charAt(indx) != ':') {
+ indx++;
+ }
+
+ // Allow for the fact that there could only be one patch statement of the
+ // form "Patch:", that is, there is no number
+ if (indx == 5) {
+ return 0;
+ }
+
+ String num = last_patch.substring(5, indx);
+
+ try {
+ patch_num = Integer.parseInt(num, 10);
+ } catch (NumberFormatException e) {
+ return -1;
+ }
+
+ return patch_num + 1;
+ }
+ public String getConfigureArgs() {
+ return configureArgs;
+ }
+ public String getName() {
+ return name;
+ }
+ public String getRelease() {
+ return release;
+ }
+ public String getVersion() {
+ return version;
+ }
+ private void setConfigureArgs(String configureArgs) {
+ this.configureArgs = configureArgs;
+ }
+ private void setName(String name) {
+ this.name = name;
+ }
+ private void setRelease(String release) {
+ this.release = release;
+ }
+ private void setVersion(String version) {
+ this.version = version;
+ }
+
+ public int getLastPatchLine() {
+ return lastPatchLine;
+ }
+
+ private void setLastPatchLine(int lastPatchLine) {
+ this.lastPatchLine = lastPatchLine;
+ }
+
+ public int getLastPatchMacroLine() {
+ return lastPatchMacroLine;
+ }
+
+ private void setLastPatchMacroLine(int lastPatchMacroLine) {
+ this.lastPatchMacroLine = lastPatchMacroLine;
+ }
+
+ public int getLastSourceLine() {
+ return lastSourceLine;
+ }
+
+ private void setLastSourceLine(int lastSourceLine) {
+ this.lastSourceLine = lastSourceLine;
+ }
+
+ public int getNumPatches() {
+ return numPatches;
+ }
+
+ private void setNumPatches(int numPatches) {
+ this.numPatches = numPatches;
+ }
+
+ public int getSetupLine() {
+ return setupLine;
+ }
+
+ private void setSetupLine(int setupLine) {
+ this.setupLine = setupLine;
+ }
+}
Index: src/org/eclipse/cdt/rpm/core/internal/rpm_strings.properties
===================================================================
RCS file: src/org/eclipse/cdt/rpm/core/internal/rpm_strings.properties
diff -N src/org/eclipse/cdt/rpm/core/internal/rpm_strings.properties
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ src/org/eclipse/cdt/rpm/core/internal/rpm_strings.properties 1 Jan 1970 00:00:00 -0000
@@ -0,0 +1,220 @@
+###############################################################################
+# (c) 2004 Red Hat, Inc.
+#
+# This program is open source software licensed under the
+# Eclipse Public License ver. 1
+#
+###############################################################################
+
+RPMCore.Error=Error
+RPMCore.Error_trying_to_copy__=Error trying to copy
+RPMCore._to__=\ to
+RPMCore.--executeRPMlinux_command__95=--executeRPMlinux_command:
+RPMCore.Error_executing__97=Error executing
+RPMCore.Error_waiting_for__99=Error waiting for
+RPMCore._to_complete._100=\ to complete.
+RPMCore.Command__102=Command
+RPMCore._was_interrupted._103=\ was interrupted.
+RPMCore.The_patch_name__109=The patch name
+RPMCore._is_not_unique._110=\ is not unique.
+RPMCore._nPlease_modify_the___Patch_tag___field_and_try_again._111=\nPlease modify the \'Patch tag\' field and try again.
+RPMCore.Error_trying_to_parse_spec_file_113=Error trying to parse spec file\nMaybe a character encoding error?
+RPMCore._nIs_there_a_spec_file_at___114=\nIs there a spec file at:
+RPMCore.Failed_to_open_the_output_spec_file_at__123=Failed to open the output spec file at
+RPMCore.Error_trying_to_modify__132=Error trying to modify
+RPMCore.Error_parsing_the_spec_file_in_the_project_--_157=Error parsing the spec file in the project --
+RPMCore.Failed_to_find_a___install__or___clean____section_in_the__180=Failed to find a \'install: or \'clean:\' section in the
+RPMCore.project__s_M/makefile.__THIS_IS_REQUIRED_!_!_!_181=project\'s M/makefile. THIS IS REQUIRED\!\!\!
+RPMCore.I/O_error_processing/reading_the_M/makefile__183=I/O error processing/reading the M/makefile
+RPMCore.Failed_to_find_a_M/makefile_in_the_project.___THIS_IS_REQUIRED_!_!_!_185=Failed to find a M/makefile in the project. THIS IS REQUIRED\!\!\!
+RPMCore.Failed_to_create_RPM_directories,_check_file_permissions_in__195=Failed to create RPM directories, check file permissions in
+RPMCore.Failed_to_create_RPM_directories_in__203=Failed to create RPM directories in
+RPMCore._--_check_file_permissions._204=\ -- check file permissions.
+RPMCore.Error_executing__208=Error executing
+RPMCore.command._nSomething_is_wrong_with_file_permissions._209=command.\nSomething is wrong with file permissions.
+RPMCore.Problem_creating_the_.rpmrc_file.__Check_file_permissions_in__217=Problem creating the .rpmrc file. Check file permissions in
+RPMCore.Problem_creating_the_.rpmmacros_file._nCheck_file_permissions_in__226=Problem creating the .rpmmacros file.\nCheck file permissions in
+RPMCore.Problem_creating_the_.rpmmacros_file._nCheck_file_permissions_in__228=Problem creating the .rpmmacros file.\nCheck file permissions in
+RPMCore.Problem_creating_the_rpm_spec_file._nCheck_file_permissions_in__247=Problem creating the rpm spec file.\nCheck file permissions in
+RPMCore.Problem_running_the___make___file_to_create_the_executables._nView_the_log_file_at__249=Problem running the \'make\' file to create the executables.\nView the log file at
+RPMCore.Problem_creating_the___make_install___shell_script_--___rpmbuild.sh__.___270=Problem creating the \'make install\' shell script -- \'rpmbuild.sh\'.
+RPMCore._nCheck_file_permissions_in__271=\nCheck file permissions in
+RPMCore.Problem_running_the___make_install___shell_script_--__273=Problem running the \'make install\' shell script --
+RPMCore._nThere_may_be_a_problem_in_the_M/makefile._274=\nThere may be a problem in the M/makefile.
+RPMCore.No_files_were_found_under_build_root_--__276=No files were found under build root --
+RPMCore._n_--_Problem_with_the___install____section_of_the_spec_file__277=\n -- Problem with the \'install:\' section of the spec file?
+RPMCore.Problem_creating_spec_file.__Check_permissions_in__324=Problem creating spec file. Check permissions in
+RPMCore.Problem_creating_spec_file.__Check_permissions_in__326=Problem creating spec file. Check permissions in
+RPMCore.source_328=source
+RPMCore.Error_executing___make_clean___in__329=Error executing \'make clean\' in
+RPMCore.Problem_creating_a_shell_script_--__342=Problem creating a shell script --
+RPMCore._nThere_may_be_a_problem_in_the_M/makefile._343=\nThere may be a problem in the M/makefile.
+RPMCore.Problem_running_this_command___346=Problem running this command:
+RPMCore._nCheck_permissions._347=\nCheck permissions.
+RPMCore.Error_trying_to_create_shell_script_to_install__352=Error trying to create shell script to install
+RPMCore.the_source_rpm._nCheck_the_file_permissions_in__353=the source rpm.\nCheck the file permissions in
+RPMCore.Error_trying_to_install_the_source_with_this_command__355=Error trying to install the source with this command
+RPMCore._nCheck_the_log_at__356=\nCheck the log at
+RPMCore./SPECS/_359=/SPECS/
+RPMCore.There_is_not_a__360=There is not a
+RPMCore._directory._nCheck_permissions_in_the_path_directories._361=\ directory.\nCheck permissions in the path directories.
+RPMCore.An_error_in_the__364=An error in the
+RPMCore.directory._nEither_there_is_either_no_spec_file_or_more_than_one._365=directory.\nEither there is either no spec file or more than one.
+RPMCore.There_are_either_no_directories_or_too_many_directories_under__369=There are either no directories or too many directories under
+RPMCore.An_error_occurred_trying_to_rename__373=An error occurred trying to rename
+RPMCore.Error_creating_shell_script_for_the__381=Error creating shell script for the
+RPMCore._nCheck_file_permissions._382=\nCheck file permissions.
+RPMCore.Error_executing_the_command_to_build_prep_the_rpm_-__384=Error executing the command to build prep the rpm -
+RPMCore._nCheck_the_log_at__385=\nCheck the log at
+RPMCore.There_should_be_only_one_directory_under__391=There should be only one directory under
+RPMCore._at_this_point_392=\ at this point
+RPMCore.This_file_already_exists___396=This file already exists:
+RPMCore.Error_trying_to_create_.srpminfo_file._401=Error trying to create .srpminfo file.
+RPMCore.Problem_copying_source_rpm_info_file._nCheck_permissions_in__409=Problem copying source rpm info file.\nCheck permissions in
+RPMCore.Problem_copying_source_rpm_info_file._nCheck_permissions_in__411=Problem copying source rpm info file.\nCheck permissions in
+RPMCore.Error_trying_to_copy_the_target_project_directory_tree_with_this_command_--__417=Error trying to copy the target project directory tree with this command --
+RPMCore._nFile_permissions_problem__418=\nFile permissions problem?
+RPMCore.Error_trying_to_check_for_Makefile_in__421=Error trying to check for Makefile in
+RPMCore.Error_--_the_M/makefile_does_not_have_either_an___install____or___clean_____423=Error -- the M/makefile does not have either an \'install:\' or \'clean:\'
+RPMCore.section._nLook_in_this_directory_____424=section.\nLook in this directory:
+RPMCore.Error_running___make_clean___in__426=Error running \'make clean\' in
+RPMCore.Error_either_creating_or_executing_the___make_clean___command_in__428=Error either creating or executing the \'make clean\' command in
+RPMCore.There_are_too_many_directories_in__432=There are too many directories in
+RPMCore.Error_trying_to_rename_directory_in__438=Error trying to rename directory in
+RPMCore.Permissions_problem__440=Permissions problem?
+RPMCore.Error_trying_to_parse_spec_file_442=Error trying to parse spec file
+RPMCore._nIs_there_a_spec_file_at___443=\nIs there a spec file at:
+RPMCore.Error_trying_to_create_a_tarball_of_the_source_using_this_command_--__454=Error trying to create a tarball of the source using this command --
+RPMCore.A_problem_occurred_creating_the_rpmbuild_shell_script.___461=A problem occurred creating the rpmbuild shell script.
+RPMCore._nPlease_check_the_file_permissions_in_/var/tmp__462=\nPlease check the file permissions in /var/tmp
+RPMCore.A_problem_occurred_running_this_command.___464=A problem occurred running this command.
+RPMCore.__nPlease_review_the_log_at__465=\ \nPlease review the log at\nWindows->Show View->Other...->RPM Plugin Log File->RPM Plugin Log Viewer
+RPMCore.There_should_be_only_one_directory_under__467=There should be only one directory under
+RPMCore.__nCheck_the_directories_there.__The_RPM_work_area_in_/var/tmp_will_be_preserved._468=\ \nCheck the directories there. The RPM work area in /var/tmp will be preserved.
+RPMCore.Error_trying_to_delete__477=Error trying to delete
+RPMCore._nCheck_permissions._478=\nCheck permissions.
+RPMCore.Error_deleting_resources.__Check_file_permissions_in__483=Error deleting resources. Check file permissions in
+RPMCore.Problem_deleting_the_log_file_at__486=Problem deleting the log file at
+RPMCore.__Check_the_permissions._487=\ \ Check the permissions.
+RPMCore.Error_deleting_files_in_deleteSRPMextrafiles_496=Error deleting files in deleteSRPMextrafiles
+RPMCore.Error_deleting_files_in_deleteSRPMextrafiles_498=Error deleting files in deleteSRPMextrafiles
+RPMCore.executeProjConfigure_500=executeProjConfigure
+RPMCore./bin/chmod_-R_u+r__501=/bin/chmod -R u+r
+RPMCore./_502=/
+RPMCore.Error_executing_the_command__503=Error executing the command
+RPMCore.__Check_permissions_of__504=\ \ Check permissions of
+RPMCore.Problem_creating_the___make_clean/distclean/maintainer-clean___shell_script_--__515=Problem creating the \'make clean/distclean/maintainer-clean\' shell script --
+RPMCore._nThere_may_be_a_problem_in_the_M/makefile._516=\nThere may be a problem in the M/makefile.
+RPMCore.Problem_running_the___make_install___shell_script_--__518=Problem running the \'make install\' shell script --
+RPMCore._nThere_may_be_a_problem_in_the_M/makefile._519=\nThere may be a problem in the M/makefile.
+RPMCore.Problem_deleting_extra_files_from_project_in_deleteSRPMextrafiles_521=Problem deleting extra files from project in deleteSRPMextrafiles
+RPMCore.Problem_deleting_extra_files_in_the_project_in_deleteEclipseiles._523=Problem deleting extra files in the project in deleteEclipseiles.
+RPMCore.There_should_only_be_two_directories_in__531=There should only be two directories in
+RPMCore.Error_executing_the_command__538=Error executing the command
+RPMCore.__Check_permissions_of__539=\ \ Check permissions of
+RPMCore.Error_in_the_Makefile_in__541=Error in the Makefile in
+RPMCore._nMake_sure_there_is_a_clean_/distclean_/realclean_section__542=\nMake sure there is a clean:/distclean:/realclean section:
+RPMCore.Error_running_the___make_distclean/realclean/mainainer-clean____544=Error running the \'make distclean/realclean/maintainer-clean\'
+RPMCore.command_on_the_previous_source_RPM_545=command on the previous source RPM
+RPMCore.Error_creating_shell_script_for_the__553=Error creating shell script for the
+RPMCore._nCheck_file_permissions._554=\nCheck file permissions.
+RPMCore.Error_executing_the_command_to_create_the_patch_file_-__558=Error executing the command to create the patch file -
+RPMCore._nAre_you_sure_there_were_changes_made_to_the_project__559=\nAre you sure there were changes made to the project?
+RPMCore.rpm_spec_should_not_be_null_here_in__567=rpm_spec should not be null here in
+RPMCore.A_problem_occurred_creating_the_rpmbuild_shell_script.___571=A problem occurred creating the rpmbuild shell script.
+RPMCore._nPlease_check_the_file_permissions_in_/var/tmp__572=\nPlease check the file permissions in /var/tmp
+RPMCore.A_problem_occurred_running_this_command.___574=A problem occurred running this command.
+RPMCore._nPlease_review_the_log_at__575=\nPlease review the log at\nWindows->Show View->Other...->RPM Plugin Log File->RPM Plugin Log Viewer
+RPMCore.There_are_too_many_directories_in__577=There are too many directories in
+RPMCore.Unable_to_delete_file__582=Unable to delete file
+RPMCore._nCheck_permissions_in_the_project._583=\nCheck permissions in the project.
+RPMCore.Error_returned_from_firstSRPM_trying__588=Error returned from firstSRPM() trying
+RPMCore.to_copy_the_spec_file_from_the_work_area_to_the_project_589=to copy the spec file from the work area to the project
+RPMCore.Error_trying_to_rename__591=Error trying to rename
+RPMCore.Error_trying_to_create_.srpminfo_file._594=Error trying to create .srpminfo file.
+RPMCore.Error_trying_to_copy_spec_file_from_work__598=Error trying to copy spec file from work
+RPMCore.area_to_Eclipse_project_directory_599=area to Eclipse project directory
+RPMCore.Error_copying_directories_in__1=Error copying directories in
+RPMCore.Error_trying_to_copy_project_directory(_3=Error trying to copy project directory(
+RPMCore.)_to_the_work_area(_4=) to the work area(
+RPMCore.Error_trying_to_write_to__8=Error trying to write to
+RPMCore.Error_1=Error
+RPMCore.Error_6=Error
+RPMCore.Error_8=Error
+RPMCore.Error_creating_directory___18=Error creating directory:
+RPMCore._nCheck_permissions__19=\nCheck permissions?
+RPMCore.Error_copying_project_source_from__20=Error copying project source from
+RPMCore._to__21=\ to
+RPMCore.Error_creating_the_shell_script_to_untar_or__22=Error creating the shell script to untar or
+RPMCore.executing_the_shell_script_to_untar_the_source._Command____23=executing the shell script to untar the source. Command =
+RPMCore.Error_copying_source_from__24=Error copying source from
+RPMCore._to__25=\ to
+RPMCore.__26=\
+RPMCore.0=Error generating checksum:
+RPMCore.Error_trying_to_copy_file__27=Error trying to copy file
+RPMCore._to__28=\ to
+RPMCore.Error_trying_to_set_up_rpm__29=Error trying to set up rpm
+RPMCore.in__30=in
+RPMCore._to_create_patches_31=\ to create patches
+RPMCore.Checksum___32=Checksum:
+RPMCore.Error_parsing_spec_file_at__33=Error parsing spec file at
+RPMCore.Error_either_creating_or_running_configure_script_34=Error either creating or running configure script
+RPMCore.RPMCore._to__7_35=RPMCore._to__7
+RPMCore.Error_36=Error
+RPMCore.Error_37=Error
+RPMCore.Error_39=Error
+RPMCore.Error_40=Error
+RPMCore.Error_47=Error
+RPMCore.An_error_occurred_either_creating_the_shell_script_containing_2=An error occurred either creating the shell script containing
+RPMCore.this_command____3=this command:\n
+RPMCore._nor_trying_to_execute_it._nView_the_log_at___4=\nor trying to execute it.\nView the log at:
+RPMCore._for_more_details_5=\ for more details
+RPMCore.Error_1=Error
+RPMCore.There_is_not_a_.srpminfo_file_in__7=There is not a .srpminfo file in
+RPMCore.There_is_no_longer_a_source_RPM_at__86=There is no longer a source RPM at
+RPMCore.Error_getting_info_from__93=Error getting info from
+RPMCore.Error_during__191=Error during
+RPMCore._execution..error____192=\ execution..error =
+RPMCore.Error_trying_to_copy__6=Error trying to copy
+RPMCore._to__7=\ to
+RPMCore.Error_trying_to_write_to__8=Error trying to write to
+RPMCore.No___%defines___were_found_in_the_spec_file_38=No \'%defines\' were found in the spec file
+RPMCore.Failed_to_find_a_spec_file_at=Failed to find a spec file at
+RPMCore.Error_using_parseDefine_to_get_the_version_no._41=Error using parseDefine to get the version no.
+RPMCore._from_the_spec_file_at___42=\ from the spec file at:
+RPMCore.Error_using_parseDefine_to_get_the_release_no._44=Error using parseDefine to get the release no.
+RPMCore._from_the_spec_file_at___45=\ from the spec file at:
+RPMCore.Error_parsing_the_spec_file_at=Error parsing the spec file at
+RPMCore.Error_creating_srpminfo_file_in_the_project._9=Error creating srpminfo file in the project.
+RPMCore._nCheck_permissions_in__10=\nCheck permissions in
+RPMExportCore.Too_many_spec_files_in__4=Too many spec files in
+RPMExportCore.Error_trying_to_delete__5=Error trying to delete
+ImportSRPM.Error_occurred_during_the_source_install._n_1=Error occurred during the source install.\n
+ImportSRPM.There_are_either_too_many_or_0_directories_under__2=There are either too many or 0 directories under
+ImportSRPM.Cannot_find_a_tarball_to_untar_in___3=Cannot find a tarball to untar in:
+LinuxShellCmds.Error_attempting_to_create___1=Error attempting to create:
+LinuxShellCmds.Cannot_copy_a_directory___2=Cannot copy a directory:
+LinuxShellCmds._to_a_file___3=\ to a file:
+LinuxShellCmds.Error_attempting_to_copy_source_from___4=Error attempting to copy source from:
+LinuxShellCmds._to__5=\ to
+LinuxShellCmds.1=Process returned non-zero value:
+LinuxShellCmds.2=Process output:\n
+LinuxShellCmds.3=Process error:\n
+LinuxShellCmds.4=Process executed successfully
+LinuxShellCmds.5=Process output:\n
+LinuxShellCmds.6=Process error:\n
+LinuxShellCmds.7=\n Error output from command:\n
+LinuxShellCmds.9=Process returned non-zero value:
+LinuxShellCmds.10=Process output:\n
+LinuxShellCmds.11=Process error:\n
+LinuxShellCmds.12=Process executed successfully
+LinuxShellCmds.13=Process output:\n
+LinuxShellCmds.14=Process error:\n
+LinuxShellCmds.15=Error executing
+RPMCore._nThis_RPM_*must*_be_restored_before_exporting_can_occur._1=\nThis RPM *must* be restored before exporting can occur.
+RPMCore.Error_creating__1=Error creating
+RPMCore._nCheck_permissions__2=\nCheck permissions?
+RPMCore.spec_file_ambiguous=More than one file found in
+RPMCore.RPMProjectFactory.0=Error constructing spec file model
+RPMCore.RPMProjectFactory.1=Error constructing source RPM model
+RPMCore.RPMProject.prepareExport=The project is not an RPM project
Index: src/org/eclipse/cdt/rpm/core/utils/Diff.java
===================================================================
RCS file: src/org/eclipse/cdt/rpm/core/utils/Diff.java
diff -N src/org/eclipse/cdt/rpm/core/utils/Diff.java
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ src/org/eclipse/cdt/rpm/core/utils/Diff.java 1 Jan 1970 00:00:00 -0000
@@ -0,0 +1,56 @@
+/*
+ * (c) 2005 Red Hat, Inc.
+ *
+ * This program is open source software licensed under the
+ * Eclipse Public License ver. 1
+ */
+
+package org.eclipse.cdt.rpm.core.utils;
+
+import org.eclipse.cdt.rpm.core.IRPMConstants;
+import org.eclipse.cdt.rpm.core.RPMCorePlugin;
+import org.eclipse.cdt.rpm.core.utils.internal.ShellScript;
+import org.eclipse.core.runtime.CoreException;
+import org.eclipse.core.runtime.Preferences;
+
+/**
+ * A utility class for executing a diff.
+ *
+ */
+public class Diff {
+
+ private String diffCmd;
+
+ /**
+ * Constructs a new object to run diff.
+ * @param baseDir the absolute path of the directory to run the diff in
+ * @param oldPath the path containing old resources to use in the diff
+ * @param newPath the path containing new resources to use in the diff
+ * @param excludes an array of paths to resources to exclude from the diff
+ * @param outputFile the path of the file to redirect the diff output to
+ */
+ public Diff(String baseDir, String oldPath, String newPath, String[] excludes,
+ String outputFile) {
+ Preferences prefs = RPMCorePlugin.getDefault().getPluginPreferences();
+ String pathToDiff = prefs.getString(IRPMConstants.DIFF_CMD);
+
+ diffCmd = "cd " + baseDir + " && "; //$NON-NLS-1$ //$NON-NLS-2$
+ diffCmd += pathToDiff + " -uNr "; //$NON-NLS-1$
+ diffCmd += "--ignore-matching-lines=POT-Creation-Date --exclude=autom4te.cache "; //$NON-NLS-1$
+ for(int i=0; i < excludes.length; i++) {
+ diffCmd += "--exclude=" + excludes[i] + " "; //$NON-NLS-1$ //$NON-NLS-2$
+ }
+ diffCmd += oldPath + " " + newPath + " "; //$NON-NLS-1$ //$NON-NLS-2$
+ diffCmd += "> " + outputFile;
+ }
+
+ /**
+ * Executes the diff operation.
+ * @throws CoreException if the operation fails
+ */
+ public void exec() throws CoreException {
+ ShellScript script = new ShellScript(diffCmd, 1);
+ script.execNoLog();
+ }
+
+}
Index: src/org/eclipse/cdt/rpm/core/utils/RPM.java
===================================================================
RCS file: src/org/eclipse/cdt/rpm/core/utils/RPM.java
diff -N src/org/eclipse/cdt/rpm/core/utils/RPM.java
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ src/org/eclipse/cdt/rpm/core/utils/RPM.java 1 Jan 1970 00:00:00 -0000
@@ -0,0 +1,58 @@
+/*
+ * (c) 2005 Red Hat, Inc.
+ *
+ * This program is open source software licensed under the
+ * Eclipse Public License ver. 1
+ */
+package org.eclipse.cdt.rpm.core.utils;
+
+import org.eclipse.cdt.rpm.core.IRPMConfiguration;
+import org.eclipse.cdt.rpm.core.IRPMConstants;
+import org.eclipse.cdt.rpm.core.RPMCorePlugin;
+import org.eclipse.cdt.rpm.core.utils.internal.ShellScript;
+import org.eclipse.core.resources.IFile;
+import org.eclipse.core.runtime.CoreException;
+
+/**
+ * A utility class for executing RPM commands.
+ *
+ */
+public class RPM {
+
+ private String macroDefines;
+ private String rpmCmd;
+ private IRPMConfiguration config;
+
+ /**
+ * Constructs a new RPM object.
+ * @param config the RPM configuration to use
+ */
+ public RPM(IRPMConfiguration config) {
+ this.config = config;
+ rpmCmd = RPMCorePlugin.getDefault().getPluginPreferences().getString(IRPMConstants.RPM_CMD) +
+ " -v "; //$NON-NLS-1$
+ macroDefines = " --define '_sourcedir " + //$NON-NLS-1$
+ config.getSourcesFolder().getLocation().toOSString() + "' "; //$NON-NLS-1$
+ macroDefines += "--define '_srcrpmdir " + //$NON-NLS-1$
+ config.getSrpmsFolder().getLocation().toOSString() + "' "; //$NON-NLS-1$
+ macroDefines += "--define '_builddir " + //$NON-NLS-1$
+ config.getBuildFolder().getLocation().toOSString() + "' "; //$NON-NLS-1$
+ macroDefines += "--define '_rpmdir " + //$NON-NLS-1$
+ config.getRpmsFolder().getLocation().toOSString() + "' "; //$NON-NLS-1$
+ macroDefines += "--define '_specdir " + //$NON-NLS-1$
+ config.getSpecsFolder().getLocation().toOSString() + "' "; //$NON-NLS-1$
+ }
+
+ /**
+ * Installs a given source RPM
+ * @param sourceRPM
+ * @throws CoreException
+ */
+ public void install(IFile sourceRPM) throws CoreException {
+ String command = rpmCmd;
+ command += macroDefines;
+ command += " -i " + sourceRPM.getLocation().toOSString(); //$NON-NLS-1$
+ ShellScript script = new ShellScript(command, 0);
+ script.exec();
+ }
+}
Index: src/org/eclipse/cdt/rpm/core/utils/RPMBuild.java
===================================================================
RCS file: src/org/eclipse/cdt/rpm/core/utils/RPMBuild.java
diff -N src/org/eclipse/cdt/rpm/core/utils/RPMBuild.java
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ src/org/eclipse/cdt/rpm/core/utils/RPMBuild.java 1 Jan 1970 00:00:00 -0000
@@ -0,0 +1,113 @@
+/*
+ * (c) 2005 Red Hat, Inc.
+ *
+ * This program is open source software licensed under the
+ * Eclipse Public License ver. 1
+ */
+package org.eclipse.cdt.rpm.core.utils;
+
+import org.eclipse.cdt.rpm.core.IRPMConfiguration;
+import org.eclipse.cdt.rpm.core.IRPMConstants;
+import org.eclipse.cdt.rpm.core.RPMCorePlugin;
+import org.eclipse.cdt.rpm.core.utils.internal.ShellScript;
+import org.eclipse.core.resources.IFile;
+import org.eclipse.core.runtime.CoreException;
+
+/**
+ * A utility class for executing rpmbuild commands.
+ *
+ */
+public class RPMBuild {
+
+ private IRPMConfiguration config;
+
+ private String macroDefines;
+
+ private String rpmBuildCmd;
+
+ /**
+ * Constructs a new object.
+ * @param config the RPM configuration to use
+ */
+ public RPMBuild(IRPMConfiguration config) {
+ this.config = config;
+ rpmBuildCmd =
+ RPMCorePlugin.getDefault().getPluginPreferences().getString(IRPMConstants.RPMBUILD_CMD) +
+ " -v "; //$NON-NLS-1$
+ macroDefines = " --define '_sourcedir " +
+ config.getSourcesFolder().getLocation().toOSString() + "' "; //$NON-NLS-1$
+ macroDefines += "--define '_srcrpmdir " + //$NON-NLS-1$
+ config.getSrpmsFolder().getLocation().toOSString() + "' "; //$NON-NLS-1$
+ macroDefines += "--define '_builddir " + //$NON-NLS-1$
+ config.getBuildFolder().getLocation().toOSString() + "' "; //$NON-NLS-1$
+ macroDefines += "--define '_rpmdir " + //$NON-NLS-1$
+ config.getRpmsFolder().getLocation().toOSString() + "' "; //$NON-NLS-1$
+ macroDefines += "--define '_specdir " + //$NON-NLS-1$
+ config.getSpecsFolder().getLocation().toOSString() + "' "; //$NON-NLS-1$
+ }
+
+ /**
+ * Prepares the sources for a given spec file.
+ * @param specFile the spec file
+ * @throws CoreException if the operation fails
+ */
+ public void buildPrep(IFile specFile) throws CoreException {
+ String command = rpmBuildCmd;
+ command += macroDefines;
+ command += " -bp " + specFile.getLocation().toOSString(); //$NON-NLS-1$
+ ShellScript script = new ShellScript(command, 0);
+ script.exec();
+ }
+
+ /**
+ * Builds a binary RPM for a given spec file.
+ * @param specFile the spec file
+ * @throws CoreException if the operation fails
+ */
+ public void buildBinary(IFile specFile) throws CoreException {
+ String command = rpmBuildCmd;
+ command += macroDefines;
+ command += " -bb " + specFile.getLocation().toOSString(); //$NON-NLS-1$
+ ShellScript script = new ShellScript(command, 0);
+ script.exec();
+ }
+
+ /**
+ * Rebuilds a binary RPM from a given source RPM.
+ * @param sourceRPM the source RPM
+ * @throws CoreException if the operation fails
+ */
+ public void rebuild(IFile sourceRPM) throws CoreException {
+ String command = rpmBuildCmd;
+ command += macroDefines;
+ command += " --rebuild " + sourceRPM.getLocation().toOSString(); //$NON-NLS-1$
+ ShellScript script = new ShellScript(command, 0);
+ script.exec();
+ }
+
+ /**
+ * Builds both a binary and source RPM for a given spec file.
+ * @param specFile the spec file
+ * @throws CoreException if the operation fails
+ */
+ public void buildAll(IFile specFile) throws CoreException {
+ String command = rpmBuildCmd;
+ command += macroDefines;
+ command += " -ba " + specFile.getLocation().toOSString(); //$NON-NLS-1$
+ ShellScript script = new ShellScript(command, 0);
+ script.exec();
+ }
+
+ /**
+ * Builds a source RPM for a given spec file.
+ * @param specFile the spec file
+ * @throws CoreException if the operation fails
+ */
+ public void buildSource(IFile specFile) throws CoreException {
+ String command = rpmBuildCmd;
+ command += macroDefines;
+ command += " -bs " + specFile.getLocation().toOSString(); //$NON-NLS-1$
+ ShellScript script = new ShellScript(command, 0);
+ script.exec();
+ }
+}
Index: src/org/eclipse/cdt/rpm/core/utils/internal/Command.java
===================================================================
RCS file: src/org/eclipse/cdt/rpm/core/utils/internal/Command.java
diff -N src/org/eclipse/cdt/rpm/core/utils/internal/Command.java
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ src/org/eclipse/cdt/rpm/core/utils/internal/Command.java 1 Jan 1970 00:00:00 -0000
@@ -0,0 +1,72 @@
+/*
+ * (c) 2005 Red Hat, Inc.
+ *
+ * This program is open source software licensed under the
+ * Eclipse Public License ver. 1
+ */
+package org.eclipse.cdt.rpm.core.utils.internal;
+
+import org.eclipse.cdt.rpm.core.IRPMConstants;
+import org.eclipse.cdt.rpm.core.internal.Messages;
+import org.eclipse.core.runtime.CoreException;
+import org.eclipse.core.runtime.IStatus;
+import org.eclipse.core.runtime.Status;
+
+/**
+ * A utility class for executing commands using @link java.lang.Runtime.exec.
+ *
+ */
+public class Command {
+
+ /**
+ * Method exec.
+ * This method executes a Linux command passed to it from other methods. It executes
+ * the command, reads the output from the command and passes back a status. This method
+ * is used when several output lines is expected from a command. If one line or less is
+ * expected and the developer wants the output of the command, use the getInfo method.
+ * @param command - a string containing a Linux command
+ * @param successCode - what the successful status value from the command should be (normally 0)
+ * @return - throws a CoreException if an error is encountered
+ */
+ /****************************************************************************/
+ public static void exec(String command, int successCode) throws CoreException {
+ Runtime r = Runtime.getRuntime();
+ Process p = null;
+ int returnCode;
+ String line = ""; //$NON-NLS-1$
+ String line2 = ""; //$NON-NLS-1$
+ // prepare buffers for process output and error streams
+ StringBuffer err = new StringBuffer();
+ StringBuffer out = new StringBuffer();
+
+ try {
+ p = r.exec((String) command);
+ // create thread for reading inputStream (process' stdout)
+ StreamReaderThread outThread = new StreamReaderThread(p
+ .getInputStream(), out);
+ // create thread for reading errorStream (process' stderr)
+ StreamReaderThread errThread = new StreamReaderThread(p
+ .getErrorStream(), err);
+ // start both threads
+ outThread.start();
+ errThread.start();
+
+ //wait for process to end
+ returnCode = p.waitFor();
+ //finish reading whatever's left in the buffers
+ outThread.join();
+ errThread.join();
+
+ if(returnCode != successCode) {
+ throw new Exception();
+ }
+ } catch (Exception e) {
+ String throw_message = Messages
+ .getString("RPMCore.Error_executing__97") + command + //$NON-NLS-1$
+ Messages.getString("LinuxShellCmds.7") + err.toString(); //$NON-NLS-1$
+ IStatus error = new Status(IStatus.ERROR, IRPMConstants.ERROR, 1, throw_message,
+ null);
+ throw new CoreException(error);
+ }
+ }
+}
Index: src/org/eclipse/cdt/rpm/core/utils/internal/ShellScript.java
===================================================================
RCS file: src/org/eclipse/cdt/rpm/core/utils/internal/ShellScript.java
diff -N src/org/eclipse/cdt/rpm/core/utils/internal/ShellScript.java
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ src/org/eclipse/cdt/rpm/core/utils/internal/ShellScript.java 1 Jan 1970 00:00:00 -0000
@@ -0,0 +1,79 @@
+/*
+ * (c) 2005 Red Hat, Inc.
+ *
+ * This program is open source software licensed under the
+ * Eclipse Public License ver. 1
+ */
+
+package org.eclipse.cdt.rpm.core.utils.internal;
+
+import java.io.BufferedOutputStream;
+import java.io.File;
+import java.io.FileOutputStream;
+import java.io.IOException;
+
+import org.eclipse.cdt.rpm.core.IRPMConstants;
+import org.eclipse.cdt.rpm.core.RPMCorePlugin;
+import org.eclipse.cdt.rpm.core.internal.Messages;
+import org.eclipse.core.runtime.CoreException;
+import org.eclipse.core.runtime.IStatus;
+import org.eclipse.core.runtime.Status;
+
+/**
+ * A utility class for constructing and executing shell scripts on the system.
+ *
+ */
+public class ShellScript {
+
+ private File script;
+ private String scriptContents;
+ private int successCode;
+
+ /**
+ * Constructs a new shell script object.
+ * @param command the command to execute
+ * @param successCode the return code that indicated command execution was successful
+ */
+ public ShellScript(String command, int successCode) {
+ scriptContents = "#!/bin/sh" + IRPMConstants.LINE_SEP + command; //$NON-NLS-1$
+ this.successCode = successCode;
+ }
+
+ /**
+ * Executes the shell script without logging standard output.
+ * @throws CoreException if the operation fails
+ */
+ public void execNoLog() throws CoreException {
+ byte[] buf = scriptContents.getBytes();
+ File file = null;
+ try {
+ file = RPMCorePlugin.getDefault().getShellScriptFile();
+ BufferedOutputStream os =
+ new BufferedOutputStream(new FileOutputStream(file));
+ for(int i = 0; i < buf.length; i++) {
+ os.write(buf[i]);
+ }
+ os.close();
+ } catch(IOException e) {
+ String throw_message = Messages.getString("RPMCore.Error_trying_to_write_to__8") + //$NON-NLS-1$
+ file.getAbsolutePath();
+ IStatus error = new Status(IStatus.ERROR, IRPMConstants.ERROR, 1,
+ throw_message, null);
+ throw new CoreException(error);
+ }
+ script = file;
+ Command.exec("chmod +x " + script.getAbsolutePath(), 0); //$NON-NLS-1$
+ Command.exec("sh " + script.getAbsolutePath(), successCode); //$NON-NLS-1$
+ }
+
+ /**
+ * Executes the shell script and logs standard output to the log file.
+ * @throws CoreException if the operation fails
+ */
+ public void exec() throws CoreException {
+ scriptContents += " >> " +
+ RPMCorePlugin.getDefault().getExternalLogFile().getAbsolutePath(); //$NON-NLS-1$
+ execNoLog();
+ }
+
+}
Index: src/org/eclipse/cdt/rpm/core/utils/internal/StreamReaderThread.java
===================================================================
RCS file: src/org/eclipse/cdt/rpm/core/utils/internal/StreamReaderThread.java
diff -N src/org/eclipse/cdt/rpm/core/utils/internal/StreamReaderThread.java
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ src/org/eclipse/cdt/rpm/core/utils/internal/StreamReaderThread.java 1 Jan 1970 00:00:00 -0000
@@ -0,0 +1,38 @@
+/*
+ * (c) 2005 Red Hat, Inc.
+ *
+ * This program is open source software licensed under the
+ * Eclipse Public License ver. 1
+ */
+package org.eclipse.cdt.rpm.core.utils.internal;
+
+import java.io.InputStreamReader;
+import java.io.InputStream;
+
+/**
+ * Thread for reading input and output streams
+ */
+public class StreamReaderThread extends Thread
+{
+ StringBuffer mOut;
+ InputStreamReader mIn;
+
+ public StreamReaderThread(InputStream in, StringBuffer out)
+ {
+ mOut=out;
+ mIn=new InputStreamReader(in);
+ }
+
+ public void run()
+ {
+ int ch;
+ try {
+ while(-1 != (ch=mIn.read()))
+ mOut.append((char)ch);
+ }
+ catch (Exception e)
+ {
+ mOut.append("\nRead error:"+e.getMessage());
+ }
+ }
+}