aboutsummaryrefslogtreecommitdiffstats
path: root/recipes-installer/anaconda/files/0007-dnfpayload.py-customize-for-OE.patch
blob: e99cb92d8bc392b64df35b1059c4246c57190485 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
From f1e88262ef77bcd9d0ec50180ecd1a9c0f646049 Mon Sep 17 00:00:00 2001
From: Hongxu Jia <hongxu.jia@windriver.com>
Date: Tue, 25 Jun 2019 10:34:14 +0800
Subject: [PATCH] dnfpayload.py: customize for OE

Upstream-Status: Inappropriate [oe specific]

Signed-off-by: Hongxu Jia <hongxu.jia@windriver.com>

Update context for anaconda 32.

the storage and data are not propagated to the payload again, so remove
from setup().

Signed-off-by: Kai Kang <kai.kang@windriver.com>

Rebase for anaconda 34 on 20210727.
* rebase code
* remove debug code
* remove patch for function language_groups() which has been remove from upstream

Signed-off-by: Kai Kang <kai.kang@windriver.com>

Rebase for anaconda 37 on 20230227.

Signed-off-by: Kai Kang <kai.kang@windriver.com>

Rebase for anaconda 38 on 20231107.

Signed-off-by: Kai Kang <kai.kang@windriver.com>


Rebase for anaconda 39 on 20240327.

* funtion is_environment_valid() has been removed in upstream
* create class OEConfigureTask to handle oe specific configuration
* set DNF default source from install disk

Signed-off-by: Kai Kang <kai.kang@windriver.com>

---
 pyanaconda/modules/payloads/payload/dnf/dnf.py     |   6 +-
 .../modules/payloads/payload/dnf/dnf_manager.py    | 181 +++++++++++++++++----
 .../modules/payloads/payload/dnf/initialization.py |   4 +
 .../modules/payloads/payload/dnf/installation.py   |  75 ++++++++-
 .../modules/payloads/payload/dnf/requirements.py   |  21 +++
 .../payloads/payload/dnf/transaction_progress.py   |   9 +-
 pyanaconda/modules/payloads/payload/dnf/utils.py   |  10 --
 .../modules/payloads/payload/dnf/validation.py     |  83 ++++++++++
 pyanaconda/payload/dnf/payload.py                  |   4 +-
 9 files changed, 347 insertions(+), 46 deletions(-)

diff --git a/pyanaconda/modules/payloads/payload/dnf/dnf.py b/pyanaconda/modules/payloads/payload/dnf/dnf.py
index 9f7921de4d..133fb8dfdb 100644
--- a/pyanaconda/modules/payloads/payload/dnf/dnf.py
+++ b/pyanaconda/modules/payloads/payload/dnf/dnf.py
@@ -37,7 +37,7 @@ from pyanaconda.modules.payloads.payload.dnf.initialization import configure_dnf
 from pyanaconda.modules.payloads.payload.dnf.installation import SetRPMMacrosTask, \
     ResolvePackagesTask, PrepareDownloadLocationTask, DownloadPackagesTask, InstallPackagesTask, \
     CleanUpDownloadLocationTask, WriteRepositoriesTask, ImportRPMKeysTask, \
-    UpdateDNFConfigurationTask
+    UpdateDNFConfigurationTask, OEConfigureTask
 from pyanaconda.modules.payloads.payload.dnf.tear_down import ResetDNFManagerTask
 from pyanaconda.modules.payloads.payload.dnf.utils import calculate_required_space
 from pyanaconda.modules.payloads.payload.payload_base import PayloadBase
@@ -473,6 +473,10 @@ class DNFModule(PayloadBase):
                 sysroot=conf.target.system_root,
                 configuration=self.packages_configuration,
             ),
+            OEConfigureTask(
+                sysroot=conf.target.system_root,
+                dnf_module=self,
+            ),
             ResetDNFManagerTask(
                 dnf_manager=self.dnf_manager
             )
