Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[updater] A component for self-updating openHAB via the UI #2372

Draft
wants to merge 53 commits into
base: main
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from 3 commits
Commits
Show all changes
53 commits
Select commit Hold shift + click to select a range
a4a868d
[updater] initial contribution
andrewfg May 19, 2021
88cd403
[updater] tweak
andrewfg May 19, 2021
848d547
[updater] add module to pom
andrewfg May 19, 2021
1d647da
[updater] added support for POSTing a JSON DTO
andrewfg May 20, 2021
e695645
[updater] added stubs for YUM, Portage, PacMan package managers
andrewfg May 20, 2021
7b447f6
[updater] sorted out Junit test
andrewfg May 20, 2021
1abfdcf
[updater] tweaks
andrewfg May 20, 2021
bbe5abb
[updater] adopt code reviewer correction
andrewfg May 20, 2021
2c93bdc
[updater] tweak comments
andrewfg May 20, 2021
3896e56
[updater] eliminate mvn errors, minimize warnings
andrewfg May 20, 2021
e5c21ce
[updater] changed rest api to servlet
andrewfg May 21, 2021
1259a81
[updater] added user credentials check
andrewfg May 23, 2021
9dcccc6
[updater] added requiresCredentials()
andrewfg May 24, 2021
e923ac5
[updater] html cosmetics
andrewfg May 24, 2021
b53c4a2
[updater] both Rest and Servlet Api, optional https redirect
andrewfg May 25, 2021
a6d7d7e
[updater] improve page layout
andrewfg May 25, 2021
ee81f11
[updater] spinner
andrewfg May 29, 2021
aa2dec1
[updater] extra logging
andrewfg May 31, 2021
5017e73
[updater] allow version down-grades
andrewfg May 31, 2021
6d83f20
[updater] refactor class and package names
andrewfg May 31, 2021
95af36e
[updater] refectored as requested by reviewer
andrewfg Jun 7, 2021
a0796d8
[updater] spelling of openHAB
andrewfg Jun 7, 2021
bcb3e4e
[updater] pom
andrewfg Jun 7, 2021
0295da7
[updater] another pom
andrewfg Jun 7, 2021
2db8111
[update] adopted changes requested by reviewer
andrewfg Jun 8, 2021
3679ff7
[updater] initial contribution
andrewfg May 19, 2021
04ce204
[updater] tweak
andrewfg May 19, 2021
2225761
[updater] add module to pom
andrewfg May 19, 2021
4f651b9
[updater] added support for POSTing a JSON DTO
andrewfg May 20, 2021
9529366
[updater] added stubs for YUM, Portage, PacMan package managers
andrewfg May 20, 2021
ecb43eb
[updater] sorted out Junit test
andrewfg May 20, 2021
8ace45d
[updater] tweaks
andrewfg May 20, 2021
7936160
[updater] adopt code reviewer correction
andrewfg May 20, 2021
5546a6e
[updater] tweak comments
andrewfg May 20, 2021
b5389ef
[updater] eliminate mvn errors, minimize warnings
andrewfg May 20, 2021
53ecada
[updater] changed rest api to servlet
andrewfg May 21, 2021
e43ee1b
[updater] added user credentials check
andrewfg May 23, 2021
fa6f78d
[updater] added requiresCredentials()
andrewfg May 24, 2021
bc5b2bb
[updater] html cosmetics
andrewfg May 24, 2021
cdf7af3
[updater] both Rest and Servlet Api, optional https redirect
andrewfg May 25, 2021
1af097c
[updater] improve page layout
andrewfg May 25, 2021
b03e783
[updater] spinner
andrewfg May 29, 2021
a44c7b7
[updater] extra logging
andrewfg May 31, 2021
f7487ab
[updater] allow version down-grades
andrewfg May 31, 2021
cf95764
[updater] refactor class and package names
andrewfg May 31, 2021
ca37a01
[updater] refectored as requested by reviewer
andrewfg Jun 7, 2021
1901629
[updater] spelling of openHAB
andrewfg Jun 7, 2021
3da4bbd
[updater] pom
andrewfg Jun 7, 2021
cd23e2f
[updater] another pom
andrewfg Jun 7, 2021
8106355
[update] adopted changes requested by reviewer
andrewfg Jun 8, 2021
9bc2570
[update] adopt reviewer proposed changes
andrewfg Jul 11, 2021
8f8f3a4
Merge branch 'core-updater' of https://github.com/andrewfg/openhab-co…
andrewfg Jul 11, 2021
c3830f4
Merge branch 'openhab:main' into core-updater
andrewfg Jul 20, 2021
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
6 changes: 6 additions & 0 deletions bom/openhab-core/pom.xml
Expand Up @@ -502,6 +502,12 @@
<version>${project.version}</version>
<scope>compile</scope>
</dependency>
<dependency>
<groupId>org.openhab.core.bundles</groupId>
<artifactId>org.openhab.core.updater</artifactId>
<version>${project.version}</version>
<scope>compile</scope>
</dependency>
<dependency>
<groupId>org.openhab.core.bundles</groupId>
<artifactId>org.openhab.core.storage.json</artifactId>
Expand Down
34 changes: 34 additions & 0 deletions bundles/org.openhab.core.updater/.classpath
@@ -0,0 +1,34 @@
<?xml version="1.0" encoding="UTF-8"?>
<classpath>
<classpathentry kind="src" output="target/classes" path="src/main/java">
<attributes>
<attribute name="optional" value="true"/>
<attribute name="maven.pomderived" value="true"/>
</attributes>
</classpathentry>
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-11">
<attributes>
<attribute name="maven.pomderived" value="true"/>
<attribute name="annotationpath" value="target/dependency"/>
</attributes>
</classpathentry>
<classpathentry kind="con" path="org.eclipse.m2e.MAVEN2_CLASSPATH_CONTAINER">
<attributes>
<attribute name="maven.pomderived" value="true"/>
<attribute name="annotationpath" value="target/dependency"/>
</attributes>
</classpathentry>
<classpathentry excluding="**" kind="src" output="target/classes" path="src/main/resources">
<attributes>
<attribute name="maven.pomderived" value="true"/>
</attributes>
</classpathentry>
<classpathentry kind="src" output="target/test-classes" path="src/test/java">
<attributes>
<attribute name="optional" value="true"/>
<attribute name="maven.pomderived" value="true"/>
<attribute name="test" value="true"/>
</attributes>
</classpathentry>
<classpathentry kind="output" path="target/classes"/>
</classpath>
23 changes: 23 additions & 0 deletions bundles/org.openhab.core.updater/.project
@@ -0,0 +1,23 @@
<?xml version="1.0" encoding="UTF-8"?>
<projectDescription>
<name>org.openhab.core.updater</name>
<comment></comment>
<projects>
</projects>
<buildSpec>
<buildCommand>
<name>org.eclipse.jdt.core.javabuilder</name>
<arguments>
</arguments>
</buildCommand>
<buildCommand>
<name>org.eclipse.m2e.core.maven2Builder</name>
<arguments>
</arguments>
</buildCommand>
</buildSpec>
<natures>
<nature>org.eclipse.jdt.core.javanature</nature>
<nature>org.eclipse.m2e.core.maven2Nature</nature>
</natures>
</projectDescription>
14 changes: 14 additions & 0 deletions bundles/org.openhab.core.updater/NOTICE
@@ -0,0 +1,14 @@
This content is produced and maintained by the openHAB project.

