Esempio n. 1
0
def config_decide(option, secondary=None, appends=['--enable-', '--disable-']):
    result = []

    option = [o for o in option.split(" ") if o.strip().isalnum()]
    if secondary:
        secondary = [s for s in secondary.split(" ") if s.strip().isalnum()]

    def secondary_add(keyword):
        if secondary is None:
            result.append(keyword+single_opt)
        else:
            for sec in secondary:
                result.append(keyword+sec)
 
    for single_opt in option:
        if not single_opt in options:
            out.warn_notify("%s is an invalid option." % single_opt)
            continue
        
        if opt(single_opt):
            secondary_add(appends[0])
        else:
            secondary_add(appends[1])

    return " ".join(result)
Esempio n. 2
0
    def run_post_install(self):
        if self.environment.no_configure or self.environment.real_root != cst.root:
            out.warn_notify("skipping post_install function...")
            pkg_data = (self.environment.repo, self.environment.category, \
                    self.environment.name, self.environment.version)
            pending_file = os.path.join(self.environment.real_root,
                                        cst.configure_pending_file)
            shelltools.makedirs(os.path.dirname(pending_file))
            if not os.path.exists(pending_file):
                with open(pending_file, "wb") as _data:
                    pickle.dump([pkg_data], _data)
            else:
                data = []
                with open(pending_file, "rb") as _data:
                    pending_packages = pickle.load(_data)
                    if not pkg_data in pending_packages:
                        data.append(pkg_data)

                    data.extend(pending_packages)
                shelltools.remove_file(pending_file)
                with open(pending_file, "wb") as _data:
                    pickle.dump(data, _data)
            return

        # sandbox must be disabled
        self.environment.sandbox = False
        self.run_stage("post_install")
Esempio n. 3
0
    def run_configure(self):
        utils.xterm_title("(%s/%s) lpms: configuring %s/%s-%s from %s" %
                          (self.environment.index, self.environment.count,
                           self.environment.category, self.environment.name,
                           self.environment.version, self.environment.repo))

        out.normal("configuring source in %s" % self.environment.build_dir)

        configured_file = os.path.join(
            os.path.dirname(os.path.dirname(self.environment.build_dir)),
            ".configured")

        if os.path.isfile(configured_file) and self.environment.resume_build:
            out.warn_notify("%s had been already configured." %
                            self.environment.fullname)
            return True

        lpms.logger.info("configuring in %s" % self.environment.build_dir)

        self.run_stage("configure")
        out.notify("%s has been configured." % self.environment.fullname)

        if not os.path.isfile(configured_file):
            touch(configured_file)
        if self.environment.stage == "configure":
            lpms.terminate()
Esempio n. 4
0
    def run_post_install(self):
        if self.environment.no_configure or self.environment.real_root != cst.root:
            out.warn_notify("skipping post_install function...")
            pkg_data = (self.environment.repo, self.environment.category, \
                    self.environment.name, self.environment.version)
            pending_file = os.path.join(self.environment.real_root, cst.configure_pending_file)
            shelltools.makedirs(os.path.dirname(pending_file))
            if not os.path.exists(pending_file):
                with open(pending_file, "wb") as _data:
                    pickle.dump([pkg_data], _data)
            else:
                data = []
                with open(pending_file, "rb") as _data:
                    pending_packages = pickle.load(_data)
                    if not pkg_data in pending_packages:
                        data.append(pkg_data)

                    data.extend(pending_packages)
                shelltools.remove_file(pending_file)
                with open(pending_file, "wb") as _data:
                    pickle.dump(data, _data)
            return

        # sandbox must be disabled
        self.environment.sandbox = False
        self.run_stage("post_install")
