Newer
Older
1001
1002
1003
1004
1005
1006
1007
1008
1009
1010
1011
1012
1013
1014
1015
1016
1017
1018
1019
1020
1021
1022
1023
1024
1025
'lsb-base',
'module-init-tools',
'plymouth',
'tcpd',
]:
if package in installed:
unwanted.append(package)
if 'python' not in installed:
unwanted.append('python-minimal')
unwanted.append('python2.7-minimal')
logger.info('Packages we will forcibly remove (first round):')
for p in sorted(unwanted):
logger.info('- %s', p)
if unwanted:
nspawn.check_call([
'dpkg', '--purge', '--force-remove-essential',
'--force-depends',
] + unwanted)
# Second round of removals.
for package in [
1026
1027
1028
1029
1030
1031
1032
1033
1034
1035
1036
1037
1038
1039
1040
1041
1042
1043
1044
1045
1046
1047
1048
1049
1050
1051
'busybox-initramfs',
'debconf',
'debian-archive-keyring',
'e2fsprogs',
'init',
'init-system-helpers',
'insserv',
'iproute',
'login',
'mount',
'mountall',
'passwd',
'systemd',
'systemd-sysv',
'sysv-rc',
'ubuntu-archive-keyring',
'ubuntu-keyring',
'udev',
'upstart',
]:
if package in installed:
unwanted.append(package)
if 'perl' not in installed:
unwanted.append('perl-base')
logger.info('Packages we will forcibly remove (second round):')
for p in sorted(unwanted):
logger.info('- %s', p)
if unwanted:
nspawn.check_call([
'dpkg', '--purge', '--force-remove-essential',
'--force-depends',
] + unwanted)
installed = nspawn.list_packages_ignore_arch()
script = self.runtime_details.get('post_script', '')
if script:
logger.info('Running custom script...')
nspawn.check_call([
'sh', '-c', script,
])
logger.info('... done')
script = platform_details.get('post_script', '')
if script:
logger.info('Running custom platform script...')
nspawn.check_call([
'sh', '-c', script,
])
logger.info('... done')
logger.info('Listing packages in platform...')
for package in nspawn.write_manifest():
logger.info(
'- %s from %s_%s',
package.binary, package.source, package.source_version)
self.sources_required.add((package.source, package.source_version))
1091
1092
1093
1094
1095
1096
1097
1098
1099
1100
1101
1102
1103
1104
1105
1106
1107
1108
1109
1110
1111
1112
1113
1114
1115
1116
1117
1118
1119
1120
1121
# This has to be last for obvious reasons!
nspawn.check_call([
'dpkg', '--purge', '--force-remove-essential',
'--force-depends',
'dpkg',
])
return installed
def ostreeify(self, prefix, chroot, sdk=False, packages=()):
"""
Move things around to turn a chroot into a runtime.
"""
if sdk:
installed = self.sdkize(chroot)
else:
installed = self.platformize(chroot)
with NspawnWorker(
self.root_worker,
chroot,
) as nspawn:
nspawn.check_call([
'find', '/', '-xdev', '(',
'-lname', '/etc/alternatives/*', '-o',
'-lname', '/etc/locale.alias',
')', '-exec', 'sh', '-euc',
'set -e\n'
'while [ $# -gt 0 ]; do\n'
' old="$(readlink "$1")"\n'
' echo "Making $1 a hard link to $target (was $old)"\n'
' rm -f "$1"\n'
' cp -al "$target" "$1"\n'
' fi\n'
' shift\n'
'done'
'',
'sh', # argv[0] for the one-line shell script
'{}', '+',
])
self.root_worker.check_call([
'chmod', '-R', '--changes', 'a-s,o-t,u=rwX,og=rX', chroot,
])
self.root_worker.check_call([
'chown', '-R', '--changes', 'root:root', chroot,
])
self.root_worker.check_call([
'rm', '-fr', '--one-file-system',
'{}/usr/local'.format(chroot),
])
# Merge /usr the hard way, if necessary.
if not self.suite_details.get('can_merge_usr', False):
self.usrmerge(chroot)
1150
1151
1152
1153
1154
1155
1156
1157
1158
1159
1160
1161
1162
1163
1164
1165
1166
1167
1168
1169
1170
1171
1172
1173
1174
1175
1176
1177
1178
1179
1180
1181
1182
1183
1184
1185
1186
1187
1188
1189
1190
1191
1192
1193
1194
1195
1196
1197
1198
1199
1200
1201
1202
1203
1204
1205
1206
1207
1208
1209
1210
1211
1212
1213
1214
1215
1216
1217
1218
1219
1220
1221
1222
1223
1224
1225
1226
1227
1228
1229
1230
1231
1232
1233
1234
1235
1236
1237
1238
self.root_worker.check_call([
'rm', '-fr', '--one-file-system',
'{}/etc/apparmor'.format(chroot),
'{}/etc/apparmor.d'.format(chroot),
'{}/etc/console-setup'.format(chroot),
'{}/etc/cron.daily'.format(chroot),
'{}/etc/cron.hourly'.format(chroot),
'{}/etc/cron.monthly'.format(chroot),
'{}/etc/cron.weekly'.format(chroot),
'{}/etc/dbus-1/system.d'.format(chroot),
'{}/etc/depmod.d'.format(chroot),
'{}/etc/dhcp'.format(chroot),
'{}/etc/emacs'.format(chroot),
'{}/etc/fstab'.format(chroot),
'{}/etc/fstab.d'.format(chroot),
'{}/etc/group-'.format(chroot),
'{}/etc/gshadow-'.format(chroot),
'{}/etc/hostname'.format(chroot),
'{}/etc/hosts'.format(chroot),
'{}/etc/hosts.allow'.format(chroot),
'{}/etc/hosts.deny'.format(chroot),
'{}/etc/init'.format(chroot),
'{}/etc/init.d'.format(chroot),
'{}/etc/initramfs-tools'.format(chroot),
'{}/etc/insserv'.format(chroot),
'{}/etc/insserv.conf'.format(chroot),
'{}/etc/insserv.conf.d'.format(chroot),
'{}/etc/iproute2'.format(chroot),
'{}/etc/issue'.format(chroot),
'{}/etc/issue.net'.format(chroot),
'{}/etc/kbd'.format(chroot),
'{}/etc/kernel'.format(chroot),
'{}/etc/localtime'.format(chroot),
'{}/etc/logcheck'.format(chroot),
'{}/etc/login.defs'.format(chroot),
'{}/etc/logrotate.d'.format(chroot),
'{}/etc/lsb-base'.format(chroot),
'{}/etc/lsb-base-logging.sh'.format(chroot),
'{}/etc/machine-id'.format(chroot),
'{}/etc/mailname'.format(chroot),
'{}/etc/modprobe.d'.format(chroot),
'{}/etc/modules'.format(chroot),
'{}/etc/network'.format(chroot),
'{}/etc/networks'.format(chroot),
'{}/etc/nologin'.format(chroot),
'{}/etc/opt'.format(chroot),
'{}/etc/pam.conf'.format(chroot),
'{}/etc/pam.d'.format(chroot),
'{}/etc/passwd-'.format(chroot),
'{}/etc/ppp'.format(chroot),
'{}/etc/rc.local'.format(chroot),
'{}/etc/rc0.d'.format(chroot),
'{}/etc/rc1.d'.format(chroot),
'{}/etc/rc2.d'.format(chroot),
'{}/etc/rc3.d'.format(chroot),
'{}/etc/rc4.d'.format(chroot),
'{}/etc/rc5.d'.format(chroot),
'{}/etc/rc6.d'.format(chroot),
'{}/etc/resolv.conf'.format(chroot),
'{}/etc/resolvconf'.format(chroot),
'{}/etc/rmt'.format(chroot),
'{}/etc/rpc'.format(chroot),
'{}/etc/rsyslog.conf'.format(chroot),
'{}/etc/rsyslog.d'.format(chroot),
'{}/etc/securetty'.format(chroot),
'{}/etc/security'.format(chroot),
'{}/etc/shadow-'.format(chroot),
'{}/etc/shells'.format(chroot),
'{}/etc/subgid-'.format(chroot),
'{}/etc/subuid-'.format(chroot),
'{}/etc/sudoers'.format(chroot),
'{}/etc/sudoers.d'.format(chroot),
'{}/etc/sysctl.conf'.format(chroot),
'{}/etc/sysctl.d'.format(chroot),
'{}/etc/systemd'.format(chroot),
'{}/etc/timezone'.format(chroot),
'{}/etc/udev'.format(chroot),
'{}/etc/update-motd.d'.format(chroot),
'{}/var/backups'.format(chroot),
'{}/var/cache'.format(chroot),
'{}/var/lib/dpkg/status-old'.format(chroot),
'{}/var/lib/dpkg/statoverride'.format(chroot),
])
self.root_worker.check_call([
'mv', '{}/etc'.format(chroot),
'{}/usr/etc'.format(chroot),
])
if sdk:
runtime = prefix + '.Sdk'
self.root_worker.check_call([
'install', '-d',
'{}/var/cache/apt/archives/partial'.format(chroot),
'{}/var/lib/extrausers'.format(chroot),
])
self.root_worker.check_call([
'touch', '{}/var/cache/apt/archives/partial/.exists'.format(chroot),
])
# This is only useful if the SDK has libnss-extrausers
self.root_worker.check_call([
'cp', '{}/usr/etc/passwd'.format(chroot),
'{}/var/lib/extrausers/passwd'.format(chroot),
])
self.root_worker.check_call([
'cp', '{}/usr/etc/group'.format(chroot),
'{}/var/lib/extrausers/groups'.format(chroot),
])
self.root_worker.check_call([
'mv', '{}/var'.format(chroot),
'{}/usr/var'.format(chroot),
])
else:
runtime = prefix + '.Platform'
self.root_worker.check_call([
'rm', '-fr', '--one-file-system',
1269
1270
1271
1272
1273
1274
1275
1276
1277
1278
1279
1280
1281
1282
1283
1284
1285
1286
1287
1288
1289
1290
'{}/etc/adduser.conf'.format(chroot),
'{}/etc/apt'.format(chroot),
'{}/etc/bash_completion.d'.format(chroot),
'{}/etc/dpkg'.format(chroot),
'{}/etc/debconf.conf'.format(chroot),
'{}/etc/default'.format(chroot),
'{}/etc/deluser.conf'.format(chroot),
'{}/etc/gdb'.format(chroot),
'{}/etc/gpasswd'.format(chroot),
'{}/etc/groff'.format(chroot),
'{}/etc/group'.format(chroot),
'{}/etc/mailcap'.format(chroot),
'{}/etc/mailcap.order'.format(chroot),
'{}/etc/manpath.config'.format(chroot),
'{}/etc/mke2fs.conf'.format(chroot),
'{}/etc/newt'.format(chroot),
'{}/etc/passwd'.format(chroot),
'{}/etc/shadow'.format(chroot),
'{}/etc/skel'.format(chroot),
'{}/etc/subgid'.format(chroot),
'{}/etc/subuid'.format(chroot),
'{}/etc/ucf.conf'.format(chroot),
'{}/share/bash-completion'.format(chroot),
'{}/share/bug'.format(chroot),
'{}/var'.format(chroot),
])
# TODO: Move lib/debug, zoneinfo, locales into extensions
# TODO: Hook point for GL, instead of just Mesa
# TODO: GStreamer extension
# TODO: Icon theme, Gtk theme extension
# TODO: VAAPI extension
# TODO: SDK extension
# TODO: ca-certificates extension to get newer certs?
self.root_worker.check_call([
'install', '-d', '{}/ostree/main'.format(chroot),
])
self.root_worker.check_call([
'mv', '{}/usr'.format(chroot),
'{}/ostree/main/files'.format(chroot),
])
ref = 'runtime/{}/{}/{}'.format(
runtime, self.flatpak_arch, self.runtime_branch,
with TemporaryDirectory(prefix='flatdeb-ostreeify.') as t:
metadata = os.path.join(t, 'metadata')
keyfile = GLib.KeyFile()
keyfile.set_string('Runtime', 'name', runtime)
keyfile.set_string(
'Runtime', 'runtime',
'{}.Platform/{}/{}'.format(
)
)
keyfile.set_string(
'Runtime', 'sdk',
'{}.Sdk/{}/{}'.format(
)
)
keyfile.set_string(
'Environment', 'XDG_DATA_DIRS',
':'.join([
'/app/share', '/usr/share', '/usr/share/runtime/share',
]),
)
search_path = []
for arch in self.dpkg_archs:
search_path.append('/app/lib/{}'.format(self.multiarch_tuple(arch)))
search_path.append('/app/lib')
keyfile.set_string(
'Environment', 'LD_LIBRARY_PATH', ':'.join(search_path),
)
1357
1358
1359
1360
1361
1362
1363
1364
1365
1366
1367
1368
1369
1370
1371
1372
1373
1374
1375
1376
1377
1378
1379
search_path = []
for arch in self.dpkg_archs:
search_path.append(
'/app/lib/{}/gstreamer-1.0'.format(
self.multiarch_tuple(arch)))
search_path.append('/app/lib/gstreamer-1.0')
for arch in self.dpkg_archs:
search_path.append(
'/usr/lib/extensions/{}/gstreamer-1.0'.format(
self.multiarch_tuple(arch)))
search_path.append('/usr/lib/extensions/gstreamer-1.0')
for arch in self.dpkg_archs:
search_path.append(
'/usr/lib/{}/gstreamer-1.0'.format(
self.multiarch_tuple(arch)))
search_path.append('/usr/lib/gstreamer-1.0')
keyfile.set_string(
'Environment', 'GST_PLUGIN_SYSTEM_PATH',
':'.join(search_path),
search_path = []
for arch in self.dpkg_archs:
search_path.append(
'/app/lib/{}/girepository-1.0'.format(
self.multiarch_tuple(arch)))
search_path.append('/app/lib/girepository-1.0')
keyfile.set_string(
'Environment', 'GI_TYPELIB_PATH',
':'.join(search_path),
keyfile.set_string(
'Runtime', 'x-flatdeb-version', VERSION,
)
for ext, detail in self.runtime_details.get(
'add-extensions', {}
).items():
group = 'Extension {}'.format(ext)
self.root_worker.check_call([
'install', '-d',
'{}/ostree/main/files/{}'.format(chroot, detail['directory']),
])
for k, v in detail.items():
if isinstance(v, str):
keyfile.set_string(group, k, v)
elif isinstance(v, bool):
keyfile.set_boolean(group, k, v)
else:
raise RuntimeError(
'Unknown type {} in {}'.format(v, ext))
keyfile.save_to_file(metadata)
self.root_worker.install_file(
metadata,
'{}/ostree/main/metadata'.format(chroot),
)
self.worker.check_call([
'time',
'ostree',
'--repo=' + self.remote_repo,
'commit',
'--branch=' + ref,
'--subject=Update',
'--tree=dir={}/ostree/main'.format(chroot),
1441
1442
1443
1444
1445
1446
1447
1448
1449
1450
1451
1452
1453
1454
1455
1456
1457
1458
1459
1460
1461
1462
1463
1464
1465
1466
1467
1468
1469
1470
1471
1472
1473
1474
1475
1476
1477
1478
1479
1480
1481
1482
1483
1484
1485
1486
1487
1488
1489
1490
1491
if os.path.exists('{}/ostree/source'.format(chroot)):
source_ref = 'runtime/{}/{}/{}'.format(
runtime + '.Sources',
self.flatpak_arch,
self.runtime_branch,
)
with TemporaryDirectory(prefix='flatdeb-ostreeify.') as t:
metadata = os.path.join(t, 'metadata')
keyfile = GLib.KeyFile()
keyfile.set_string('Runtime', 'name', runtime + '.Sources')
keyfile.set_string(
'Runtime', 'runtime',
'{}.Platform/{}/{}'.format(
prefix,
self.flatpak_arch,
self.runtime_branch,
)
)
keyfile.set_string(
'Runtime', 'sdk',
'{}.Sdk/{}/{}'.format(
prefix,
self.flatpak_arch,
self.runtime_branch,
)
)
keyfile.set_string(
'Runtime', 'x-flatdeb-version', VERSION,
)
keyfile.save_to_file(metadata)
self.root_worker.install_file(
metadata,
'{}/ostree/source/metadata'.format(chroot),
)
self.worker.check_call([
'time',
'ostree',
'--repo=' + self.remote_repo,
'commit',
'--branch=' + source_ref,
'--subject=Update',
'--tree=dir={}/ostree/source'.format(chroot),
'--fsync=false',
])
# Don't keep the history in this working repository:
# if history is desired, mirror the commits into a public
# repository and maintain history there.
self.worker.check_call([
'time',
'ostree',
'--repo=' + self.remote_repo,
'prune',
'--refs-only',
'--depth=1',
])
if not isinstance(self.worker, HostWorker):
self.worker.check_call([
'time',
'flatpak',
'build-update-repo',
self.remote_repo,
])
with self.worker.remote_dir_context(self.remote_repo) as mount:
'ostree',
'--repo={}'.format(self.repo),
'remote',
'delete',
'flatdeb-worker',
])
print('^ It is OK if that failed with "remote not found"')
'ostree',
'--repo={}'.format(self.repo),
'remote',
'add',
'--no-gpg-verify',
'flatdeb-worker',
'file://' + urllib.parse.quote(mount),
])
'ostree',
'--repo={}'.format(self.repo),
'pull',
'--disable-fsync',
'--mirror',
'--untrusted',
'flatdeb-worker',
'runtime/{}/{}/{}'.format(
runtime,
self.flatpak_arch,
self.runtime_branch,
),
])
'ostree',
'--repo={}'.format(self.repo),
'remote',
'delete',
'flatdeb-worker',
])
self.host_worker.check_call([
'time',
'flatpak',
'build-update-repo',
self.repo,
])
def command_app(self, *, app_branch, yaml_manifest, **kwargs):
with open(yaml_manifest) as reader:
if self.runtime_branch is None:
self.runtime_branch = manifest.get('runtime-version')
if self.runtime_branch is None:
self.runtime_branch = self.apt_suite
self.app_branch = app_branch
if self.app_branch is None:
self.app_branch = manifest.get('branch')
if self.app_branch is None:
self.app_branch = 'master'
manifest['branch'] = self.app_branch
manifest['runtime-version'] = self.runtime_branch
with ExitStack() as stack:
stack.enter_context(self.worker)
self.ensure_build_area()
self.ensure_remote_repo()
t = stack.enter_context(
TemporaryDirectory(prefix='flatpak-app.')
)
'mkdir', '-p', '{}/home'.format(self.remote_build_area),
if isinstance(self.worker, SshWorker):
# ostree over sshfs is painfully slow so do something different
self.host_worker.call([
'time',
'rsync',
'-aW',
'--no-i-r',
'--info=progress2',
'{}/'.format(self.repo),
'{}:{}/'.format(self.worker.remote, self.remote_repo),
])
elif not isinstance(self.worker, HostWorker):
with self.worker.remote_dir_context(self.remote_repo) as mount:
'ostree',
'--repo={}'.format(mount),
'remote',
'delete',
'flatdeb-host',
])
print('^ It is OK if that failed with "remote not found"')
'ostree',
'--repo={}'.format(mount),
'remote',
'add',
'--no-gpg-verify',
'flatdeb-host',
'file://' + urllib.parse.quote(self.repo),
])
'ostree',
'--repo={}'.format(mount),
'pull',
'--disable-fsync',
'--mirror',
'flatdeb-host',
'runtime/{}/{}/{}'.format(
manifest['sdk'],
self.flatpak_arch,
self.runtime_branch,
'ostree',
'--repo={}'.format(mount),
'pull',
'--disable-fsync',
'--mirror',
'flatdeb-host',
'runtime/{}/{}/{}'.format(
manifest['runtime'],
self.flatpak_arch,
self.runtime_branch,
'ostree',
'--repo={}'.format(mount),
'remote',
'delete',
'flatdeb-host',
])
self.worker.check_call([
'time',
'flatpak',
'build-update-repo',
self.remote_repo,
])
'env',
'XDG_DATA_HOME={}/home'.format(self.remote_build_area),
'flatpak', '--user',
'remote-add', '--if-not-exists', '--no-gpg-verify',
'file://{}'.format(urllib.parse.quote(self.remote_repo)),
'XDG_DATA_HOME={}/home'.format(self.remote_build_area),
'remote-modify', '--no-gpg-verify',
'--url=file://{}'.format(urllib.parse.quote(self.remote_repo)),
'flatdeb',
1680
1681
1682
1683
1684
1685
1686
1687
1688
1689
1690
1691
1692
1693
1694
1695
1696
1697
1698
1699
1700
1701
1702
1703
for runtime in (manifest['sdk'], manifest['runtime']):
if self.worker.call([
'env',
'XDG_DATA_HOME={}/home'.format(self.remote_build_area),
'flatpak', '--user',
'install', 'flatdeb',
'{}/{}/{}'.format(
runtime,
self.flatpak_arch,
self.runtime_branch,
),
]) != 0:
self.worker.check_call([
'env',
'XDG_DATA_HOME={}/home'.format(self.remote_build_area),
'flatpak', '--user',
'update',
'{}/{}/{}'.format(
runtime,
self.flatpak_arch,
self.runtime_branch,
),
])
for module in manifest.get('modules', []):
if isinstance(module, dict):
sources = module.setdefault('sources', [])
for source in sources:
if 'path' in source:
if source.get('type') == 'git':
clone = self.worker.check_output([
'mktemp', '-d',
'-p', self.worker.scratch,
'flatdeb-git.XXXXXX',
'tar',
'-cf-',
'-C', source['path'],
'.',
], stdout=subprocess.PIPE)
self.worker.check_call([
'tar',
'-xf-',
'-C', clone,
], stdin=uploader.stdout)
uploader.wait()
source['path'] = clone
else:
d = self.worker.check_output([
'mktemp', '-d',
'-p', self.worker.scratch,
'flatdeb-path.XXXXXX',
1735
1736
1737
1738
1739
1740
1741
1742
1743
1744
1745
1746
1747
1748
1749
1750
1751
1752
1753
1754
1755
1756
]).decode('utf-8').rstrip('\n')
clone = '{}/{}'.format(
d, os.path.basename(source['path']),
)
permissions = 0o644
if GLib.file_test(
source['path'],
GLib.FileTest.IS_EXECUTABLE,
):
permissions = 0o755
self.worker.install_file(
source['path'],
clone,
permissions,
)
source['path'] = clone
if 'x-flatdeb-apt-packages' in module:
packages = self.worker.check_output([
'mktemp', '-d',
'-p', self.worker.scratch,
'flatdeb-debs.XXXXXX',
]).decode('utf-8').rstrip('\n')
self.worker.check_call([
'env',
'XDG_DATA_HOME={}/home'.format(self.remote_build_area),
'flatpak', 'run',
'--filesystem={}'.format(packages),
'--share=network',
'--command=/usr/bin/env',
'{}/{}/{}'.format(
manifest['sdk'],
self.flatpak_arch,
'http_proxy=http://192.168.122.1:3142',
'export={}'.format(packages),
'sh',
'-euc',
'cp -a /usr/var /\n'
'install -d /var/cache/apt/archives/partial\n'
'fakeroot apt-get update\n'
'fakeroot apt-get -y --download-only \\\n'
' --no-install-recommends install "$@"\n'
'for x in /var/cache/apt/archives/*.deb; do\n'
' package="$(dpkg-deb -f "$x" Package)"\n'
' source="$(dpkg-deb -f "$x" Source)"\n'
' version="$(dpkg-deb -f "$x" Version)"\n'
' if [ -z "$source" ]; then\n'
' source="$package"\n'
' fi\n'
' if [ "${source% (*}" != "$source" ]; then\n'
' version="${source#* (}"\n'
' version="${version%)}"\n'
' source="${source% (*}"\n'
' fi\n'
' ( cd "$export" && \\\n'
' apt-get -y --download-only source \\\n'
' "$source=$version"\n'
' )\n'
'done\n'
'mv /var/cache/apt/archives/*.deb "$export"\n'
'mv /var/lib/apt/lists "$export"\n'
'',
'sh', # argv[0]
] + module['x-flatdeb-apt-packages'])
obtained = self.worker.check_output([
'sh', '-euc',
'cd "$1"\n'
'find * -type f -print0 | xargs -0 sha256sum -b\n'
'',
'sh', # argv[0]
packages,
for line in obtained:
sha256, f = line.split(' *', 1)
path = '{}/{}'.format(packages, f)
if f.endswith('.deb'):
sources.append({
'dest': '.',
'type': 'file',
'sha256': sha256,
'url': urllib.parse.urlunsplit((
'file',
'',
urllib.parse.quote(path),
'',
'',
))
remote_manifest = '{}/{}.json'.format(
self.worker.scratch,
manifest['id'],
)
self.worker.check_call([
'mkdir', '-p',
'{}/.flatpak-builder'.format(self.remote_build_area),
])
self.worker.check_call([
'ln', '-nsf',
'{}/.flatpak-builder'.format(self.remote_build_area),
'{}/'.format(self.worker.scratch),
])
with TemporaryDirectory(prefix='flatdeb-manifest.') as t:
json_manifest = os.path.join(t, manifest['id'] + '.json')
with open(
json_manifest, 'w', encoding='utf-8',
) as writer:
json.dump(manifest, writer, indent=2, sort_keys=True)
self.worker.install_file(json_manifest, remote_manifest)
self.worker.check_call([
'env',
'XDG_DATA_HOME={}/home'.format(self.remote_build_area),
'http_proxy=http://192.168.122.1:3142',
'--arch={}'.format(self.flatpak_arch),
'--bundle-sources',
'{}/workdir'.format(self.worker.scratch),
remote_manifest,
])
if not isinstance(self.worker, HostWorker):
self.worker.check_call([
'time',
'flatpak',
'build-update-repo',
self.remote_repo,
])
with self.worker.remote_dir_context(self.remote_repo) as mount:
'ostree',
'--repo={}'.format(self.repo),
'remote',
'delete',
'flatdeb-worker',
])
'ostree',
'--repo={}'.format(self.repo),
'remote',
'add',
'--no-gpg-verify',
'flatdeb-worker',
'file://' + urllib.parse.quote(mount),
])
'ostree',
'--repo={}'.format(self.repo),
'pull',
'--disable-fsync',
'--mirror',
'--untrusted',
'app/{}/{}/{}'.format(
manifest['id'],
self.flatpak_arch,
manifest['branch'],
),
])
'ostree',
'--repo={}'.format(self.repo),
'remote',
'delete',
'flatdeb-worker',
])
self.host_worker.check_call([
'time',
'flatpak',
'build-update-repo',
self.repo,
])
'XDG_DATA_HOME={}/home'.format(self.remote_build_area),
'flatpak',
'build-bundle',
self.remote_repo,
manifest['id'],
manifest['branch'],
])
bundle = '{}-{}-{}.bundle'.format(
manifest['id'],
self.flatpak_arch,
manifest['branch'],
)
output = os.path.join(self.build_area, bundle)
with open(output + '.new', 'wb') as writer:
self.worker.check_call([
'cat',
'{}/bundle'.format(self.worker.scratch),
], stdout=writer)
os.rename(output + '.new', output)
1956
1957
1958
1959
1960
1961
1962
1963
1964
1965
1966
1967
1968
1969
1970
1971
1972
1973
1974
1975
1976
1977
1978
1979
1980
1981
1982
1983
1984
1985
1986
1987
1988
1989
1990
1991
1992
1993
1994
1995
1996
1997
1998
1999
2000
def usrmerge(self, chroot):
self.root_worker.check_call([
'time',
'chroot', chroot,
'sh',
'-euc',
'usrmerge () {\n'
' local f="$1"\n'
'\n'
' ls -dl "$f" "/usr$f" >&2 || true\n'
' if [ "$(readlink "$f")" = "/usr$f" ]; then\n'
' echo "Removing $f in favour of /usr$f" >&2\n'
' rm -v -f "$f"\n'
' elif [ "$(readlink "/usr$f")" = "$f" ]; then\n'
' echo "Removing /usr$f in favour of $f" >&2\n'
' rm -v -f "/usr$f"\n'
' elif [ "$(readlink -f "/usr$f")" = \\\n'
' "$(readlink -f "$f")" ]; then\n'
' echo "/usr$f and $f are functionally identical" >&2\n'
' rm -v -f "$f"\n'
' else\n'
' echo "Cannot merge $f with /usr$f" >&2\n'
' exit 1\n'
' fi\n'
'}\n'
'\n'
'find /bin /sbin /lib* -not -xtype d |\n'
'while read f; do\n'
' if [ -e "/usr$f" ]; then\n'
' usrmerge "$f"\n'
' fi\n'
'done\n'
'',
'sh', # argv[0]
chroot,
])
self.root_worker.check_call([
'time',
'sh', '-euc',
'cd "$1"; tar -cf- bin sbin lib* | tar -C usr -xf-',
'sh', chroot,
])
self.root_worker.check_call([