mirror of
https://github.com/Maks1mS/altlinux-autorepacked.git
synced 2024-12-23 22:52:59 +03:00
wip
This commit is contained in:
parent
dc54853fc7
commit
85cda3e705
@ -6,7 +6,6 @@ RUN apt-get update && apt-get install -y \
|
||||
alien \
|
||||
pip && \
|
||||
wget -O- https://eepm.ru/epm.sh | bash /dev/stdin ei
|
||||
# && rm -rf /var/lib/apt/lists/*
|
||||
|
||||
COPY requirements.txt .
|
||||
RUN pip --no-cache-dir install -r requirements.txt
|
||||
|
@ -13,6 +13,8 @@ def _get_file(directory):
|
||||
|
||||
|
||||
class BaseProvider:
|
||||
disabled = False
|
||||
|
||||
def __init__(self, config):
|
||||
self.config = config
|
||||
|
||||
@ -23,11 +25,7 @@ class BaseProvider:
|
||||
return self._name
|
||||
|
||||
def get_version(self):
|
||||
url = utils.run([
|
||||
'epm',
|
||||
'--silent',
|
||||
'tool',
|
||||
'eget',
|
||||
url = utils.eget([
|
||||
'--get-real-url',
|
||||
self.get_download_url(),
|
||||
])
|
||||
@ -42,24 +40,27 @@ class BaseProvider:
|
||||
def get_download_url(self):
|
||||
return self.DOWNLOAD_URL
|
||||
|
||||
def get_download_name(self):
|
||||
return ""
|
||||
|
||||
def download(self):
|
||||
download_directory = tempfile.mkdtemp()
|
||||
repacked_directory = tempfile.mkdtemp()
|
||||
|
||||
utils.run([
|
||||
'epm',
|
||||
'--silent',
|
||||
'tool',
|
||||
'eget',
|
||||
'-q',
|
||||
self.get_download_url(),
|
||||
], cwd=download_directory)
|
||||
args = []
|
||||
|
||||
download_name = self.get_download_name()
|
||||
|
||||
if download_name:
|
||||
args += ["-O", download_name]
|
||||
|
||||
args += [self.get_download_url()]
|
||||
|
||||
utils.eget(args, cwd=download_directory)
|
||||
|
||||
file = _get_file(download_directory)
|
||||
|
||||
utils.run([
|
||||
'epm',
|
||||
'--silent',
|
||||
utils.epm([
|
||||
'-y',
|
||||
'repack',
|
||||
file,
|
||||
@ -69,9 +70,7 @@ class BaseProvider:
|
||||
|
||||
file = _get_file(repacked_directory)
|
||||
|
||||
utils.run([
|
||||
'epm',
|
||||
'--silent',
|
||||
utils.epm([
|
||||
'repo',
|
||||
'pkgadd',
|
||||
self.config.get('repo_path'),
|
||||
|
@ -8,11 +8,7 @@ class GithubReleasesProvider(BaseProvider):
|
||||
_repo = ''
|
||||
|
||||
def _last_release_url(self):
|
||||
return utils.run([
|
||||
'epm',
|
||||
'--silent',
|
||||
'tool',
|
||||
'eget',
|
||||
return utils.eget([
|
||||
'--get-real-url',
|
||||
f'https://github.com/{self._repo}/releases/latest'
|
||||
])
|
||||
|
35
autorepacked/common_providers/snap_provider.py
Normal file
35
autorepacked/common_providers/snap_provider.py
Normal file
@ -0,0 +1,35 @@
|
||||
import json
|
||||
import urllib
|
||||
|
||||
from autorepacked.common_providers.base_provider import BaseProvider
|
||||
from urllib.request import Request, urlopen
|
||||
|
||||
class SnapProvider(BaseProvider):
|
||||
_package_name = "package"
|
||||
_channel = "stable"
|
||||
_arch = "amd64"
|
||||
|
||||
def _get_snap_info(self):
|
||||
request = Request(
|
||||
f"http://api.snapcraft.io/v2/snaps/info/{self._package_name}",
|
||||
headers={"Content-Type": "application/json", "Snap-Device-Series": "16"},
|
||||
)
|
||||
response = urlopen(request).read()
|
||||
return json.loads(response)
|
||||
|
||||
def get_download_name(self):
|
||||
return f"{self._package_name}-{self.get_version()}.snap"
|
||||
|
||||
def get_version(self):
|
||||
snap_info = self._get_snap_info()
|
||||
for channel_map in snap_info["channel-map"]:
|
||||
if (channel_map["channel"]["name"] == self._channel
|
||||
and channel_map["channel"]["architecture"] == self._arch):
|
||||
return channel_map['version']
|
||||
|
||||
def get_download_url(self):
|
||||
snap_info = self._get_snap_info()
|
||||
for channel_map in snap_info["channel-map"]:
|
||||
if (channel_map["channel"]["name"] == self._channel
|
||||
and channel_map["channel"]["architecture"] == self._arch):
|
||||
return channel_map['download']['url']
|
@ -14,8 +14,7 @@ from autorepacked.config import Config
|
||||
|
||||
|
||||
def create_repo(config: Config):
|
||||
utils.run([
|
||||
'epm',
|
||||
utils.epm([
|
||||
'repo',
|
||||
'create',
|
||||
config.get('repo_path')
|
||||
@ -23,8 +22,7 @@ def create_repo(config: Config):
|
||||
|
||||
|
||||
def update_epm():
|
||||
utils.run([
|
||||
'epm',
|
||||
utils.epm([
|
||||
'ei'
|
||||
])
|
||||
|
||||
@ -69,23 +67,23 @@ def update():
|
||||
module = importlib.import_module(f'providers.{module_name}')
|
||||
if hasattr(module, 'get_provider'):
|
||||
provider = module.get_provider(config) # type: BaseProvider
|
||||
name = provider.get_name()
|
||||
print(f"request version of {name}")
|
||||
version = provider.get_version()
|
||||
if name not in versions or versions[name] != version:
|
||||
print(f'{name} has new version {version}')
|
||||
versions[name] = version
|
||||
provider.download()
|
||||
need_update_index = True
|
||||
if not provider.disabled:
|
||||
name = provider.get_name()
|
||||
print(f"request version of {name}")
|
||||
version = provider.get_version()
|
||||
if name not in versions or versions[name] != version:
|
||||
print(f'{name} has new version {version}')
|
||||
versions[name] = version
|
||||
provider.download()
|
||||
need_update_index = True
|
||||
|
||||
repo_data['versions'] = versions
|
||||
|
||||
current_date = datetime.datetime.utcnow()
|
||||
|
||||
if need_update_index:
|
||||
utils.run(
|
||||
utils.epm(
|
||||
args=[
|
||||
'epm',
|
||||
'repo',
|
||||
'index',
|
||||
config.get('repo_path'),
|
||||
|
12
autorepacked/providers/singularityapp/__init__.py
Normal file
12
autorepacked/providers/singularityapp/__init__.py
Normal file
@ -0,0 +1,12 @@
|
||||
from autorepacked.common_providers.snap_provider import SnapProvider
|
||||
|
||||
|
||||
class SingularityApp(SnapProvider):
|
||||
disabled = True
|
||||
|
||||
_name = 'singularityapp'
|
||||
_package_name = 'singularityapp'
|
||||
|
||||
|
||||
def get_provider(config):
|
||||
return SingularityApp(config)
|
@ -7,3 +7,12 @@ def run(args, cwd=None):
|
||||
cwd=cwd,
|
||||
stdout=subprocess.PIPE,
|
||||
).stdout.decode('utf-8')
|
||||
|
||||
|
||||
def epm(args, cwd=None):
|
||||
return run(["epm"] + args, cwd=cwd)
|
||||
|
||||
|
||||
def eget(args, cwd=None):
|
||||
return epm(["tool", "eget"] + args, cwd=cwd)
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user