Skip to content

Commit

Permalink
clean up debian package extractor
Browse files Browse the repository at this point in the history
  • Loading branch information
christian-monch committed Aug 24, 2022
1 parent 3ffdd01 commit 97e0ac8
Show file tree
Hide file tree
Showing 2 changed files with 35 additions and 27 deletions.
1 change: 1 addition & 0 deletions .appveyor.yml
Original file line number Diff line number Diff line change
Expand Up @@ -108,6 +108,7 @@ install:
build_script:
- python -m pip install -r requirements-devel.txt
- python -m pip install .
- python -m pip uninstall dataclasses # TODO: where do dataclasses come from on python3.8? Our packages should not require them!


#after_build:
Expand Down
61 changes: 34 additions & 27 deletions datalad_debian/metadata/extractors/debian_package_dataset.py
Original file line number Diff line number Diff line change
Expand Up @@ -116,12 +116,6 @@ def extract(self, _=None) -> ExtractorResult:

package_name = version_info.name
package_dsc = Dsc(open(d / source_element_names["dsc"], "rt"))
source_info = {
"dsc": str(package_dsc),
"orig": "NOT IMPLEMENTED",
"debian": "NOT IMPLEMENTED"
}

binary_names = {
platform: DebianPackageElementNames(
version_info.name,
Expand Down Expand Up @@ -149,34 +143,47 @@ def extract(self, _=None) -> ExtractorResult:
}
revision_dict = version_dict["debian_revisions"][version_info.debian_revision]

revision_dict["debian"] = f"{source_element_names['debian']}"
revision_dict["maintainer"] = f"{package_dsc['maintainer']}"
revision_dict["homepage"] = f"{package_dsc['homepage']}"
revision_dict["debian"] = source_element_names['debian']
revision_dict["maintainer"] = package_dsc['maintainer']
revision_dict["homepage"] = package_dsc.get('homepage', None)
revision_dict["standards-version"] = package_dsc["standards-version"]

for platform, element_names in binary_names.items():
assert platform not in revision_dict["binaries"]
revision_dict["binaries"][platform] = binary_infos[platform]

return ExtractorResult(
extractor_version=self.get_version(),
extraction_parameter=self.parameter or {},
extraction_success=True,
datalad_result_dict={
"type": "dataset",
"status": "ok",
},
immediate_data={
"name": package_name,
"upstream_version": upstream_versions,
}
)
if package_name is not None:
return ExtractorResult(
extractor_version=self.get_version(),
extraction_parameter=self.parameter or {},
extraction_success=True,
datalad_result_dict={
"type": "dataset",
"status": "ok",
},
immediate_data={
"name": package_name,
"upstream_version": upstream_versions,
}
)
else:
return ExtractorResult(
extractor_version=self.get_version(),
extraction_parameter=self.parameter or {},
extraction_success=False,
datalad_result_dict={
"type": "dataset",
"status": "error",
"message": "no debian package"
}
)

def _get_binary_info(self, path, names):
return {
"deb": f"{names['deb']} {DebFile(path / names['deb'])}",
"dbgsym": f"{names['dbgsym']} {DebFile(path / names['dbgsym'])}",
"build_info": f"{names['buildinfo']} {BuildInfo(open(path / names['buildinfo'], 'rt'))}",
"changes": f"{names['changes']} {Changes(open(path / names['changes'], 'rt'))}",
"deb": f"{names['deb']}: {DebFile(path / names['deb'])}",
"dbgsym": f"{names['dbgsym']}: {DebFile(path / names['dbgsym'])}",
"build_info": f"{names['buildinfo']}: {BuildInfo(open(path / names['buildinfo'], 'rt'))}",
"changes": f"{names['changes']}: {Changes(open(path / names['changes'], 'rt'))}",
}

def _find_versions(self):
Expand All @@ -198,7 +205,7 @@ def _find_versions(self):

version_info = path.name[len(name) + 1:-4]
if "-" in version_info:
upstream_version, debian_revision = version_info.split("-")
upstream_version, debian_revision = version_info.rsplit("-", 1)
else:
upstream_version, debian_revision = version_info, "0"

Expand Down

0 comments on commit 97e0ac8

Please sign in to comment.