diff options
author | Richard Purdie <richard@openedhand.com> | 2008-04-28 10:31:26 +0000 |
---|---|---|
committer | Richard Purdie <richard@openedhand.com> | 2008-04-28 10:31:26 +0000 |
commit | 9b0fe9f37578cb786216ea390cc584965f97c211 (patch) | |
tree | df52e69448aace46492e4161e87df1a1dd1fef2a | |
parent | 116861d6622cbddb6c8c79ac67ade2a8b0ae2658 (diff) | |
download | poky-9b0fe9f37578cb786216ea390cc584965f97c211.tar.gz |
packaged-staging.bbclass: Fix install race, improve staging cleaning functions.
git-svn-id: https://svn.o-hand.com/repos/poky/trunk@4358 311d38ba-8fff-0310-9ca6-ca027cbcb966
-rw-r--r-- | meta/classes/packaged-staging.bbclass | 64 |
1 files changed, 48 insertions, 16 deletions
diff --git a/meta/classes/packaged-staging.bbclass b/meta/classes/packaged-staging.bbclass index e6f2f3b53e..efc9aa6ce8 100644 --- a/meta/classes/packaged-staging.bbclass +++ b/meta/classes/packaged-staging.bbclass | |||
@@ -90,17 +90,48 @@ PSTAGE_LIST_CMD = "opkg-cl list_installed -f ${PSTAGE_MACHCONFIG} -o ${TMPDIR}" | |||
90 | 90 | ||
91 | PSTAGE_TMPDIR_STAGE = "${WORKDIR}/staging-pkg" | 91 | PSTAGE_TMPDIR_STAGE = "${WORKDIR}/staging-pkg" |
92 | 92 | ||
93 | do_clean_append() { | 93 | def pstage_manualclean(srcname, destvarname, d): |
94 | import os, bb | ||
95 | |||
96 | src = os.path.join(bb.data.getVar('PSTAGE_TMPDIR_STAGE', d, True), srcname) | ||
97 | dest = bb.data.getVar(destvarname, d, True) | ||
98 | |||
99 | for walkroot, dirs, files in os.walk(src): | ||
100 | for file in files: | ||
101 | filepath = os.path.join(walkroot, file).replace(src, dest) | ||
102 | bb.note("rm %s" % filepath) | ||
103 | os.system("rm %s" % filepath) | ||
104 | |||
105 | def pstage_cleanpackage(pkgname, d): | ||
106 | import os, bb | ||
107 | |||
108 | path = bb.data.getVar("PATH", d, 1) | ||
109 | list_cmd = bb.data.getVar("PSTAGE_LIST_CMD", d, True) | ||
110 | |||
111 | bb.note("Checking if staging package installed") | ||
112 | lf = bb.utils.lockfile(bb.data.expand("${STAGING_DIR}/staging.lock", d)) | ||
113 | ret = os.system("PATH=\"%s\" %s | grep %s" % (path, list_cmd, pkgname)) | ||
114 | if ret == 0: | ||
115 | bb.note("Yes. Uninstalling package from staging...") | ||
116 | removecmd = bb.data.getVar("PSTAGE_REMOVE_CMD", d, 1) | ||
117 | ret = os.system("PATH=\"%s\" %s %s" % (path, removecmd, removepkg)) | ||
118 | if ret != 0: | ||
119 | bb.note("Failure removing staging package") | ||
120 | else: | ||
121 | bb.note("No. Manually removing any installed files") | ||
122 | pstage_manualclean("staging", "STAGING_DIR", d) | ||
123 | pstage_manualclean("cross", "CROSS_DIR", d) | ||
124 | pstage_manualclean("deploy", "DEPLOY_DIR", d) | ||
125 | |||
126 | bb.utils.unlockfile(lf) | ||
127 | |||
128 | do_clean_prepend() { | ||
94 | """ | 129 | """ |
95 | Clear the build and temp directories | 130 | Clear the build and temp directories |
96 | """ | 131 | """ |
97 | bb.note("Uninstalling package from staging...") | 132 | |
98 | path = bb.data.getVar("PATH", d, 1) | ||
99 | removecmd = bb.data.getVar("PSTAGE_REMOVE_CMD", d, 1) | ||
100 | removepkg = bb.data.expand("${PSTAGE_PKGPN}", d) | 133 | removepkg = bb.data.expand("${PSTAGE_PKGPN}", d) |
101 | ret = os.system("PATH=\"%s\" %s %s" % (path, removecmd, removepkg)) | 134 | pstage_cleanpackage(removepkg, d) |
102 | if ret != 0: | ||
103 | bb.note("Failure removing staging package") | ||
104 | 135 | ||
105 | stagepkg = bb.data.expand("${PSTAGE_PKG}", d) | 136 | stagepkg = bb.data.expand("${PSTAGE_PKG}", d) |
106 | bb.note("Removing staging package %s" % stagepkg) | 137 | bb.note("Removing staging package %s" % stagepkg) |
@@ -132,15 +163,8 @@ python packagestage_scenefunc () { | |||
132 | bb.build.make_stamp("do_prepackaged_stage", d) | 163 | bb.build.make_stamp("do_prepackaged_stage", d) |
133 | return | 164 | return |
134 | 165 | ||
135 | bb.note("Uninstalling any existing package from staging...") | ||
136 | path = bb.data.getVar("PATH", d, 1) | ||
137 | removecmd = bb.data.getVar("PSTAGE_REMOVE_CMD", d, 1) | ||
138 | removepkg = bb.data.expand("${PSTAGE_PKGPN}", d) | 166 | removepkg = bb.data.expand("${PSTAGE_PKGPN}", d) |
139 | lf = bb.utils.lockfile(bb.data.expand("${STAGING_DIR}/staging.lock", d)) | 167 | pstage_cleanpackage(removepkg, d) |
140 | ret = os.system("PATH=\"%s\" %s %s" % (path, removecmd, removepkg)) | ||
141 | bb.utils.unlockfile(lf) | ||
142 | if ret != 0: | ||
143 | bb.note("Failure attempting to remove staging package") | ||
144 | 168 | ||
145 | stagepkg = bb.data.expand("${PSTAGE_PKG}", d) | 169 | stagepkg = bb.data.expand("${PSTAGE_PKG}", d) |
146 | 170 | ||
@@ -162,6 +186,7 @@ python packagestage_scenefunc () { | |||
162 | 186 | ||
163 | } | 187 | } |
164 | packagestage_scenefunc[cleandirs] = "${PSTAGE_TMPDIR_STAGE}" | 188 | packagestage_scenefunc[cleandirs] = "${PSTAGE_TMPDIR_STAGE}" |
189 | packagestage_scenefunc[dirs] = "${STAGING_DIR}" | ||
165 | 190 | ||
166 | addhandler packagedstage_stampfixing_eventhandler | 191 | addhandler packagedstage_stampfixing_eventhandler |
167 | python packagedstage_stampfixing_eventhandler() { | 192 | python packagedstage_stampfixing_eventhandler() { |
@@ -241,7 +266,14 @@ staging_packager () { | |||
241 | } | 266 | } |
242 | 267 | ||
243 | staging_package_installer () { | 268 | staging_package_installer () { |
244 | ${PSTAGE_INSTALL_CMD} ${PSTAGE_PKG} | 269 | #${PSTAGE_INSTALL_CMD} ${PSTAGE_PKG} |
270 | |||
271 | STATUSFILE=${TMPDIR}${layout_libdir}/opkg/status | ||
272 | echo "Package: ${PSTAGE_PKGPN}" >> $STATUSFILE | ||
273 | echo "Version: ${PSTAGE_PKGVERSION}" >> $STATUSFILE | ||
274 | echo "Status: install user installed" >> $STATUSFILE | ||
275 | echo "Architecture: ${PSTAGE_PKGARCH}" >> $STATUSFILE | ||
276 | echo "" >> $STATUSFILE | ||
245 | } | 277 | } |
246 | 278 | ||
247 | python do_package_stage () { | 279 | python do_package_stage () { |