Ejemplo n.º 1
0
def upgrade_from_batch(r, b):
    f = chroot.popen("rpm --test -F %s 2>&1" % string.join(b.files), user = "******")
    killset = {}
    rx = re.compile(r' \(installed\) (?P<name>[^\s]+)-[^-]+-[^-]+$')
    for l in f.xreadlines():
        m = rx.search(l)
        if m: killset[m.group('name')] = 1
    f.close()
    if len(killset) != 0:
        err = close_killset(killset)
        if err != "":
            util.append_to(b.logfile, err)
            log.notice("cannot upgrade rpms")
            return False
        k = string.join(killset.keys())
        if True:
            b.log_line("upgrade requires removal of %s" % k)
            res = chroot.run("rpm -e %s" % k, logfile = b.logfile, user = "******")
            if res != 0:
                b.log_line("package removal failed")
                return False
            else:
                b.log_line("packages removed sucessfuly")
        else:
            b.log_line("upgrade would need removal of %s" % k)
            return False
    b.log_line("upgrading packages")
    logbuf = StringIO.StringIO()
    res = chroot.run("rpm -Fvh %s" % string.join(b.files), user = "******", logfile = b.logfile)
    if res != 0:
        b.log_line("package upgrade failed")
        logbuf.close()
        return False
    logbuf.close()
    return True
Ejemplo n.º 2
0
def uninstall(conflicting, b):
    b.log_line("uninstalling conflicting packages")
    err = close_killset(conflicting)
    if err != "":
        util.append_to(b.logfile, err)
        b.log_line("error: conflicting packages uninstallation failed")
        return False
    else:
        for k in conflicting.keys():
            b.log_line("removing %s" % k)
            res = chroot.run("poldek --noask --erase %s" % k, logfile = b.logfile, user = "******")
            if res != 0:
                b.log_line("package %s removal failed" % k)
    return True
Ejemplo n.º 3
0
def uninstall(conflicting, b):
    b.log_line("uninstalling conflicting packages")
    err = close_killset(conflicting)
    if err != "":
        util.append_to(b.logfile, err)
        b.log_line("error: conflicting packages uninstallation failed")
        return False
    else:
        for k in conflicting.keys():
            b.log_line("removing %s" % k)
            res = chroot.run("poldek --noask --erase %s" % k,
                             logfile=b.logfile,
                             user="******")
            if res != 0:
                b.log_line("package %s removal failed" % k)
    return True
Ejemplo n.º 4
0
def handle_reqs(builder, reqs):
    qpath = path.queue_file + "-" + builder
    if not os.access(qpath, os.F_OK):
        util.append_to(qpath, "<queue/>\n")
    q = B_Queue(qpath)
    q.lock(0)
    q.read()
    for r in reqs:
        if r.kind != 'group':
            raise Exception, 'handle_reqs: fatal: huh? %s' % r.kind
        need_it = 0
        for b in r.batches:
            if builder in b.builders:
                need_it = 1
        if need_it:
            log.notice("queued %s (%d) for %s" % (r.id, r.no, builder))
            q.add(r)
    q.write()
    q.unlock()
Ejemplo n.º 5
0
def handle_reqs(builder, reqs):
    qpath = path.queue_file + "-" + builder
    if not os.access(qpath, os.F_OK):
        util.append_to(qpath, "<queue/>\n")
    q = B_Queue(qpath)
    q.lock(0)
    q.read()
    for r in reqs:
        if r.kind != 'group':
            raise Exception, 'handle_reqs: fatal: huh? %s' % r.kind
        need_it = 0
        for b in r.batches:
            if builder in b.builders:
                need_it = 1
        if need_it:
            log.notice("queued %s (%d) for %s" % (r.id, r.no, builder))
            q.add(r)
    q.write()
    q.unlock()
Ejemplo n.º 6
0
def upgrade_from_batch(r, b):
    f = chroot.popen("rpm --test -F %s 2>&1" % string.join(b.files),
                     user="******")
    killset = {}
    rx = re.compile(r' \(installed\) (?P<name>[^\s]+)-[^-]+-[^-]+$')
    for l in f.xreadlines():
        m = rx.search(l)
        if m: killset[m.group('name')] = 1
    f.close()
    if len(killset) != 0:
        err = close_killset(killset)
        if err != "":
            util.append_to(b.logfile, err)
            log.notice("cannot upgrade rpms")
            return False
        k = string.join(killset.keys())
        if True:
            b.log_line("upgrade requires removal of %s" % k)
            res = chroot.run("rpm -e %s" % k, logfile=b.logfile, user="******")
            if res != 0:
                b.log_line("package removal failed")
                return False
            else:
                b.log_line("packages removed sucessfuly")
        else:
            b.log_line("upgrade would need removal of %s" % k)
            return False
    b.log_line("upgrading packages")
    logbuf = StringIO.StringIO()
    res = chroot.run("rpm -Fvh %s" % string.join(b.files),
                     user="******",
                     logfile=b.logfile)
    if res != 0:
        b.log_line("package upgrade failed")
        logbuf.close()
        return False
    logbuf.close()
    return True