* Project home: https://www.openhab.org

== Declared Project Licenses

This program and the accompanying materials are made available under the terms
of the Eclipse Public License 2.0 which is available at
https://www.eclipse.org/legal/epl-2.0/.

== Source Code

https://github.com/openhab/openhab-core

69 changes: 69 additions & 0 deletions bundles/org.openhab.core.updater/pom.xml
@@ -0,0 +1,69 @@
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">

<modelVersion>4.0.0</modelVersion>

<parent>
<groupId>org.openhab.core.bundles</groupId>
<artifactId>org.openhab.core.reactor.bundles</artifactId>
<version>3.1.0-SNAPSHOT</version>
</parent>

<artifactId>org.openhab.core.updater</artifactId>

<name>openHAB Core :: Bundles :: Updater</name>

<dependencies>
<dependency>
<groupId>org.openhab.core.bundles</groupId>
<artifactId>org.openhab.core</artifactId>
<version>3.1.0-SNAPSHOT</version>
</dependency>
<dependency>
<groupId>org.openhab.core.bundles</groupId>
<artifactId>org.openhab.core.io.rest</artifactId>
<version>3.1.0-SNAPSHOT</version>
</dependency>
<dependency>
<groupId>com.jcraft</groupId>
<artifactId>jsch</artifactId>
<version>0.1.55</version>
<scope>compile</scope>
</dependency>
<dependency>
<groupId>com.jcraft</groupId>
<artifactId>jzlib</artifactId>
<version>1.1.3</version>
<scope>compile</scope>
</dependency>
</dependencies>

<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-dependency-plugin</artifactId>
<version>3.1.1</version>
<executions>
<execution>
<id>embed-dependencies</id>
<goals>
<goal>unpack-dependencies</goal>
</goals>
<configuration>
<includeScope>runtime</includeScope>
<includeTypes>jar</includeTypes>
<excludeGroupIds>javax.activation,org.apache.karaf.features,org.openhab.core.bundles</excludeGroupIds>
<outputDirectory>${project.build.directory}/classes</outputDirectory>
<overWriteReleases>true</overWriteReleases>
<overWriteSnapshots>true</overWriteSnapshots>
<excludeTransitive>true</excludeTransitive>
<type>jar</type>
</configuration>
</execution>
</executions>
</plugin>
</plugins>
</build>
</project>
@@ -0,0 +1,26 @@
/**
* Copyright (c) 2010-2021 Contributors to the openHAB project
*
* See the NOTICE file(s) distributed with this work for additional
* information.
*
* This program and the accompanying materials are made available under the
* terms of the Eclipse Public License 2.0 which is available at
* http://www.eclipse.org/legal/epl-2.0
*
* SPDX-License-Identifier: EPL-2.0
*/
package org.openhab.core.updater.dto;