Esempio n. 5
0
    def run_install(self):
        utils.xterm_title("(%s/%s) lpms: installing %s/%s-%s from %s" % (self.environment.index, self.environment.count, 
            self.environment.category, self.environment.name, self.environment.version, self.environment.repo))
        out.normal("installing %s to %s" % (self.environment.fullname, self.environment.install_dir))
        installed_file = os.path.join(os.path.dirname(os.path.dirname(
            self.environment.build_dir)), ".installed")

        if os.path.isfile(installed_file) and self.environment.resume_build:
            out.warn_notify("%s had been already installed." % self.environment.fullname)
            return True
        
        lpms.logger.info("installing to %s" % self.environment.build_dir)

        self.run_stage("install")
        if self.environment.docs is not None:
            for doc in self.environment.docs:
                if isinstance(doc, list) or isinstance(doc, tuple):
                    source_file, target_file = doc
                    namestr = self.environment.fullname if self.environment.slot != "0" else self.environment.name
                    target = self.environment.fix_target_path("/usr/share/doc/%s/%s" % (namestr, target_file))
                    source = os.path.join(self.environment.build_dir, source_file)
                #    self.environment.index, insfile(source, target)
                #else:
                #    self.environment.index, insdoc(doc)
        out.notify("%s has been installed." % self.environment.fullname)
        if not os.path.isfile(installed_file):
            touch(installed_file)
        if self.environment.stage == "install":
            lpms.terminate()
Esempio n. 6
0
 def run_prepare(self):
     out.normal("preparing source...")
     prepared_file = os.path.join(os.path.dirname(os.path.dirname(self.environment.build_dir)), ".prepared")
     if os.path.isfile(prepared_file):
         out.warn_notify("%s had been already prepared." % self.environment.fullname)
         return True
     self.run_stage("prepare")
     out.notify("%s has been prepared." % self.environment.fullname)
     if not os.path.isfile(prepared_file):
         touch(prepared_file)
     if self.environment.stage == "prepare":
         lpms.terminate()
Esempio n. 7
0
 def run_prepare(self):
     out.normal("preparing source...")
     prepared_file = os.path.join(
         os.path.dirname(os.path.dirname(self.environment.build_dir)),
         ".prepared")
     if os.path.isfile(prepared_file):
         out.warn_notify("%s had been already prepared." %
                         self.environment.fullname)
         return True
     self.run_stage("prepare")
     out.notify("%s has been prepared." % self.environment.fullname)
     if not os.path.isfile(prepared_file):
         touch(prepared_file)
     if self.environment.stage == "prepare":
         lpms.terminate()
Esempio n. 8
0
    def run_build(self):
        utils.xterm_title("(%s/%s) lpms: building %s/%s-%s from %s" % (self.environment.index, self.environment.count, 
            self.environment.category, self.environment.name, self.environment.version, self.environment.repo))
        out.normal("compiling source in %s" % self.environment.build_dir)
        built_file = os.path.join(os.path.dirname(os.path.dirname(
            self.environment.build_dir)), ".built")
        if os.path.isfile(built_file) and self.environment.resume_build:
            out.warn_notify("%s had been already built." % self.environment.fullname)
            return True
        
        lpms.logger.info("building in %s" % self.environment.build_dir)

        self.run_stage("build")
        out.notify("%s has been built." % self.environment.fullname)
        if not os.path.isfile(built_file):
            touch(built_file)
        if self.environment.stage == "build":
            lpms.terminate()
Esempio n. 9
0
    def run_install(self):
        utils.xterm_title("(%s/%s) lpms: installing %s/%s-%s from %s" %
                          (self.environment.index, self.environment.count,
                           self.environment.category, self.environment.name,
                           self.environment.version, self.environment.repo))
        out.normal("installing %s to %s" %
                   (self.environment.fullname, self.environment.install_dir))
        installed_file = os.path.join(
            os.path.dirname(os.path.dirname(self.environment.build_dir)),
            ".installed")

        if os.path.isfile(installed_file) and self.environment.resume_build:
            out.warn_notify("%s had been already installed." %
                            self.environment.fullname)
            return True

        lpms.logger.info("installing to %s" % self.environment.build_dir)

        self.run_stage("install")
        if self.environment.docs is not None:
            for doc in self.environment.docs:
                if isinstance(doc, list) or isinstance(doc, tuple):
                    source_file, target_file = doc
                    namestr = self.environment.fullname if self.environment.slot != "0" else self.environment.name
                    target = self.environment.fix_target_path(
                        "/usr/share/doc/%s/%s" % (namestr, target_file))
                    source = os.path.join(self.environment.build_dir,
                                          source_file)
                #    self.environment.index, insfile(source, target)
                #else:
                #    self.environment.index, insdoc(doc)
        out.notify("%s has been installed." % self.environment.fullname)
        if not os.path.isfile(installed_file):
            touch(installed_file)
        if self.environment.stage == "install":
            lpms.terminate()
