Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 21 additions & 0 deletions xbstrap/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,14 +10,17 @@
import shutil
import stat
import subprocess
import sys
import tarfile
import tempfile
import urllib.request
import zipfile
from distutils.version import StrictVersion
from enum import Enum

import colorama
import jsonschema
import pkg_resources
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

due to this, we now depend on setuptools. consider instead extracting the version into a file that setup.py reads/imports

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What's the problem with depending on setuptools?

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

that we don't declare it... plus, decently sure this won't work when doing a distro install. there's simply no need

import yaml

import xbstrap.util as _util
Expand Down Expand Up @@ -218,6 +221,13 @@ def __init__(self, path, changed_source_root=None):

self._parse_yml(root_path, self._root_yml)

if self.installed_version < self.min_version:
_util.log_err(
f"Installed xbstrap version {self.installed_version} does not satisfy "
f"the minimum required version {self.min_version}"
)
sys.exit(1)

# Collect all architectures that this build uses.
for tool in self._tool_pkgs.values():
arch = tool.architecture
Expand Down Expand Up @@ -316,6 +326,17 @@ def _parse_yml(
continue
self._tasks[task.name] = task

@property
def min_version(self):
default = "0.0"
if "general" not in self._root_yml:
return StrictVersion(default)
return StrictVersion(self._root_yml["general"].get("min_version", default))

@property
def installed_version(self):
return StrictVersion(pkg_resources.get_distribution("xbstrap").version)

@property
def patch_author(self):
default = "xbstrap"
Expand Down
2 changes: 2 additions & 0 deletions xbstrap/schema.yml
Original file line number Diff line number Diff line change
Expand Up @@ -156,6 +156,8 @@ properties:
type: object
additionalProperties: false
properties:
'min_version':
type: string
'patch_author':
type: string
'patch_email':
Expand Down