diff --git a/pyanaconda/modules/payloads/payload/dnf/dnf_manager.py b/pyanaconda/modules/payloads/payload/dnf/dnf_manager.py
index 4852fcdc9d..8256bd9e2b 100644
--- a/pyanaconda/modules/payloads/payload/dnf/dnf_manager.py
+++ b/pyanaconda/modules/payloads/payload/dnf/dnf_manager.py
@@ -21,6 +21,10 @@ import multiprocessing
 import shutil
 import threading
 import traceback
+import os
+import inspect
+import collections
+import configparser
 
 import dnf
 import dnf.exceptions
@@ -37,7 +41,7 @@ from pyanaconda.core.constants import DNF_DEFAULT_TIMEOUT, DNF_DEFAULT_RETRIES,
     URL_TYPE_MIRRORLIST, URL_TYPE_METALINK, DNF_DEFAULT_REPO_COST
 from pyanaconda.core.i18n import _
 from pyanaconda.core.payload import ProxyString, ProxyStringError
-from pyanaconda.core.util import get_os_release_value
+from pyanaconda.core.util import get_os_release_value, execWithRedirect, execWithCapture
 from pyanaconda.modules.common.errors.installation import PayloadInstallationError
 from pyanaconda.modules.common.errors.payload import UnknownCompsEnvironmentError, \
     UnknownCompsGroupError, UnknownRepositoryError
@@ -104,11 +108,17 @@ class DNFManager(object):
         self._md_hashes = {}
         self._enabled_system_repositories = []
 
+        # OE specific
+        self.image = {}
+        self.tasks = {}
+        self.failed_scriptlets_pkgnames = collections.OrderedDict()
+
     @property
     def _base(self):
         """The DNF base."""
         if self.__base is None:
             self.__base = self._create_base()
+            self._oe_configure(self.__base.conf)
 
         return self.__base
 
@@ -137,7 +147,7 @@ class DNFManager(object):
 
         # Set the platform id based on the /os/release present
         # in the installation environment.
-        platform_id = get_os_release_value("PLATFORM_ID")
+        platform_id = get_os_release_value("VERSION_ID")
 
         if platform_id is not None:
             base.conf.module_platform_id = platform_id
@@ -171,6 +181,9 @@ class DNFManager(object):
         self._md_hashes = {}
         self._enabled_system_repositories = []
 
+        self.image = {}
+        self.tasks = {}
+
         log.debug("The DNF base has been reset.")
 
     def configure_base(self, data: PackagesConfigurationData):
@@ -225,7 +238,8 @@ class DNFManager(object):
 
         :return: a list of ids
         """
-        return [env.id for env in self._base.comps.environments]
+        log.info("%s %s: %s" % (self.__class__.__name__, inspect.stack()[0][3], self.tasks.keys()))
+        return sorted(self.tasks.keys())
 
     def _get_environment(self, environment_name):
         """Translate the given environment name to a DNF object.
@@ -236,7 +250,7 @@ class DNFManager(object):
         if not environment_name:
             return None
 
-        return self._base.comps.environment_by_pattern(environment_name)
+        return environment_name
 
     def resolve_environment(self, environment_name):
         """Translate the given environment name to a group ID.
@@ -244,12 +258,9 @@ class DNFManager(object):
         :param environment_name: an identifier of an environment
         :return: a string with the environment ID or None
         """
-        env = self._get_environment(environment_name)
+        log.info("%s %s, environment %s" % (self.__class__.__name__, inspect.stack()[0][3], environment_name))
 
-        if not env:
-            return None
-
-        return env.id
+        return environment_name
 
     def get_environment_data(self, environment_name) -> CompsEnvironmentData:
         """Get the data of the specified environment.
@@ -271,24 +282,11 @@ class DNFManager(object):
         :param env: a DNF representation of the environment
         :return: an instance of CompsEnvironmentData
         """
+        task = self.tasks.get(env)
         data = CompsEnvironmentData()
