karaf-issues mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "ASF GitHub Bot (JIRA)" <j...@apache.org>
Subject [jira] [Commented] (KARAF-5810) No config file installed in custom distribution.
Date Fri, 03 Aug 2018 07:53:00 GMT

    [ https://issues.apache.org/jira/browse/KARAF-5810?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=16567912#comment-16567912
] 

ASF GitHub Bot commented on KARAF-5810:
---------------------------------------

jbonofre closed pull request #554: [KARAF-5810] No config file installed in custom distribution.
(On karaf-4.1.x)
URL: https://github.com/apache/karaf/pull/554
 
 
   

This is a PR merged from a forked repository.
As GitHub hides the original diff on merge, it is displayed below for
the sake of provenance:

As this is a foreign pull request (from a fork), the diff is supplied
below (as it won't show otherwise due to GitHub magic):

diff --git a/profile/src/main/java/org/apache/karaf/profile/assembly/Builder.java b/profile/src/main/java/org/apache/karaf/profile/assembly/Builder.java
index a14b285834..e09fdf9fa5 100644
--- a/profile/src/main/java/org/apache/karaf/profile/assembly/Builder.java
+++ b/profile/src/main/java/org/apache/karaf/profile/assembly/Builder.java
@@ -51,6 +51,7 @@
 import java.util.zip.ZipEntry;
 import java.util.zip.ZipInputStream;
 
+import org.apache.commons.io.FilenameUtils;
 import org.apache.felix.resolver.ResolverImpl;
 import org.apache.felix.utils.manifest.Clause;
 import org.apache.felix.utils.properties.InterpolationHelper;
@@ -910,10 +911,16 @@ private void installStage(Profile installedProfile, Set<Feature>
allBootFeatures
             // Install config files
             for (ConfigFile configFile : feature.getConfigfile()) {
                 installArtifact(downloader, configFile.getLocation().trim());
+                if (pidMatching(FilenameUtils.getBaseName(configFile.getFinalname()))) {
+                    installConfigFile(downloader, configFile);
+                }
             }
             for (Conditional cond : feature.getConditional()) {
                 for (ConfigFile configFile : cond.getConfigfile()) {
                     installArtifact(downloader, configFile.getLocation().trim());
+                    if (pidMatching(FilenameUtils.getBaseName(configFile.getFinalname())))
{
+                        installConfigFile(downloader, configFile);
+                    }
                 }
             }
             // Extract configs
@@ -1244,6 +1251,58 @@ public void downloaded(final StreamProvider provider) throws Exception
{
         }
     }
 
+    private void installConfigFile(Downloader downloader, ConfigFile configFile) throws Exception
{
+        String path = configFile.getFinalname();
+
+        if (path.startsWith("/")) {
+            path = path.substring(1);
+        }
+
+        Path configFileTarget = homeDirectory.resolve(substFinalName(path));
+        LOGGER.info("      adding config file: {}", homeDirectory.relativize(configFileTarget));
+
+        String location = DownloadManagerHelper.stripUrl(configFile.getLocation().trim());
+        if (location.startsWith("mvn:")) {
+            if (location.endsWith("/")) {
+                // for bad formed URL (like in Camel for mustache-compiler), we remove the
trailing /
+                location = location.substring(0, location.length() - 1);
+            }
+
+            downloader.download(location, new DownloadCallback() {
+                @Override
+                public void downloaded(final StreamProvider pProvider) throws Exception {
+                    synchronized (pProvider) {
+                        Files.createDirectories(configFileTarget.getParent());
+                        Files.copy(pProvider.getFile().toPath(), configFileTarget, StandardCopyOption.REPLACE_EXISTING);
+                    }
+                }
+
+            });
+        } else {
+            LOGGER.warn("Ignoring non maven artifact {}", location);
+        }
+    }
+
+    private String substFinalName(String finalname) {
+        final String markerVarBeg = "${";
+        final String markerVarEnd = "}";
+
+        boolean startsWithVariable = finalname.startsWith(markerVarBeg) && finalname.contains(markerVarEnd);
+        if (startsWithVariable) {
+            String marker = finalname.substring(markerVarBeg.length(), finalname.indexOf(markerVarEnd));
+            switch (marker) {
+                case "karaf.home":
+                case "karaf.base":
+                    return this.homeDirectory + finalname.substring(finalname.indexOf(markerVarEnd)
+ markerVarEnd.length());
+                case "karaf.etc":
+                    return this.etcDirectory + finalname.substring(finalname.indexOf(markerVarEnd)
+ markerVarEnd.length());
+                default:
+                    break;
+            }
+        }
+        return finalname;
+    }
+
     private List<String> getStaged(Stage stage, Map<String, Stage> data) {
         List<String> staged = new ArrayList<>();
         for (String s : data.keySet()) {


 

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
users@infra.apache.org


> No config file installed in custom distribution.
> ------------------------------------------------
>
>                 Key: KARAF-5810
>                 URL: https://issues.apache.org/jira/browse/KARAF-5810
>             Project: Karaf
>          Issue Type: Bug
>          Components: karaf-tooling
>    Affects Versions: 4.1.5, 4.2.0.M2
>            Reporter: svs
>            Assignee: Jean-Baptiste Onofré
>            Priority: Major
>              Labels: maven
>
> Configuration files (<configfile finalname=mvn ..../>) specified in the feature
file are not installed when a custom distribution is created.



--
This message was sent by Atlassian JIRA
(v7.6.3#76005)

Mime
View raw message