def __setup(self):
        """Construct the series of commands to execute"""

        if self.__extra_opts:
            self.__download_args += ' ' + ' '.join(self.__extra_opts)
            self.__opts.extend(self.__extra_opts)

        # Use yum version 4 is requested.  yum 4 is the default on
        # CentOS 8.
        yum = 'yum'
        if self.__yum4 and hpccm.config.g_linux_version < Version('8.0'):
            self.__commands.append('yum install -y nextgen-yum4')
            yum = 'yum4'

        if self.__keys:
            self.__commands.append('rpm --import {}'.format(
                ' '.join(self.__keys)))

        if self.__repositories:
            # Need yum-config-manager
            if hpccm.config.g_linux_version >= Version('8.0'):
                # CentOS 8
                self.__commands.append('yum install -y dnf-utils')
            else:
                # CentOS 7
                self.__commands.append('yum install -y yum-utils')

            for repo in self.__repositories:
                if self.__force_add_repo:
                    self.__commands.append(
                        '(yum-config-manager --add-repo {} || true)'.format(repo))
                else:
                    self.__commands.append(
                        'yum-config-manager --add-repo {}'.format(repo))

        if self.__epel:
            # This needs to be a discrete, preliminary step so that
            # packages from EPEL are available to be installed.
            self.__commands.append('yum install -y epel-release')

        if (self.__powertools and
            hpccm.config.g_linux_version >= Version('8.0')):
            # This needs to be a discrete, preliminary step so that
            # packages from PowerTools are available to be installed.
            if not self.__repositories:
                # dnf-utils will be installed above if repositories are
                # enabled
                self.__commands.append('yum install -y dnf-utils')
            self.__commands.append('yum-config-manager --set-enabled powertools')

        if (self.__release_stream and
            hpccm.config.g_linux_version >= Version('8.0') and
            hpccm.config.g_linux_version < Version('9.0')):
            # This needs to be a discrete, preliminary step so that
            # packages from release stream are available to be installed.
            self.__commands.append('yum install -y centos-release-stream')

        if (self.__scl and
            hpccm.config.g_linux_version < Version('8.0')):
            # This needs to be a discrete, preliminary step so that
            # packages from SCL are available to be installed.
            self.__commands.append('yum install -y centos-release-scl')

        if self.ospackages:
            packages = []
            for pkg in sorted(self.ospackages):
                packages.append('        {}'.format(pkg))

            if self.__download:
                # Download packages

                # Need yumdownloader
                self.__commands.append('yum install -y yum-utils')

                self.__commands.append('mkdir -p {0}'.format(
                    self.__download_directory))

                download = 'yumdownloader --destdir={0} {1} \\\n'.format(
                    self.__download_directory, self.__download_args)
                download = download + ' \\\n'.join(packages)
                self.__commands.append(download)

                if self.__extract:
                    # Extract the packages to a prefix - not a "real"
                    # package manager install
                    self.__commands.append('mkdir -p {0} && cd {0}'.format(
                        self.__extract))

                    regex = posixpath.join(
                        self.__download_directory,
                        '(' + '|'.join(sorted(self.ospackages)) + ').*rpm')
                    self.__commands.append('find {0} -regextype posix-extended -type f -regex "{1}" -exec sh -c "rpm2cpio {{}} | cpio -idm" \;'.format(self.__download_directory, regex))

                    # Cleanup downloaded packages
                    self.__commands.append(
                        'rm -rf {}'.format(self.__download_directory))
            else:
                # Install packages
                install = '{0} install {1} \\\n'.format(yum,
                                                        ' '.join(self.__opts))
                install = install + ' \\\n'.join(packages)
                self.__commands.append(install)

        if self.__epel or self.ospackages:
            self.__commands.append('rm -rf /var/cache/yum/*')
Construct the series of commands to execute
hpccm/building_blocks/yum.py