diff options
author | Richard Purdie <richard@openedhand.com> | 2008-08-18 08:01:41 +0000 |
---|---|---|
committer | Richard Purdie <richard@openedhand.com> | 2008-08-18 08:01:41 +0000 |
commit | ded39e22cde334c31f56ea1603942327b3cf0614 (patch) | |
tree | e803b9d883e1ba67c94c9e4c035e63d0aa536558 | |
parent | c87b3a87aa143eb2166da910b8553742617339a9 (diff) | |
download | poky-ded39e22cde334c31f56ea1603942327b3cf0614.tar.gz |
package_rpm.bbclass: Update against recent packaging changes and start to implement dependency handling. Drop pointless rpm_core class.
git-svn-id: https://svn.o-hand.com/repos/poky/trunk@5067 311d38ba-8fff-0310-9ca6-ca027cbcb966
-rw-r--r-- | meta/classes/package_rpm.bbclass | 82 | ||||
-rw-r--r-- | meta/classes/rpm_core.bbclass | 16 |
2 files changed, 59 insertions, 39 deletions
diff --git a/meta/classes/package_rpm.bbclass b/meta/classes/package_rpm.bbclass index 6713f8fcad..ac6ac2ca54 100644 --- a/meta/classes/package_rpm.bbclass +++ b/meta/classes/package_rpm.bbclass | |||
@@ -1,9 +1,16 @@ | |||
1 | inherit package | 1 | inherit package |
2 | inherit rpm_core | 2 | |
3 | #IMAGE_PKGTYPE ?= "rpm" | ||
3 | 4 | ||
4 | RPMBUILD="rpmbuild --short-circuit ${RPMOPTS}" | 5 | RPMBUILD="rpmbuild --short-circuit ${RPMOPTS}" |
5 | IMAGE_PKGTYPE ?= "rpm" | 6 | IMAGE_PKGTYPE ?= "rpm" |
6 | 7 | ||
8 | RPMBUILDPATH="${WORKDIR}/rpm" | ||
9 | |||
10 | RPMOPTS="--rcfile=${WORKDIR}/rpmrc" | ||
11 | RPMOPTS="--rcfile=${WORKDIR}/rpmrc --target ${TARGET_SYS}" | ||
12 | RPM="rpm ${RPMOPTS}" | ||
13 | |||
7 | python write_specfile() { | 14 | python write_specfile() { |
8 | from bb import data, build | 15 | from bb import data, build |
9 | import sys | 16 | import sys |
@@ -57,7 +64,13 @@ python write_specfile() { | |||
57 | for var in out_vartranslate.keys(): | 64 | for var in out_vartranslate.keys(): |
58 | if out_vartranslate[var][0] == "%": | 65 | if out_vartranslate[var][0] == "%": |
59 | continue | 66 | continue |
60 | fd.write("%s\t: %s\n" % (out_vartranslate[var], bb.data.getVar(var, d))) | 67 | val = bb.data.getVar(var, d, 1) |
68 | if var == "RDEPENDS": | ||
69 | val = val.split()[0] | ||
70 | fd.write("%s\t: %s\n" % (out_vartranslate[var], val)) | ||
71 | rdepends = " ".join(bb.utils.explode_deps(bb.data.getVar('RDEPENDS', d, True))) | ||
72 | if rdepends: | ||
73 | fd.write("Requires: %s\n" % rdepends) | ||
61 | fd.write("Summary\t: .\n") | 74 | fd.write("Summary\t: .\n") |
62 | 75 | ||
63 | for var in out_vartranslate.keys(): | 76 | for var in out_vartranslate.keys(): |
@@ -74,6 +87,8 @@ python write_specfile() { | |||
74 | 87 | ||
75 | # call out rpm -bb on the .spec, thereby creating an rpm | 88 | # call out rpm -bb on the .spec, thereby creating an rpm |
76 | 89 | ||
90 | bb.note(bb.data.expand("${RPMBUILD} -bb ${OUTSPECFILE}", d)) | ||
91 | |||
77 | bb.data.setVar('BUILDSPEC', "${RPMBUILD} -bb ${OUTSPECFILE}\n", d) | 92 | bb.data.setVar('BUILDSPEC', "${RPMBUILD} -bb ${OUTSPECFILE}\n", d) |
78 | bb.data.setVarFlag('BUILDSPEC', 'func', '1', d) | 93 | bb.data.setVarFlag('BUILDSPEC', 'func', '1', d) |
79 | bb.build.exec_func('BUILDSPEC', d) | 94 | bb.build.exec_func('BUILDSPEC', d) |
@@ -84,51 +99,69 @@ python write_specfile() { | |||
84 | bb.movefile(rpm, outrpm) | 99 | bb.movefile(rpm, outrpm) |
85 | } | 100 | } |
86 | 101 | ||
102 | |||
103 | rpm_prep() { | ||
104 | if [ ! -e ${WORKDIR}/rpmrc ]; then | ||
105 | mkdir -p ${RPMBUILDPATH}/{SPECS,RPMS/{i386,i586,i686,noarch,ppc,mips,mipsel,arm},SRPMS,SOURCES,BUILD} | ||
106 | echo 'macrofiles:/usr/lib/rpm/macros:${WORKDIR}/macros' > ${WORKDIR}/rpmrc | ||
107 | echo '%_topdir ${RPMBUILDPATH}' > ${WORKDIR}/macros | ||
108 | echo '%_repackage_dir ${WORKDIR}' >> ${WORKDIR}/macros | ||
109 | fi | ||
110 | } | ||
111 | |||
87 | python do_package_rpm () { | 112 | python do_package_rpm () { |
88 | workdir = bb.data.getVar('WORKDIR', d) | 113 | workdir = bb.data.getVar('WORKDIR', d, 1) |
89 | if not workdir: | 114 | if not workdir: |
90 | raise bb.build.FuncFailed("WORKDIR not defined") | 115 | bb.error("WORKDIR not defined, unable to package") |
91 | workdir = bb.data.expand(workdir, d) | 116 | return |
92 | 117 | ||
93 | import os # path manipulations | 118 | import os # path manipulations |
94 | outdir = bb.data.getVar('DEPLOY_DIR_RPM', d) | 119 | outdir = bb.data.getVar('DEPLOY_DIR_RPM', d, 1) |
95 | if not outdir: | 120 | if not outdir: |
96 | raise bb.build.FuncFailed("DEPLOY_DIR_RPM not defined") | 121 | bb.error("DEPLOY_DIR_RPM not defined, unable to package") |
97 | outdir = bb.data.expand(outdir, d) | 122 | return |
98 | bb.mkdirhier(outdir) | 123 | bb.mkdirhier(outdir) |
99 | 124 | ||
100 | packages = bb.data.getVar('PACKAGES', d) | 125 | packages = bb.data.getVar('PACKAGES', d, 1) |
101 | if not packages: | 126 | if not packages: |
102 | packages = "${PN}" | 127 | bb.debug(1, "PACKAGES not defined, nothing to package") |
103 | bb.data.setVar('FILES', '', d) | 128 | return |
104 | ddir = bb.data.expand(bb.data.getVar('D', d), d) | 129 | |
105 | bb.mkdirhier(ddir) | 130 | if packages == []: |
106 | bb.data.setVar(bb.data.expand('FILES_${PN}', d), ''.join([ "./%s" % x for x in os.listdir(ddir)]), d) | 131 | bb.debug(1, "No packages; nothing to do") |
107 | packages = bb.data.expand(packages, d) | 132 | return |
133 | |||
134 | # If "rpm" comes into overrides the presence of this function causes problems. | ||
135 | # Since we don't need it, remove it for now - hacky. | ||
136 | bb.data.delVar("do_package_write_rpm", d) | ||
108 | 137 | ||
109 | for pkg in packages.split(): | 138 | for pkg in packages.split(): |
110 | localdata = bb.data.createCopy(d) | 139 | localdata = bb.data.createCopy(d) |
111 | root = "%s/install/%s" % (workdir, pkg) | 140 | pkgdest = bb.data.getVar('PKGDEST', d, 1) |
141 | root = "%s/%s" % (pkgdest, pkg) | ||
142 | |||
143 | lf = bb.utils.lockfile(root + ".lock") | ||
112 | 144 | ||
113 | bb.data.setVar('ROOT', '', localdata) | 145 | bb.data.setVar('ROOT', '', localdata) |
114 | bb.data.setVar('ROOT_%s' % pkg, root, localdata) | 146 | bb.data.setVar('ROOT_%s' % pkg, root, localdata) |
115 | bb.data.setVar('PKG', pkg, localdata) | 147 | pkgname = bb.data.getVar('PKG_%s' % pkg, localdata, 1) |
148 | if not pkgname: | ||
149 | pkgname = pkg | ||
150 | bb.data.setVar('PKG', pkgname, localdata) | ||
116 | 151 | ||
117 | overrides = bb.data.getVar('OVERRIDES', localdata) | 152 | overrides = bb.data.getVar('OVERRIDES', localdata) |
118 | if not overrides: | 153 | if not overrides: |
119 | raise bb.build.FuncFailed('OVERRIDES not defined') | 154 | raise bb.build.FuncFailed('OVERRIDES not defined') |
120 | overrides = bb.data.expand(overrides, localdata) | 155 | overrides = bb.data.expand(overrides, localdata) |
121 | bb.data.setVar('OVERRIDES', '%s:%s' % (overrides, pkg), localdata) | 156 | bb.data.setVar('OVERRIDES', overrides + ':' + pkg, localdata) |
122 | 157 | ||
123 | bb.data.update_data(localdata) | 158 | bb.data.update_data(localdata) |
124 | 159 | basedir = os.path.join(os.path.dirname(root)) | |
125 | root = bb.data.getVar('ROOT', localdata) | ||
126 | basedir = os.path.dirname(root) | ||
127 | pkgoutdir = outdir | 160 | pkgoutdir = outdir |
128 | bb.mkdirhier(pkgoutdir) | 161 | bb.mkdirhier(pkgoutdir) |
129 | bb.data.setVar('OUTSPECFILE', os.path.join(workdir, "%s.spec" % pkg), localdata) | 162 | bb.data.setVar('OUTSPECFILE', os.path.join(workdir, "%s.spec" % pkg), localdata) |
130 | bb.build.exec_func('write_specfile', localdata) | 163 | bb.build.exec_func('write_specfile', localdata) |
131 | del localdata | 164 | bb.utils.unlockfile(lf) |
132 | } | 165 | } |
133 | 166 | ||
134 | python () { | 167 | python () { |
@@ -143,7 +176,10 @@ python () { | |||
143 | 176 | ||
144 | python do_package_write_rpm () { | 177 | python do_package_write_rpm () { |
145 | bb.build.exec_func("read_subpackage_metadata", d) | 178 | bb.build.exec_func("read_subpackage_metadata", d) |
179 | bb.build.exec_func("rpm_prep", d) | ||
146 | bb.build.exec_func("do_package_rpm", d) | 180 | bb.build.exec_func("do_package_rpm", d) |
147 | } | 181 | } |
182 | |||
148 | do_package_write_rpm[dirs] = "${D}" | 183 | do_package_write_rpm[dirs] = "${D}" |
149 | addtask package_write_rpm before do_build after do_package | 184 | addtask package_write_rpm before do_package_write after do_package |
185 | |||
diff --git a/meta/classes/rpm_core.bbclass b/meta/classes/rpm_core.bbclass deleted file mode 100644 index f28abbb1c3..0000000000 --- a/meta/classes/rpm_core.bbclass +++ /dev/null | |||
@@ -1,16 +0,0 @@ | |||
1 | RPMBUILDPATH="${WORKDIR}/rpm" | ||
2 | |||
3 | RPMOPTS="--rcfile=${WORKDIR}/rpmrc" | ||
4 | RPMOPTS="--rcfile=${WORKDIR}/rpmrc --target ${TARGET_SYS}" | ||
5 | RPM="rpm ${RPMOPTS}" | ||
6 | RPMBUILD="rpmbuild --buildroot ${D} --short-circuit ${RPMOPTS}" | ||
7 | |||
8 | rpm_core_do_preprpm() { | ||
9 | mkdir -p ${RPMBUILDPATH}/{SPECS,RPMS/{i386,i586,i686,noarch,ppc,mips,mipsel,arm},SRPMS,SOURCES,BUILD} | ||
10 | echo 'macrofiles:/usr/lib/rpm/macros:${WORKDIR}/macros' > ${WORKDIR}/rpmrc | ||
11 | echo '%_topdir ${RPMBUILDPATH}' > ${WORKDIR}/macros | ||
12 | echo '%_repackage_dir ${WORKDIR}' >> ${WORKDIR}/macros | ||
13 | } | ||
14 | |||
15 | EXPORT_FUNCTIONS do_preprpm | ||
16 | addtask preprpm before do_fetch | ||