Esempio n. 10
0
def binutils_cmd(command):
    """
    Checks a binutils command's existence
    """
    try:
        host = os.environ['HOST']
    except KeyError:
        out.warn_notify("HOST value does not defined in environment.")
        return ''

    cmd = "%s-%s" % (host, command)

    if not shelltools.binary_isexists(cmd):
        if not utils.check_path(command):
            out.warn_notify("%s not found." % command)
            return ''
        else:
            return command
        out.warn_notify("%s not found." % cmd)
        return ''

    return cmd
Esempio n. 11
0
    def perform_operation(self):
        '''Handles command line arguments and drive building operation'''
        self.set_environment_variables()
        # Check /proc and /dev. These filesystems must be mounted 
        # to perform operations properly.
        for item in ('/proc', '/dev'):
            if not os.path.ismount(item):
                out.warn("%s is not mounted. You have been warned." % item)

        # clean source code extraction directory if it is wanted
        # TODO: check the following condition when resume functionality is back
        if self.instruction.clean_tmp:
            if self.instruction.resume_build is not None:
                out.warn("clean-tmp is disabled because of resume-build is enabled.")
            else:
                self.clean_temporary_directory()

        # we want to save starting time of the build operation to calculate building time
        # The starting point of logging
        lpms.logger.info("starting build (%s/%s) %s/%s/%s-%s" % (
            self.instruction.index,
            self.instruction.count,
            self.internals.env.repo,
            self.internals.env.category,
            self.internals.env.name,
            self.internals.env.version
            )
        )

        out.normal("(%s/%s) building %s/%s from %s" % (
            self.instruction.index,
            self.instruction.count,
            out.color(self.internals.env.category, "green"),
            out.color(self.internals.env.name+"-"+self.internals.env.version, "green"),
            self.internals.env.repo
            )
        )

        if self.internals.env.sandbox:
            lpms.logger.info("sandbox enabled build")
            out.notify("sandbox is enabled")
        else:
            lpms.logger.warning("sandbox disabled build")
            out.warn_notify("sandbox is disabled")

        # fetch packages which are in download_plan list
        if self.internals.env.src_url is not None:
            # preprocess url shortcuts such as $name, $version and etc
            self.parse_src_url_field()
            # if the package is revisioned, override build_dir and install_dir. 
            # remove revision number from these variables.
            if self.revisioned:
                for variable in ("build_dir", "install_dir"):
                    new_variable = "".join(os.path.basename(getattr(self.internals.env, \
                            variable)).split(self.revision))
                    setattr(self.internals.env, variable, \
                            os.path.join(os.path.dirname(getattr(self.internals.env, \
                            variable)), new_variable))

            utils.xterm_title("lpms: downloading %s/%s/%s-%s" % (
                self.internals.env.repo,
                self.internals.env.category,
                self.internals.env.name,
                self.internals.env.version
                )
            )

            self.prepare_download_plan(self.internals.env.applied_options)

            if not fetcher.URLFetcher().run(self.download_plan):
                lpms.terminate("\nplease check the spec")

        if self.internals.env.applied_options is not None and self.internals.env.applied_options:
            out.notify("applied options: %s" %
                    " ".join(self.internals.env.applied_options))

        if self.internals.env.src_url is None and not self.extract_plan \
                and hasattr(self.internals.env, "extract"):
            # Workaround for #208
            self.internals.env.extract_nevertheless = True

        # Remove previous sandbox log if it is exist.
        if os.path.exists(cst.sandbox_log):
            shelltools.remove_file(cst.sandbox_log)

        # Enter the building directory
        os.chdir(self.internals.env.build_dir)

        # Manage ccache
        if hasattr(self.config, "ccache") and self.config.ccache:
            if utils.drive_ccache(config=self.config):
                out.notify("ccache is enabled.")
            else:
                out.warn("ccache could not be enabled. so you should check dev-util/ccache")

        self.internals.env.start_time = time.time()
        return True, self.internals.env
