...
 
Commits (2)
......@@ -8,6 +8,8 @@
{{- $keyring := or .keyring "" -}}
{{- $keyringpackage := or .keyringpackage "" -}}
{{- $build_id := or .build_id "" -}}
{{- $variant := or .variant "Minimal base system" -}}
{{- $variant_id := or .variant_id "base" -}}
{{- $artifact_prefix := or .artifact_prefix (printf "base-%s-%s" $suite $architecture) -}}
{{- $ospack := or .ospack (printf "%s.tar.gz" $artifact_prefix) -}}
......@@ -115,14 +117,28 @@ actions:
cp "$ROOTDIR/usr/manifest.dpkg" "$ARTIFACTDIR/{{ $artifact_prefix }}.manifest.dpkg"
cp "$ROOTDIR/usr/manifest.dpkg.built-using" "$ARTIFACTDIR/{{ $artifact_prefix }}.manifest.dpkg.built-using"
cp "$ROOTDIR/usr/manifest.deb822.gz" "$ARTIFACTDIR/{{ $artifact_prefix }}.manifest.deb822.gz"
if test -e "$ROOTDIR/etc/os-release" && ! test -e "$ROOTDIR/usr/lib/os-release"; then
rm -f "$ROOTDIR/usr/lib/os-release"
mv "$ROOTDIR/etc/os-release" "$ROOTDIR/usr/lib/os-release"
ln -fns ../usr/lib/os-release "$ROOTDIR/etc/os-release"
fi
if test -e "$ROOTDIR/usr/lib/os-release" && test -n "{{ $build_id }}"; then
sed -n -i -e '/^BUILD_ID=/!p' "$ROOTDIR/usr/lib/os-release"
echo 'BUILD_ID="{{ $build_id }}"' >> "$ROOTDIR/usr/lib/os-release"
if test -e "$ROOTDIR/usr/lib/os-release"; then
sed -i -e '/^BUILD_ID=/d' -e '/^VARIANT=/d' -e '/^VARIANT_ID=/d' "$ROOTDIR/usr/lib/os-release"
if test -n "{{ $build_id }}"; then
echo 'BUILD_ID="{{ $build_id }}"' >> "$ROOTDIR/usr/lib/os-release"
fi
if test -n "{{ $variant }}"; then
echo 'VARIANT="{{ $variant }}"' >> "$ROOTDIR/usr/lib/os-release"
fi
if test -n "{{ $variant_id }}"; then
echo 'VARIANT_ID="{{ $variant_id }}"' >> "$ROOTDIR/usr/lib/os-release"
fi
cp "$ROOTDIR/usr/lib/os-release" "$ARTIFACTDIR/{{ $artifact_prefix }}.os-release.txt"
fi
......
......@@ -10,6 +10,8 @@
{{- $platform_post_script := or .platform_post_script "" -}}
{{- $strip_source_version_suffix := or .strip_source_version_suffix "" -}}
{{- $build_id := or .build_id "" -}}
{{- $variant := or .variant "" -}}
{{- $variant_id := or .variant_id "" -}}
{{- $ospack := or .ospack (printf "base-%s-%s.tar.gz" $suite $architecture) -}}
{{- $runtime := .runtime -}}
{{- $runtime_branch := or .runtime_branch "master" -}}
......@@ -114,9 +116,22 @@ actions:
cp "$ROOTDIR/usr/manifest.dpkg" "$ARTIFACTDIR/{{ $artifact_prefix }}.manifest.dpkg"
cp "$ROOTDIR/usr/manifest.dpkg.built-using" "$ARTIFACTDIR/{{ $artifact_prefix }}.manifest.dpkg.built-using"
cp "$ROOTDIR/usr/manifest.deb822.gz" "$ARTIFACTDIR/{{ $artifact_prefix }}.manifest.deb822.gz"
if test -e "$ROOTDIR/usr/lib/os-release" && test -n "{{ $build_id }}"; then
sed -n -i -e '/^BUILD_ID=/!p' "$ROOTDIR/usr/lib/os-release"
echo 'BUILD_ID="{{ $build_id }}"' >> "$ROOTDIR/usr/lib/os-release"
if test -e "$ROOTDIR/usr/lib/os-release"; then
sed -i -e '/^BUILD_ID=/d' -e '/^VARIANT=/d' -e '/^VARIANT_ID=/d' "$ROOTDIR/usr/lib/os-release"
if test -n "{{ $build_id }}"; then
echo 'BUILD_ID="{{ $build_id }}"' >> "$ROOTDIR/usr/lib/os-release"
fi
if test -n "{{ $variant }}"; then
echo 'VARIANT="{{ $variant }}"' >> "$ROOTDIR/usr/lib/os-release"
fi
if test -n "{{ $variant_id }}"; then
echo 'VARIANT_ID="{{ $variant_id }}"' >> "$ROOTDIR/usr/lib/os-release"
fi
cp "$ROOTDIR/usr/lib/os-release" "$ARTIFACTDIR/{{ $artifact_prefix }}.os-release.txt"
fi
......
......@@ -203,6 +203,10 @@ class Builder:
self.apt_keyrings = []
self.apt_sources = []
self.build_id = None
self.variant_name = None
self.variant_id = None
self.sdk_variant_name = None
self.sdk_variant_id = None
self.logger = logger.getChild('Builder')
......@@ -365,6 +369,14 @@ class Builder:
'--generate-sysroot-tarball', action='store_true')
parser.add_argument(
'--build-id', default=None)
parser.add_argument(
'--variant-name', default=None)
parser.add_argument(
'--variant-id', default=None)
parser.add_argument(
'--sdk-variant-name', default=None)
parser.add_argument(
'--sdk-variant-id', default=None)
subparsers = parser.add_subparsers(dest='command', metavar='command')
subparser = subparsers.add_parser(
......@@ -407,6 +419,8 @@ class Builder:
self.build_area = args.build_area
self.build_id = args.build_id
self.variant_name = args.variant_name
self.variant_id = args.variant_id
self.apt_suite = args.suite
self.runtime_branch = args.runtime_branch
self.ostree_repo = args.ostree_repo
......@@ -594,6 +608,16 @@ class Builder:
argv.append('-t')
argv.append('build_id:{}'.format(self.build_id))
if self.variant_name is not None:
argv.append('-t')
argv.append('variant:{}'.format(self.variant_name))
if self.variant_id is not None:
argv.append('-t')
argv.append('variant_id:{}'.format(
self.escape_variant_id(self.variant_id)
))
for keyring in self.apt_keyrings:
if os.path.exists(os.path.join('suites', keyring)):
keyring = os.path.join('suites', keyring)
......@@ -643,6 +667,21 @@ class Builder:
'--mode={}'.format(self.ostree_mode),
])
def escape_variant_id(self, variant_id):
"""
Return a version of the variant_id that fits in the restricted
character set documented in os-release(5).
"""
buf = bytearray(variant_id.lower(), 'ascii', 'replace')
for i, b in enumerate(buf):
c = chr(b)
if not c.isalnum() and c not in '._-':
buf[i] = ord('_')
return buf.decode('ascii')
def command_runtimes(
self,
*,
......@@ -745,6 +784,29 @@ class Builder:
argv.append('-t')
argv.append('build_id:{}'.format(self.build_id))
if sdk:
variant_name = self.sdk_variant_name
variant_id = self.sdk_variant_id
if variant_name is None and self.variant_name is not None:
variant_name = self.variant_name + ' (SDK)'
else:
variant_name = self.variant_name
variant_id = self.variant_id
if variant_name is None:
variant_name = artifact_prefix
if variant_id is None:
variant_id = artifact_prefix
argv.append('-t')
argv.append('variant:{}'.format(variant_name))
argv.append('-t')
argv.append('variant_id:{}'.format(
self.escape_variant_id(variant_id)
))
if packages:
logger.info('Installing packages:')
packages.sort()
......