diff options
author | Michael Opdenacker <michael.opdenacker@bootlin.com> | 2024-05-11 16:31:34 +0530 |
---|---|---|
committer | Richard Purdie <richard.purdie@linuxfoundation.org> | 2024-05-21 14:23:43 +0100 |
commit | ae0725577dfcfbe3a439c6bebd114f677e4b5081 (patch) | |
tree | be013b499e2114e84abc4f127582867543dc9330 /bitbake/lib/prserv/db.py | |
parent | 3be2201de538a484e94ba91356a2fbe121a53308 (diff) | |
download | poky-ae0725577dfcfbe3a439c6bebd114f677e4b5081.tar.gz |
bitbake: prserv: import simplification
Simplify the importone() hook:
- to make it independent from the "history" mode which is
client specific.
- remove the "history" parameter
- we want all values to be imported for binary
reproducibility purposes.
- using the store_value() function (which warrants
you don't save the same value twice and doesn't write
when you're using a read-only server) is enough.
(Bitbake rev: 000704a53470ab1ead840403b5531f22ebf1fd49)
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 | 64 |
1 files changed, 3 insertions, 61 deletions
diff --git a/bitbake/lib/prserv/db.py b/bitbake/lib/prserv/db.py index 88ed8e2125..2da493ddf5 100644 --- a/bitbake/lib/prserv/db.py +++ b/bitbake/lib/prserv/db.py | |||
@@ -192,67 +192,9 @@ class PRTable(object): | |||
192 | self.store_value(version, pkgarch, checksum, value) | 192 | self.store_value(version, pkgarch, checksum, value) |
193 | return value | 193 | return value |
194 | 194 | ||
195 | def _import_hist(self, version, pkgarch, checksum, value): | 195 | def importone(self, version, pkgarch, checksum, value): |
196 | if self.read_only: | 196 | self.store_value(version, pkgarch, checksum, value) |
197 | return None | 197 | return value |
198 | |||
199 | val = None | ||
200 | with closing(self.conn.cursor()) as cursor: | ||
201 | data = cursor.execute("SELECT value FROM %s WHERE version=? AND pkgarch=? AND checksum=?;" % self.table, | ||
202 | (version, pkgarch, checksum)) | ||
203 | row = data.fetchone() | ||
204 | if row is not None: | ||
205 | val=row[0] | ||
206 | else: | ||
207 | #no value found, try to insert | ||
208 | try: | ||
209 | cursor.execute("INSERT INTO %s VALUES (?, ?, ?, ?);" % (self.table), | ||
210 | (version, pkgarch, checksum, value)) | ||
211 | except sqlite3.IntegrityError as exc: | ||
212 | logger.error(str(exc)) | ||
213 | |||
214 | self.conn.commit() | ||
215 | |||
216 | data = cursor.execute("SELECT value FROM %s WHERE version=? AND pkgarch=? AND checksum=?;" % self.table, | ||
217 | (version, pkgarch, checksum)) | ||
218 | row = data.fetchone() | ||
219 | if row is not None: | ||
220 | val = row[0] | ||
221 | return val | ||
222 | |||
223 | def _import_no_hist(self, version, pkgarch, checksum, value): | ||
224 | if self.read_only: | ||
225 | return None | ||
226 | |||
227 | with closing(self.conn.cursor()) as cursor: | ||
228 | try: | ||
229 | #try to insert | ||
230 | cursor.execute("INSERT INTO %s VALUES (?, ?, ?, ?);" % (self.table), | ||
231 | (version, pkgarch, checksum, value)) | ||
232 | except sqlite3.IntegrityError as exc: | ||
233 | #already have the record, try to update | ||
234 | try: | ||
235 | cursor.execute("UPDATE %s SET value=? WHERE version=? AND pkgarch=? AND checksum=? AND value<?" | ||
236 | % (self.table), | ||
237 | (value, version, pkgarch, checksum, value)) | ||
238 | except sqlite3.IntegrityError as exc: | ||
239 | logger.error(str(exc)) | ||
240 | |||
241 | self.conn.commit() | ||
242 | |||
243 | data = cursor.execute("SELECT value FROM %s WHERE version=? AND pkgarch=? AND checksum=? AND value>=?;" % self.table, | ||
244 | (version, pkgarch, checksum, value)) | ||
245 | row=data.fetchone() | ||
246 | if row is not None: | ||
247 | return row[0] | ||
248 | else: | ||
249 | return None | ||
250 | |||
251 | def importone(self, version, pkgarch, checksum, value, history=False): | ||
252 | if history: | ||
253 | return self._import_hist(version, pkgarch, checksum, value) | ||
254 | else: | ||
255 | return self._import_no_hist(version, pkgarch, checksum, value) | ||
256 | 198 | ||
257 | def export(self, version, pkgarch, checksum, colinfo, history=False): | 199 | def export(self, version, pkgarch, checksum, colinfo, history=False): |
258 | metainfo = {} | 200 | metainfo = {} |