-        data.id = env.id or ""
-        data.name = env.ui_name or ""
-        data.description = env.ui_description or ""
-
-        optional = {i.name for i in env.option_ids}
-        default = {i.name for i in env.option_ids if i.default}
-
-        for grp in self._base.comps.groups:
-
-            if grp.id in optional:
-                data.optional_groups.append(grp.id)
-
-            if grp.visible:
-                data.visible_groups.append(grp.id)
-
-            if grp.id in default:
-                data.default_groups.append(grp.id)
+        data.id = env or ""
+        data.name = task[0] or ""
+        data.description = task[1] or ""
 
         return data
 
@@ -298,7 +296,8 @@ class DNFManager(object):
 
         :return: a list of IDs
         """
-        return [g.id for g in self._base.comps.groups]
+        log.info("%s %s: %s" % (self.__class__.__name__, inspect.stack()[0][3], self.tasks.keys()))
+        return []
 
     def _get_group(self, group_name):
         """Translate the given group name into a DNF object.
@@ -343,9 +342,8 @@ class DNFManager(object):
         :return: an instance of CompsGroupData
         """
         data = CompsGroupData()
-        data.id = grp.id or ""
-        data.name = grp.ui_name or ""
-        data.description = grp.ui_description or ""
+        log.info("%s %s, %s" % (self.__class__.__name__, inspect.stack()[0][3], grp))
+        (data.id, data.name, data.description) = self.tasks[grp]
         return data
 
     def configure_proxy(self, url):
@@ -684,6 +682,16 @@ class DNFManager(object):
 
             # Wait for the transaction to end.
             process.join()
+
+            for pkg in self.failed_scriptlets_pkgnames.keys():
+                self._save_rpmpostinst(pkg)
+
+            # create symlinks for distro feature usrmerge
+            for d in ('bin', 'sbin', 'lib', 'lib32', 'lib64'):
+                if (not os.path.lexists(os.path.join(conf.target.system_root, d))
+                    and os.path.exists(os.path.join(conf.target.system_root, 'usr', d))):
+                    execWithCapture("ln", ["-rs", os.path.join('/usr', d), os.path.join('/', d)],
+                                    root=conf.target.system_root)
         finally:
             # Kill the transaction after the timeout.
             process.join(timeout)
@@ -1047,3 +1055,116 @@ class DNFManager(object):
                 continue
 
         return ""
+
+    def environment_description(self, environment_id):
+        log.info("%s %s, %s" % (self.__class__.__name__, inspect.stack()[0][3], environment_id))
+
+        if environment_id not in self.tasks:
+            raise NoSuchGroup(environment_id)
+
+        if environment_id in self.tasks:
+            log.info("environmentDescription %s" % self.tasks)
+            (name, description, group) = self.tasks[environment_id]
+
+            return (name, description)
+        return (environment_id, environment_id)
+
+    def _oe_configure(self, dnf_conf):
+        # Refers oe-core's recipes of dnf and rpm
+        os.environ['RPM_NO_CHROOT_FOR_SCRIPTS'] = "1"
+
+        # Refers oe-core's meta/lib/oe/package_manager.py
+        # def _prepare_pkg_transaction(self) in class RpmPM(PackageManager)
+        target_rootfs = conf.target.system_root
+        os.environ['D'] = target_rootfs
+        os.environ['OFFLINE_ROOT'] = target_rootfs
+        os.environ['IPKG_OFFLINE_ROOT'] = target_rootfs
+        os.environ['OPKG_OFFLINE_ROOT'] = target_rootfs
+
+        # Refer oe-core's meta/lib/oe/package_manager.py
+        # def _configure_dnf(self) in class RpmPM(PackageManager)
+        # directly read its result from installer system
+        dnf_conf.substitutions['arch'] = open("/etc/dnf/vars/arch", "r").readline()
+
+        dnf_conf.errorlevel = dnf.const.VERBOSE_LEVEL
+        dnf_conf.debuglevel = dnf.const.VERBOSE_LEVEL
+
+    # OE specific
+    def read_buildstamp(self):
+        self.image, self.tasks = self._read_buildstamp()
+
+    def _read_buildstamp(self):
+        image = {}
+        tasks = {}
+
+        config = configparser.ConfigParser()
+        config.read(["/tmp/product/.buildstamp", "/.buildstamp", os.environ.get("PRODBUILDPATH", "")])
+
+        image_list = config.get("Rootfs", "LIST", fallback='').split()
+        for image_name in image_list:
+            _id_ = image_name.split('-')[0]
+            image_summary = config.get(image_name, "SUMMARY")
+            image_description = config.get(image_name, "DESCRIPTION")
+            package_install = config.get(image_name, "PACKAGE_INSTALL")
+            package_install_attemptonly = config.get(image_name,
+                                                         "PACKAGE_INSTALL_ATTEMPTONLY")
+            image_linguas = config.get(image_name, "IMAGE_LINGUAS")
+            image[image_name] = (image_summary,
+                                 image_description,
+                                 package_install,
+                                 package_install_attemptonly,
+                                 image_linguas)
+
+            short_image = image_name.replace("%s-image-" % _id_, "")
+
+            taskid = short_image
+            name = image_name
+            description = "%s" % image_summary
+            group = ""
+            tasks[taskid] = (name, description, group)
+
+            taskid = "%s-dev" % short_image
+            name = "%s dev-pkgs staticdev-pkgs" % image_name
+            description = "%s with development files" % image_summary
+            group = "dev-pkgs staticdev-pkgs"
+            tasks[taskid] = (name, description, group)
+
+            taskid = "%s-dbg" % short_image
+            name = "%s dbg-pkgs" % image_name
+            description = "%s with debug symbols" % image_summary
+            group = "dbg-pkgs"
+            tasks[taskid] = (name, description, group)
+
+            taskid = "%s-dev-dbg" % short_image
+            name = "%s dev-pkgs staticdev-pkgs dbg-pkgs" % image_name
+            description = "%s with development files and debug symbols" % image_summary
+            group = "dev-pkgs staticdev-pkgs dbg-pkgs"
+            tasks[taskid] = (name, description, group)
+
+        return image, tasks
+
+    # Refer upstream oe-core meta/lib/oe/package_manager.py
+    def _save_rpmpostinst(self, pkg):
+        def _script_num_prefix(path):
+            files = os.listdir(path)
+            numbers = set()
+            numbers.add(99)
+            for f in files:
+                numbers.add(int(f.split("-")[0]))
+            return max(numbers) + 1
+
+        log.info("Saving postinstall script of %s" % (pkg))
+
+        target_rootfs = conf.target.system_root
+        args = ["-q", "--root=%s" % target_rootfs, "--queryformat", "%{postin}", pkg]
+
+        output = execWithCapture('rpm', args, log_output=False)
+        log.info(output)
+
+        target_path = "%s/etc/rpm-postinsts" % target_rootfs
+        execWithRedirect("mkdir", ["-p", target_path])
+        num = _script_num_prefix(target_path)
+        saved_script_name = os.path.join(target_path, "%d-%s" % (num, pkg))
+        with open(saved_script_name, 'w') as f:
+            f.write(output)
+        os.chmod(saved_script_name, 0o755)
diff --git a/pyanaconda/modules/payloads/payload/dnf/initialization.py b/pyanaconda/modules/payloads/payload/dnf/initialization.py
index 841c122c3e..6f5192b068 100644
--- a/pyanaconda/modules/payloads/payload/dnf/initialization.py
+++ b/pyanaconda/modules/payloads/payload/dnf/initialization.py
@@ -201,6 +201,10 @@ class SetUpDNFSourcesTask(SetUpSourcesTask):
         dnf_manager.configure_substitution(self._release_version)
         dnf_manager.dump_configuration()
         dnf_manager.read_system_repositories()
+
+        # OE specific
+        dnf_manager.read_buildstamp()
+
         return dnf_manager
 
     def _load_source(self, dnf_manager, source, repository=None):
diff --git a/pyanaconda/modules/payloads/payload/dnf/installation.py b/pyanaconda/modules/payloads/payload/dnf/installation.py
index 222cceebb5..c24fb3a283 100644
--- a/pyanaconda/modules/payloads/payload/dnf/installation.py
+++ b/pyanaconda/modules/payloads/payload/dnf/installation.py
@@ -31,7 +31,7 @@ from pyanaconda.modules.common.structures.packages import PackagesConfigurationD
 from pyanaconda.modules.common.task import Task
 from pyanaconda.modules.payloads.payload.dnf.requirements import collect_remote_requirements, \
     collect_language_requirements, collect_platform_requirements, \
-    collect_driver_disk_requirements, apply_requirements
+    collect_driver_disk_requirements, apply_requirements, collect_oe_requirements
 from pyanaconda.modules.payloads.payload.dnf.utils import pick_download_location, \
     get_kernel_version_list
 from pyanaconda.modules.payloads.payload.dnf.validation import CheckPackagesSelectionTask
@@ -132,7 +132,8 @@ class ResolvePackagesTask(CheckPackagesSelectionTask):
         return collect_remote_requirements() \
             + collect_language_requirements(self._dnf_manager) \
             + collect_platform_requirements(self._dnf_manager) \
-            + collect_driver_disk_requirements()
+            + collect_driver_disk_requirements() \
+            + collect_oe_requirements()
 
     def _collect_required_specs(self):
         """Collect specs for the required software."""
@@ -248,6 +249,12 @@ class InstallPackagesTask(Task):
         self._dnf_manager.install_packages(self.report_progress)
         return get_kernel_version_list()
 
+    def report_progress(self, message, step_number=None, step_size=None):
+        super().report_progress(message, step_number, step_size)
+
+        if message.startswith("Error in POSTIN scriptlet in rpm package"):
+            self._dnf_manager.failed_scriptlets_pkgnames[message.split()[-1]] = True
+
 
 class WriteRepositoriesTask(Task):
     """The installation task for writing repositories on the target system."""
@@ -420,3 +427,67 @@ class UpdateDNFConfigurationTask(Task):
         if rc != 0:
             log.warning("Failed to update the DNF configuration (%s).", rc)
             return
+
+
+class OEConfigureTask(Task):
+    """The OE configuration task."""
+
+    def __init__(self, sysroot, dnf_module):
+        """Create a new task.
+
+        :param str sysroot: a path to the system root
+        :param DNFManager dnf_manager: a DNF manager
+        """
+        super().__init__()
+        self._sysroot = sysroot
+        self._dnf_module = dnf_module
+
+    @property
+    def name(self):
+        return "Update DNF configuration for OE"
+
+    def run(self):
+        """Run the task."""
+        self._oe_configure_post()
+
+        # For the generation of anaconda-ks.cfg
+        pkg_data = self._dnf_module.packages_selection
+        for pkg in self._list_installed():
+            if pkg not in pkg_data.packages:
+                pkg_data.packages.append(pkg)
+        self._dnf_module.set_packages_selection(pkg_data)
+
+        util.execWithRedirect("depmod",
+                              ["-a"],
+                              root=conf.target.system_root)
+
+    def _oe_configure_post(self):
+        # Refers oe-core's meta/lib/oe/package_manager.py
+        # def _configure_rpm(self) and def _configure_dnf(self)
+        # in class RpmPM(PackageManager)
+        # directly copy its result from installer system
+        target_sysconf = "%s/etc" % conf.target.system_root
+        util.execWithRedirect("cp", ["-fr", "/etc/rpmrc", target_sysconf])
+        util.execWithRedirect("cp", ["-rf", "/etc/dnf", target_sysconf])
+        util.execWithRedirect("cp", ["-rf", "/etc/rpm", target_sysconf])
+
+    def _list_installed(self):
+        output = util.execWithCapture(
+                         'dnf',
+                         [
+                           'repoquery',
+                           '--installed',
+                           '--installroot=' + self._sysroot,
+                           '--queryformat=Package:%{name}'
+                         ],
+                         log_output=False
+                 )
+        output = output.rstrip()
+        lines = output.splitlines()
+        installed = []
+        for line in lines:
+            if not line.startswith("Package:"):
+                continue
+            installed.append(line.replace("Package:", ""))
+
+        return installed
diff --git a/pyanaconda/modules/payloads/payload/dnf/requirements.py b/pyanaconda/modules/payloads/payload/dnf/requirements.py
index ee1f517ce2..c5536a9698 100644
--- a/pyanaconda/modules/payloads/payload/dnf/requirements.py
+++ b/pyanaconda/modules/payloads/payload/dnf/requirements.py
@@ -127,6 +127,27 @@ def collect_driver_disk_requirements(path="/run/install/dd_packages"):
     return requirements
 
 
+def collect_oe_requirements():
+    """Collect the requirements for oe
+    """
+    requirements = []
+
+    # base packages
+    for pkg in ('base-files', 'base-passwd', 'shadow'):
+        requirements.append(Requirement.for_package(
+            pkg,
+            reason='base packages'
+        ))
+    # Support grub-mkconfig
+    for pkg in ('sed', 'coreutils'):
+        requirements.append(Requirement.for_package(
+            pkg,
+            reason='support grub-mkconfig'
+        ))
+
+    return requirements
+
+
 def apply_requirements(requirements, include_list, exclude_list):
     """Apply the provided requirements.
 
