diff options
-rw-r--r-- | meta/classes/package_rpm.bbclass | 18 | ||||
-rwxr-xr-x | scripts/rpm-createsolvedb.py | 63 |
2 files changed, 67 insertions, 14 deletions
diff --git a/meta/classes/package_rpm.bbclass b/meta/classes/package_rpm.bbclass index d90976b65d..623069e377 100644 --- a/meta/classes/package_rpm.bbclass +++ b/meta/classes/package_rpm.bbclass | |||
@@ -40,12 +40,13 @@ package_update_index_rpm_common () { | |||
40 | rpmconf_base="$1" | 40 | rpmconf_base="$1" |
41 | shift | 41 | shift |
42 | 42 | ||
43 | createdirs="" | ||
43 | for archvar in "$@"; do | 44 | for archvar in "$@"; do |
44 | eval archs=\${${archvar}} | 45 | eval archs=\${${archvar}} |
45 | packagedirs="" | 46 | packagedirs="" |
46 | for arch in $archs; do | 47 | for arch in $archs; do |
47 | packagedirs="${DEPLOY_DIR_RPM}/$arch $packagedirs" | 48 | packagedirs="${DEPLOY_DIR_RPM}/$arch $packagedirs" |
48 | rm -rf ${DEPLOY_DIR_RPM}/$arch/solvedb | 49 | rm -rf ${DEPLOY_DIR_RPM}/$arch/solvedb.done |
49 | done | 50 | done |
50 | 51 | ||
51 | cat /dev/null > ${rpmconf_base}-${archvar}.conf | 52 | cat /dev/null > ${rpmconf_base}-${archvar}.conf |
@@ -53,22 +54,11 @@ package_update_index_rpm_common () { | |||
53 | if [ -e $pkgdir/ ]; then | 54 | if [ -e $pkgdir/ ]; then |
54 | echo "Generating solve db for $pkgdir..." | 55 | echo "Generating solve db for $pkgdir..." |
55 | echo $pkgdir/solvedb >> ${rpmconf_base}-${archvar}.conf | 56 | echo $pkgdir/solvedb >> ${rpmconf_base}-${archvar}.conf |
56 | if [ -d $pkgdir/solvedb ]; then | 57 | createdirs="$createdirs $pkgdir" |
57 | # We've already processed this and it's a duplicate | ||
58 | continue | ||
59 | fi | ||
60 | mkdir -p $pkgdir/solvedb | ||
61 | echo "# Dynamically generated solve manifest" >> $pkgdir/solvedb/manifest | ||
62 | find $pkgdir -maxdepth 1 -type f >> $pkgdir/solvedb/manifest | ||
63 | ${RPM} -i --replacepkgs --replacefiles --oldpackage \ | ||
64 | -D "_dbpath $pkgdir/solvedb" --justdb \ | ||
65 | --noaid --nodeps --noorder --noscripts --notriggers --noparentdirs --nolinktos --stats \ | ||
66 | --ignoresize --nosignature --nodigest \ | ||
67 | -D "__dbi_txn create nofsync" \ | ||
68 | $pkgdir/solvedb/manifest | ||
69 | fi | 58 | fi |
70 | done | 59 | done |
71 | done | 60 | done |
61 | rpm-createsolvedb.py "${RPM}" $createdirs | ||
72 | } | 62 | } |
73 | 63 | ||
74 | # | 64 | # |
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 | |||
14 | import sys, os | ||
15 | import hashlib | ||
16 | import stat | ||
17 | |||
18 | if len(sys.argv) < 1: | ||
19 | print("Error, rpm command not specified") | ||
20 | sys.exit(1) | ||
21 | |||
22 | if len(sys.argv) < 2: | ||
23 | print("Error, no paths specified") | ||
24 | sys.exit(1) | ||
25 | |||
26 | paths = sys.argv[2:] | ||
27 | |||
28 | for 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 | |||