예제 #1
0
    def clone_from_xml(self, node):
        if (node.nodeType != node.ELEMENT_NODE or node.nodeName != self.name):
            raise utils.MuddleBug(
                "Invalid outer element for %s user instruction - %s" %
                (self.name, node))

        new_spec = None
        new_user = None
        new_group = None

        for c in node.childNodes:
            if (c.nodeType == c.ELEMENT_NODE):
                if (c.nodeName == filespec.proto.outer_elem_name()):
                    new_spec = filespec.proto.clone_from_xml(c)
                elif (c.nodeName == "user"):
                    new_user = utils.text_in_node(c)
                elif (c.nodeName == "group"):
                    new_group = utils.text_in_node(c)
                else:
                    raise utils.MuddleBug(
                        "Invalid element in %s instruction: %s" %
                        (self.name, c.nodeName))
        if (new_spec is None) or ((new_user is None) and (new_group is None)):
            raise utils.MuddleBug(
                "Either user/group or filespec is not specified in XML.")

        return ChangeUserInstruction(new_spec, new_user, new_group, self.name)
예제 #2
0
    def from_xml(self, xmlNode):
        n = xmlNode.nodeName

        if (n is None):
            raise utils.MuddleBug(
                "Attempt to initialise an instruction from %s which has no name."
                % (str(n)))

        # Otherwise ..
        if (n in self.instr_map):
            return self.instr_map[n].clone_from_xml(xmlNode)
        else:
            raise utils.MuddleBug("No instruction corresponding to tag %s" % n)
예제 #3
0
파일: pkg.py 프로젝트: crazyscot/muddle
    def build_label(self, builder, co_label):

        # Note that we don't in fact check that self.name matches (part of)
        # the checkout label we're building.

        target_tag = co_label.tag

        if (target_tag == utils.LabelTag.CheckedOut):
            self.vcs.checkout(builder, co_label)
            # For all intents and purposes, cloning is equivalent to pulling
            builder.db.just_pulled.add(co_label)
        elif (target_tag == utils.LabelTag.Pulled):
            if self.vcs.pull(builder, co_label):
                builder.db.just_pulled.add(co_label)
        elif (target_tag == utils.LabelTag.Merged):
            if self.vcs.merge(builder, co_label):
                builder.db.just_pulled.add(co_label)
        elif (target_tag == utils.LabelTag.ChangesCommitted):
            if self._checkout_is_checked_out(builder, co_label):
                self.vcs.commit(builder, co_label)
            else:
                print "Checkout %s has not been checked out - not commiting" % co_label
        elif (target_tag == utils.LabelTag.ChangesPushed):
            if self._checkout_is_checked_out(builder, co_label):
                self.vcs.push(builder, co_label)
            else:
                print "Checkout %s has not been checked out - not pushing" % co_label.name
        else:
            raise utils.MuddleBug("Attempt to build unknown tag %s " %
                                  target_tag + "in checkout %s." % co_label)

        return True
예제 #4
0
파일: pkg.py 프로젝트: crazyscot/muddle
 def build_label(self, builder, label):
     if (utils.arch_name() == self.arch):
         return self.underlying.build_label(builder, label)
     else:
         raise utils.MuddleBug(
             "Label %s cannot be built on this architecture (%s) - requires %s"
             % (label, utils.arch_name(), self.arch))
예제 #5
0
    def list_files_under(self, dir, recursively=False, vroot=None):
        """
        Return a list of the files under dir. If dir is not a directory,
        returns an empty list.

        The files are returned without 'dir', so::

            list_files_under("/fred/wombat", False)

        gives::

            [ "a", "b", "c" ]

        *not*::

            [ "/fred/wombat/a" .. ]

        whilst::

            list_files_under("/fred", True)

        gives::

            [ "wombat", "wombat/a", "wombat/b", "wombat/c" ]
        """
        raise utils.MuddleBug(
            "Cannot call FileSpecDataProvider.list_files_under() - "
            "try a subclass")
