Commit a12672c7 authored by Tristan Van Berkom's avatar Tristan Van Berkom Committed by Javier Jardón Cabezas

Removing old cargo mechanics

The new cargo plugin renders the old cargo mechanics
obsolete, this commit removes:

 o plugins/ The old crate downloading Source plugin

 o utils/ The script to manually
   update crate using bst files
parent cc99faf6
Pipeline #111400 passed with stages
in 237 minutes and 33 seconds
import json
import tarfile
from buildstream import SourceError
import os.path
import buildstream
import importlib.util
_downloadablefilesource_src = os.path.join(os.path.dirname(buildstream.__file__), "plugins", "sources", "")
_downloadablefilesource_spec = importlib.util.spec_from_file_location("._downloadablefilesource", _downloadablefilesource_src)
_downloadablefilesource = importlib.util.module_from_spec(_downloadablefilesource_spec)
DownloadableFileSource = _downloadablefilesource.DownloadableFileSource
class CrateSource(DownloadableFileSource):
def configure(self, node):
self.subdir = self.node_get_member(node, str, 'subdir', 'crates') or None
self.node_validate(node, DownloadableFileSource.COMMON_CONFIG_KEYS + ['subdir'])
def stage(self, directory):
crates = os.path.join(directory, self.subdir)
os.makedirs(crates, exist_ok=True)
with as tar:
members = tar.getmembers()
if len(members) != 0:
dirname = members[0].name.split('/')[0]
package_dir = os.path.join(crates, dirname)
checksum_file = os.path.join(package_dir,
with open(checksum_file, 'w') as f:
checksum_data = {'package': self.ref,
'files': {}}
json.dump(checksum_data, f)
except (tarfile.TarError, OSError) as e:
raise SourceError("{}: Error staging source: {}".format(self, e)) from e
def setup():
return CrateSource
# If Cargo.lock file is not provided, generate it:
# cargo generate-lockfile
# Then run this script into the source directory. It will generate
# file "sources.yml", to insert into .bst element.
import pytoml
import json
import os, sys
with open('Cargo.lock', 'r') as f:
lock = pytoml.load(f)
with open('sources.yml', 'wb') as sources:
for package in lock['package']:
if 'source' not in package:
name = package['name']
version = package['version']
lines = ['- kind: crate',
' url:{name}/{name}-{version}.crate'.format(name = name, version = version)]
sources.write(('\n'.join(lines) + '\n').encode('ascii'))
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment