[java-identity-provider] branch main updated: IDP-1651 Installer should conditionally put system files into place for upgrades

Rod Widdowson rdw at steadingsoftware.com
Wed Sep 16 10:11:51 UTC 2020


This is an automated email from the git hooks/post-receive script.

rdw pushed a commit to branch main
in repository java-identity-provider.

View the commit online:
http://git.shibboleth.net/view/?p=java-identity-provider.git;a=commit;h=a46f2312b16b215cc3b10f4a62d9aca8785a0145

The following commit(s) were added to refs/heads/main by this push:
       new  a46f2312b IDP-1651 Installer should conditionally put system files into place for upgrades
a46f2312b is described below

commit a46f2312b16b215cc3b10f4a62d9aca8785a0145
Author: Rod Widdowson <rdw at steadingsoftware.com>
AuthorDate: Wed Sep 16 10:53:14 2020 +0100

    IDP-1651 Installer should conditionally put system files into place for upgrades
    
    https://issues.shibboleth.net/jira/browse/IDP-1651
    
    This requires that we extend thje "current state" interface and then
    consult it as required.  The interface is api so we default it to
    true and do the real work in our impl classes.
---
 .../main/java/net/shibboleth/idp/installer/CopyDistribution.java | 4 +++-
 .../java/net/shibboleth/idp/installer/CurrentInstallState.java   | 9 +++++++++
 .../src/main/java/net/shibboleth/idp/installer/V4Install.java    | 8 ++++++--
 .../shibboleth/idp/installer/impl/CurrentInstallStateImpl.java   | 9 +++++++++
 4 files changed, 27 insertions(+), 3 deletions(-)

diff --git a/idp-installer/src/main/java/net/shibboleth/idp/installer/CopyDistribution.java b/idp-installer/src/main/java/net/shibboleth/idp/installer/CopyDistribution.java
index 0c38335fe..049964139 100644
--- a/idp-installer/src/main/java/net/shibboleth/idp/installer/CopyDistribution.java
+++ b/idp-installer/src/main/java/net/shibboleth/idp/installer/CopyDistribution.java
@@ -139,6 +139,8 @@ public final class CopyDistribution extends AbstractInitializableComponent {
     protected void copyBinDocSystem() {
         distCopy(installerProps.getSourceDir(), installerProps.getTargetDir(), "bin");
         distCopy(installerProps.getSourceDir(), installerProps.getTargetDir(), "doc");
-        distCopy(installerProps.getSourceDir(), installerProps.getTargetDir(), "system");
+        if (installState.isSystemPresent()) {
+            distCopy(installerProps.getSourceDir(), installerProps.getTargetDir(), "system");
+        }
     }
 }
diff --git a/idp-installer/src/main/java/net/shibboleth/idp/installer/CurrentInstallState.java b/idp-installer/src/main/java/net/shibboleth/idp/installer/CurrentInstallState.java
index c22ae04cd..f2c589f80 100644
--- a/idp-installer/src/main/java/net/shibboleth/idp/installer/CurrentInstallState.java
+++ b/idp-installer/src/main/java/net/shibboleth/idp/installer/CurrentInstallState.java
@@ -65,4 +65,13 @@ public interface CurrentInstallState extends InitializableComponent {
      * @return the list of paths.
      */
     @Nonnull List<Path> getPathsToBeDeleted();
+
+    /** If this is an upgrade were there files in %{idp.home}system?  If so then we need
+     * to copy the files in.  Otherwise not.
+     * For new installs this is false
+     * @return whether the old install has %{idp.home}\system
+     */
+    default boolean isSystemPresent() {
+        return true;
+    }
 }
diff --git a/idp-installer/src/main/java/net/shibboleth/idp/installer/V4Install.java b/idp-installer/src/main/java/net/shibboleth/idp/installer/V4Install.java
index fb73a4b22..0f535bf89 100644
--- a/idp-installer/src/main/java/net/shibboleth/idp/installer/V4Install.java
+++ b/idp-installer/src/main/java/net/shibboleth/idp/installer/V4Install.java
@@ -447,11 +447,15 @@ public class V4Install extends AbstractInitializableComponent {
      */
     protected void reprotect() throws BuildException {
         InstallerSupport.setReadOnly(installerProps.getTargetDir().resolve("dist"), true);
-        InstallerSupport.setReadOnly(installerProps.getTargetDir().resolve("system"), true);
+        if (currentState.isSystemPresent()) {
+            InstallerSupport.setReadOnly(installerProps.getTargetDir().resolve("system"), true);
+        }
 
         if (installerProps.isSetGroupAndMode()) {
             InstallerSupport.setMode(installerProps.getTargetDir().resolve("bin"), "755", "**/*.sh");
-            InstallerSupport.setMode(installerProps.getTargetDir().resolve("system"), "444", "**/*");
+            if (currentState.isSystemPresent()) {
+                InstallerSupport.setMode(installerProps.getTargetDir().resolve("system"), "444", "**/*");
+            }
             InstallerSupport.setMode(installerProps.getTargetDir().resolve("dist"), "444", "**/*");
             if (currentState.getInstalledVersion() == null) {
                 InstallerSupport.setMode(installerProps.getTargetDir().resolve("credentials"),
diff --git a/idp-installer/src/main/java/net/shibboleth/idp/installer/impl/CurrentInstallStateImpl.java b/idp-installer/src/main/java/net/shibboleth/idp/installer/impl/CurrentInstallStateImpl.java
index 963bcda2f..0adf3e43d 100644
--- a/idp-installer/src/main/java/net/shibboleth/idp/installer/impl/CurrentInstallStateImpl.java
+++ b/idp-installer/src/main/java/net/shibboleth/idp/installer/impl/CurrentInstallStateImpl.java
@@ -62,6 +62,9 @@ public final class CurrentInstallStateImpl extends AbstractInitializableComponen
     /** Whether the LDAP properties file exists.*/
     private boolean ldapPropertiesPresent;
 
+    /** Whether system is present. */
+    private boolean systemPresent;
+
     /** Old Version. */
     private String oldVersion;
     
@@ -154,6 +157,7 @@ public final class CurrentInstallStateImpl extends AbstractInitializableComponen
         super.doInitialize();
         idpPropertiesPresent = Files.exists(targetDir.resolve("conf").resolve("idp.properties"));
         ldapPropertiesPresent = Files.exists(targetDir.resolve("conf").resolve("ldap.properties"));
+        systemPresent = Files.exists(targetDir.resolve("system"));
         findPreviousVersion();
         setupPreviousProps();
 
@@ -200,4 +204,9 @@ public final class CurrentInstallStateImpl extends AbstractInitializableComponen
     public List<Path> getPathsToBeDeleted() {
         return pathsToDelete;
     }
+
+    /** {@inheritDoc} */
+    public boolean isSystemPresent() {
+        return systemPresent;
+    }
 }

-- 
To stop receiving notification emails like this one, please contact
the administrator of this repository.


More information about the commits mailing list