예제 #6
0
    def build_label(self, builder, label):
        """
        Build the relevant label. We'll assume that the
        checkout actually exists.
        """
        tag = label.tag

        self.ensure_dirs(builder, label)

        # XXX We have no way of remembering a checkout in a different domain
        # XXX (from the label we're building) so for the moment we won't even
        # XXX try...
        tmp = Label(utils.LabelType.Checkout, self.co, domain=label.domain)
        co_path = builder.db.get_checkout_path(tmp)
        with Directory(co_path):
            self._amend_env(co_path)

            makefile_name = deduce_makefile_name(self.makefile_name,
                                                 self.per_role_makefiles,
                                                 label.role)

            make_cmd = self._make_command(builder, makefile_name)

            if (tag == utils.LabelTag.PreConfig):
                # Preconfigure - nothing need be done
                pass
            elif (tag == utils.LabelTag.Configured):
                # We should probably do the configure thing ..
                if (self.has_make_config):
                    utils.run0(make_cmd + ["config"])
            elif (tag == utils.LabelTag.Built):
                utils.run0(make_cmd)
            elif (tag == utils.LabelTag.Installed):
                utils.run0(make_cmd + ["install"])
            elif (tag == utils.LabelTag.PostInstalled):
                if (self.rewriteAutoconf):
                    #print "> Rewrite autoconf for label %s"%(label)
                    obj_path = builder.package_obj_path(label)
                    #print ">obj_path = %s"%(obj_path)
                    if (self.execRelPath is None):
                        sendExecPrefix = None
                    else:
                        sendExecPrefix = os.path.join(obj_path,
                                                      self.execRelPath)

                    rewrite.fix_up_pkgconfig_and_la(builder,
                                                    obj_path,
                                                    execPrefix=sendExecPrefix)
            elif (tag == utils.LabelTag.Clean):
                utils.run0(make_cmd + ["clean"])
            elif (tag == utils.LabelTag.DistClean):
                utils.run0(make_cmd + ["distclean"])
            else:
                raise utils.MuddleBug("Invalid tag specified for "
                                      "MakePackage building %s" % (label))
예제 #7
0
파일: deb.py 프로젝트: crazyscot/muddle
    def build_label(self, builder, label):
        """
        Actually install the dev package.
        """
        self.ensure_dirs(builder, label)

        tag = label.tag

        if (tag == utils.LabelTag.PreConfig):
            # Nothing to do
            pass
        elif (tag == utils.LabelTag.Configured):
            pass
        elif (tag == utils.LabelTag.Built):
            pass
        elif (tag == utils.LabelTag.Installed):
            # Extract into /obj
            inv = builder
            extract_into_obj(inv, self.co_name, label, self.pkg_file)
            if (self.nonDevPkgFile is not None):
                extract_into_obj(inv, self.nonDevCoName, label,
                                 self.nonDevPkgFile)

            # Now we rewrite all the absolute links to be relative to the install
            # directory.
            rewrite_links(inv, label)

        elif (tag == utils.LabelTag.PostInstalled):
            if self.post_install_makefile is not None:
                inv = builder
                tmp = Label(utils.LabelType.Checkout,
                            self.co_name,
                            domain=label.domain)
                co_path = inv.checkout_path(tmp)
                with Directory(co_path):
                    utils.run0([
                        "make", "-f", self.post_install_makefile,
                        "%s-postinstall" % (label.name)
                    ])

            # .. and now we rewrite any pkgconfig etc. files left lying
            # about.
            obj_path = builder.package_obj_path(label)
            print "> Rewrite .pc and .la files in %s" % (obj_path)
            rewrite.fix_up_pkgconfig_and_la(builder, obj_path)

        elif (tag == utils.LabelTag.Clean or tag == utils.LabelTag.DistClean):
            # Just remove the object directory.
            inv = builder
            utils.recursively_remove(inv.package_obj_path(label))
        else:
            raise utils.MuddleBug("Invalid tag specified for deb pkg %s" %
                                  (label))
예제 #8
0
 def get_setvars_script(self, builder,  name, lang):
     """
     Write a setvars script in the chosen language.
     """
     if (lang == EnvLanguage.Sh):
         return self.get_setvars_sh(name)
     elif (lang == EnvLanguage.Python):
         return self.get_setvars_py(name)
     elif (lang == EnvLanguage.C):
         return self.get_setvars_c(builder, name)
     else:
         raise utils.MuddleBug("Can't write a setvars script for language %s"%lang)
