diff options
author | Michael Opdenacker <michael.opdenacker@bootlin.com> | 2024-04-12 11:02:29 +0200 |
---|---|---|
committer | Richard Purdie <richard.purdie@linuxfoundation.org> | 2024-04-14 06:31:45 +0100 |
commit | 112a37e6a9ce095003228950962903eae46fc55e (patch) | |
tree | 02676d726d0b22e22fd1451ca38594a290f78cc5 /bitbake/lib/prserv/db.py | |
parent | 62a3a7172a0cf71889603698780a5911b7f84e36 (diff) | |
download | poky-112a37e6a9ce095003228950962903eae46fc55e.tar.gz |
bitbake: prserv: add extra requests
Useful for connecting a PR server to an upstream one
- "test-package" checks whether the specified package
version and arch is known in the database.
- "test-pr" checks a specified output hash is found in the database.
Otherwise it returns 'None' instead of a new value.
- "max-package-pr" returns the highest PR number for
(version, arch) entries in the database, and None if not found
Add new DB functions supporting the above, plus test_value()
which tells whether a given value is available for the specified
package and architecture.
(Bitbake rev: 0f1474a30f741b760ca81c19dd1d8f3bd5647251)
Signed-off-by: Michael Opdenacker <michael.opdenacker@bootlin.com>
Cc: Joshua Watt <JPEWhacker@gmail.com>
Cc: Tim Orling <ticotimo@gmail.com>
Cc: Thomas Petazzoni <thomas.petazzoni@bootlin.com>
Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
Diffstat (limited to 'bitbake/lib/prserv/db.py')
-rw-r--r-- | bitbake/lib/prserv/db.py | 46 |
1 files changed, 46 insertions, 0 deletions
diff --git a/bitbake/lib/prserv/db.py b/bitbake/lib/prserv/db.py index 7bc2b2dc2d..7c200602ed 100644 --- a/bitbake/lib/prserv/db.py +++ b/bitbake/lib/prserv/db.py | |||
@@ -78,6 +78,52 @@ class PRTable(object): | |||
78 | self.sync() | 78 | self.sync() |
79 | self.dirty = False | 79 | self.dirty = False |
80 | 80 | ||
81 | def test_package(self, version, pkgarch): | ||
82 | """Returns whether the specified package version is found in the database for the specified architecture""" | ||
83 | |||
84 | # Just returns the value if found or None otherwise | ||
85 | data=self._execute("SELECT value FROM %s WHERE version=? AND pkgarch=?;" % self.table, | ||
86 | (version, pkgarch)) | ||
87 | row=data.fetchone() | ||
88 | if row is not None: | ||
89 | return True | ||
90 | else: | ||
91 | return False | ||
92 | |||
93 | def test_value(self, version, pkgarch, value): | ||
94 | """Returns whether the specified value is found in the database for the specified package and architecture""" | ||
95 | |||
96 | # Just returns the value if found or None otherwise | ||
97 | data=self._execute("SELECT value FROM %s WHERE version=? AND pkgarch=? and value=?;" % self.table, | ||
98 | (version, pkgarch, value)) | ||
99 | row=data.fetchone() | ||
100 | if row is not None: | ||
101 | return True | ||
102 | else: | ||
103 | return False | ||
104 | |||
105 | def find_value(self, version, pkgarch, checksum): | ||
106 | """Returns the value for the specified checksum if found or None otherwise.""" | ||
107 | |||
108 | data=self._execute("SELECT value FROM %s WHERE version=? AND pkgarch=? AND checksum=?;" % self.table, | ||
109 | (version, pkgarch, checksum)) | ||
110 | row=data.fetchone() | ||
111 | if row is not None: | ||
112 | return row[0] | ||
113 | else: | ||
114 | return None | ||
115 | |||
116 | def find_max_value(self, version, pkgarch): | ||
117 | """Returns the greatest value for (version, pkgarch), or None if not found. Doesn't create a new value""" | ||
118 | |||
119 | data = self._execute("SELECT max(value) FROM %s where version=? AND pkgarch=?;" % (self.table), | ||
120 | (version, pkgarch)) | ||
121 | row = data.fetchone() | ||
122 | if row is not None: | ||
123 | return row[0] | ||
124 | else: | ||
125 | return None | ||
126 | |||
81 | def _get_value_hist(self, version, pkgarch, checksum): | 127 | def _get_value_hist(self, version, pkgarch, checksum): |
82 | data=self._execute("SELECT value FROM %s WHERE version=? AND pkgarch=? AND checksum=?;" % self.table, | 128 | data=self._execute("SELECT value FROM %s WHERE version=? AND pkgarch=? AND checksum=?;" % self.table, |
83 | (version, pkgarch, checksum)) | 129 | (version, pkgarch, checksum)) |