mirror of
https://github.com/Maks1mS/altlinux-autorepacked.git
synced 2024-12-23 14:42:59 +03:00
refactor
This commit is contained in:
parent
657c424bf1
commit
dc54853fc7
@ -1,11 +1,11 @@
|
||||
FROM registry.altlinux.org/alt/python:p10
|
||||
|
||||
RUN apt-get update && apt-get install -y \
|
||||
eepm \
|
||||
wget \
|
||||
apt-repo-tools \
|
||||
alien \
|
||||
pip
|
||||
pip && \
|
||||
wget -O- https://eepm.ru/epm.sh | bash /dev/stdin ei
|
||||
# && rm -rf /var/lib/apt/lists/*
|
||||
|
||||
COPY requirements.txt .
|
||||
|
39
autorepacked/common_providers/github_releases_provider.py
Normal file
39
autorepacked/common_providers/github_releases_provider.py
Normal file
@ -0,0 +1,39 @@
|
||||
import re
|
||||
|
||||
from autorepacked import utils
|
||||
from autorepacked.common_providers.base_provider import BaseProvider
|
||||
|
||||
|
||||
class GithubReleasesProvider(BaseProvider):
|
||||
_repo = ''
|
||||
|
||||
def _last_release_url(self):
|
||||
return utils.run([
|
||||
'epm',
|
||||
'--silent',
|
||||
'tool',
|
||||
'eget',
|
||||
'--get-real-url',
|
||||
f'https://github.com/{self._repo}/releases/latest'
|
||||
])
|
||||
|
||||
def _last_tag_name(self):
|
||||
return self.get_version()
|
||||
|
||||
def _get_release_filename(self):
|
||||
return ''
|
||||
|
||||
def get_version(self):
|
||||
url = self._last_release_url()
|
||||
|
||||
pattern = r'\d+\.\d+\.\d+'
|
||||
match = re.search(pattern, url)
|
||||
if match:
|
||||
return match.group()
|
||||
else:
|
||||
return "not found"
|
||||
|
||||
def get_download_url(self):
|
||||
return (f"https://github.com/"
|
||||
f"{self._repo}/releases/download/"
|
||||
f"{self._last_tag_name()}/{self._get_release_filename()}")
|
@ -9,7 +9,7 @@ import uvicorn
|
||||
from fastapi_utils.tasks import repeat_every
|
||||
|
||||
from autorepacked import utils
|
||||
from autorepacked.base_provider import BaseProvider
|
||||
from autorepacked.common_providers.base_provider import BaseProvider
|
||||
from autorepacked.config import Config
|
||||
|
||||
|
||||
@ -22,6 +22,13 @@ def create_repo(config: Config):
|
||||
])
|
||||
|
||||
|
||||
def update_epm():
|
||||
utils.run([
|
||||
'epm',
|
||||
'ei'
|
||||
])
|
||||
|
||||
|
||||
@asynccontextmanager
|
||||
async def lifespan(app: FastAPI):
|
||||
await update_repeat()
|
||||
@ -51,6 +58,8 @@ def update():
|
||||
update_task_started = False
|
||||
return
|
||||
|
||||
update_epm()
|
||||
|
||||
providers_path = os.path.join(os.getcwd(), 'autorepacked/providers')
|
||||
modules = os.listdir(providers_path)
|
||||
|
||||
|
@ -1,4 +1,4 @@
|
||||
from autorepacked.base_provider import BaseProvider
|
||||
from autorepacked.common_providers.base_provider import BaseProvider
|
||||
|
||||
|
||||
class CodeProvider(BaseProvider):
|
||||
|
@ -1,4 +1,4 @@
|
||||
from autorepacked.base_provider import BaseProvider
|
||||
from autorepacked.common_providers.base_provider import BaseProvider
|
||||
|
||||
|
||||
class DiscordProvider(BaseProvider):
|
||||
|
@ -1,30 +1,13 @@
|
||||
import subprocess
|
||||
|
||||
from autorepacked.base_provider import BaseProvider
|
||||
from autorepacked.common_providers.github_releases_provider import GithubReleasesProvider
|
||||
|
||||
|
||||
class RustdeskProvider(BaseProvider):
|
||||
class RustdeskProvider(GithubReleasesProvider):
|
||||
_name = 'rustdesk'
|
||||
_release_url = 'https://github.com/rustdesk/rustdesk/releases'
|
||||
_release_file = '[0-9]/rustdesk-[0-9].[0-9].[0-9].deb'
|
||||
|
||||
def get_download_url(self):
|
||||
url = subprocess.run(
|
||||
args=[
|
||||
'epm',
|
||||
'--silent',
|
||||
'tool',
|
||||
'eget',
|
||||
'--list',
|
||||
'--latest',
|
||||
'--get-real-url',
|
||||
self._release_url,
|
||||
self._release_file,
|
||||
],
|
||||
stdout=subprocess.PIPE
|
||||
).stdout.decode('utf-8')
|
||||
_repo = 'rustdesk/rustdesk'
|
||||
|
||||
return url
|
||||
def _get_release_filename(self):
|
||||
return f'rustdesk-{self.get_version()}-x86_64.deb'
|
||||
|
||||
|
||||
def get_provider(config):
|
||||
|
17
autorepacked/providers/trezor_suite/__init__.py
Normal file
17
autorepacked/providers/trezor_suite/__init__.py
Normal file
@ -0,0 +1,17 @@
|
||||
from autorepacked.common_providers.github_releases_provider import GithubReleasesProvider
|
||||
|
||||
|
||||
class TrezorSuiteProvider(GithubReleasesProvider):
|
||||
_name = 'Trezor-Suite'
|
||||
|
||||
_repo = 'trezor/trezor-suite'
|
||||
|
||||
def _last_tag_name(self):
|
||||
return f'v{self.get_version()}'
|
||||
|
||||
def _get_release_filename(self):
|
||||
return f'Trezor-Suite-{self.get_version()}-linux-x86_64.AppImage'
|
||||
|
||||
|
||||
def get_provider(config):
|
||||
return TrezorSuiteProvider(config)
|
Loading…
Reference in New Issue
Block a user