Exemple #1
0
    def __init__(self, createopts=None, pkgmgr=None):
        """Initialize an ImageCreator instance.

        ks -- a pykickstart.KickstartParser instance; this instance will be
              used to drive the install by e.g. providing the list of packages
              to be installed, the system configuration and %post scripts

        name -- a name for the image; used for e.g. image filenames or
                filesystem labels
        """

        self.pkgmgr = pkgmgr

        self.__builddir = None
        self.__bindmounts = []

        self.ks = None
        self.name = "target"
        self.tmpdir = "/var/tmp/mic"
        self.cachedir = "/var/tmp/mic/cache"
        self.destdir = "."
        self.target_arch = "noarch"
        self._local_pkgs_path = None
        self.pack_to = None

        # If the kernel is save to the destdir when copy_kernel cmd is called.
        self._need_copy_kernel = False

        if createopts:
            # Mapping table for variables that have different names.
            optmap = {
                "pkgmgr": "pkgmgr_name",
                "outdir": "destdir",
                "arch": "target_arch",
                "local_pkgs_path": "_local_pkgs_path",
                "copy_kernel": "_need_copy_kernel",
            }

            # update setting from createopts
            for key in createopts.keys():
                if key in optmap:
                    option = optmap[key]
                else:
                    option = key
                setattr(self, option, createopts[key])

            self.destdir = os.path.abspath(os.path.expanduser(self.destdir))

            if "release" in createopts and createopts["release"]:
                self.name += "-" + createopts["release"]

            if self.pack_to:
                if "@NAME@" in self.pack_to:
                    self.pack_to = self.pack_to.replace("@NAME@", self.name)
                (tar, ext) = os.path.splitext(self.pack_to)
                if ext in (".gz", ".bz2") and tar.endswith(".tar"):
                    ext = ".tar" + ext
                if ext not in misc.pack_formats:
                    self.pack_to += ".tar"

        self._dep_checks = ["ls", "bash", "cp", "echo", "modprobe", "passwd"]

        # Output image file names
        self.outimage = []

        # A flag to generate checksum
        self._genchecksum = False

        self._alt_initrd_name = None

        self._recording_pkgs = []

        # available size in root fs, init to 0
        self._root_fs_avail = 0

        # Name of the disk image file that is created.
        self._img_name = None

        self.image_format = None

        # Save qemu emulator file name in order to clean up it finally
        self.qemu_emulator = None

        # No ks provided when called by convertor, so skip the dependency check
        if self.ks:
            # If we have btrfs partition we need to check necessary tools
            for part in self.ks.handler.partition.partitions:
                if part.fstype and part.fstype == "btrfs":
                    self._dep_checks.append("mkfs.btrfs")
                    break

        if self.target_arch and self.target_arch.startswith("arm"):
            for dep in self._dep_checks:
                if dep == "extlinux":
                    self._dep_checks.remove(dep)

            if not os.path.exists("/usr/bin/qemu-arm") or not misc.is_statically_linked("/usr/bin/qemu-arm"):
                self._dep_checks.append("qemu-arm-static")

            if os.path.exists("/proc/sys/vm/vdso_enabled"):
                vdso_fh = open("/proc/sys/vm/vdso_enabled", "r")
                vdso_value = vdso_fh.read().strip()
                vdso_fh.close()
                if (int)(vdso_value) == 1:
                    msger.warning(
                        "vdso is enabled on your host, which might "
                        "cause problems with arm emulations.\n"
                        "\tYou can disable vdso with following command before "
                        "starting image build:\n"
                        "\techo 0 | sudo tee /proc/sys/vm/vdso_enabled"
                    )

        # make sure the specified tmpdir and cachedir exist
        if not os.path.exists(self.tmpdir):
            os.makedirs(self.tmpdir)
        if not os.path.exists(self.cachedir):
            os.makedirs(self.cachedir)
