Пример #1
0
    def _buildhistory_is_enabled(self):
        enabled = False

        if settings.get("buildhistory", "no") == "yes":
            if 'buildhistory' in self.base_env['INHERIT']:
                if not 'BUILDHISTORY_COMMIT' in self.base_env:
                    E(" Buildhistory was INHERIT in conf/local.conf"\
                      " but need BUILDHISTORY_COMMIT=1 please set.")
                    exit(1)

                if not self.base_env['BUILDHISTORY_COMMIT'] == '1':
                    E(" Buildhistory was INHERIT in conf/local.conf"\
                      " but need BUILDHISTORY_COMMIT=1 please set.")
                    exit(1)

                if self.opts['skip_compilation']:
                    W(" Buildhistory disabled because user" \
                            " skip compilation!")
                else:
                    enabled = True
            else:
                E(" Buildhistory was enabled in upgrade-helper.conf"\
                  " but isn't INHERIT in conf/local.conf, if you want"\
                  " to enable please set.")
                exit(1)
        else:
            if 'buildhistory' in self.base_env['INHERIT']:
                E(" Buildhistory was INHERIT in conf/local.conf"\
                  " but buildhistory=yes isn't in upgrade-helper.conf,"\
                  " if you want to enable please set.")
                exit(1)

        return enabled
Пример #2
0
def compile(bb, git, opts, pkg_ctx):
    if opts['skip_compilation']:
        W(" %s: Compilation was skipped by user choice!")
        return

    for machine in opts['machines']:
        I(" %s: compiling for %s ..." % (pkg_ctx['PN'], machine))
        pkg_ctx['recipe'].compile(machine)
        if opts['buildhistory']:
            pkg_ctx['buildhistory'].add()
Пример #3
0
def compile(devtool, bb, git, opts, pkg_ctx):
    if opts['skip_compilation']:
        W(" %s: Compilation was skipped by user choice!")
        return

    for machine in opts['machines']:
        I(" %s: compiling upgraded version for %s ..." %
          (pkg_ctx['PN'], machine))
        _compile(bb, pkg_ctx['PN'], machine, pkg_ctx['workdir'])
        if opts['buildhistory']:
            pkg_ctx['buildhistory'].add()
Пример #4
0
def pack_original_workdir(bb, git, opts, pkg_ctx):
    recipe_workdir = os.path.dirname(pkg_ctx['env']['S'])
    pkg_ctx['recipe_workdir_tarball'] = os.path.join(
        pkg_ctx['workdir'], 'original_workdir.tar.gz')

    try:
        subprocess.call([
            "tar", "-chzf", pkg_ctx['recipe_workdir_tarball'], recipe_workdir
        ],
                        stdout=subprocess.PIPE,
                        stderr=subprocess.PIPE)
    except:
        W(" %s, Can't compress original workdir, if license diff" \
          " is needed will show full file." % pkg_ctx['PN'])
Пример #5
0
    def send_status_mail(self, statistics_summary):
        if "status_recipients" not in settings:
            E(" Could not send status email, no recipients set!")
            return -1

        to_list = settings["status_recipients"].split()

        if self.opts['layer_mode'] == 'yes':
            subject = "[AUH] Upgrade status %s: %s" \
                    % (self.opts['layer_name'], date.isoformat(date.today()))
        else:
            subject = "[AUH] Upgrade status: " + date.isoformat(date.today())

        if self.statistics.total_attempted:
            self.email_handler.send_email(to_list, subject, statistics_summary)
        else:
            W("No recipes attempted, not sending status mail!")
Пример #6
0
    def diff(self):
        rev_initial = self.revs[0]
        rev_final = self.revs[-1]

        try:
            cmd = "buildhistory-diff -p %s %s %s"  % (self.buildhistory_dir, 
                rev_initial, rev_final)
            stdout, stderr = bb.process.run(cmd)
            if stdout and os.path.exists(self.workdir):
                with open(os.path.join(self.workdir, "buildhistory-diff.txt"),
                        "w+") as log:
                    log.write(stdout)

            cmd_full = "buildhistory-diff -a -p %s %s %s"  % (self.buildhistory_dir, 
                        rev_initial, rev_final)
            stdout, stderr = bb.process.run(cmd_full)
            if stdout and os.path.exists(self.workdir):
                with open(os.path.join(self.workdir, "buildhistory-diff-full.txt"),
                        "w+") as log:
                    log.write(stdout)
        except bb.process.ExecutionError as e:
            W( "%s: Buildhistory checking fails\n%s" % (self.pn, e.stdout))
Пример #7
0
def load_env(bb, git, opts, pkg_ctx):
    stdout = git.status()
    if stdout != "":
        if opts['interactive']:
            W(" %s: git repository has uncommited work which will be dropped!" \
                    " Proceed? (y/N)" % pkg_ctx['PN'])
            answer = sys.stdin.readline().strip().upper()
            if answer == '' or answer != 'Y':
                I(" %s: User abort!" % pkg_ctx['PN'])
                exit(1)

        I(" %s: Dropping uncommited work!" % pkg_ctx['PN'])
        git.reset_hard()
        git.clean_untracked()

    pkg_ctx['env'] = bb.env(pkg_ctx['PN'])
    pkg_ctx['workdir'] = os.path.join(pkg_ctx['base_dir'], pkg_ctx['PN'])
    os.mkdir(pkg_ctx['workdir'])
    pkg_ctx['recipe_dir'] = os.path.dirname(pkg_ctx['env']['FILE'])

    if pkg_ctx['env']['PV'] == pkg_ctx['NPV']:
        raise UpgradeNotNeededError
