summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorRichard Purdie <rpurdie@linux.intel.com>2009-07-09 17:19:29 +0100
committerRichard Purdie <rpurdie@linux.intel.com>2009-07-09 17:19:29 +0100
commitffe979a855bc3bc0c56fc1e6c35b35fbace5334c (patch)
tree2e2dea9b1d13cfe57e0c76c9dc65876dc9751739
parentf5d0882b4099b74560fbbd5546ca00228c7e2cdd (diff)
downloadpoky-ffe979a855bc3bc0c56fc1e6c35b35fbace5334c.tar.gz
Add package_history.bbclass which checks generated package against previous package looking for problematic changes
-rw-r--r--meta-moblin/conf/distro/moblin.conf2
-rw-r--r--meta/classes/packagehistory.bbclass100
2 files changed, 101 insertions, 1 deletions
diff --git a/meta-moblin/conf/distro/moblin.conf b/meta-moblin/conf/distro/moblin.conf
index d27aa96e0e..485c3a13f1 100644
--- a/meta-moblin/conf/distro/moblin.conf
+++ b/meta-moblin/conf/distro/moblin.conf
@@ -6,7 +6,7 @@ MAINTAINER = "Moblin <dev@lists.moblin.org>"
6 6
7PACKAGE_CLASSES ?= "package_ipk package_rpm" 7PACKAGE_CLASSES ?= "package_ipk package_rpm"
8INHERIT_INSANE ?= "insane" 8INHERIT_INSANE ?= "insane"
9INHERIT += "${PACKAGE_CLASSES} debian moblin devshell ${INHERIT_INSANE} packaged-staging" 9INHERIT += "${PACKAGE_CLASSES} debian moblin devshell ${INHERIT_INSANE} packaged-staging packagehistory"
10 10
11# For some reason, this doesn't work 11# For some reason, this doesn't work
12# TARGET_OS ?= "linux" 12# TARGET_OS ?= "linux"
diff --git a/meta/classes/packagehistory.bbclass b/meta/classes/packagehistory.bbclass
new file mode 100644
index 0000000000..c48deb3e57
--- /dev/null
+++ b/meta/classes/packagehistory.bbclass
@@ -0,0 +1,100 @@
1PACKAGEFUNCS += "emit_pkghistory"
2
3PKGHIST_DIR = "${TMPDIR}/pkghistory/"
4
5
6#
7# Called during do_package to write out metadata about this package
8# for comparision when writing future packages
9#
10python emit_pkghistory() {
11 packages = bb.data.getVar('PACKAGES', d, True)
12 pkghistdir = bb.data.getVar('PKGHIST_DIR', d, True)
13
14
15 # Should check PACKAGES here to see if anything removed
16
17 def getpkgvar(pkg, var):
18 val = bb.data.getVar('%s_%s' % (var, pkg), d, 1)
19 if val:
20 return val
21 val = bb.data.getVar('%s' % (var), d, 1)
22
23 return val
24
25 def getlastversion(pkg):
26 try:
27 pe = os.path.basename(os.readlink(os.path.join(pkghistdir, pkg, "latest")))
28 pv = os.path.basename(os.readlink(os.path.join(pkghistdir, pkg, pe, "latest")))
29 pr = os.path.basename(os.readlink(os.path.join(pkghistdir, pkg, pe, pv, "latest")))
30 return (pe, pv, pr)
31 except OSError:
32 return (None, None, None)
33
34 for pkg in packages.split():
35 pe = getpkgvar(pkg, 'PE') or "0"
36 pv = getpkgvar(pkg, 'PV')
37 pr = getpkgvar(pkg, 'PR')
38 destdir = os.path.join(pkghistdir, pkg, pe, pv, pr)
39
40 #
41 # Find out what the last version was
42 # Make sure the version did not decrease
43 #
44 lastversion = getlastversion(pkg)
45 (last_pe, last_pv, last_pr) = lastversion
46
47 if last_pe is not None:
48 r = bb.utils.vercmp((pe, pv, pr), lastversion)
49 if r < 0:
50 bb.fatal("Package version for package %s went backwards which would break package feeds from (%s:%s-%s to %s:%s-%s)" % (pkg, last_pe, last_pv, last_pr, pe, pv, pr))
51
52 write_pkghistory(pkg, pe, pv, pr, d)
53
54 if last_pe is not None:
55 check_pkghistory(pkg, pe, pv, pr, lastversion)
56
57 write_latestlink(pkg, pe, pv, pr, d)
58}
59
60
61def check_pkghistory(pkg, pe, pv, pr, lastversion):
62 import bb
63
64 (last_pe, last_pv, last_pr) = lastversion
65
66 bb.debug(2, "Checking package history")
67 # RDEPENDS removed?
68 # PKG changed?
69 # Each file list of each package for file removals?
70
71
72def write_pkghistory(pkg, pe, pv, pr, d):
73 import bb, os
74 bb.debug(2, "Writing package history")
75
76 pkghistdir = bb.data.getVar('PKGHIST_DIR', d, True)
77
78 verpath = os.path.join(pkghistdir, pkg, pe, pv, pr)
79 if not os.path.exists(verpath):
80 os.makedirs(verpath)
81
82def write_latestlink(pkg, pe, pv, pr, d):
83 import bb, os
84
85 pkghistdir = bb.data.getVar('PKGHIST_DIR', d, True)
86
87 def rm_link(path):
88 try:
89 os.unlink(path)
90 except OSError:
91 return
92
93 rm_link(os.path.join(pkghistdir, pkg, "latest"))
94 rm_link(os.path.join(pkghistdir, pkg, pe, "latest"))
95 rm_link(os.path.join(pkghistdir, pkg, pe, pv, "latest"))
96
97 os.symlink(os.path.join(pkghistdir, pkg, pe), os.path.join(pkghistdir, pkg, "latest"))
98 os.symlink(os.path.join(pkghistdir, pkg, pe, pv), os.path.join(pkghistdir, pkg, pe, "latest"))
99 os.symlink(os.path.join(pkghistdir, pkg, pe, pv, pr), os.path.join(pkghistdir, pkg, pe, pv, "latest"))
100