Exemple #2
0
    def __init__(self, createopts=None, pkgmgr=None):
        """Initialize an ImageCreator instance.

        ks -- a pykickstart.KickstartParser instance; this instance will be
              used to drive the install by e.g. providing the list of packages
              to be installed, the system configuration and %post scripts

        name -- a name for the image; used for e.g. image filenames or
                filesystem labels
        """

        self.pkgmgr = pkgmgr

        self.__builddir = None
        self.__bindmounts = []

        self.ks = None
        self.name = "target"
        self.tmpdir = "/var/tmp/mic"
        self.cachedir = "/var/tmp/mic/cache"
        self.workdir = "/var/tmp/mic/build"
        self.destdir = "."
        self.target_arch = "noarch"
        self._local_pkgs_path = None
        self.pack_to = None
        self.repourl = {}

        # If the kernel is save to the destdir when copy_kernel cmd is called.
        self._need_copy_kernel = False
        # setup tmpfs tmpdir when enabletmpfs is True
        self.enabletmpfs = False

        if createopts:
            # Mapping table for variables that have different names.
            optmap = {
                "pkgmgr": "pkgmgr_name",
                "outdir": "destdir",
                "arch": "target_arch",
                "local_pkgs_path": "_local_pkgs_path",
                "copy_kernel": "_need_copy_kernel",
            }

            # update setting from createopts
            for key in createopts.keys():
                if key in optmap:
                    option = optmap[key]
                else:
                    option = key
                setattr(self, option, createopts[key])

            self.destdir = os.path.abspath(os.path.expanduser(self.destdir))

            if 'release' in createopts and createopts['release']:
                self.name = createopts['release'] + '_' + self.name

            if self.pack_to:
                if '@NAME@' in self.pack_to:
                    self.pack_to = self.pack_to.replace('@NAME@', self.name)
                (tar, ext) = os.path.splitext(self.pack_to)
                if ext in (".gz", ".bz2") and tar.endswith(".tar"):
                    ext = ".tar" + ext
                if ext not in misc.pack_formats:
                    self.pack_to += ".tar"

        self._dep_checks = ["ls", "bash", "cp", "echo", "modprobe"]

        # Output image file names
        self.outimage = []

        # A flag to generate checksum
        self._genchecksum = False

        self._alt_initrd_name = None

        self._recording_pkgs = []

        # available size in root fs, init to 0
        self._root_fs_avail = 0

        # Name of the disk image file that is created.
        self._img_name = None

        self.image_format = None

        # Save qemu emulator file name in order to clean up it finally
        self.qemu_emulator = None

        # No ks provided when called by convertor, so skip the dependency check
        if self.ks:
            # If we have btrfs partition we need to check necessary tools
            for part in self.ks.handler.partition.partitions:
                if part.fstype and part.fstype == "btrfs":
                    self._dep_checks.append("mkfs.btrfs")
                    break

        if self.target_arch and self.target_arch.startswith("arm"):
            for dep in self._dep_checks:
                if dep == "extlinux":
                    self._dep_checks.remove(dep)

            if not os.path.exists("/usr/bin/qemu-arm") or \
               not misc.is_statically_linked("/usr/bin/qemu-arm"):
                self._dep_checks.append("qemu-arm-static")

            if os.path.exists("/proc/sys/vm/vdso_enabled"):
                vdso_fh = open("/proc/sys/vm/vdso_enabled", "r")
                vdso_value = vdso_fh.read().strip()
                vdso_fh.close()
                if (int)(vdso_value) == 1:
                    msger.warning(
                        "vdso is enabled on your host, which might "
                        "cause problems with arm emulations.\n"
                        "\tYou can disable vdso with following command before "
                        "starting image build:\n"
                        "\techo 0 | sudo tee /proc/sys/vm/vdso_enabled")

        # make sure the specified tmpdir and cachedir exist
        if not os.path.exists(self.tmpdir):
            os.makedirs(self.tmpdir)
        if not os.path.exists(self.cachedir):
            os.makedirs(self.cachedir)
