mirror of
https://github.com/ElementsProject/lightning.git
synced 2025-02-21 14:24:09 +01:00
reckless: add installation metadata
The metadata includes an original retrieval source, timestamp, and commit hash. This will allow a future update command to more easily evaluate the status of the existing installation.
This commit is contained in:
parent
2b502ebcbc
commit
d5ed7b7b5c
1 changed files with 29 additions and 6 deletions
|
@ -1,19 +1,21 @@
|
|||
#!/usr/bin/env python3
|
||||
|
||||
from subprocess import Popen, PIPE, TimeoutExpired, run
|
||||
import sys
|
||||
import json
|
||||
import os
|
||||
import argparse
|
||||
import copy
|
||||
import datetime
|
||||
from enum import Enum
|
||||
import json
|
||||
import logging
|
||||
import os
|
||||
from pathlib import Path, PosixPath
|
||||
import shutil
|
||||
from subprocess import Popen, PIPE, TimeoutExpired, run
|
||||
import tempfile
|
||||
import time
|
||||
from typing import Union
|
||||
from urllib.parse import urlparse
|
||||
from urllib.request import urlopen
|
||||
import logging
|
||||
import copy
|
||||
from enum import Enum
|
||||
|
||||
|
||||
logging.basicConfig(
|
||||
|
@ -654,6 +656,26 @@ def get_temp_reckless_dir() -> PosixPath:
|
|||
return new_path
|
||||
|
||||
|
||||
def add_installation_metadata(installed: InstInfo,
|
||||
original_request: InstInfo):
|
||||
"""Document the install request and installation details for use when
|
||||
updating the plugin."""
|
||||
install_dir = Path(installed.source_loc)
|
||||
assert install_dir.is_dir()
|
||||
data = ('installation date\n'
|
||||
f'{datetime.date.today().isoformat()}\n'
|
||||
'installation time\n'
|
||||
f'{int(time.time())}\n'
|
||||
'original source\n'
|
||||
f'{original_request.source_loc}\n'
|
||||
'requested commit\n'
|
||||
f'{original_request.commit}\n'
|
||||
'installed commit\n'
|
||||
f'{installed.commit}\n')
|
||||
with open(install_dir / '.metadata', 'w') as metadata:
|
||||
metadata.write(data)
|
||||
|
||||
|
||||
def _install_plugin(src: InstInfo) -> Union[InstInfo, None]:
|
||||
"""make sure the repo exists and clone it."""
|
||||
logging.debug(f'Install requested from {src}.')
|
||||
|
@ -777,6 +799,7 @@ def _install_plugin(src: InstInfo) -> Union[InstInfo, None]:
|
|||
|
||||
# Find this cute little plugin a forever home
|
||||
shutil.copytree(str(staging_path), inst_path)
|
||||
add_installation_metadata(staged_src, src)
|
||||
print(f'plugin installed: {inst_path}')
|
||||
remove_dir(clone_path)
|
||||
return staged_src
|
||||
|
|
Loading…
Add table
Reference in a new issue