diff --git a/bundles/gitea/items.py b/bundles/gitea/items.py index faf3578..14e6b21 100644 --- a/bundles/gitea/items.py +++ b/bundles/gitea/items.py @@ -1,16 +1,3 @@ -downloads = { - '/usr/local/bin/gitea': { - 'url': 'https://dl.gitea.io/gitea/{version}/gitea-{version}-linux-amd64'.format(version=node.metadata['gitea']['version']), - 'sha256': node.metadata['gitea']['sha256'], - 'triggers': { - 'svc_systemd:gitea:restart', - }, - 'preceded_by': { - 'svc_systemd:gitea:stop', - }, - }, -} - users = { 'git': {}, } @@ -35,16 +22,6 @@ directories = { }, } -actions = { - 'chmod_gitea': { - 'command': 'chmod a+x /usr/local/bin/gitea', - 'unless': 'test -x /usr/local/bin/gitea', - 'needs': { - 'download:/usr/local/bin/gitea', - }, - }, -} - files = { '/etc/systemd/system/gitea.service': { 'content_type': 'mako', @@ -61,6 +38,18 @@ files = { 'svc_systemd:gitea:restart', }, }, + '/usr/local/bin/gitea': { + 'content_type': 'download', + 'source': 'https://dl.gitea.io/gitea/{version}/gitea-{version}-linux-amd64'.format(version=node.metadata['gitea']['version']), + 'content_hash': node.metadata['gitea']['sha1'], + 'mode': '0755', + 'triggers': { + 'svc_systemd:gitea:restart', + }, + 'preceded_by': { + 'svc_systemd:gitea:stop', + }, + }, } if node.metadata['gitea'].get('install_ssh_key', False): @@ -74,10 +63,9 @@ if node.metadata['gitea'].get('install_ssh_key', False): svc_systemd = { 'gitea': { 'needs': { - 'action:chmod_gitea', - 'download:/usr/local/bin/gitea', - 'file:/etc/systemd/system/gitea.service', 'file:/etc/gitea/app.ini', + 'file:/etc/systemd/system/gitea.service', + 'file:/usr/local/bin/gitea', }, }, } diff --git a/items/download.py b/items/download.py deleted file mode 100644 index a313acf..0000000 --- a/items/download.py +++ /dev/null @@ -1,120 +0,0 @@ -from bundlewrap.items import Item, ItemStatus -from bundlewrap.exceptions import BundleError -from bundlewrap.utils.text import force_text, mark_for_translation as _ -from bundlewrap.utils.remote import PathInfo -import types -from pipes import quote - -# Original file: https://github.com/bundlewrap/plugins/blob/master/item_download/items/download.py -# BW4 does not support plugins anymore, thus we download it manually. - -class Download(Item): - """ - Download a file and verify its Hash. - """ - BUNDLE_ATTRIBUTE_NAME = "downloads" - NEEDS_STATIC = [ - "pkg_apt:", - "pkg_pacman:", - "pkg_yum:", - "pkg_zypper:", - ] - ITEM_ATTRIBUTES = { - 'url': "", - 'sha256': "", - 'verifySSL': True, - } - ITEM_TYPE_NAME = "download" - REQUIRED_ATTRIBUTES = [] - - def __repr__(self): - return "".format(self.name) - - def __hash_remote_file(self, filename): - path_info = PathInfo(self.node, filename) - if not path_info.is_file: - return None - - if hasattr(path_info, 'sha256'): - return path_info.sha256 - else: - """"pending pr so do it manualy""" - if self.node.os == 'macos': - result = self.node.run("shasum -a 256 -- {}".format(quote(filename))) - elif self.node.os in self.node.OS_FAMILY_BSD: - result = self.node.run("sha256 -q -- {}".format(quote(filename))) - else: - result = self.node.run("sha256sum -- {}".format(quote(filename))) - return force_text(result.stdout).strip().split()[0] - - def fix(self, status): - if status.must_be_deleted: - # Not possible - pass - else: - # download file - try: - self.node.run("curl -L {verify}-s -o {file} -- {url}".format( - verify="" if self.attributes.get('verifySSL', True) else "-k ", - file=quote(self.name), - url=quote(self.attributes['url']) - )) - except: - return False - - # 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): - """This is how the world should be""" - cdict = { - 'type': 'download', - 'sha256': self.attributes['sha256'], - } - - return cdict - - def sdict(self): - """This is how the world is right now""" - path_info = PathInfo(self.node, self.name) - if not path_info.exists: - return None - else: - sdict = { - 'type': 'download', - 'sha256': self.__hash_remote_file(self.name) - } - - return sdict - - @classmethod - def validate_attributes(cls, bundle, item_id, attributes): - if 'sha256' not in attributes: - raise BundleError(_( - "at least one hash must be set on {item} in bundle '{bundle}'" - ).format( - bundle=bundle.name, - item=item_id, - )) - - if 'url' not in attributes: - raise BundleError(_( - "you need to specify the url on {item} in bundle '{bundle}'" - ).format( - bundle=bundle.name, - item=item_id, - )) - - def get_auto_deps(self, items): - deps = [] - for item in items: - # debian TODO: add other package manager - if item.ITEM_TYPE_NAME == 'pkg_apt' and item.name == 'curl': - deps.append(item.id) - return deps diff --git a/nodes/rx300.py b/nodes/rx300.py index 9d39886..6dc9810 100644 --- a/nodes/rx300.py +++ b/nodes/rx300.py @@ -135,7 +135,7 @@ nodes['rx300'] = { }, 'gitea': { 'version': '1.15.2', - 'sha256': '9a7fae605dc182e0c7b1d380647518aaa8736ad5a42f7e9299099317f1e614c9', + 'sha1': '548018e2c9c1dfd9ac0919aec743759027ad9c72', 'domain': 'git.franzi.business', 'email_domain_blocklist': { 'gmail.com',