Exemple #3
0
    def __init__(self, createopts = None, pkgmgr = None):
        """Initialize an ImageCreator instance.

        ks -- a pykickstart.KickstartParser instance; this instance will be
              used to drive the install by e.g. providing the list of packages
              to be installed, the system configuration and %post scripts

        name -- a name for the image; used for e.g. image filenames or
                filesystem labels
        """

        self.pkgmgr = pkgmgr

        self.__builddir = None
        self.__bindmounts = []

        # Eeach image type can change these values as they might be image type
        # specific
        if not hasattr(self, "_valid_compression_methods"):
            self._valid_compression_methods = ['bz2']

        # The compression method for disk image.
        self._img_compression_method = None

        if createopts:
            # A pykickstart.KickstartParser instance."""
            self.ks = createopts['ks']

            self.destdir = os.path.abspath(os.path.expanduser(createopts["outdir"]))

            # A name for the image."""
            self.name = createopts['name']
            if createopts['release']:
                self.name += '-' + createopts['release']

                # check whether destine dir exist
                if os.path.exists(self.destdir):
                    if msger.ask('Image dir: %s already exists, cleanup and continue?' % self.destdir):
                        shutil.rmtree(self.destdir, ignore_errors = True)
                    else:
                        raise Abort('Canceled')

                # pending FEA: save log by default for --release

            # The directory in which all temporary files will be created."""
            self.tmpdir = createopts['tmpdir']
            self.cachedir = createopts['cachedir']
            self.target_arch = createopts['arch']
            self._local_pkgs_path = createopts['local_pkgs_path']
            self._img_compression_method = createopts['compress_disk_image']

        else:
            self.ks = None
            self.name = "target"
            self.tmpdir = "/var/tmp/mic"
            self.cachedir = "/var/tmp/mic/cache"
            self.destdir = "."
            self.target_arch = "noarch"
            self._local_pkgs_path = None

        self._dep_checks = ["ls", "bash", "cp", "echo", "modprobe", "passwd"]

        #FIXME to be obsolete, make it configurable
        self.distro_name = "Tizen"

        # Output image file names
        self.outimage = []

        # A flag to generate checksum
        self._genchecksum = False

        self._alt_initrd_name = None

        self._recording_pkgs = []

        # available size in root fs, init to 0
        self._root_fs_avail = 0

        # Name of the disk image file that is created.
        self._img_name = None

        self.image_format = None

        # Save qemu emulator file name in order to clean up it finally
        self.qemu_emulator = None

        # No ks provided when called by convertor, so skip the dependency check
        if self.ks:
            # If we have btrfs partition we need to check that we have toosl for those
            for part in self.ks.handler.partition.partitions:
                if part.fstype and part.fstype == "btrfs":
                    self._dep_checks.append("mkfs.btrfs")
                    break

        if self.target_arch and self.target_arch.startswith("arm"):
            for dep in self._dep_checks:
                if dep == "extlinux":
                    self._dep_checks.remove(dep)

            if not os.path.exists("/usr/bin/qemu-arm") or not misc.is_statically_linked("/usr/bin/qemu-arm"):
                self._dep_checks.append("qemu-arm-static")

            if os.path.exists("/proc/sys/vm/vdso_enabled"):
                vdso_fh = open("/proc/sys/vm/vdso_enabled","r")
                vdso_value = vdso_fh.read().strip()
                vdso_fh.close()
                if (int)(vdso_value) == 1:
                    msger.warning("vdso is enabled on your host, which might cause problems with arm emulations.\n"
                                  "\tYou can disable vdso with following command before starting image build:\n"
                                  "\techo 0 | sudo tee /proc/sys/vm/vdso_enabled")

        # make sure the specified tmpdir and cachedir exist
        if not os.path.exists(self.tmpdir):
            os.makedirs(self.tmpdir)
        if not os.path.exists(self.cachedir):
            os.makedirs(self.cachedir)

        if self._img_compression_method != None and self._img_compression_method not in self._valid_compression_methods:
            raise CreatorError("Given disk image compression method ('%s') is not valid. Valid values are '%s'." % (self._img_compression_method, ' '.join(self._valid_compression_methods)))