Пример #8
0
    def compile(self, machine):
        try:
            self.bb.complete(self.env['PN'], machine)
            if self.removed_patches:
                # move temporary changes into upgrades branch
                self.git.checkout_branch("upgrades")
                self.git.delete_branch("comment_patches")
                self.git.reset_soft(1)
                self.commit_msg += self.comment_patches_msg + "\n"
                self.removed_patches = False
        except Error as e:
            if self._is_incompatible_host(e.stdout):
                W(" %s: compilation failed: incompatible host" %
                  self.env['PN'])
                return
            machine, failed_recipes = self._get_failed_recipes(e.stdout)
            if not self.env['PN'] in failed_recipes:
                if not self._clean_failed_recipes(failed_recipes):
                    self._undo_temporary()
                    raise CompilationError()

                # retry
                self.compile(machine)
            else:
                failed_task = failed_recipes[self.env['PN']][0]
                log_file = failed_recipes[self.env['PN']][1]
                if failed_task == "do_patch":

                    # Comment one patch after the other until
                    # compilation works.
                    if not self.removed_patches:
                        self.git.commit("temporary")
                        self.git.create_branch("comment_patches")
                        self.git.checkout_branch("comment_patches")
                        self.removed_patches = True

                    if not self._comment_faulty_patch(log_file):
                        self._undo_temporary()
                        raise PatchError()

                    # retry
                    I(" %s: Recompiling for %s ..." %
                      (self.env['PN'], machine))
                    self.compile(machine)
                elif failed_task == "do_configure":
                    self._undo_temporary()
                    if not self._is_license_issue(log_file):
                        raise ConfigureError()

                    if not self._license_issue_handled(log_file):
                        raise LicenseError()
                    #retry
                    self.compile(machine)
                elif failed_task == "do_fetch":
                    raise FetchError()
                elif failed_task == "do_package":
                    raise PackageError()
                    #if self._add_not_shipped(log_file):
                    #    self.compile(machine)
                    #else:
                else:
                    self._undo_temporary()
                    # throw a compilation exception for everything else. It
                    # doesn't really matter
                    raise CompilationError()
Пример #9
0
    def _license_issue_handled(self, config_log):
        @modify_recipe_files
        def _update_license_checksum(line, temp_recipe, *args, **kwargs):
            d = args[0]
            m = re.match("(.*)" + d['old_md5'] + "(.*)", line)
            if m is not None:
                temp_recipe.write(
                    m.group(1) + d['new_md5'] + m.group(2) + "\n")
            else:
                temp_recipe.write(line)

        license_file = None
        with open(config_log) as log:
            for line in log:
                if not line.startswith("ERROR:"):
                    continue
                m_old = re.match(
                    "ERROR: " + self.env['PN'] +
                    "[^:]*: md5 data is not matching for file://([^;]*);md5=(.*)$",
                    line)
                if not m_old:
                    m_old = re.match(
                        "ERROR: " + self.env['PN'] +
                        "[^:]*: md5 data is not matching for file://([^;]*);beginline=[0-9]*;endline=[0-9]*;md5=(.*)$",
                        line)
                if not m_old:
                    m_old = re.match(
                        "ERROR: " + self.env['PN'] +
                        "[^:]*: md5 data is not matching for file://([^;]*);endline=[0-9]*;md5=(.*)$",
                        line)
                if not m_old:
                    m_old = re.match(
                        "ERROR: " + self.env['PN'] +
                        "[^:]*: md5 data is not matching for file://([^;]*);beginline=[0-9]*;md5=(.*)$",
                        line)
                m_new = re.match(
                    "ERROR: " + self.env['PN'] +
                    "[^:]*: The new md5 checksum is (.*)", line)
                if m_old:
                    license_file = m_old.group(1)
                    old_md5 = m_old.group(2)
                elif m_new:
                    new_md5 = m_new.group(1)

        if license_file is not None:
            d = {}
            d['old_md5'] = old_md5
            d['new_md5'] = new_md5
            _update_license_checksum(self.env, self.recipe_dir, d)

            self.create_diff_file(license_file, old_md5, new_md5)
            self.license_diff_file = os.path.join(
                self.workdir, os.path.basename(license_file + ".diff"))

            if self.interactive:
                W("  %s: license checksum failed for file %s. The recipe has"
                  "been updated! View diff? (Y/n)" %
                  (self.env['PN'], license_file))
                answer = sys.stdin.readline().strip().upper()
                if answer == '' or answer == 'Y':
                    I(" ################ Licence file diff #################")
                    with open(self.license_diff_file) as diff:
                        I("%s" % diff.read())
                    I(" ####################################################")
                I(" Retry compilation? (Y/n)")
                answer = sys.stdin.readline().strip().upper()
                if answer == '' or answer == 'Y':
                    return True
            else:
                W(" %s: license checksum failed for file %s."
                  " The recipe has been updated! Diff file located at %s" %
                  (self.env['PN'], license_file, self.license_diff_file))
                I(" Recompiling ...")
                self.commit_msg += "License checksum changed for file " + license_file
                return True

        return False