diff options
| author | Paul Eggleton <paul.eggleton@linux.intel.com> | 2012-01-13 17:22:36 +0000 |
|---|---|---|
| committer | Richard Purdie <richard.purdie@linuxfoundation.org> | 2012-01-17 14:53:26 +0000 |
| commit | f290935151eea6d020815889b8698877dacae2cd (patch) | |
| tree | 9bfb8e7a16b10a04cbdb8afc8f3248467825f9dc | |
| parent | ee7fb2b86df6e66eefa5a0d98441536e8b424038 (diff) | |
| download | poky-f290935151eea6d020815889b8698877dacae2cd.tar.gz | |
classes/packagehistory: remove now obsolete class
packagehistory.bbclass has been superseded by buildhistory.bbclass,
which gives more detailed output (including information on produced
images) as well as other enhanced functionality.
(From OE-Core rev: d07bd704e2c0624deba10f33ccc946bd1338855c)
Signed-off-by: Paul Eggleton <paul.eggleton@linux.intel.com>
Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
| -rw-r--r-- | meta/classes/packagehistory.bbclass | 249 |
1 files changed, 0 insertions, 249 deletions
diff --git a/meta/classes/packagehistory.bbclass b/meta/classes/packagehistory.bbclass deleted file mode 100644 index 5a1c84663a..0000000000 --- a/meta/classes/packagehistory.bbclass +++ /dev/null | |||
| @@ -1,249 +0,0 @@ | |||
| 1 | # Must inherit package first before changing PACKAGEFUNCS | ||
| 2 | inherit package | ||
| 3 | PACKAGEFUNCS += "emit_pkghistory" | ||
| 4 | |||
| 5 | PKGHIST_DIR = "${TMPDIR}/pkghistory/${MULTIMACH_TARGET_SYS}/" | ||
| 6 | |||
| 7 | # | ||
| 8 | # Called during do_package to write out metadata about this package | ||
| 9 | # for comparision when writing future packages | ||
| 10 | # | ||
| 11 | python emit_pkghistory() { | ||
| 12 | import re | ||
| 13 | |||
| 14 | pkghistdir = os.path.join(d.getVar('PKGHIST_DIR', True), d.getVar('PN', True)) | ||
| 15 | |||
| 16 | class RecipeInfo: | ||
| 17 | def __init__(self, name): | ||
| 18 | self.name = name | ||
| 19 | self.pe = "0" | ||
| 20 | self.pv = "0" | ||
| 21 | self.pr = "r0" | ||
| 22 | self.depends = "" | ||
| 23 | self.packages = "" | ||
| 24 | |||
| 25 | class PackageInfo: | ||
| 26 | def __init__(self, name): | ||
| 27 | self.name = name | ||
| 28 | self.pe = "0" | ||
| 29 | self.pv = "0" | ||
| 30 | self.pr = "r0" | ||
| 31 | self.size = 0 | ||
| 32 | self.depends = "" | ||
| 33 | self.rdepends = "" | ||
| 34 | self.rrecommends = "" | ||
| 35 | self.files = "" | ||
| 36 | self.filelist = "" | ||
| 37 | |||
| 38 | # Should check PACKAGES here to see if anything removed | ||
| 39 | |||
| 40 | def getpkgvar(pkg, var): | ||
| 41 | val = d.getVar('%s_%s' % (var, pkg), True) | ||
| 42 | if val: | ||
| 43 | return val | ||
| 44 | val = d.getVar(var, True) | ||
| 45 | |||
| 46 | return val | ||
| 47 | |||
| 48 | def readRecipeInfo(pn, histfile): | ||
| 49 | rcpinfo = RecipeInfo(pn) | ||
| 50 | f = open(histfile, "r") | ||
| 51 | try: | ||
| 52 | for line in f: | ||
| 53 | lns = line.split('=') | ||
| 54 | name = lns[0].strip() | ||
| 55 | value = lns[1].strip(" \t\r\n").strip('"') | ||
| 56 | if name == "PE": | ||
| 57 | rcpinfo.pe = value | ||
| 58 | elif name == "PV": | ||
| 59 | rcpinfo.pv = value | ||
| 60 | elif name == "PR": | ||
| 61 | rcpinfo.pr = value | ||
| 62 | elif name == "DEPENDS": | ||
| 63 | rcpinfo.depends = value | ||
| 64 | elif name == "PACKAGES": | ||
| 65 | rcpinfo.packages = value | ||
| 66 | finally: | ||
| 67 | f.close() | ||
| 68 | return rcpinfo | ||
| 69 | |||
| 70 | def readPackageInfo(pkg, histfile): | ||
| 71 | pkginfo = PackageInfo(pkg) | ||
| 72 | f = open(histfile, "r") | ||
| 73 | try: | ||
| 74 | for line in f: | ||
| 75 | lns = line.split('=') | ||
| 76 | name = lns[0].strip() | ||
| 77 | value = lns[1].strip(" \t\r\n").strip('"') | ||
| 78 | if name == "PE": | ||
| 79 | pkginfo.pe = value | ||
| 80 | elif name == "PV": | ||
| 81 | pkginfo.pv = value | ||
| 82 | elif name == "PR": | ||
| 83 | pkginfo.pr = value | ||
| 84 | elif name == "RDEPENDS": | ||
| 85 | pkginfo.rdepends = value | ||
| 86 | elif name == "RRECOMMENDS": | ||
| 87 | pkginfo.rrecommends = value | ||
| 88 | elif name == "PKGSIZE": | ||
| 89 | pkginfo.size = long(value) | ||
| 90 | elif name == "FILES": | ||
| 91 | pkginfo.files = value | ||
| 92 | elif name == "FILELIST": | ||
| 93 | pkginfo.filelist = value | ||
| 94 | finally: | ||
| 95 | f.close() | ||
| 96 | return pkginfo | ||
| 97 | |||
| 98 | def getlastrecipeversion(pn): | ||
| 99 | try: | ||
| 100 | histfile = os.path.join(pkghistdir, "latest") | ||
| 101 | return readRecipeInfo(pn, histfile) | ||
| 102 | except EnvironmentError: | ||
| 103 | return None | ||
| 104 | |||
| 105 | def getlastpkgversion(pkg): | ||
| 106 | try: | ||
| 107 | histfile = os.path.join(pkghistdir, pkg, "latest") | ||
| 108 | return readPackageInfo(pkg, histfile) | ||
| 109 | except EnvironmentError: | ||
| 110 | return None | ||
| 111 | |||
| 112 | def squashspaces(string): | ||
| 113 | return re.sub("\s+", " ", string) | ||
| 114 | |||
| 115 | pn = d.getVar('PN', True) | ||
| 116 | pe = d.getVar('PE', True) or "0" | ||
| 117 | pv = d.getVar('PV', True) | ||
| 118 | pr = d.getVar('PR', True) | ||
| 119 | packages = squashspaces(d.getVar('PACKAGES', True)) | ||
| 120 | |||
| 121 | rcpinfo = RecipeInfo(pn) | ||
| 122 | rcpinfo.pe = pe | ||
| 123 | rcpinfo.pv = pv | ||
| 124 | rcpinfo.pr = pr | ||
| 125 | rcpinfo.depends = squashspaces(d.getVar('DEPENDS', True) or "") | ||
| 126 | rcpinfo.packages = packages | ||
| 127 | write_recipehistory(rcpinfo, d) | ||
| 128 | write_latestlink(None, pe, pv, pr, d) | ||
| 129 | |||
| 130 | # Apparently the version can be different on a per-package basis (see Python) | ||
| 131 | pkgdest = d.getVar('PKGDEST', True) | ||
| 132 | for pkg in packages.split(): | ||
| 133 | pe = getpkgvar(pkg, 'PE') or "0" | ||
| 134 | pv = getpkgvar(pkg, 'PV') | ||
| 135 | pr = getpkgvar(pkg, 'PR') | ||
| 136 | # | ||
| 137 | # Find out what the last version was | ||
| 138 | # Make sure the version did not decrease | ||
| 139 | # | ||
| 140 | lastversion = getlastpkgversion(pkg) | ||
| 141 | if lastversion: | ||
| 142 | last_pe = lastversion.pe | ||
| 143 | last_pv = lastversion.pv | ||
| 144 | last_pr = lastversion.pr | ||
| 145 | r = bb.utils.vercmp((pe, pv, pr), (last_pe, last_pv, last_pr)) | ||
| 146 | if r < 0: | ||
| 147 | 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)) | ||
| 148 | |||
| 149 | pkginfo = PackageInfo(pkg) | ||
| 150 | pkginfo.pe = pe | ||
| 151 | pkginfo.pv = pv | ||
| 152 | pkginfo.pr = pr | ||
| 153 | pkginfo.rdepends = squashspaces(getpkgvar(pkg, 'RDEPENDS') or "") | ||
| 154 | pkginfo.rrecommends = squashspaces(getpkgvar(pkg, 'RRECOMMENDS') or "") | ||
| 155 | pkginfo.files = squashspaces(getpkgvar(pkg, 'FILES') or "") | ||
| 156 | |||
| 157 | # Gather information about packaged files | ||
| 158 | pkgdestpkg = os.path.join(pkgdest, pkg) | ||
| 159 | filelist = [] | ||
| 160 | pkginfo.size = 0 | ||
| 161 | for root, dirs, files in os.walk(pkgdestpkg): | ||
| 162 | relpth = os.path.relpath(root, pkgdestpkg) | ||
| 163 | for f in files: | ||
| 164 | fstat = os.lstat(os.path.join(root, f)) | ||
| 165 | pkginfo.size += fstat.st_size | ||
| 166 | filelist.append(os.sep + os.path.join(relpth, f)) | ||
| 167 | pkginfo.filelist = " ".join(filelist) | ||
| 168 | |||
| 169 | write_pkghistory(pkginfo, d) | ||
| 170 | |||
| 171 | if lastversion: | ||
| 172 | check_pkghistory(pkginfo, lastversion) | ||
| 173 | |||
| 174 | write_latestlink(pkg, pe, pv, pr, d) | ||
| 175 | } | ||
| 176 | |||
| 177 | |||
| 178 | def check_pkghistory(pkginfo, lastversion): | ||
| 179 | |||
| 180 | bb.debug(2, "Checking package history") | ||
| 181 | # RDEPENDS removed? | ||
| 182 | # PKG changed? | ||
| 183 | # Each file list of each package for file removals? | ||
| 184 | |||
| 185 | |||
| 186 | def write_recipehistory(rcpinfo, d): | ||
| 187 | bb.debug(2, "Writing recipe history") | ||
| 188 | |||
| 189 | pkghistdir = os.path.join(d.getVar('PKGHIST_DIR', True), d.getVar('PN', True)) | ||
| 190 | |||
| 191 | if not os.path.exists(pkghistdir): | ||
| 192 | os.makedirs(pkghistdir) | ||
| 193 | |||
| 194 | verfile = os.path.join(pkghistdir, "%s:%s-%s" % (rcpinfo.pe, rcpinfo.pv, rcpinfo.pr)) | ||
| 195 | f = open(verfile, "w") | ||
| 196 | try: | ||
| 197 | if rcpinfo.pe != "0": | ||
| 198 | f.write("PE = %s\n" % rcpinfo.pe) | ||
| 199 | f.write("PV = %s\n" % rcpinfo.pv) | ||
| 200 | f.write("PR = %s\n" % rcpinfo.pr) | ||
| 201 | f.write("DEPENDS = %s\n" % rcpinfo.depends) | ||
| 202 | f.write("PACKAGES = %s\n" % rcpinfo.packages) | ||
| 203 | finally: | ||
| 204 | f.close() | ||
| 205 | |||
| 206 | |||
| 207 | def write_pkghistory(pkginfo, d): | ||
| 208 | bb.debug(2, "Writing package history") | ||
| 209 | |||
| 210 | pkghistdir = os.path.join(d.getVar('PKGHIST_DIR', True), d.getVar('PN', True)) | ||
| 211 | |||
| 212 | verpath = os.path.join(pkghistdir, pkginfo.name) | ||
| 213 | if not os.path.exists(verpath): | ||
| 214 | os.makedirs(verpath) | ||
| 215 | |||
| 216 | verfile = os.path.join(verpath, "%s:%s-%s" % (pkginfo.pe, pkginfo.pv, pkginfo.pr)) | ||
| 217 | f = open(verfile, "w") | ||
| 218 | try: | ||
| 219 | if pkginfo.pe != "0": | ||
| 220 | f.write("PE = %s\n" % pkginfo.pe) | ||
| 221 | f.write("PV = %s\n" % pkginfo.pv) | ||
| 222 | f.write("PR = %s\n" % pkginfo.pr) | ||
| 223 | f.write("RDEPENDS = %s\n" % pkginfo.rdepends) | ||
| 224 | f.write("RRECOMMENDS = %s\n" % pkginfo.rrecommends) | ||
| 225 | f.write("PKGSIZE = %d\n" % pkginfo.size) | ||
| 226 | f.write("FILES = %s\n" % pkginfo.files) | ||
| 227 | f.write("FILELIST = %s\n" % pkginfo.filelist) | ||
| 228 | finally: | ||
| 229 | f.close() | ||
| 230 | |||
| 231 | |||
| 232 | def write_latestlink(pkg, pe, pv, pr, d): | ||
| 233 | import shutil | ||
| 234 | |||
| 235 | pkghistdir = os.path.join(d.getVar('PKGHIST_DIR', True), d.getVar('PN', True)) | ||
| 236 | |||
| 237 | def rm_link(path): | ||
| 238 | try: | ||
| 239 | os.unlink(path) | ||
| 240 | except OSError: | ||
| 241 | return | ||
| 242 | |||
| 243 | if pkg: | ||
| 244 | filedir = os.path.join(pkghistdir, pkg) | ||
| 245 | else: | ||
| 246 | filedir = pkghistdir | ||
| 247 | rm_link(os.path.join(filedir, "latest")) | ||
| 248 | shutil.copy(os.path.join(filedir, "%s:%s-%s" % (pe, pv, pr)), os.path.join(filedir, "latest")) | ||
| 249 | |||
