This commit is contained in:
mwiegand 2021-07-01 00:11:40 +02:00
parent dee39170f3
commit fb1c7a2bcc
3 changed files with 35 additions and 33 deletions

View file

@ -4,6 +4,7 @@ from shlex import quote
from os.path import join from os.path import join
from mako.template import Template from mako.template import Template
version = node.metadata.get('nextcloud/version')
directories = { directories = {
'/opt/nextcloud': {}, '/opt/nextcloud': {},
@ -26,21 +27,25 @@ directories = {
}, },
} }
git_deploy = { downloads[f'/tmp/nextcloud-{version}.tar.bz2'] = {
'/opt/nextcloud': { 'url': f'https://download.nextcloud.com/server/releases/nextcloud-{version}.tar.bz2',
'repo': 'git://github.com/nextcloud/server.git', 'sha256_url': f'https://download.nextcloud.com/server/releases/nextcloud-{version}.tar.bz2.sha256',
'rev': f"v{node.metadata.get('nextcloud/version')}", 'triggered': True,
'needs': { }
'directory:/opt/nextcloud', actions['delete_nextcloud'] = {
}, 'command': 'rm -rf /opt/nextcloud/{.*,*}',
}, 'triggered': True,
'/opt/nextcloud/3rdparty': { }
'repo': 'git://github.com/nextcloud/3rdparty.git', actions['extract_nextcloud'] = {
'rev': f"v{node.metadata.get('nextcloud/version')}", 'command': f'tar xfvj /tmp/nextcloud-{version}.tar.bz2 --skip-old-files --strip 1 -C /opt/nextcloud nextcloud',
'needs': { 'unless': f"""php -r 'include "/opt/nextcloud/version.php"; echo "$OC_VersionString";' | grep -q '^{version}$'""",
'git_deploy:/opt/nextcloud', 'preceded_by': [
}, 'action:delete_nextcloud',
}, f'download:/tmp/nextcloud-{version}.tar.bz2',
],
'needs': [
'directory:/opt/nextcloud',
],
} }
symlinks = { symlinks = {
@ -49,7 +54,7 @@ symlinks = {
'owner': 'www-data', 'owner': 'www-data',
'group': 'www-data', 'group': 'www-data',
'needs': [ 'needs': [
'git_deploy:/opt/nextcloud', 'action:extract_nextcloud',
], ],
}, },
'/opt/nextcloud/userapps': { '/opt/nextcloud/userapps': {
@ -57,7 +62,7 @@ symlinks = {
'owner': 'www-data', 'owner': 'www-data',
'group': 'www-data', 'group': 'www-data',
'needs': [ 'needs': [
'git_deploy:/opt/nextcloud', 'action:extract_nextcloud',
], ],
}, },
} }
@ -65,7 +70,7 @@ symlinks = {
files = { files = {
# '/opt/nextcloud/core/shipped.json': { # '/opt/nextcloud/core/shipped.json': {
# 'needs': [ # 'needs': [
# 'git_deploy:/opt/nextcloud', # 'action:extract_nextcloud',
# ], # ],
# }, # },
'/etc/nextcloud/CAN_INSTALL': { '/etc/nextcloud/CAN_INSTALL': {
@ -115,8 +120,7 @@ actions['install_nextcloud'] = {
'directory:/var/lib/nextcloud/.cache', 'directory:/var/lib/nextcloud/.cache',
'symlink:/opt/nextcloud/config', 'symlink:/opt/nextcloud/config',
'symlink:/opt/nextcloud/userapps', 'symlink:/opt/nextcloud/userapps',
'git_deploy:/opt/nextcloud', 'action:extract_nextcloud',
'git_deploy:/opt/nextcloud/3rdparty',
'file:/etc/nextcloud/CAN_INSTALL', 'file:/etc/nextcloud/CAN_INSTALL',
'file:/etc/nextcloud/managed.config.php', 'file:/etc/nextcloud/managed.config.php',
'postgres_db:nextcloud', 'postgres_db:nextcloud',
@ -140,6 +144,6 @@ actions['nextcloud_add_missing_inidces'] = {
], ],
'triggered': True, 'triggered': True,
'triggered_by': [ 'triggered_by': [
f'git_deploy:/opt/nextcloud', f'action:extract_nextcloud',
], ],
} }

View file

@ -22,6 +22,7 @@ class Download(Item):
ITEM_ATTRIBUTES = { ITEM_ATTRIBUTES = {
'url': "", 'url': "",
'sha256': "", 'sha256': "",
'sha256_url': "",
'verifySSL': True, 'verifySSL': True,
'decompress': None, 'decompress': None,
} }
@ -62,15 +63,6 @@ class Download(Item):
url=quote(self.attributes['url']) url=quote(self.attributes['url'])
)) ))
# check hash
sha256 = self.__hash_remote_file(self.name)
if sha256 != self.attributes['sha256']:
# unlink file
self.node.run("rm -rf -- {}".format(quote(self.name)))
return False
def cdict(self): def cdict(self):
"""This is how the world should be""" """This is how the world should be"""
cdict = { cdict = {
@ -88,14 +80,19 @@ class Download(Item):
else: else:
sdict = { sdict = {
'type': 'download', 'type': 'download',
'sha256': self.__hash_remote_file(self.name)
} }
if 'sha256' in self.attributes:
sdict['sha256'] = self.attributes['sha256']
elif 'sha256_url' in self.attributes:
sdict['sha256'] = force_text(
self.node.run(f"curl -L -s -- {quote(self.attributes['sha256_url'])}").stdout
).strip().split()[0]
return sdict return sdict
@classmethod @classmethod
def validate_attributes(cls, bundle, item_id, attributes): def validate_attributes(cls, bundle, item_id, attributes):
if 'sha256' not in attributes: if 'sha256' not in attributes and 'sha256_url' not in attributes:
raise BundleError(_( raise BundleError(_(
"at least one hash must be set on {item} in bundle '{bundle}'" "at least one hash must be set on {item} in bundle '{bundle}'"
).format( ).format(

View file

@ -18,7 +18,8 @@
'metadata': { 'metadata': {
'nextcloud': { 'nextcloud': {
'domain': 'cloud.sublimity.de', 'domain': 'cloud.sublimity.de',
'version': '20.0.10', 'version': '20.0.5',
'sha256': '5e5b38109a3485db5fd2d248f24478eabe6c0790ec10b030acbbee207d5511fe',
}, },
'id': 'ea29bdf0-0b47-4bf4-8346-67d60c9dc4ae', 'id': 'ea29bdf0-0b47-4bf4-8346-67d60c9dc4ae',
'bind': { 'bind': {