mirror of
https://git.planet-casio.com/Lephenixnoir/GiteaPC.git
synced 2024-12-28 04:23:40 +01:00
* Reject invalid configs * Overwrite even if giteapc-config.make is broken * Allow ':' as a specification to remove the current config Fixes: #3, #4
This commit is contained in:
parent
3881b12ba4
commit
5f2757e11b
2 changed files with 15 additions and 4 deletions
|
@ -105,7 +105,7 @@ def pretty_repo(r):
|
||||||
|
|
||||||
class Spec:
|
class Spec:
|
||||||
# A spec in REPOSITORY[@VERSION][:CONFIGURATION]
|
# A spec in REPOSITORY[@VERSION][:CONFIGURATION]
|
||||||
RE_SPEC = re.compile(r'^([^@:]+)(?:@([^@:]+))?(?:[:]([^@:]+))?')
|
RE_SPEC = re.compile(r'^([^@:]+)(?:@([^@:]+))?(?:([:])([^@:]*))?')
|
||||||
|
|
||||||
def __init__(self, string):
|
def __init__(self, string):
|
||||||
m = re.match(Spec.RE_SPEC, string)
|
m = re.match(Spec.RE_SPEC, string)
|
||||||
|
@ -114,7 +114,7 @@ class Spec:
|
||||||
|
|
||||||
self.name = m[1]
|
self.name = m[1]
|
||||||
self.version = m[2]
|
self.version = m[2]
|
||||||
self.config = m[3]
|
self.config = m[4] or (m[3] and "")
|
||||||
self.repo = None
|
self.repo = None
|
||||||
|
|
||||||
def resolve(self, local_only=False, remote_only=False):
|
def resolve(self, local_only=False, remote_only=False):
|
||||||
|
@ -286,7 +286,7 @@ def build(*args, install=False, skip_configure=False):
|
||||||
raise Error(f"{r.fullname} has no giteapc.make")
|
raise Error(f"{r.fullname} has no giteapc.make")
|
||||||
|
|
||||||
env = os.environ.copy()
|
env = os.environ.copy()
|
||||||
if s.config:
|
if s.config is not None:
|
||||||
env["GITEAPC_CONFIG"] = s.config
|
env["GITEAPC_CONFIG"] = s.config
|
||||||
r.set_config(s.config)
|
r.set_config(s.config)
|
||||||
env["GITEAPC_PREFIX"] = PREFIX_FOLDER
|
env["GITEAPC_PREFIX"] = PREFIX_FOLDER
|
||||||
|
|
|
@ -165,8 +165,19 @@ class LocalRepo:
|
||||||
source = self.folder + f"/giteapc-config.make"
|
source = self.folder + f"/giteapc-config.make"
|
||||||
target = self.folder + f"/giteapc-config-{config}.make"
|
target = self.folder + f"/giteapc-config-{config}.make"
|
||||||
|
|
||||||
if os.path.exists(source):
|
if config == "":
|
||||||
|
if os.path.islink(source):
|
||||||
|
os.remove(source)
|
||||||
|
return
|
||||||
|
|
||||||
|
if not os.path.exists(target):
|
||||||
|
raise Error(f"config '{config}' does not exist")
|
||||||
|
|
||||||
|
if os.path.islink(source):
|
||||||
os.remove(source)
|
os.remove(source)
|
||||||
|
elif os.path.exists(source):
|
||||||
|
raise Error("giteapc-config.make is not a link, was it altered?")
|
||||||
|
|
||||||
os.symlink(target, source)
|
os.symlink(target, source)
|
||||||
|
|
||||||
# Metadata
|
# Metadata
|
||||||
|
|
Loading…
Reference in a new issue