예제 #9
0
    def append(self, other):
        # None just means 'don't append anything'
        if other is None:
            return

        if ((self.type == EnvExpr.StringType or
             self.type == EnvExpr.RefType) and
            type(other) == type(str())):
            self.values.append(other)
        elif (self.type == EnvExpr.CatType and
              (isinstance(other, EnvExpr))):
            self.values.append(other)
        else:
            raise utils.MuddleBug("Attempt to append"
                              " %s (type %s) to an EnvExpr of type %s"%(other,
                                                                        type(other),
                                                                        self.type))
예제 #10
0
    def goto_revision(self, revision, branch=None, repo=None, verbose=False):
        """
        Make the specified revision current.

        Note that this may leave the working data (the actual checkout
        directory) in an odd state, in which it is not sensible to
        commit, depending on the VCS and the revision.

        Will be called in the actual checkout's directory.

        Raises GiveUp if there is no such revision, or if branch is given.
        """
        if branch:
            raise utils.GiveUp("Subversion does not support branch (in the muddle sense), branch=%s"%branch)

        if not repo:
            raise utils.MuddleBug("Subversion needs a Repository instance to do goto_revision()");

        # Luckily, our pull method does more-or-less what we want
        repo = repo.copy_with_changed_revision(revision)
        self.pull(repo, None, verbose=verbose)
예제 #11
0
파일: deb.py 프로젝트: crazyscot/muddle
    def build_label(self, builder, label):
        """
        Build the relevant label.
        """

        self.ensure_dirs(builder, label)

        tag = label.tag

        if (tag == utils.LabelTag.PreConfig):
            # Nothing to do.
            pass
        elif (tag == utils.LabelTag.Configured):
            pass
        elif (tag == utils.LabelTag.Built):
            pass
        elif (tag == utils.LabelTag.Installed):
            # Concoct a suitable dpkg command.
            inv = builder

            # Extract into the object directory .. so I can depend on them later.
            # - actually, Debian packaging doesn't work like that. Rats.
            #  - rrw 2009-11-24
            #extract_into_obj(inv, self.co_name, label, self.pkg_file)

            inst_dir = inv.package_install_path(label)
            tmp = Label(utils.LabelType.Checkout,
                        self.co_name,
                        domain=label.domain)
            co_dir = inv.checkout_path(tmp)

            # Using dpkg doesn't work here for many reasons.
            dpkg_cmd = [
                "dpkg-deb", "-X",
                os.path.join(co_dir, self.pkg_file), inst_dir
            ]
            utils.run0(dpkg_cmd)

            # Pick up any instructions that got left behind
            instr_file = self.instr_name
            if (instr_file is None):
                instr_file = "%s.instructions.xml" % (label.name)

            instr_path = os.path.join(co_dir, instr_file)

            if (os.path.exists(instr_path)):
                # We have instructions ..
                ifile = db.InstructionFile(instr_path)
                ifile.get()
                builder.instruct(label.name, label.role, ifile)
        elif (tag == utils.LabelTag.PostInstalled):
            if self.post_install_makefile is not None:
                inv = builder
                tmp = Label(utils.LabelType.Checkout,
                            self.co_name,
                            domain=label.domain)
                co_path = inv.checkout_path(tmp)
                with Directory(co_path):
                    utils.run0([
                        "make", "-f", self.post_install_makefile,
                        "%s-postinstall" % label.name
                    ])
        elif (tag == utils.LabelTag.Clean
              or tag == utils.LabelTag.DistClean):  #
            inv = builder
            admin_dir = os.path.join(inv.package_obj_path(label))
            utils.recursively_remove(admin_dir)
        else:
            raise utils.MuddleBug("Invalid tag specified for deb pkg %s" %
                                  (label))
예제 #12
0
파일: pkg.py 프로젝트: crazyscot/muddle
 def build_label(self, builder, label):
     raise utils.MuddleBug("Attempt to build unknown label %s" % label)