+ if (log.isDebugEnabled())
+ log.debug(output + "\n");
+ // reader = new StringReader(output);
+ StringTokenizer lines = new StringTokenizer(output, "\n");
+ // List<String> dependencies = IOUtils.readLines(reader);
+ dependencies: while (lines.hasMoreTokens()) {
+ String urlStr = lines.nextToken();
+ InputStream in = null;
+ try {
+ URL url = new URL(urlStr);
+ String fileName = FilenameUtils.getName(url.getFile());
+ String[] tokens = fileName.split("-");
+ if (tokens.length < 3)
+ continue dependencies;
+ StringBuilder buf = new StringBuilder();
+ for (int i = 0; i < tokens.length - 2; i++) {
+ if (i != 0)
+ buf.append('-');
+ buf.append(tokens[i]);
+
+ }
+ String packageName = buf.toString();
+ for (RpmPackageSet excluded : rpmDistribution
+ .getExcludedPackages()) {
+ if (excluded.contains(packageName)) {
+ if (log.isDebugEnabled())
+ log.debug("Skipped " + packageName);
+ continue dependencies;// skip
+ }
+ }
+ in = url.openStream();
+ JcrUtils.copyStreamAsFile(targetFolder, fileName, in);
+ targetFolder.getSession().save();
+ if (log.isDebugEnabled())
+ log.debug("Copied " + packageName);
+ } catch (Exception e) {
+ log.error("Cannot copy " + urlStr, e);
+ } finally {
+ IOUtils.closeQuietly(in);
+ }
+ }
+
+ // createrepo
+ File workspaceDir = rpmFactory.getWorkspaceDir(rpmDistribution
+ .getId());
+ SystemCall createrepo = new SystemCall();
+ createrepo.arg("createrepo");
+ createrepo.arg("-q");
+ createrepo.arg("-d");
+ File archDir = new File(workspaceDir.getPath()
+ + targetFolder.getPath());
+ createrepo.arg(archDir.getAbsolutePath());
+ createrepo.run();
+ } catch (Exception e) {
+ throw new SlcException("Cannot generate distribution "
+ + rpmDistribution.getId(), e);
+ } finally {
+ JcrUtils.logoutQuietly(session);
+ // IOUtils.closeQuietly(reader);
+ }
+ }
+
+ public void setRpmDistribution(RpmDistribution rpmDistribution) {
+ this.rpmDistribution = rpmDistribution;
+ }
+
+ public void setRpmFactory(RpmFactory rpmFactory) {
+ this.rpmFactory = rpmFactory;