summaryrefslogtreecommitdiffstats
path: root/scripts/rpm-createsolvedb.py
diff options
context:
space:
mode:
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