Exemple #4
0
    def __init__(self, createopts=None, pkgmgr=None):
        """Initialize an ImageCreator instance.

        ks -- a pykickstart.KickstartParser instance; this instance will be
              used to drive the install by e.g. providing the list of packages
              to be installed, the system configuration and %post scripts

        name -- a name for the image; used for e.g. image filenames or
                filesystem labels
        """

        self.pkgmgr = pkgmgr

        self.__builddir = None
        self.__bindmounts = []

        # Eeach image type can change these values as they might be image type
        # specific
        if not hasattr(self, "_valid_compression_methods"):
            self._valid_compression_methods = ["bz2"]

        # The compression method for disk image.
        self._img_compression_method = None

        if createopts:
            # A pykickstart.KickstartParser instance."""
            self.ks = createopts["ks"]

            self.destdir = os.path.abspath(os.path.expanduser(createopts["outdir"]))

            # A name for the image."""
            self.name = createopts["name"]
            if createopts["release"]:
                self.name += "-" + createopts["release"]

                # check whether destine dir exist
                if os.path.exists(self.destdir):
                    if msger.ask("Image dir: %s already exists, cleanup and continue?" % self.destdir):
                        shutil.rmtree(self.destdir, ignore_errors=True)
                    else:
                        raise Abort("Canceled")

                # pending FEA: save log by default for --release

            # The directory in which all temporary files will be created."""
            self.tmpdir = createopts["tmpdir"]
            self.cachedir = createopts["cachedir"]
            self.target_arch = createopts["arch"]
            self._local_pkgs_path = createopts["local_pkgs_path"]
            self._img_compression_method = createopts["compress_disk_image"]

        else:
            self.ks = None
            self.name = "target"
            self.tmpdir = "/var/tmp/mic"
            self.cachedir = "/var/tmp/mic/cache"
            self.destdir = "."
            self.target_arch = "noarch"
            self._local_pkgs_path = None

        self._dep_checks = ["ls", "bash", "cp", "echo", "modprobe", "passwd"]

        # FIXME to be obsolete, make it configurable
        self.distro_name = "Tizen"

        # Output image file names
        self.outimage = []

        # A flag to generate checksum
        self._genchecksum = False

        self._alt_initrd_name = None

        self._recording_pkgs = []

        # available size in root fs, init to 0
        self._root_fs_avail = 0

        # Name of the disk image file that is created.
        self._img_name = None

        self.image_format = None

        # Save qemu emulator file name in order to clean up it finally
        self.qemu_emulator = None

        # No ks provided when called by convertor, so skip the dependency check
        if self.ks:
            # If we have btrfs partition we need to check that we have toosl for those
            for part in self.ks.handler.partition.partitions:
                if part.fstype and part.fstype == "btrfs":
                    self._dep_checks.append("mkfs.btrfs")
                    break

        if self.target_arch and self.target_arch.startswith("arm"):
            for dep in self._dep_checks:
                if dep == "extlinux":
                    self._dep_checks.remove(dep)

            if not os.path.exists("/usr/bin/qemu-arm") or not misc.is_statically_linked("/usr/bin/qemu-arm"):
                self._dep_checks.append("qemu-arm-static")

            if os.path.exists("/proc/sys/vm/vdso_enabled"):
                vdso_fh = open("/proc/sys/vm/vdso_enabled", "r")
                vdso_value = vdso_fh.read().strip()
                vdso_fh.close()
                if (int)(vdso_value) == 1:
                    msger.warning(
                        "vdso is enabled on your host, which might cause problems with arm emulations.\n"
                        "\tYou can disable vdso with following command before starting image build:\n"
                        "\techo 0 | sudo tee /proc/sys/vm/vdso_enabled"
                    )

        # make sure the specified tmpdir and cachedir exist
        if not os.path.exists(self.tmpdir):
            os.makedirs(self.tmpdir)
        if not os.path.exists(self.cachedir):
            os.makedirs(self.cachedir)

        if self._img_compression_method != None and self._img_compression_method not in self._valid_compression_methods:
            raise CreatorError(
                "Given disk image compression method ('%s') is not valid. Valid values are '%s'."
                % (self._img_compression_method, " ".join(self._valid_compression_methods))
            )
    def __init__(self, createopts = None, pkgmgr = None):
        """Initialize an ImageCreator instance.

        ks -- a pykickstart.KickstartParser instance; this instance will be
              used to drive the install by e.g. providing the list of packages
              to be installed, the system configuration and %post scripts

        name -- a name for the image; used for e.g. image filenames or
                filesystem labels
        """

        self.pkgmgr = pkgmgr

        self.__builddir = None
        self.__bindmounts = []

        self.ks = None
        self.name = "target"
        self.tmpdir = "/var/tmp/mic"
        self.cachedir = "/var/tmp/mic/cache"
        self.destdir = "."
        self.target_arch = "noarch"
        self._local_pkgs_path = None

        # If the kernel is save to the destdir when copy_kernel cmd is called.
        self._need_copy_kernel = False

        # The compression method for disk image.
        self._img_compression_method = None

        if createopts:
            # Mapping table for variables that have different names.
            optmap = {"pkgmgr" : "pkgmgr_name",
                      "outdir" : "destdir",
                      "arch" : "target_arch",
                      "local_pkgs_path" : "_local_pkgs_path",
                      "compress_disk_image" : "_img_compression_method",
                      "copy_kernel" : "_need_copy_kernel",
                     }
    
            # update setting from createopts
            for key in createopts.keys():
                if key in optmap:
                    option = optmap[key]
                else:
                    option = key
                setattr(self, option, createopts[key])

            self.destdir = os.path.abspath(os.path.expanduser(self.destdir))

            if 'release' in createopts and createopts['release']:
                self.name += '-' + createopts['release']

                if os.path.exists(self.destdir):
                    if msger.ask("Image dir: %s already exists, cleanup and" \
                                 "continue?" % self.destdir):
                        shutil.rmtree(self.destdir, ignore_errors = True)
                    else:
                        raise Abort("Canceled")

                    # pending FEA: save log by default for --release

        self._dep_checks = ["ls", "bash", "cp", "echo", "modprobe", "passwd"]

        # Output image file names
        self.outimage = []

        # A flag to generate checksum
        self._genchecksum = False

        self._alt_initrd_name = None

        self._recording_pkgs = []

        # available size in root fs, init to 0
        self._root_fs_avail = 0

        # Name of the disk image file that is created.
        self._img_name = None

        self.image_format = None

        # Save qemu emulator file name in order to clean up it finally
        self.qemu_emulator = None

        # No ks provided when called by convertor, so skip the dependency check
        if self.ks:
            # If we have btrfs partition we need to check that we have toosl for those
            for part in self.ks.handler.partition.partitions:
                if part.fstype and part.fstype == "btrfs":
                    self._dep_checks.append("mkfs.btrfs")
                    break

        if self.target_arch and self.target_arch.startswith("arm"):
            for dep in self._dep_checks:
                if dep == "extlinux":
                    self._dep_checks.remove(dep)

            if not os.path.exists("/usr/bin/qemu-arm") or \
               not misc.is_statically_linked("/usr/bin/qemu-arm"):
                self._dep_checks.append("qemu-arm-static")

            if os.path.exists("/proc/sys/vm/vdso_enabled"):
                vdso_fh = open("/proc/sys/vm/vdso_enabled","r")
                vdso_value = vdso_fh.read().strip()
                vdso_fh.close()
                if (int)(vdso_value) == 1:
                    msger.warning("vdso is enabled on your host, which might "
                        "cause problems with arm emulations.\n"
                        "\tYou can disable vdso with following command before "
                        "starting image build:\n"
                        "\techo 0 | sudo tee /proc/sys/vm/vdso_enabled")

        # make sure the specified tmpdir and cachedir exist
        if not os.path.exists(self.tmpdir):
            os.makedirs(self.tmpdir)
        if not os.path.exists(self.cachedir):
            os.makedirs(self.cachedir)

        if self._img_compression_method != None and \
           self._img_compression_method not in self.zips:
            raise CreatorError("Given disk image compression method ('%s') is "
                               "not valid. Valid values are: %s." \
                               % (self._img_compression_method,
                                  ', '.join(self.zips.keys())))