Ejemplo n.º 7
0
def build_srpm(r, b):
    if len(b.spec) <= len('.spec'):
        # should not really get here
        util.append_to(b.logfile,
                       "error: No .spec given but build src.rpm wanted")
        return "FAIL"

    status.push("building %s" % b.spec)
    #    messagebus.notify(topic="build_srpm.start", spec=b.spec, flags=r.flags, batch=b, request=r)

    b.src_rpm = ""
    builder_opts = "-nu -nm --nodeps --http --define \'_pld_builder 1\'"
    if ("test-build" in r.flags):
        tag_test = ""
    else:
        tag_test = " -Tp %s -tt" % (config.tag_prefixes[0], )
    cmd = (
        "cd rpm/packages; nice -n %s ./builder %s -bs %s -r %s %s %s %s %s 2>&1"
        % (config.nice, builder_opts, b.bconds_string(), b.branch, tag_test,
           b.kernel_string(), b.defines_string(), b.spec))
    util.append_to(b.logfile, "request from: %s" % r.requester)
    util.append_to(b.logfile, "started at: %s" % time.asctime())
    util.append_to(b.logfile, "building SRPM using: %s\n" % cmd)
    res = chroot.run(cmd, logfile=b.logfile)
    util.append_to(b.logfile, "exit status %d" % res)
    files = util.collect_files(b.logfile)
    if len(files) > 0:
        if len(files) > 1:
            util.append_to(b.logfile,
                           "error: More than one file produced: %s" % files)
            res = "FAIL_TOOMANYFILES"
        last = files[len(files) - 1]
        b.src_rpm_file = last
        b.src_rpm = os.path.basename(last)
        r.chroot_files.extend(files)
    else:
        util.append_to(b.logfile, "error: No files produced.")
        res = "FAIL"
    if res == 0 and not "test-build" in r.flags:
        for pref in config.tag_prefixes:
            util.append_to(b.logfile, "Tagging with prefix: %s" % pref)
            res = chroot.run("cd rpm/packages; ./builder -bs %s -r %s -Tp %s -Tv %s %s" % \
                        (b.bconds_string(), b.branch, pref, b.defines_string(), b.spec), logfile = b.logfile)
    if res == 0:
        transfer_file(r, b)

    packagename = b.spec[:-5]
    packagedir = "rpm/packages/%s" % packagename
    chroot.run("rpm/packages/builder -m %s" % \
            (b.spec,), logfile = b.logfile)
    chroot.run("rm -rf %s" % packagedir, logfile=b.logfile)
    status.pop()

    if res:
        res = "FAIL"


#    messagebus.notify(topic="build_srpm.finish", spec=b.spec)
    return res
Ejemplo n.º 8
0
def build_srpm(r, b):
    if len(b.spec) <= len('.spec'):
        # should not really get here
        util.append_to(b.logfile, "error: No .spec given but build src.rpm wanted")
        return "FAIL"

    status.push("building %s" % b.spec)

    b.src_rpm = ""
    builder_opts = "-nu -nm --nodeps --http"
    if ("test-build" in r.flags):
                    tag_test=""
    else:
                    tag_test=" -Tp %s -tt" % (config.tag_prefixes[0],)
    cmd = ("cd rpm/packages; nice -n %s ./builder %s -bs %s -r %s %s %s %s %s 2>&1" %
             (config.nice, builder_opts, b.bconds_string(), b.branch,
              tag_test, b.kernel_string(), b.defines_string(), b.spec))
    util.append_to(b.logfile, "request from: %s" % r.requester)
    util.append_to(b.logfile, "started at: %s" % time.asctime())
    util.append_to(b.logfile, "building SRPM using: %s\n" % cmd)
    res = chroot.run(cmd, logfile = b.logfile)
    util.append_to(b.logfile, "exit status %d" % res)
    files = util.collect_files(b.logfile)
    if len(files) > 0:
        if len(files) > 1:
            util.append_to(b.logfile, "error: More than one file produced: %s" % files)
            res = "FAIL_TOOMANYFILES"
        last = files[len(files) - 1]
        b.src_rpm_file = last
        b.src_rpm = os.path.basename(last)
        r.chroot_files.extend(files)
    else:
        util.append_to(b.logfile, "error: No files produced.")
        res = "FAIL"
    if res == 0 and not "test-build" in r.flags:
        for pref in config.tag_prefixes:
            util.append_to(b.logfile, "Tagging with prefix: %s" % pref)
            res = chroot.run("cd rpm/packages; ./builder -r %s -Tp %s -Tv %s" % \
                        (b.branch, pref, b.spec), logfile = b.logfile)
    if res == 0:
        transfer_file(r, b)

    packagename = b.spec[:-5]
    packagedir = "rpm/packages/%s" % packagename
    chroot.run("rpm/packages/builder -m %s" % \
            (b.spec,), logfile = b.logfile)
    chroot.run("rm -rf %s" % packagedir, logfile = b.logfile)
    status.pop()

    if res:
        res = "FAIL"
    return res
Ejemplo n.º 9
0
 def ll(l):
     util.append_to(b.logfile, l)
Ejemplo n.º 10
0
 def log_line(self, l):
     log.notice(l)
     if self.logfile != None:
         util.append_to(self.logfile, l)
Ejemplo n.º 11
0
 def ll(l):
     util.append_to(b.logfile, l)
Ejemplo n.º 12
0
 def log_line(self, l):
     log.notice(l)
     if self.logfile != None:
         util.append_to(self.logfile, l)