diff --git a/pyanaconda/modules/payloads/payload/dnf/transaction_progress.py b/pyanaconda/modules/payloads/payload/dnf/transaction_progress.py
index b277156819..f992debae1 100644
--- a/pyanaconda/modules/payloads/payload/dnf/transaction_progress.py
+++ b/pyanaconda/modules/payloads/payload/dnf/transaction_progress.py
@@ -55,6 +55,9 @@ def process_transaction_progress(queue, callback):
             break  # Installation finished successfully
         elif token == 'quit':
             raise RuntimeError("The transaction process has ended abruptly: " + msg)
+        elif token == 'warn':
+            if msg.startswith("Error in POSTIN scriptlet in rpm package"):
+                callback(msg)
         elif token == 'error':
             raise PayloadInstallationError("An error occurred during the transaction: " + msg)
 
@@ -140,7 +143,11 @@ class TransactionProgress(dnf.callback.TransactionProgress):
 
         :param message: a string that describes the error
         """
-        self._queue.put(('error', message))
+        token = "error"
+        if message.startswith("Error in POSTIN scriptlet in rpm package"):
+            token = "warn"
+        self._queue.put((token, message))
+        log.info("error: %s" % message)
 
     def quit(self, message):
         """Report the end of the transaction and close the queue.
diff --git a/pyanaconda/modules/payloads/payload/dnf/utils.py b/pyanaconda/modules/payloads/payload/dnf/utils.py
index 9e0c8805a9..032d1eac81 100644
--- a/pyanaconda/modules/payloads/payload/dnf/utils.py
+++ b/pyanaconda/modules/payloads/payload/dnf/utils.py
@@ -111,18 +111,8 @@ def get_installation_specs(data: PackagesSelectionData, default_environment=None
     exclude_list = []
 
     # Handle the environment.
-    if data.default_environment_enabled and default_environment:
-        log.info("Selecting default environment '%s'.", default_environment)
-        include_list.append("@{}".format(default_environment))
-    elif data.environment:
-        include_list.append("@{}".format(data.environment))
 
     # Handle the core group.
-    if not data.core_group_enabled:
-        log.info("Skipping @core group; system may not be complete.")
-        exclude_list.append("@core")
-    else:
-        include_list.append("@core")
 
     # Handle groups.
     for group_name in data.excluded_groups:
diff --git a/pyanaconda/modules/payloads/payload/dnf/validation.py b/pyanaconda/modules/payloads/payload/dnf/validation.py
index 49ce63f5af..6bc5541857 100644
--- a/pyanaconda/modules/payloads/payload/dnf/validation.py
+++ b/pyanaconda/modules/payloads/payload/dnf/validation.py
@@ -17,6 +17,7 @@
 #
 from contextlib import contextmanager
 
+from pyanaconda.core import util
 from pyanaconda.anaconda_loggers import get_module_logger
 from pyanaconda.core.i18n import _
 from pyanaconda.modules.common.structures.packages import PackagesSelectionData
@@ -112,6 +113,17 @@ class CheckPackagesSelectionTask(ValidationTask):
             self._selection, default_environment
         )
 