Esempio n. 12
0
    def perform_operation(self):
        '''Handles command line arguments and drive building operation'''
        self.set_environment_variables()
        # Check /proc and /dev. These filesystems must be mounted
        # to perform operations properly.
        for item in ('/proc', '/dev'):
            if not os.path.ismount(item):
                out.warn("%s is not mounted. You have been warned." % item)

        # clean source code extraction directory if it is wanted
        # TODO: check the following condition when resume functionality is back
        if self.instruction.clean_tmp:
            if self.instruction.resume_build is not None:
                out.warn(
                    "clean-tmp is disabled because of resume-build is enabled."
                )
            else:
                self.clean_temporary_directory()

        # we want to save starting time of the build operation to calculate building time
        # The starting point of logging
        lpms.logger.info("starting build (%s/%s) %s/%s/%s-%s" %
                         (self.instruction.index, self.instruction.count,
                          self.internals.env.repo, self.internals.env.category,
                          self.internals.env.name, self.internals.env.version))

        out.normal(
            "(%s/%s) building %s/%s from %s" %
            (self.instruction.index, self.instruction.count,
             out.color(self.internals.env.category, "green"),
             out.color(
                 self.internals.env.name + "-" + self.internals.env.version,
                 "green"), self.internals.env.repo))

        if self.internals.env.sandbox:
            lpms.logger.info("sandbox enabled build")
            out.notify("sandbox is enabled")
        else:
            lpms.logger.warning("sandbox disabled build")
            out.warn_notify("sandbox is disabled")

        # fetch packages which are in download_plan list
        if self.internals.env.src_url is not None:
            # preprocess url shortcuts such as $name, $version and etc
            self.parse_src_url_field()
            # if the package is revisioned, override build_dir and install_dir.
            # remove revision number from these variables.
            if self.revisioned:
                for variable in ("build_dir", "install_dir"):
                    new_variable = "".join(os.path.basename(getattr(self.internals.env, \
                            variable)).split(self.revision))
                    setattr(self.internals.env, variable, \
                            os.path.join(os.path.dirname(getattr(self.internals.env, \
                            variable)), new_variable))

            utils.xterm_title(
                "lpms: downloading %s/%s/%s-%s" %
                (self.internals.env.repo, self.internals.env.category,
                 self.internals.env.name, self.internals.env.version))

            self.prepare_download_plan(self.internals.env.applied_options)

            if not fetcher.URLFetcher().run(self.download_plan):
                lpms.terminate("\nplease check the spec")

        if self.internals.env.applied_options is not None and self.internals.env.applied_options:
            out.notify("applied options: %s" %
                       " ".join(self.internals.env.applied_options))

        if self.internals.env.src_url is None and not self.extract_plan \
                and hasattr(self.internals.env, "extract"):
            # Workaround for #208
            self.internals.env.extract_nevertheless = True

        # Remove previous sandbox log if it is exist.
        if os.path.exists(cst.sandbox_log):
            shelltools.remove_file(cst.sandbox_log)

        # Enter the building directory
        os.chdir(self.internals.env.build_dir)

        # Manage ccache
        if hasattr(self.config, "ccache") and self.config.ccache:
            if utils.drive_ccache(config=self.config):
                out.notify("ccache is enabled.")
            else:
                out.warn(
                    "ccache could not be enabled. so you should check dev-util/ccache"
                )

        self.internals.env.start_time = time.time()
        return True, self.internals.env
Esempio n. 13
0
def warn(msg):
    out.warn_notify(msg)