mirror of
https://github.com/Maks1mS/altlinux-autorepacked.git
synced 2024-12-23 14:42:59 +03:00
init
This commit is contained in:
commit
250fe07bf0
0
.env.example
Normal file
0
.env.example
Normal file
1
.gitignore
vendored
Normal file
1
.gitignore
vendored
Normal file
@ -0,0 +1 @@
|
||||
.env
|
12
Dockerfile
Normal file
12
Dockerfile
Normal file
@ -0,0 +1,12 @@
|
||||
FROM registry.altlinux.org/alt/python:p10
|
||||
|
||||
RUN apt-get update && apt-get install -y \
|
||||
eepm \
|
||||
wget
|
||||
# && rm -rf /var/lib/apt/lists/*
|
||||
|
||||
COPY ./autorepacked ./autorepacked
|
||||
|
||||
ENV PYTHONPATH "${PYTHONPATH}:."
|
||||
|
||||
CMD ["python3", "-u", "./autorepacked/main.py"]
|
5
README.md
Normal file
5
README.md
Normal file
@ -0,0 +1,5 @@
|
||||
Usage:
|
||||
```
|
||||
docker build -t maks1ms/altlinux-autorepacked:p10 .
|
||||
docker run -e REPO_PATH=/repo -v /www/ALTLinux/autorepacked/p10/branch:/repo maks1ms/altlinux-autorepacked:p10
|
||||
```
|
91
autorepacked/base_provider.py
Normal file
91
autorepacked/base_provider.py
Normal file
@ -0,0 +1,91 @@
|
||||
import os
|
||||
import shutil
|
||||
import subprocess
|
||||
import tempfile
|
||||
import re
|
||||
|
||||
|
||||
def _get_file(directory):
|
||||
files_and_dirs = os.listdir(directory)
|
||||
files = [f for f in files_and_dirs if os.path.isfile(os.path.join(directory, f))]
|
||||
return os.path.join(directory, files[0]) if files else None
|
||||
|
||||
class BaseProvider:
|
||||
def __init__(self, config):
|
||||
self.config = config
|
||||
|
||||
DOWNLOAD_URL = ''
|
||||
_name = ''
|
||||
|
||||
def get_name(self):
|
||||
return self._name
|
||||
|
||||
def get_version(self):
|
||||
url = subprocess.run([
|
||||
'epm',
|
||||
'--silent',
|
||||
'tool',
|
||||
'eget',
|
||||
'--get-real-url',
|
||||
self.get_download_url(),
|
||||
], stdout=subprocess.PIPE).stdout.decode('utf-8')
|
||||
|
||||
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 self.DOWNLOAD_URL
|
||||
|
||||
def download(self):
|
||||
download_directory = tempfile.mkdtemp()
|
||||
repacked_directory = tempfile.mkdtemp()
|
||||
|
||||
subprocess.run(
|
||||
args=[
|
||||
'epm',
|
||||
'--silent',
|
||||
'tool',
|
||||
'eget',
|
||||
'-q',
|
||||
self.get_download_url(),
|
||||
],
|
||||
stdout=subprocess.PIPE,
|
||||
cwd=download_directory,
|
||||
).stdout.decode('utf-8')
|
||||
|
||||
file = _get_file(download_directory)
|
||||
|
||||
subprocess.run(
|
||||
args=[
|
||||
'epm',
|
||||
'--silent',
|
||||
'-y',
|
||||
'repack',
|
||||
file,
|
||||
],
|
||||
stdout=subprocess.PIPE,
|
||||
cwd=repacked_directory,
|
||||
).stdout.decode('utf-8')
|
||||
|
||||
shutil.rmtree(download_directory)
|
||||
|
||||
file = _get_file(repacked_directory)
|
||||
|
||||
subprocess.run(
|
||||
args=[
|
||||
'epm',
|
||||
'--silent',
|
||||
'repo',
|
||||
'pkgadd',
|
||||
self.config.get('repo_path'),
|
||||
file,
|
||||
],
|
||||
stdout=subprocess.PIPE,
|
||||
cwd=repacked_directory,
|
||||
).stdout.decode('utf-8')
|
||||
|
||||
shutil.rmtree(repacked_directory)
|
19
autorepacked/config.py
Normal file
19
autorepacked/config.py
Normal file
@ -0,0 +1,19 @@
|
||||
import os
|
||||
|
||||
|
||||
class Config:
|
||||
def __init__(self):
|
||||
|
||||
required_vars = [
|
||||
"REPO_PATH"
|
||||
]
|
||||
|
||||
missing_vars = [var for var in required_vars if var.upper() not in os.environ]
|
||||
if missing_vars:
|
||||
raise ValueError(f"Missing required environment variables: {', '.join(missing_vars)}")
|
||||
|
||||
for key in os.environ:
|
||||
setattr(self, key.lower(), os.environ[key])
|
||||
|
||||
def get(self, key):
|
||||
return getattr(self, key.lower(), None)
|
11
autorepacked/providers/code/__init__.py
Normal file
11
autorepacked/providers/code/__init__.py
Normal file
@ -0,0 +1,11 @@
|
||||
from autorepacked.base_provider import BaseProvider
|
||||
|
||||
|
||||
class CodeProvider(BaseProvider):
|
||||
_name = 'code'
|
||||
|
||||
DOWNLOAD_URL = "https://code.visualstudio.com/sha/download?build=stable&os=linux-rpm-x64"
|
||||
|
||||
|
||||
def get_provider(config):
|
||||
return CodeProvider(config)
|
11
autorepacked/providers/discord/__init__.py
Normal file
11
autorepacked/providers/discord/__init__.py
Normal file
@ -0,0 +1,11 @@
|
||||
from autorepacked.base_provider import BaseProvider
|
||||
|
||||
|
||||
class DiscordProvider(BaseProvider):
|
||||
_name = 'discord'
|
||||
|
||||
DOWNLOAD_URL = "https://discord.com/api/download?platform=linux&format=deb"
|
||||
|
||||
|
||||
def get_provider(config):
|
||||
return DiscordProvider(config)
|
31
autorepacked/providers/rustdesk/__init__.py
Normal file
31
autorepacked/providers/rustdesk/__init__.py
Normal file
@ -0,0 +1,31 @@
|
||||
import subprocess
|
||||
|
||||
from autorepacked.base_provider import BaseProvider
|
||||
|
||||
|
||||
class RustdeskProvider(BaseProvider):
|
||||
_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')
|
||||
|
||||
return url
|
||||
|
||||
|
||||
def get_provider(config):
|
||||
return RustdeskProvider(config)
|
Loading…
Reference in New Issue
Block a user