+        env = None
+        if self._selection.environment:
+            env = self._selection.environment
+        elif default_environment:
+            env = default_environment
+        log.info("selected environment: %s", env)
+
+        for pkg_name in self._apply_yocto_environment(env):
+            log.info("selected yocto package: '%s'", pkg_name)
+            include_list.append(pkg_name)
+
         self._include_list.extend(include_list)
         self._exclude_list.extend(exclude_list)
 
@@ -159,3 +171,74 @@ class CheckPackagesSelectionTask(ValidationTask):
             report.error_messages.append(str(e))
         except InvalidSelectionError as e:
             report.error_messages.append(str(e))
+
+    def _apply_yocto_environment(self, env):
+        if not env:
+            return []
+
+        (image_name, description) = self._dnf_manager.environment_description(env)
+        log.info("image_name %s, des %s" % (image_name, description))
+        image_id = image_name.split()[0]
+        (image_summary, image_description, package_install,
+            package_install_attemptonly, image_linguas) = self._dnf_manager.image[image_id]
+        log.info("package_install %s, attempt %s, linguas %s" %
+                 (package_install, package_install_attemptonly, image_linguas))
+
+        # Language locale
+        self._select_yocto_linguas(image_linguas)
+
+        # -dbg/-doc/-dev
+        for group in self._dnf_manager.tasks[env][2].split():
+            self._select_yocto_group(group)
+
+        # Installing packages
+        return package_install.split()
+
+    def _select_yocto_group(self, group_id):
+        log.info("_select_yocto_group %s" % group_id)
+        if not group_id:
+            return []
+
+        glob = self._yocto_complementary_glob(group_id)
+
+        # get all available languages in repos
+        available_packs = self._dnf_manager._base.sack.query().available().filter(
+                            name__glob="*-%s" % glob)
+        allpkgnames = [p.name for p in available_packs]
+        log.info("allpkgnames %d" % len(allpkgnames))
+        for pkgname in allpkgnames:
+            self._try_install_package(pkgname)
+
+    def _select_yocto_linguas(self, image_linguas):
+        lc_globs = []
+        for ling in image_linguas.split():
+            if ling not in lc_globs:
+                lc_globs.append(ling)
+
+            baselang = ling.split('-')[0]
+            if ling != baselang and baselang not in lc_globs:
+                lc_globs.append(baselang)
+
+        log.info("lc_globs: %s" % lc_globs)
+        for lc_glob in lc_globs:
+            self._select_yocto_group("locale-%s" % lc_glob)
+
+    def _try_install_package(self, pkg_name):
+        try:
+            return self._dnf_manager._base.install(pkg_name, strict=False)
+        except dnf.exceptions.MarkingError:
+            msg = "Payload error - No such package: %s" % pkg_name
+            raise PayloadError(msg)
+
+    def _yocto_complementary_glob(self, group):
+        complementary_glob = {}
+        complementary_glob['dev-pkgs'] = 'dev'
+        complementary_glob['staticdev-pkgs'] = 'staticdev'
+        complementary_glob['doc-pkgs'] = 'doc'
+        complementary_glob['dbg-pkgs'] = 'dbg'
+        complementary_glob['ptest-pkgs'] = 'ptest'
+
+        if group in complementary_glob:
+            return complementary_glob[group]
+
+        return group
diff --git a/pyanaconda/payload/dnf/payload.py b/pyanaconda/payload/dnf/payload.py
index 0d55a69fd2..2ad4ab7e2a 100644
--- a/pyanaconda/payload/dnf/payload.py
+++ b/pyanaconda/payload/dnf/payload.py
@@ -101,8 +101,8 @@ class DNFPayload(MigratedDBusPayload):
             set_source(self.proxy, source_proxy)
 
         else:
-            log.debug("Use the DNF source from the Anaconda configuration file.")
-            source_proxy = create_source(conf.payload.default_source)
+            log.debug("Use the DNF source from install disk.")
+            source_proxy = create_source(SOURCE_TYPE_CDROM)
             set_source(self.proxy, source_proxy)
 
     @staticmethod
-- 
2.34.1