142 Commits

Author SHA1 Message Date
Eric Callahan
51e3568aac
update_manager: add git repo instance detection
Use git-config to set track the current Moonraker instance managing a
a git repo.  If multiple  instances are detected log and create a repo
warning.

Singed-off-by:  Eric Callahan <arksine.code@gmail.com>
2023-07-13 07:58:40 -04:00
Eric Callahan
011179ca6d
git_deploy: improve submodule validation
Submodules contain a .git file that includes the path to the
actual repository folder.  Extract that path and use it for
lock file detection.

Signed-off-by:  Eric Callahan <arksine.code@gmail.com>
2023-07-13 07:58:40 -04:00
Eric Callahan
270c78d8af
git_deploy: refactor initialization
Use git-branch to determine current the current branch and
head state instead of git-status.  The former is a porcelain
command with guaranteed output.

Signed-off-by:  Eric Callahan <arksine.code@gmail.com>
2023-07-13 07:58:40 -04:00
Eric Callahan
3f1e9e397e
update_manger: log remaining refresh time on init
Signed-off-by:  Eric Callahan <arksine.code@gmail.com>
2023-07-12 13:57:27 -04:00
Eric Callahan
1c16233da0
git_deploy: rollback improvements
Streamline the rollback defaults so only one dict object
is explicitly defined in "capture_state_for_rollback()".
Validate the rollback branch on detached heads before
setting it.

Signed-off-by:  Eric Callahan <arksine.code@gmail.com>
2023-07-12 13:57:26 -04:00
Eric Callahan
9651923f8e
git_deploy: fetch partial clones for hard recovery
It isn't necessary to download and decompress all blobs.

Signed-off-by:  Eric Callahan <arksine.code@gmail.com>
2023-07-12 13:57:26 -04:00
Eric Callahan
3e875b583c
git_deploy: add support for stable updates
Signed-off-by:  Eric Callahan <arksine.code@gmail.com>
2023-07-12 13:57:25 -04:00
Eric Callahan
1a4480e74c
git_deploy: use versions utility
Use the newly implemented versions utility for git version parsing.
This allows for simple access to version information and
version comparison.

Signed-off-by:  Eric Callahan <arksine.code@gmail.com>
2023-07-12 13:57:25 -04:00
Eric Callahan
69710e10e0
update_manager: reset to correct commit after recovery
If a git repo not configured on the dev channel it is necessary
to move the HEAD to the commit for the correct tag.

Signed-off-by:  Eric Callahan <arksine.code@gmail.com>
2023-07-12 13:57:24 -04:00
Eric Callahan
41d945803f
update_manager: replace string choices with enums
Signed-off-by:  Eric Callahan <arksine.code@gmail.com>
2023-07-12 13:57:24 -04:00
Eric Callahan
c903dd6af4
update_manager: implement update rollback support
Signed-off-by:  Eric Callahan <arksine.code@gmail.com>
2023-07-12 13:55:47 -04:00
Eric Callahan
26975e055b
update_manager: fix klipper instantiation on path switch
Signed-off-by:  Eric  Callahan <arksine.code@gmail.com>
2023-07-12 13:50:47 -04:00
Eric Callahan
2ef4dc4d8e
update_manager: fix initial name parsing
This fixes an issue where a configuration name with spaces
may not match the reported name.

Signed-off-by:  Eric Callahan <arksine.code>
2023-06-27 12:26:58 -04:00
Eric Callahan
5f43536612
update_manager: update base channel config
Allow independent channel configuration for Moonraker and
Klipper.

Signed-off-by:  Eric Callahan <arksine.code@gmail.com>
2023-06-27 12:16:57 -04:00
Eric Callahan
a1e786fd73
update_manager: fix defaults for base configuration
Signed-off-by:  Eric Callahan <arksine.code@gmail.com>
2023-06-27 12:10:19 -04:00
Eric Callahan
1d3e5564a2
git deploy: use python requirements file for updates
The package parsing only serves the purpose of performing the diff.

Signed-off-by:  Eric Callahan <arksine.code@gmail.com>
2023-06-26 16:48:47 -04:00
Eric Callahan
1cfeb853a5
update_manager: improve logging
Add a debug logging helper to the base class.  Use unique
logging prefixes for subclasses of AppDeploy.

Signed-off-by:  Eric Callahan <arksine.code@gmail.com>
2023-06-26 16:48:47 -04:00
Eric Callahan
4edfbce3ce
app_deploy: refactor configuration handling
Move specific configuration out of __init__ into several methods
that may be called by subclasses.   This allows child implementations
to define and share specific sets of configuration that they require
without forcing all implementations to do so.