/**
* This is a DTO for OpenHAB self updating features.
*
* @author Andrew Fiddian-Green - Initial contribution
*/
public class StatusDTO {
public VersionDTO actualVersion;
public Integer latestVersionCount;
public VersionDTO[] latestVersions;
public String targetNewVersionType;
public String newVersionAvailable;
}
@@ -0,0 +1,23 @@
/**
* Copyright (c) 2010-2021 Contributors to the openHAB project
*
* See the NOTICE file(s) distributed with this work for additional
* information.
*
* This program and the accompanying materials are made available under the
* terms of the Eclipse Public License 2.0 which is available at
* http://www.eclipse.org/legal/epl-2.0
*
* SPDX-License-Identifier: EPL-2.0
*/
package org.openhab.core.updater.dto;

/**
* This is a DTO for OpenHAB self updater versions.
*
* @author Andrew Fiddian-Green - Initial contribution
*/
public class VersionDTO {
public String versionName;
public String versionType;
}
@@ -0,0 +1,49 @@
/**
* Copyright (c) 2010-2021 Contributors to the openHAB project
*
* See the NOTICE file(s) distributed with this work for additional
* information.
*
* This program and the accompanying materials are made available under the
* terms of the Eclipse Public License 2.0 which is available at
* http://www.eclipse.org/legal/epl-2.0
*
* SPDX-License-Identifier: EPL-2.0
*/
package org.openhab.core.updater.enums;

import org.eclipse.jdt.annotation.NonNullByDefault;

/**
* The {@link OperatingSystem} determines what type of update to apply
*
* @author Andrew Fiddian-Green - Initial contribution
*/
@NonNullByDefault
public enum OperatingSystem {
UNKNOWN,
UNIX,
WINDOWS,
SOLARIS,
MAC;

public static OperatingSystem getOperatingSystemVersion() {
String os = System.getProperty("os.name");
if (os != null) {
os = os.toLowerCase();
if (os.contains("win")) {
return OperatingSystem.WINDOWS;
}
if (os.contains("mac")) {
return OperatingSystem.MAC;
}
if (os.contains("nix") || os.contains("nux") || os.contains("aix")) {
return OperatingSystem.UNIX;
}
if (os.contains("sunos")) {
return OperatingSystem.SOLARIS;
}
}
return OperatingSystem.UNKNOWN;
}
}
@@ -0,0 +1,28 @@
/**
* Copyright (c) 2010-2021 Contributors to the openHAB project
*
* See the NOTICE file(s) distributed with this work for additional
* information.
*
* This program and the accompanying materials are made available under the
* terms of the Eclipse Public License 2.0 which is available at
* http://www.eclipse.org/legal/epl-2.0
*
* SPDX-License-Identifier: EPL-2.0
*/
package org.openhab.core.updater.enums;

import org.eclipse.jdt.annotation.NonNullByDefault;

/**
* The {@link PackageManager} identifies the type of Linux Package Manager.
*
* @author Andrew Fiddian-Green - Initial contribution
*/
@NonNullByDefault
public enum PackageManager {
UNKNOWN_PACKAGE_MANAGER,
DEBIAN_PACKAGE_MANAGER,
REDHAT_PACKAGE_MANAGER,
GENTOO_PACKAGE_MANAGER;
}
@@ -0,0 +1,33 @@
/**
* Copyright (c) 2010-2021 Contributors to the openHAB project
*
* See the NOTICE file(s) distributed with this work for additional
* information.
*
* This program and the accompanying materials are made available under the
* terms of the Eclipse Public License 2.0 which is available at
* http://www.eclipse.org/legal/epl-2.0
*
* SPDX-License-Identifier: EPL-2.0
*/
package org.openhab.core.updater.enums;

import org.eclipse.jdt.annotation.NonNullByDefault;

/**
* This is an enum that can have three values.
*
* @author Andrew Fiddian-Green - Initial contribution
*/
@NonNullByDefault
public enum TriState {
DONT_KNOW("don't know"),
NO("no"),
YES("yes");

public final String label;

TriState(String label) {
this.label = label;
}
}
@@ -0,0 +1,34 @@
/**
* Copyright (c) 2010-2021 Contributors to the openHAB project
*
* See the NOTICE file(s) distributed with this work for additional
* information.
*
* This program and the accompanying materials are made available under the
* terms of the Eclipse Public License 2.0 which is available at
* http://www.eclipse.org/legal/epl-2.0
*
* SPDX-License-Identifier: EPL-2.0
*/
package org.openhab.core.updater.enums;

import org.eclipse.jdt.annotation.NonNullByDefault;

/**
* The {@link VersionType} determines what type of update to apply
*
* @author Andrew Fiddian-Green - Initial contribution
*/
@NonNullByDefault
public enum VersionType {
STABLE("stable"),
MILESTONE("unstable"),
SNAPSHOT("testing"),
andrewfg marked this conversation as resolved.
Show resolved Hide resolved
UNKNOWN("unkown");

public final String label;

private VersionType(String label) {
this.label = label;
}
}