summaryrefslogtreecommitdiffstats
path: root/scripts/rpm-createsolvedb.py
diff options
context:
space:
mode:
authorRichard Purdie <richard.purdie@linuxfoundation.org>2012-02-09 14:09:18 +0000
committerRichard Purdie <richard.purdie@linuxfoundation.org>2012-04-30 11:37:30 +0100
commit4a0c704c803d927fc8c5574453c8e37b838af8b2 (patch)
tree57213863747b03ddf318a2102cf09403762d5733 /scripts/rpm-createsolvedb.py
parent53cf1a8977691827ace66ecc4aa5bf4b4a13d9f1 (diff)
downloadpoky-4a0c704c803d927fc8c5574453c8e37b838af8b2.tar.gz
package_rpm: Only rebuild the indexes if the packages have changed
This change farms the solvedb creation out to a separate script which handles creation of the index, only if mtime of any of the packages has changed. For a core-image-minimal set of rpm's this saves ~20s of a 45s rootfs build. For core-image-sato it saves 1 minute of a 5 minute rootfs build. The more packages in the system, the bigger the saving will be. (From OE-Core rev: 3021136e7b42ab64ca16f30c88467c4b00d51ee0) Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
Diffstat (limited to 'scripts/rpm-createsolvedb.py')
-rwxr-xr-xscripts/rpm-createsolvedb.py63
1 files changed, 63 insertions, 0 deletions
diff --git a/scripts/rpm-createsolvedb.py b/scripts/rpm-createsolvedb.py
new file mode 100755
index 0000000000..0d5f2198a9
--- /dev/null
+++ b/scripts/rpm-createsolvedb.py
@@ -0,0 +1,63 @@
1#!/usr/bin/env python
2#
3# This script generates a solution database for a directory containing rpm packages
4# but tries to be efficient about this, only doing so when the packages have changed
5# in some way.
6#
7# It is assumed something already went through and removed all the solvedb.done stamp files
8# in advance.
9#
10# First argument - the rpm binary to use
11# Subsequent arguments - paths to process solution databases for
12#
13
14import sys, os
15import hashlib
16import stat
17
18if len(sys.argv) < 1:
19 print("Error, rpm command not specified")
20 sys.exit(1)
21
22if len(sys.argv) < 2:
23 print("Error, no paths specified")
24 sys.exit(1)
25
26paths = sys.argv[2:]
27
28for path in paths:
29 if os.path.exists(path + "/solvedb.done"):
30 continue
31 data = ""
32 manifest = []
33 for root, dirs, files in os.walk(path):
34 for file in files:
35 f = os.path.join(root, file)
36 if f.startswith(path + "/" + "solvedb"):
37 continue
38 data = data + str(os.stat(f)[stat.ST_MTIME])
39 manifest.append(f)
40 checksum = hashlib.md5(data).hexdigest()
41
42 if os.path.exists(path + "/solvedb.checksum") and open(path + "/solvedb.checksum", "r").read() == checksum:
43 open(path + "/solvedb.done", "w")
44 continue
45
46 if os.path.exists(path + "/solvedb"):
47 os.system("rm -rf %s" % (path + "/solvedb"))
48 os.mkdir(path + "/solvedb")
49 m = open(path + "/solvedb/manifest", "w")
50 m.write("# Dynamically generated solve manifest\n")
51 for f in manifest:
52 m.write(f + "\n")
53 m.close()
54
55 cmd = sys.argv[1] + ' -i --replacepkgs --replacefiles --oldpackage -D "_dbpath ' + path + '/solvedb" --justdb \
56 --noaid --nodeps --noorder --noscripts --notriggers --noparentdirs --nolinktos --stats \
57 --ignoresize --nosignature --nodigest -D "__dbi_txn create nofsync" \
58 ' + path + '/solvedb/manifest'
59 os.system(cmd)
60
61 open(path + "/solvedb.checksum", "w").write(checksum)
62 open(path + "/solvedb.done", "w")
63