Signed-off-by: Eric Callahan <arksine.code@gmail.com>
2023-06-26 16:48:46 -04:00
Eric Callahan
ee8f77c8c6
update_manager: disable repo binding
Remove hardcoded beta binding between Moonraker and Klipper.
This could result in a user getting stuck on a commit that requires
a future patch.

The original purpose of binding versions was to avoid a scenario
where Klipper introduces a feature incompatible with the current
Moonraker beta.  Rather than binding the  better solution is to
fix the incompatibility and tag a new beta.

Signed-off-by:  Eric Callahan <arksine.code@gmail.com>
2023-06-26 16:48:46 -04:00
Eric Callahan
357276b1d9
update_manager: remove unused reinstall functionality
This functionality was intended to allow for an automated
reinstallation between "git_repo" and "zip" types.  The
"zip" type remains unused, and attempting to automate
this would likely be unreliable.

Signed-off-by:  Eric Callahan <arksine.code@gmail.com>
2023-06-26 16:48:45 -04:00
Eric Callahan
b2d84bc733
update_manager: handle app entry points
If the exectuable in the virtualenv is not "python" attempt to
detect the python executable.  Use the pip entry point for the
pip command.

Signed-off-by:  Eric Callahan <arksine.code@gmail.com>
2023-06-26 16:48:45 -04:00
Eric Callahan
a797dd0b50
update_manager: validate web type installations
Require that "web" installations provide release info to validate
existing installations.  For known web clients provide a fallback
that uses the manifest to validate the installation.

Signed-off-by: Eric Callahan <arksine.code@gmail.com>
2023-06-20 11:59:41 -04:00
Eric Callahan
a7b9e5783d
git_deploy: relax validation requirements
Do not report invalid if the remote or branch does not match
the configured values.  In these conditions report them as
"repo_warnings" that frontends may display to the user.

Hard recovery now requires a recovery URL detected from the git
repo's "origin" remote.  This closes a potential security issue where a
malicioius repo could be cloned over an installed repo.

Signed-off-by:  Eric Callahan <arskine.code@gmail.com>
2023-06-20 11:59:40 -04:00
Eric Callahan
c41c5881c8
git_deploy: fix tag format specifier
Signed-off-by:  Eric Callahan <arksine.code@gmail.com>
2023-05-26 14:51:16 -04:00
Eric Callahan
c609060352
app_deploy: escape pip requirements installed via command line
Signed-off-by:  Eric Callahan <arksine.code@gmail.com>
2023-05-26 07:57:09 -04:00
Eric Callahan
ead4cc21ce
update_manager: fix service restart
On machines running instances of Moonraker and Klipper without
the default service names it is necessary to look up their unit names
using systemd.

Signed-off-by:  Eric Callahan <arksine.code@gmail.com>
2023-02-26 16:19:38 -05:00
Eric Callahan
6a5a5b50d3
update_manager: validate web_request args
Signed-off-by:  Eric Callahan <arksine.code@gmail.com>
2023-02-24 10:26:16 -05:00
Eric Callahan
6d73c60a38
moonraker: move common classes to common.py
Signed-off-by:  Eric Callahan <arksine.code@gmail.com>
2023-02-24 07:08:41 -05:00
Eric Callahan
68c5fb6f6b
git_deploy: strip comments when parsing python reqs
Signed-off-by:  Eric Callahan <arksine.code@gmail.com>
2023-02-22 18:08:52 -05:00
Eric Callahan
e32fd688e4
moonraker: correct stale annotations
Signed-off-by:  Eric Callahan <arksine.code@gmail.com>
2023-02-22 18:08:50 -05:00
Eric Callahan
79467e6484
utils: add source_info utility module
Signed-off-by:  Eric Callahan <arksine.code@gmail.com>
2023-02-22 18:08:48 -05:00
Eric Callahan
0f8638fec7
components: correct imports
All imports must now be relative to work correctly with the
moonraker parent package.

Signed-off-by:  Eric Callahan <arksine.code@gmail.com>
2023-02-22 12:16:27 -05:00
Eric Callahan
a5d63db9a6
server: rename moonraker.py to server.py
Signed-off-by:  Eric Callahan <arksiine.code@gmail.com>
2023-02-21 18:05:01 -05:00
Eric Callahan
385b9a1b7a
update_manager: handle rev-list on tagless repos
Signed-off-by:  Eric Callahan <arksine.code@gmail.com>
2023-02-07 11:20:08 -05:00
Eric Callahan
d75831f10a
update_manager: require at least two parts in a tag
Allowing only a single part in the regex resulted in repos
without tags being assigned erronous version info.  With
this change, the following tags can be parsed:

v1.0
v1.0.2
1.0
1.0.2

Signed-off-by:  Eric Callahan <arksine.code@gmail.com>
2023-02-07 11:09:50 -05:00
Eric Callahan
c331c5a7d7
update_manager: fix semver conversion
When converting a semantic version to a list for comparisons
guarantee that the base version has 3 parts.

Signed-off-by:  Eric Callahan <arksine.code@gmail.com>
2023-02-07 10:28:36 -05:00
Eric Callahan
4ff7a50821
update_manager: relax semantic tag requirement
Allow tags versions with one, two, or three parts.  The following
examples are now valid:

v1
v1.3
v1.0,10

Signed-off-by:  Eric Callahan <arksine.code@gmail.com>
2023-02-07 08:06:13 -05:00
Eric Callahan
01977c8775
update_manager: refactoring
Code style and naming convention improvements.

Signed-off-by:  Eric Callahan <arksine.code@gmail.com>
2023-02-06 07:50:08 -05:00
Eric Callahan
c8ad69b902
update_manager: add individual refresh endpoint
This endpoint allows clients to refresh items on an individual basis
when the "name" parameter is specified.  This endpoint replaces

Signed-off-by:  Eric Callahan <arksine.code@gmail.com>
2023-02-06 06:42:56 -05:00
Eric Callahan
f50fa3c5e7
update_manager: add package resolution check to apt backend
Make sure packages within the package list exist prior to installation.

Signed-off-by:  Eric Callahan <arksine.code@gmail.com>
2023-02-05 19:25:54 -05:00
Eric Callahan
21a7928ea2
update_manager: pip improvements
Re-implement pip updates using a pinned version.  A version
check is now always done prior to installing python requirements,
updating when necessary.

Signed-off-by:  Eric Callahan <arksine.code@gmail.com>
2023-02-05 19:25:54 -05:00
Eric Callahan
76500fe9f9
update_manager: improve dependency detection
Parse system packages and python requirements prior to and after each
updating, using the difference to determine if an update is necessary.
Only the new detected packages are installed unless the "force" variable
is set.

Signed-off-by:  Eric Callahan <arksine.code@gmail.com>
2023-02-05 19:25:53 -05:00
Eric Callahan
c1e4142a40
update_manager: add arch filter
Signed-off-by:  Eric Callahan <arksine.code@gmail.com>
2023-01-31 14:00:54 -05:00
Eric Callahan
b02e766a4d
update_manager: log detected packages
Signed-off-by:  Eric Callahan <arksine.code@gmail.com>
2023-01-31 14:00:54 -05:00
Eric Callahan
ecf7fb9267
klippy_connection: add is_printing() and is_ready() methods
Several components throughout Moonraker determine whether or not
Klipper is printing or is ready before taking action.  This centralizes
queries in one area.  The checks do not query Klipper directly but
rather rely on subscriptions to push state to Moonraker.

Signed-off-by:  Eric Callahan <arksine.code@gmail.com>
2023-01-06 12:20:52 -05:00
Eric Callahan
f296c6fadd
update_manager: allow old application naming convention
While the [update_manager client ...] naming convention is
deprecated it should not be disallowed.  This fixes service restart
issues using the old naming convention.

Signed-off-by:  Eric Callahan <arksine.code@gmail.com>
2022-12-12 16:59:22 -05:00
Eric Callahan
779997c2b8
git_deploy: refresh previously corrupt repos
It is possible that the user manually corrected a corrupt repo.
If a repo makes it past initialization reset the corrupt flag.

Signed-off-by: Eric Callahan <arksine.code@gmail.com>
2022-10-22 19:03:48 -04:00
Eric Callahan
59cc8c6c7b
update_manager: report errors in update response
Signed-off-by:  Eric Callahan <arksine.code@gmail.com>
2022-10-20 16:54:35 -04:00
Eric Callahan
e4a670a380
update_manager: improve corrupt repo detection
It that "git status" will not detect some repo issues, these are only
found after a fetch.  When this condition is detected save the repo
state and report that the repo is corrupt and invalid.

Signed-off-by:  Eric Callahan <arksine.code@gmail.com>
2022-10-20 16:54:34 -04:00
Eric Callahan
74f43cad6e
git_deploy: notify attempts to fix loose objects
Signed-off-by:  Eric Callahan <arksine.code@gmail.com>
2022-10-19 19:32:54 -04:00