Exemple #6
0
    def __init__(self, createopts=None, pkgmgr=None):
        """Initialize an ImageCreator instance.

        ks -- a pykickstart.KickstartParser instance; this instance will be
              used to drive the install by e.g. providing the list of packages
              to be installed, the system configuration and %post scripts

        name -- a name for the image; used for e.g. image filenames or
                filesystem labels
        """

        self.pkgmgr = pkgmgr

        self.__builddir = None
        self.__bindmounts = []

        self.ks = None
        self.name = "target"
        self.tmpdir = "/var/tmp/mic"
        self.cachedir = "/var/tmp/mic/cache"
        self.destdir = "."
        self.target_arch = "noarch"
        self._local_pkgs_path = None

        # If the kernel is save to the destdir when copy_kernel cmd is called.
        self._need_copy_kernel = False

        # The compression method for disk image.
        self._img_compression_method = None

        if createopts:
            # Mapping table for variables that have different names.
            optmap = {
                "pkgmgr": "pkgmgr_name",
                "outdir": "destdir",
                "arch": "target_arch",
                "local_pkgs_path": "_local_pkgs_path",
                "compress_disk_image": "_img_compression_method",
                "copy_kernel": "_need_copy_kernel",
            }

            # update setting from createopts
            for key in createopts.keys():
                if key in optmap:
                    option = optmap[key]
                else:
                    option = key
                setattr(self, option, createopts[key])

            self.destdir = os.path.abspath(os.path.expanduser(self.destdir))

            if 'release' in createopts and createopts['release']:
                self.name += '-' + createopts['release']

                if os.path.exists(self.destdir):
                    if msger.ask("Image dir: %s already exists, cleanup and" \
                                 "continue?" % self.destdir):
                        shutil.rmtree(self.destdir, ignore_errors=True)
                    else:
                        raise Abort("Canceled")

                    # pending FEA: save log by default for --release

        self._dep_checks = ["ls", "bash", "cp", "echo", "modprobe", "passwd"]

        # Output image file names
        self.outimage = []

        # A flag to generate checksum
        self._genchecksum = False

        self._alt_initrd_name = None

        self._recording_pkgs = []

        # available size in root fs, init to 0
        self._root_fs_avail = 0

        # Name of the disk image file that is created.
        self._img_name = None

        self.image_format = None

        # Save qemu emulator file name in order to clean up it finally
        self.qemu_emulator = None

        # No ks provided when called by convertor, so skip the dependency check
        if self.ks:
            # If we have btrfs partition we need to check that we have toosl for those
            for part in self.ks.handler.partition.partitions:
                if part.fstype and part.fstype == "btrfs":
                    self._dep_checks.append("mkfs.btrfs")
                    break

        if self.target_arch and self.target_arch.startswith("arm"):
            for dep in self._dep_checks:
                if dep == "extlinux":
                    self._dep_checks.remove(dep)

            if not os.path.exists("/usr/bin/qemu-arm") or \
               not misc.is_statically_linked("/usr/bin/qemu-arm"):
                self._dep_checks.append("qemu-arm-static")

            if os.path.exists("/proc/sys/vm/vdso_enabled"):
                vdso_fh = open("/proc/sys/vm/vdso_enabled", "r")
                vdso_value = vdso_fh.read().strip()
                vdso_fh.close()
                if (int)(vdso_value) == 1:
                    msger.warning(
                        "vdso is enabled on your host, which might "
                        "cause problems with arm emulations.\n"
                        "\tYou can disable vdso with following command before "
                        "starting image build:\n"
                        "\techo 0 | sudo tee /proc/sys/vm/vdso_enabled")

        # make sure the specified tmpdir and cachedir exist
        if not os.path.exists(self.tmpdir):
            os.makedirs(self.tmpdir)
        if not os.path.exists(self.cachedir):
            os.makedirs(self.cachedir)

        if self._img_compression_method != None and \
           self._img_compression_method not in self.zips:
            raise CreatorError("Given disk image compression method ('%s') is "
                               "not valid. Valid values are: %s." \
                               % (self._img_compression_method,
                                  ', '.join(self.zips.keys())))