Fixes to have mock worrking in RAP
authorMathieu Baudier <mbaudier@argeo.org>
Tue, 4 Jun 2013 16:39:34 +0000 (16:39 +0000)
committerMathieu Baudier <mbaudier@argeo.org>
Tue, 4 Jun 2013 16:39:34 +0000 (16:39 +0000)
git-svn-id: https://svn.argeo.org/slc/trunk@6330 4cfe0d0a-d680-48aa-b62c-e0a02a3f76cc

runtime/org.argeo.slc.rpmfactory/src/main/java/org/argeo/slc/rpmfactory/core/BuildInMock.java

index 50daabce3f3d0c1a5bb1e2cbdf77f8394ac55570..11b772be9eadafc72d7a570d1dd6b0570b99845d 100644 (file)
@@ -43,6 +43,7 @@ public class BuildInMock implements Runnable {
        private Executor executor;
 
        private String debuginfoDirName = "debuginfo";
+       private String mockExecutable = "/usr/bin/mock";
 
        public void run() {
                String mockCfg = factory.getMockConfig(arch);
@@ -52,7 +53,7 @@ public class BuildInMock implements Runnable {
                SystemCall mock = new SystemCall();
                if (arch != null)
                        mock.arg("setarch").arg(arch);
-               mock.arg("mock");
+               mock.arg(mockExecutable);
                mock.arg("-v");
                mock.arg("--configdir=" + mockConfigFile.getAbsoluteFile().getParent());
                if (arch != null)
@@ -89,35 +90,36 @@ public class BuildInMock implements Runnable {
                // copy RPMs
                Set<File> reposToRecreate = new HashSet<File>();
                File resultDir = factory.getResultDir(arch);
-               rpms: for (File file : resultDir.listFiles()) {
-                       if (file.isDirectory())
-                               continue rpms;
-
-                       File[] targetDirs;
-                       if (file.getName().contains(".src.rpm"))
-                               targetDirs = new File[] { srpmDir };
-                       else if (file.getName().contains("-debuginfo-"))
-                               targetDirs = new File[] { debuginfoDir };
-                       else if (!arch.equals(NOARCH)
-                                       && file.getName().contains("." + arch + ".rpm"))
-                               targetDirs = new File[] { archDir };
-                       else if (file.getName().contains(".noarch.rpm")) {
-                               List<File> dirs = new ArrayList<File>();
-                               for (String arch : factory.getArchs())
-                                       dirs.add(new File(stagingDir, arch));
-                               targetDirs = dirs.toArray(new File[dirs.size()]);
-                       } else if (file.getName().contains(".rpm"))
-                               throw new SlcException("Don't know where to copy " + file);
-                       else {
-                               if (log.isTraceEnabled())
-                                       log.trace("Skip " + file);
-                               continue rpms;
+               if (resultDir.exists())
+                       rpms: for (File file : resultDir.listFiles()) {
+                               if (file.isDirectory())
+                                       continue rpms;
+
+                               File[] targetDirs;
+                               if (file.getName().contains(".src.rpm"))
+                                       targetDirs = new File[] { srpmDir };
+                               else if (file.getName().contains("-debuginfo-"))
+                                       targetDirs = new File[] { debuginfoDir };
+                               else if (!arch.equals(NOARCH)
+                                               && file.getName().contains("." + arch + ".rpm"))
+                                       targetDirs = new File[] { archDir };
+                               else if (file.getName().contains(".noarch.rpm")) {
+                                       List<File> dirs = new ArrayList<File>();
+                                       for (String arch : factory.getArchs())
+                                               dirs.add(new File(stagingDir, arch));
+                                       targetDirs = dirs.toArray(new File[dirs.size()]);
+                               } else if (file.getName().contains(".rpm"))
+                                       throw new SlcException("Don't know where to copy " + file);
+                               else {
+                                       if (log.isTraceEnabled())
+                                               log.trace("Skip " + file);
+                                       continue rpms;
+                               }
+
+                               reposToRecreate.addAll(Arrays.asList(targetDirs));
+                               copyToDirs(file, targetDirs);
                        }
 
-                       reposToRecreate.addAll(Arrays.asList(targetDirs));
-                       copyToDirs(file, targetDirs);
-               }
-
                // recreate changed repos
                for (File repoToRecreate : reposToRecreate) {
                        SystemCall createrepo = new SystemCall();
@@ -171,4 +173,9 @@ public class BuildInMock implements Runnable {
        public void setExecutor(Executor executor) {
                this.executor = executor;
        }
+
+       public void setMockExecutable(String mockExecutable) {
+               this.mockExecutable = mockExecutable;
+       }
+
 }
\ No newline at end of file