コード例 #1
0
ファイル: UiUtils.java プロジェクト: nbguzman/linuxtools
  public static void pluginSanityCheck() throws IOException {
    boolean exists = (new File(PreferenceConstants.RPMMACRO_FILE)).exists();
    // Check if ~/.rpmmacros exist, if the file don't exist we create
    // it with the appropriate command.
    if (!exists && Utils.fileExist("/usr/bin/rpmdev-setuptree")) { // $NON-NLS-1$
      org.eclipse.linuxtools.rpm.core.utils.Utils.runCommandToInputStream(
          "rpmdev-setuptree"); //$NON-NLS-1$
    }

    // Check RPM tool preference.
    String currentRpmTool =
        Activator.getDefault()
            .getPreferenceStore()
            .getString(PreferenceConstants.P_CURRENT_RPMTOOLS);
    if (!Utils.fileExist("/usr/bin/yum")) { // $NON-NLS-1$
      if (currentRpmTool.equals(PreferenceConstants.DP_RPMTOOLS_YUM)) {
        Activator.getDefault()
            .getPreferenceStore()
            .setValue(PreferenceConstants.P_CURRENT_RPMTOOLS, PreferenceConstants.DP_RPMTOOLS_RPM);
      }
    } else if (!Utils.fileExist("/usr/bin/urpmq")) { // $NON-NLS-1$
      if (currentRpmTool.equals(PreferenceConstants.DP_RPMTOOLS_URPM)) {
        Activator.getDefault()
            .getPreferenceStore()
            .setValue(PreferenceConstants.P_CURRENT_RPMTOOLS, PreferenceConstants.DP_RPMTOOLS_RPM);
      }
    }
  }
コード例 #2
0
 /** Build the macro list. */
 public final void buildMacroList() {
   for (String definedMacro : SpecfileScanner.DEFINED_MACROS) {
     macroMap.put(definedMacro, Messages.RpmMacroProposalsList_0);
     // TODO find way to provide info about buildin macros.
   }
   String macroProposalsPaths =
       Activator.getDefault()
           .getPreferenceStore()
           .getString(PreferenceConstants.P_MACRO_PROPOSALS_FILESPATH);
   String[] paths = macroProposalsPaths.split(";"); // $NON-NLS-1$
   // paths must be reversed because the last value added
   // into a Map overwrites the first.
   paths = reverseStringArray(paths);
   for (String path : paths) {
     if (!path.equals(EMPTY_STRING)) {
       File pathFile = new File(path);
       if (pathFile.exists()) {
         if (pathFile.isDirectory()) {
           File[] macrosFiles = pathFile.listFiles();
           for (File macrosFile : macrosFiles) {
             addMacroToMap(macrosFile.getAbsolutePath());
           }
         } else {
           addMacroToMap(path);
         }
       }
     }
   }
 }
コード例 #3
0
 @Before
 public void setUp() {
   Activator.getDefault()
       .getPreferenceStore()
       .setValue(PreferenceConstants.P_RPM_LIST_FILEPATH, "/tmp/pkglist");
   try (BufferedWriter out = new BufferedWriter(new FileWriter("/tmp/pkglist"))) {
     out.write("setup\ntest\nrpm\n");
   } catch (IOException e) {
     e.printStackTrace();
   }
   packageProposalsList = new RpmPackageProposalsList();
 }