nicholasdavidson / pybit

Python Build Integration Toolkit - a distributed cross platform AMQP based build system
17 stars 5 forks source link

Add a blacklist of possible package names to be omitted from job list #104

Closed ghost closed 11 years ago

ghost commented 11 years ago

Currently, the subversion hook activates when any debian/changelog is modified but the package itself has no reasonable expectation of being buildable or no requirement for it to be built by pybit.

This table needs to be in the database with a web frontend to add records. Records need to include: package name (all packages which completely match this name are omitted), architecture (all packages which match this name are omitted from the job list for the specified architecture) and version (whether this should be versions older than specified or newer than specified needs to be decided). Only a package name is required, other fields are optional.

jamesbennet commented 11 years ago

Something like

controller.py

    def process_job(self, dist, architectures, version, name, suite, pkg_format, transport, commands = None) :
        try:
            # Look at blacklist, dont build excluded package names
            if name in self.db.get_blacklist(name):
                print "Name IS in blacklist " + str(name)
                return
            else:
                print "Name NOT in blacklist " + str(name)
        except Exception as e:
            print "Exception checking blacklist " + str(e)
            return
....................

db.py

    def get_blacklist(self)
        try:
            cur = self.conn.cursor(cursor_factory=psycopg2.extras.DictCursor)
            cur.execute("SELECT name FROM blacklist ORDER BY name")
            res = cur.fetchall()
            self.conn.commit()
            blacklist = []
            for i in res:
                blacklist.append(i['name'])
            cur.close()
            return blacklist
        except psycopg2.Error as e:
            self.conn.rollback()
            raise Exception("Error retrieving blacklist. Database error code: "  + str(e.pgcode) + " - Details: " + str(e.pgerror))
            return None
jamesbennet commented 11 years ago

Experimental support for blacklisting by name. Schema change

30b307f4b4eee2aa27d6f9bd76096bae5db83e81 and 57f2aeeb714af1fe58b9b26deaf661202cfc7357

jamesbennet commented 11 years ago

This needs testing. There should also be a change to hook? Also UI changes needed.

jamesbennet commented 11 years ago

Can also blacklist by VCS path as of r9c1a8febadf00547ba7eabfc207e5f2e61397867

We have a new table "Blacklist" with fields "field" and "regex". Blacklist is used internally by process_job() in controller to determine if certain packages are centrally blacklisted using regexes. If there is a match on the field in question , we will not build. process_job() is called by both the WebGUI and the Hook.

For example "name" and "(._-dev)" will mean we do not autobuild any development packages, while "vcsuri" and "(./users/*)" will block sources from locations such as /repo/users/jamesb/somebadcode

The controller log will print "BLACKLISTED! - [regex] matches [fieldname]:[data]" if a package is blacklisted.

A 403 will be returned, as well as a False, from process_job to its caller (previously it returned void whatever)

Documented at https://github.com/nicholasdavidson/pybit/wiki/Blacklisting-packages.