[OE-core] [PATCH 2/2] tar_archive.bbclass: Package source codes and log files to tar package
Mark Hatle
mark.hatle at windriver.com
Mon Jan 9 16:20:25 UTC 2012
On 1/8/12 1:11 AM, Xiaofeng Yan wrote:
> From: Xiaofeng Yan<xiaofeng.yan at windriver.com>
>
> Source rpm package needs tar package as its source codes. log files \
> are required as a part of source (description in bug 1655).
> So log files need be packaged as tar package too.
> User can select two types of package, the first is tar package and the second is src.rpm package.
> The option item is defined in conf/local.conf.(ARCHIVE_TYPE ?= "SRPM"(default) or ARCHIVE_TYPE ?= "TARGZ")
> if the option is the first type, then tar_archive.bbclass should be inherited in an suitable position.
> The tar packages(sources.tar.gz and log.tar.gz) will be created in workdir.
> if the option is the second type, then tar_archive.bbclass shoud be inherited in package_rpm.bbclass.
> The sources rpm packages will be created in workdir/deploy-srpm when building.
> The following command can ship all of source packages(src.rpm or tar.gz) to build/tmp/deploy/sources
> $bitbake core-image-sato -c copysources
>
> [YOCTO #1655]
>
> Signed-off-by: Xiaofeng Yan<xiaofeng.yan at windriver.com>
> ---
> meta/classes/tar_archive.bbclass | 216 ++++++++++++++++++++++++++++++++++++++
> 1 files changed, 216 insertions(+), 0 deletions(-)
> create mode 100644 meta/classes/tar_archive.bbclass
>
...
> +addtask do_logarchive after do_install before do_package
> +
> +# This is used for fixing the "Bad owner/group: ..."
> +# Set owner and group for patches, log.tar.gz and ${PF}.tar.gz to "root"
> +do_setowngroup[dirs] = "${WORKDIR}"
> +fakeroot python do_setowngroup(){
> + import os
> +
> + if not d.getVar('ARCHIVE_TYPE', True):
> + return
> + bb.build.exec_func('not_srpm', d)
> + if d.getVar('NOTSRPM', True):
> + return
> + bb.build.exec_func('get_patches', d)
> + srcpatches = d.getVar('PLIST',True)
> + for patch in srcpatches:
> + os.system('chown root.root' + ' ' + patch)
> + os.system('chown root.root' + ' ' + "log.tar.gz")
> + os.system('chown root.root' + ' ' + d.getVar('PF', True) + ".tar.gz")
> +}
Instead of the above during the creation of the tar archive, you should be able
to pass in --owner=root --group=root and tar will ignore the on-disk
permissions and set it based on the arguments.
> +addtask do_setowngroup after do_logarchive before do_package
> +
> +# Copy source package to build/tmp/deploy/sources
> +do_copysources[dirs] = "${PWD}/tmp/work"
> +python do_copysources (){
> + import os
> +
> + archive_type = d.getVar('ARCHIVE_TYPE', True)
> + pwd = d.getVar('PWD', True)
> + machine = d.getVar('MACHINE', True)
> + target_sys = d.getVar('TARGET_SYS', True)
> + target_os = d.getVar('TARGET_OS', True)
> + target_vendor = d.getVar('TARGET_VENDOR', True)
> + tune_pkgarch = d.getVar('TUNE_PKGARCH', True)
> + multimach_host_sys = d.getVar('MULTIMACH_HOST_SYS', True)
> + all = 'all' + target_vendor + '-' + 'linux'
> + target = tune_pkgarch + target_vendor + '-' + target_os
> + srpmdir=pwd + '/tmp/deploy/' + 'sources' + '/' + machine
> +
> + if not os.path.exists(srpmdir):
> + os.makedirs(srpmdir)
> + global_work = pwd + '/tmp' + '/work'
> + os.chdir(global_work)
> + for dirs in multimach_host_sys, all, target:
> + localdir = srpmdir + '/' + dirs
> + if not os.path.exists(localdir):
> + os.mkdir(localdir)
> + os.chdir(dirs)
> + if archive_type == 'SRPM':
> + os.system('cp */deploy-srpm/*/*.src.rpm ' + localdir)
> + elif archive_type == 'TARGZ':
> + for dir in os.listdir('.'):
> + if os.path.isdir(dir):
> + os.chdir(dir)
> + if not os.path.exists(dir):
> + os.mkdir(localdir + '/' + dir)
> + os.system('cp *.gz ' + localdir + '/' + dir)
> + os.chdir('../')
> + else:
> + return
> + os.chdir(global_work)
> +}
> +addtask do_copysources after do_rootfs
> +
> +EXPORT_FUNCTIONS do_archive do_logarchive do_setowngroup do_copysources
More information about the Openembedded-core
mailing list