Autodetect Current Revision of Alpine Version (#113)
* continue to use provided 'release' value if specified * continue to use 'edge' for edge versions * deduce 'release' value from the version on the alpine-base APK in https://dl-cdn.alpinelinux.org/alpine/v<version/main/<arch>/ * update test profile with 3.13
This commit is contained in:
parent
30550530fe
commit
88f3f1374e
|
@ -8,7 +8,7 @@ revision = "r0"
|
||||||
|
|
||||||
# Versioning
|
# Versioning
|
||||||
version = null
|
version = null
|
||||||
release = null
|
release = null # defaults to autodetect
|
||||||
end_of_life = null
|
end_of_life = null
|
||||||
|
|
||||||
# Architecture
|
# Architecture
|
||||||
|
|
|
@ -8,7 +8,7 @@ revision = "r0"
|
||||||
|
|
||||||
# Versioning
|
# Versioning
|
||||||
version = null
|
version = null
|
||||||
release = null
|
release = null # defaults to autodetect
|
||||||
end_of_life = null
|
end_of_life = null
|
||||||
|
|
||||||
# Architecture
|
# Architecture
|
||||||
|
|
|
@ -1,6 +1,7 @@
|
||||||
### Profile for Testing Builds
|
### Profile for Testing Builds
|
||||||
# vim: ts=2 et:
|
# vim: ts=2 et:
|
||||||
|
|
||||||
|
version-3_13 { include required("version/3.13") }
|
||||||
version-3_12 { include required("version/3.12") }
|
version-3_12 { include required("version/3.12") }
|
||||||
version-3_11 { include required("version/3.11") }
|
version-3_11 { include required("version/3.11") }
|
||||||
version-3_10 { include required("version/3.10") }
|
version-3_10 { include required("version/3.10") }
|
||||||
|
@ -25,11 +26,13 @@ test {
|
||||||
# Build definitions
|
# Build definitions
|
||||||
BUILDS {
|
BUILDS {
|
||||||
# merge version, arch, profile, and build vars
|
# merge version, arch, profile, and build vars
|
||||||
|
v3_13-x86_64 = ${version-3_13} ${arch-x86_64} ${test}
|
||||||
v3_12-x86_64 = ${version-3_12} ${arch-x86_64} ${test}
|
v3_12-x86_64 = ${version-3_12} ${arch-x86_64} ${test}
|
||||||
v3_11-x86_64 = ${version-3_11} ${arch-x86_64} ${test} { revision = "r1" }
|
v3_11-x86_64 = ${version-3_11} ${arch-x86_64} ${test} { revision = "r1" }
|
||||||
v3_10-x86_64 = ${version-3_10} ${arch-x86_64} ${test} { revision = "r2" }
|
v3_10-x86_64 = ${version-3_10} ${arch-x86_64} ${test} { revision = "r2" }
|
||||||
edge-x86_64 = ${version-edge} ${arch-x86_64} ${test}
|
edge-x86_64 = ${version-edge} ${arch-x86_64} ${test}
|
||||||
|
|
||||||
|
v3_13-aarch64 = ${version-3_13} ${arch-aarch64} ${test}
|
||||||
v3_12-aarch64 = ${version-3_12} ${arch-aarch64} ${test}
|
v3_12-aarch64 = ${version-3_12} ${arch-aarch64} ${test}
|
||||||
edge-aarch64 = ${version-edge} ${arch-aarch64} ${test}
|
edge-aarch64 = ${version-edge} ${arch-aarch64} ${test}
|
||||||
}
|
}
|
||||||
|
|
|
@ -6,7 +6,6 @@ include required("../base/1")
|
||||||
|
|
||||||
# set version-specific vars
|
# set version-specific vars
|
||||||
version = "3.10"
|
version = "3.10"
|
||||||
release = "3.10.5"
|
|
||||||
end_of_life = "2021-05-01"
|
end_of_life = "2021-05-01"
|
||||||
repos {
|
repos {
|
||||||
"http://dl-cdn.alpinelinux.org/alpine/v3.10/main" = true
|
"http://dl-cdn.alpinelinux.org/alpine/v3.10/main" = true
|
||||||
|
|
|
@ -6,7 +6,6 @@ include required("../base/1")
|
||||||
|
|
||||||
# set version-specific vars
|
# set version-specific vars
|
||||||
version = "3.11"
|
version = "3.11"
|
||||||
release = "3.11.7"
|
|
||||||
end_of_life = "2021-11-01"
|
end_of_life = "2021-11-01"
|
||||||
repos {
|
repos {
|
||||||
"http://dl-cdn.alpinelinux.org/alpine/v3.11/main" = true
|
"http://dl-cdn.alpinelinux.org/alpine/v3.11/main" = true
|
||||||
|
|
|
@ -6,7 +6,6 @@ include required("../base/1")
|
||||||
|
|
||||||
# set version-specific vars
|
# set version-specific vars
|
||||||
version = "3.12"
|
version = "3.12"
|
||||||
release = "3.12.3"
|
|
||||||
end_of_life = "2022-05-01"
|
end_of_life = "2022-05-01"
|
||||||
repos {
|
repos {
|
||||||
"http://dl-cdn.alpinelinux.org/alpine/v3.12/main" = true
|
"http://dl-cdn.alpinelinux.org/alpine/v3.12/main" = true
|
||||||
|
|
|
@ -6,7 +6,6 @@ include required("../base/current")
|
||||||
|
|
||||||
# add edge-specific tweaks...
|
# add edge-specific tweaks...
|
||||||
version = "3.13"
|
version = "3.13"
|
||||||
release = "3.13.1"
|
|
||||||
end_of_life = "2022-11-01"
|
end_of_life = "2022-11-01"
|
||||||
|
|
||||||
repos {
|
repos {
|
||||||
|
|
|
@ -6,7 +6,6 @@ include required("../base/1")
|
||||||
|
|
||||||
# set version-specific vars
|
# set version-specific vars
|
||||||
version = "3.9"
|
version = "3.9"
|
||||||
release = "3.9.6"
|
|
||||||
end_of_life = "2021-01-01"
|
end_of_life = "2021-01-01"
|
||||||
repos {
|
repos {
|
||||||
"http://dl-cdn.alpinelinux.org/alpine/v3.9/main" = true
|
"http://dl-cdn.alpinelinux.org/alpine/v3.9/main" = true
|
||||||
|
|
|
@ -6,7 +6,6 @@ include required("../base/current")
|
||||||
|
|
||||||
# add edge-specific tweaks...
|
# add edge-specific tweaks...
|
||||||
version = "edge"
|
version = "edge"
|
||||||
release = "edge"
|
|
||||||
end_of_life = null # defaults to tomorrow
|
end_of_life = null # defaults to tomorrow
|
||||||
revision = null # defaults to datetime
|
revision = null # defaults to datetime
|
||||||
|
|
||||||
|
|
|
@ -404,12 +404,38 @@ class ConfigBuilder:
|
||||||
def force_iso_date(input):
|
def force_iso_date(input):
|
||||||
return datetime.fromisoformat(input).isoformat(timespec="seconds")
|
return datetime.fromisoformat(input).isoformat(timespec="seconds")
|
||||||
|
|
||||||
|
@classmethod
|
||||||
|
def resolve_release(cls, input, cfg):
|
||||||
|
if input:
|
||||||
|
# release is explicitly defined, run with it
|
||||||
|
return input
|
||||||
|
if cfg['version'] == 'edge':
|
||||||
|
return 'edge'
|
||||||
|
# hack to determine release value from version's alpine-base APK
|
||||||
|
pkgs_url = f"https://dl-cdn.alpinelinux.org/alpine/v{cfg['version']}/main/{cfg['arch']}/"
|
||||||
|
try:
|
||||||
|
res = urlopen(pkgs_url)
|
||||||
|
except urllib.error.HTTPError as ex:
|
||||||
|
print(f"Unable to urlopen {pkgs_url} - {ex}", file=sys.stderr)
|
||||||
|
exit(1)
|
||||||
|
|
||||||
|
line = res.readline().decode('utf-8')
|
||||||
|
while line:
|
||||||
|
if line.startswith('<a href="'):
|
||||||
|
pkg = line.split('"')[1]
|
||||||
|
if pkg.startswith('alpine-base-'):
|
||||||
|
# we got it, use package version as the revision value
|
||||||
|
return pkg.split('-')[2]
|
||||||
|
line = res.readline().decode('utf-8')
|
||||||
|
# didn't find it?
|
||||||
|
raise RuntimeError(f"Unable to parse 'alpine-base' APK from {pkgs_url}")
|
||||||
|
|
||||||
@classmethod
|
@classmethod
|
||||||
def resolve_now(cls):
|
def resolve_now(cls):
|
||||||
return cls.now.strftime("%Y%m%d%H%M%S")
|
return cls.now.strftime("%Y%m%d%H%M%S")
|
||||||
|
|
||||||
@classmethod
|
@classmethod
|
||||||
def resolve_revision(cls, input):
|
def resolve_revision(cls, input, cfg):
|
||||||
if input is None or input == "":
|
if input is None or input == "":
|
||||||
return cls.resolve_now()
|
return cls.resolve_now()
|
||||||
return input
|
return input
|
||||||
|
@ -419,33 +445,33 @@ class ConfigBuilder:
|
||||||
return cls.tomorrow.isoformat(timespec="seconds")
|
return cls.tomorrow.isoformat(timespec="seconds")
|
||||||
|
|
||||||
@classmethod
|
@classmethod
|
||||||
def resolve_end_of_life(cls, input):
|
def resolve_end_of_life(cls, input, cfg):
|
||||||
if input is None or input == "":
|
if input is None or input == "":
|
||||||
return cls.resolve_tomorrow()
|
return cls.resolve_tomorrow()
|
||||||
return input
|
return input
|
||||||
|
|
||||||
@classmethod
|
@classmethod
|
||||||
def fold_comma(cls, input):
|
def fold_comma(cls, input, cfg):
|
||||||
return ",".join([cls.unquote(k) for k in input.keys()])
|
return ",".join([cls.unquote(k) for k in input.keys()])
|
||||||
|
|
||||||
@classmethod
|
@classmethod
|
||||||
def fold_space(cls, input):
|
def fold_space(cls, input, cfg):
|
||||||
return " ".join([cls.unquote(k) for k in input.keys()])
|
return " ".join([cls.unquote(k) for k in input.keys()])
|
||||||
|
|
||||||
@classmethod
|
@classmethod
|
||||||
def fold_repos(cls, input):
|
def fold_repos(cls, input, cfg):
|
||||||
return "\n".join(
|
return "\n".join(
|
||||||
f"@{v} {cls.unquote(k)}" if isinstance(v, str) else cls.unquote(k)
|
f"@{v} {cls.unquote(k)}" if isinstance(v, str) else cls.unquote(k)
|
||||||
for k, v in input.items())
|
for k, v in input.items())
|
||||||
|
|
||||||
@staticmethod
|
@staticmethod
|
||||||
def fold_packages(input):
|
def fold_packages(input, cfg):
|
||||||
return " ".join(
|
return " ".join(
|
||||||
f"{k}@{v}" if isinstance(v, str) else k
|
f"{k}@{v}" if isinstance(v, str) else k
|
||||||
for k, v in input.items())
|
for k, v in input.items())
|
||||||
|
|
||||||
@staticmethod
|
@staticmethod
|
||||||
def fold_services(input):
|
def fold_services(input, cfg):
|
||||||
return " ".join(
|
return " ".join(
|
||||||
"{}={}".format(k, ",".join(v.keys()))
|
"{}={}".format(k, ",".join(v.keys()))
|
||||||
for k, v in input.items())
|
for k, v in input.items())
|
||||||
|
@ -461,9 +487,10 @@ class ConfigBuilder:
|
||||||
"repos" : self.fold_repos,
|
"repos" : self.fold_repos,
|
||||||
"pkgs" : self.fold_packages,
|
"pkgs" : self.fold_packages,
|
||||||
"svcs" : self.fold_services,
|
"svcs" : self.fold_services,
|
||||||
|
"release" : self.resolve_release,
|
||||||
"revision" : self.resolve_revision,
|
"revision" : self.resolve_revision,
|
||||||
"end_of_life" : lambda x: \
|
"end_of_life" : lambda x, y: \
|
||||||
self.force_iso_date(self.resolve_end_of_life(x)),
|
self.force_iso_date(self.resolve_end_of_life(x, y)),
|
||||||
}
|
}
|
||||||
|
|
||||||
def build_all(self):
|
def build_all(self):
|
||||||
|
@ -509,7 +536,7 @@ class ConfigBuilder:
|
||||||
for k, v in cfg.items():
|
for k, v in cfg.items():
|
||||||
transform = self._keys_to_transform.get(k)
|
transform = self._keys_to_transform.get(k)
|
||||||
if transform:
|
if transform:
|
||||||
cfg[k] = transform(v)
|
cfg[k] = transform(v, cfg)
|
||||||
|
|
||||||
if isinstance(v, str) and "{var." in v:
|
if isinstance(v, str) and "{var." in v:
|
||||||
cfg[k] = v.format(var=cfg)
|
cfg[k] = v.format(var=cfg)
|
||||||
|
|
|
@ -122,7 +122,7 @@ install_base() {
|
||||||
if [ "$VERSION" != edge ]; then
|
if [ "$VERSION" != edge ]; then
|
||||||
ALPINE_RELEASE=$(cat "$TARGET/etc/alpine-release")
|
ALPINE_RELEASE=$(cat "$TARGET/etc/alpine-release")
|
||||||
[ "$RELEASE" = "$ALPINE_RELEASE" ] || \
|
[ "$RELEASE" = "$ALPINE_RELEASE" ] || \
|
||||||
die "Newer Alpine release detected: $ALPINE_RELEASE"
|
die "Release '$RELEASE' does not match /etc/alpine-release: $ALPINE_RELEASE"
|
||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue