]> code.ossystems Code Review - openembedded-core.git/commitdiff
Add package_history.bbclass which checks generated package against previous package...
authorRichard Purdie <rpurdie@linux.intel.com>
Thu, 9 Jul 2009 16:19:29 +0000 (17:19 +0100)
committerRichard Purdie <rpurdie@linux.intel.com>
Thu, 9 Jul 2009 16:19:29 +0000 (17:19 +0100)
meta-moblin/conf/distro/moblin.conf
meta/classes/packagehistory.bbclass [new file with mode: 0644]

index d27aa96e0e9405f8a426a0b66cacac215e8e9784..485c3a13f10b5742f8ee1c766a4eec2583904951 100644 (file)
@@ -6,7 +6,7 @@ MAINTAINER = "Moblin <dev@lists.moblin.org>"
 
 PACKAGE_CLASSES ?= "package_ipk package_rpm"
 INHERIT_INSANE ?= "insane"
-INHERIT += "${PACKAGE_CLASSES} debian moblin devshell ${INHERIT_INSANE} packaged-staging"
+INHERIT += "${PACKAGE_CLASSES} debian moblin devshell ${INHERIT_INSANE} packaged-staging packagehistory"
 
 # For some reason, this doesn't work
 # TARGET_OS ?= "linux"
diff --git a/meta/classes/packagehistory.bbclass b/meta/classes/packagehistory.bbclass
new file mode 100644 (file)
index 0000000..c48deb3
--- /dev/null
@@ -0,0 +1,100 @@
+PACKAGEFUNCS += "emit_pkghistory"
+
+PKGHIST_DIR = "${TMPDIR}/pkghistory/"
+
+
+#
+# Called during do_package to write out metadata about this package
+# for comparision when writing future packages
+#
+python emit_pkghistory() {
+       packages = bb.data.getVar('PACKAGES', d, True)
+       pkghistdir = bb.data.getVar('PKGHIST_DIR', d, True)
+
+
+       # Should check PACKAGES here to see if anything removed
+
+       def getpkgvar(pkg, var):
+               val = bb.data.getVar('%s_%s' % (var, pkg), d, 1)
+               if val:
+                       return val
+               val = bb.data.getVar('%s' % (var), d, 1)
+
+               return val
+
+       def getlastversion(pkg):
+               try:
+                       pe = os.path.basename(os.readlink(os.path.join(pkghistdir, pkg, "latest")))
+                       pv = os.path.basename(os.readlink(os.path.join(pkghistdir, pkg, pe, "latest")))
+                       pr = os.path.basename(os.readlink(os.path.join(pkghistdir, pkg, pe, pv, "latest")))
+                       return (pe, pv, pr)
+               except OSError:
+                       return (None, None, None)                       
+
+       for pkg in packages.split():
+               pe = getpkgvar(pkg, 'PE') or "0"
+               pv = getpkgvar(pkg, 'PV')
+               pr = getpkgvar(pkg, 'PR')
+               destdir = os.path.join(pkghistdir, pkg, pe, pv, pr)
+               
+               #
+               # Find out what the last version was
+               # Make sure the version did not decrease
+               #
+               lastversion = getlastversion(pkg)
+               (last_pe, last_pv, last_pr) = lastversion
+
+               if last_pe is not None:
+                       r = bb.utils.vercmp((pe, pv, pr), lastversion)
+                       if r < 0:
+                               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))
+
+               write_pkghistory(pkg, pe, pv, pr, d)
+
+               if last_pe is not None:
+                       check_pkghistory(pkg, pe, pv, pr, lastversion)
+
+               write_latestlink(pkg, pe, pv, pr, d)            
+}
+
+
+def check_pkghistory(pkg, pe, pv, pr, lastversion):
+       import bb
+
+       (last_pe, last_pv, last_pr) = lastversion
+
+       bb.debug(2, "Checking package history")
+       # RDEPENDS removed?
+       # PKG changed?
+       # Each file list of each package for file removals?
+
+
+def write_pkghistory(pkg, pe, pv, pr, d):
+       import bb, os
+       bb.debug(2, "Writing package history")
+
+       pkghistdir = bb.data.getVar('PKGHIST_DIR', d, True)
+
+       verpath = os.path.join(pkghistdir, pkg, pe, pv, pr)
+       if not os.path.exists(verpath):
+               os.makedirs(verpath)
+
+def write_latestlink(pkg, pe, pv, pr, d):
+       import bb, os
+
+       pkghistdir = bb.data.getVar('PKGHIST_DIR', d, True)
+
+       def rm_link(path):
+               try: 
+                       os.unlink(path)
+               except OSError:
+                       return
+
+       rm_link(os.path.join(pkghistdir, pkg, "latest"))
+       rm_link(os.path.join(pkghistdir, pkg, pe, "latest"))
+       rm_link(os.path.join(pkghistdir, pkg, pe, pv, "latest"))
+
+       os.symlink(os.path.join(pkghistdir, pkg, pe), os.path.join(pkghistdir, pkg, "latest"))
+       os.symlink(os.path.join(pkghistdir, pkg, pe, pv), os.path.join(pkghistdir, pkg, pe, "latest"))
+       os.symlink(os.path.join(pkghistdir, pkg, pe, pv, pr), os.path.join(pkghistdir, pkg, pe, pv, "latest"))
+