* [PATCH 0/6] archiver.bbclass: fixes and clean up
@ 2012-08-26 6:51 Robert Yang
2012-08-26 6:51 ` [PATCH 1/6] archiver.bbclass: indent fixes Robert Yang
` (6 more replies)
0 siblings, 7 replies; 8+ messages in thread
From: Robert Yang @ 2012-08-26 6:51 UTC (permalink / raw)
To: openembedded-core; +Cc: Zhenfeng.Zhao
* Fix the indent and coding style
* Fix the fakeroot error and other issues
* remove the "upper()" function
* copyleft_compliance.bbclass: remove the duplicated code
* fix the remove error
I have sent a patch to yocto@yoctoproject.org to update the
local.conf.sample.extended
// Robert
The following changes since commit b4c5725af4cd85d5644f0373e2674e903c4eab2b:
yocto-bsp: add missing xserver-xf86-config .bbappend for qemu (2012-08-25 14:47:07 +0100)
are available in the git repository at:
git://git.pokylinux.org/poky-contrib robert/archiver
http://git.pokylinux.org/cgit.cgi/poky-contrib/log/?h=robert/archiver_sample
Robert Yang (6):
archiver.bbclass: indent fixes
archiver.bbclass: fix the coding style
archiver.bbclass: fix the fakeroot and other issues
archiver.bbclass: remove the "upper()" function
copyleft_compliance.bbclass: remove the duplicated code
archiver.bbclass: fix the remove error
meta/classes/archive-configured-source.bbclass | 9 +-
meta/classes/archive-original-source.bbclass | 9 +-
meta/classes/archive-patched-source.bbclass | 9 +-
meta/classes/archiver.bbclass | 884 +++++++++++++------------
meta/classes/copyleft_compliance.bbclass | 51 +-
meta/classes/package_rpm.bbclass | 43 +-
6 files changed, 503 insertions(+), 502 deletions(-)
--
1.7.11.2
^ permalink raw reply [flat|nested] 8+ messages in thread
* [PATCH 1/6] archiver.bbclass: indent fixes
2012-08-26 6:51 [PATCH 0/6] archiver.bbclass: fixes and clean up Robert Yang
@ 2012-08-26 6:51 ` Robert Yang
2012-08-26 6:51 ` [PATCH 2/6] archiver.bbclass: fix the coding style Robert Yang
` (5 subsequent siblings)
6 siblings, 0 replies; 8+ messages in thread
From: Robert Yang @ 2012-08-26 6:51 UTC (permalink / raw)
To: openembedded-core; +Cc: Zhenfeng.Zhao
Several fixes:
* It uses mixed tab and whitespace as the indent in one function,
Fix them to use "4 spaces" as the indent.
* Remove the unwanted blank, for example, more than one blank lines
appeared together.
* Remove the tail whitespace.
[YOCTO #2619]
Signed-off-by: Robert Yang <liezhi.yang@windriver.com>
---
meta/classes/archiver.bbclass | 757 ++++++++++++++++++++-------------------
meta/classes/package_rpm.bbclass | 1 -
2 files changed, 379 insertions(+), 379 deletions(-)
diff --git a/meta/classes/archiver.bbclass b/meta/classes/archiver.bbclass
index 8e97e44..117ad02 100644
--- a/meta/classes/archiver.bbclass
+++ b/meta/classes/archiver.bbclass
@@ -1,6 +1,10 @@
+# ex:ts=4:sw=4:sts=4:et
+# -*- tab-width: 4; c-basic-offset: 4; indent-tabs-mode: nil -*-
+#
# This file is used for archiving sources ,patches,and logs to tarball.
-# It also output building environment to xxx.dump.data and create xxx.diff.gz to record
-# all content in ${S} to a diff file.
+# It also output building environment to xxx.dump.data and create xxx.diff.gz to record
+# all content in ${S} to a diff file.
+#
ARCHIVE_EXCLUDE_FROM ?= ".pc autom4te.cache"
ARCHIVE_TYPE ?= "TAR SRPM"
@@ -67,454 +71,451 @@ def tar_filter(d):
if d.getVar('FILTER', True).upper() == "YES":
included, reason = copyleft_should_include(d)
if not included:
- return False
+ return False
else:
- return True
+ return True
else:
return False
def get_bb_inc(d):
- '''create a directory "script-logs" including .bb and .inc file in ${WORKDIR}'''
- import re
- import shutil
-
- bbinc = []
- pat=re.compile('require\s*([^\s]*\.*)(.*)')
- work_dir = d.getVar('WORKDIR', True)
- bbfile = d.getVar('FILE', True)
- bbdir = os.path.dirname(bbfile)
- script_logs = os.path.join(work_dir,'script-logs')
- bb_inc = os.path.join(script_logs,'bb_inc')
- bb.mkdirhier(script_logs)
- bb.mkdirhier(bb_inc)
-
- def find_file(dir,file):
- for root, dirs, files in os.walk(dir):
- if file in files:
- return os.path.join(root,file)
-
- def get_inc (file):
- f = open(file,'r')
- for line in f.readlines():
- if 'require' not in line:
- bbinc.append(file)
- else:
- try:
- incfile = pat.match(line).group(1)
- incfile = bb.data.expand(os.path.basename(incfile),d)
- abs_incfile = find_file(bbdir,incfile)
- if abs_incfile:
- bbinc.append(abs_incfile)
- get_inc(abs_incfile)
- except AttributeError:
- pass
- get_inc(bbfile)
- bbinc = list(set(bbinc))
- for bbincfile in bbinc:
- shutil.copy(bbincfile,bb_inc)
-
- try:
- bb.mkdirhier(os.path.join(script_logs,'temp'))
- oe.path.copytree(os.path.join(work_dir,'temp'), os.path.join(script_logs,'temp'))
- except (IOError,AttributeError):
- pass
- return script_logs
-
-def get_series(d):
- '''copy patches and series file to a pointed directory which will be archived to tarball in ${WORKDIR}'''
- import shutil
-
- src_patches=[]
- pf = d.getVar('PF', True)
- work_dir = d.getVar('WORKDIR', True)
- s = d.getVar('S',True)
- dest = os.path.join(work_dir, pf + '-series')
- shutil.rmtree(dest, ignore_errors=True)
- bb.mkdirhier(dest)
-
- src_uri = d.getVar('SRC_URI', True).split()
- fetch = bb.fetch2.Fetch(src_uri, d)
- locals = (fetch.localpath(url) for url in fetch.urls)
- for local in locals:
- src_patches.append(local)
- if not cmp(work_dir,s):
- tmp_list = src_patches
- else:
- tmp_list = src_patches[1:]
-
- for patch in tmp_list:
- try:
- shutil.copy(patch,dest)
- except IOError:
- if os.path.isdir(patch):
- bb.mkdirhier(os.path.join(dest,patch))
- oe.path.copytree(patch, os.path.join(dest,patch))
- return dest
-
-def get_applying_patches(d):
- """only copy applying patches to a pointed directory which will be archived to tarball"""
- import shutil
+ '''create a directory "script-logs" including .bb and .inc file in ${WORKDIR}'''
+ import re
+ import shutil
+
+ bbinc = []
+ pat=re.compile('require\s*([^\s]*\.*)(.*)')
+ work_dir = d.getVar('WORKDIR', True)
+ bbfile = d.getVar('FILE', True)
+ bbdir = os.path.dirname(bbfile)
+ script_logs = os.path.join(work_dir,'script-logs')
+ bb_inc = os.path.join(script_logs,'bb_inc')
+ bb.mkdirhier(script_logs)
+ bb.mkdirhier(bb_inc)
+
+ def find_file(dir,file):
+ for root, dirs, files in os.walk(dir):
+ if file in files:
+ return os.path.join(root,file)
+
+ def get_inc (file):
+ f = open(file,'r')
+ for line in f.readlines():
+ if 'require' not in line:
+ bbinc.append(file)
+ else:
+ try:
+ incfile = pat.match(line).group(1)
+ incfile = bb.data.expand(os.path.basename(incfile),d)
+ abs_incfile = find_file(bbdir,incfile)
+ if abs_incfile:
+ bbinc.append(abs_incfile)
+ get_inc(abs_incfile)
+ except AttributeError:
+ pass
+ get_inc(bbfile)
+ bbinc = list(set(bbinc))
+ for bbincfile in bbinc:
+ shutil.copy(bbincfile,bb_inc)
+ try:
+ bb.mkdirhier(os.path.join(script_logs,'temp'))
+ oe.path.copytree(os.path.join(work_dir,'temp'), os.path.join(script_logs,'temp'))
+ except (IOError,AttributeError):
+ pass
+ return script_logs
- pf = d.getVar('PF', True)
- work_dir = d.getVar('WORKDIR', True)
- dest = os.path.join(work_dir, pf + '-patches')
- shutil.rmtree(dest, ignore_errors=True)
- bb.mkdirhier(dest)
+def get_series(d):
+ '''copy patches and series file to a pointed directory which will be archived to tarball in ${WORKDIR}'''
+ import shutil
+
+ src_patches=[]
+ pf = d.getVar('PF', True)
+ work_dir = d.getVar('WORKDIR', True)
+ s = d.getVar('S',True)
+ dest = os.path.join(work_dir, pf + '-series')
+ shutil.rmtree(dest, ignore_errors=True)
+ bb.mkdirhier(dest)
+
+ src_uri = d.getVar('SRC_URI', True).split()
+ fetch = bb.fetch2.Fetch(src_uri, d)
+ locals = (fetch.localpath(url) for url in fetch.urls)
+ for local in locals:
+ src_patches.append(local)
+ if not cmp(work_dir,s):
+ tmp_list = src_patches
+ else:
+ tmp_list = src_patches[1:]
+ for patch in tmp_list:
+ try:
+ shutil.copy(patch,dest)
+ except IOError:
+ if os.path.isdir(patch):
+ bb.mkdirhier(os.path.join(dest,patch))
+ oe.path.copytree(patch, os.path.join(dest,patch))
+ return dest
- patches = src_patches(d)
- for patch in patches:
- _, _, local, _, _, parm = bb.decodeurl(patch)
- if local:
- shutil.copy(local,dest)
- return dest
+def get_applying_patches(d):
+ """only copy applying patches to a pointed directory which will be archived to tarball"""
+ import shutil
+
+ pf = d.getVar('PF', True)
+ work_dir = d.getVar('WORKDIR', True)
+ dest = os.path.join(work_dir, pf + '-patches')
+ shutil.rmtree(dest, ignore_errors=True)
+ bb.mkdirhier(dest)
+
+ patches = src_patches(d)
+ for patch in patches:
+ _, _, local, _, _, parm = bb.decodeurl(patch)
+ if local:
+ shutil.copy(local,dest)
+ return dest
def not_tarball(d):
- '''packages including key words 'work-shared','native', 'task-' will be passed'''
+ '''packages including key words 'work-shared','native', 'task-' will be passed'''
- workdir = d.getVar('WORKDIR',True)
- s = d.getVar('S',True)
- if 'work-shared' in s or 'task-' in workdir or 'native' in workdir:
- return True
- else:
- return False
+ workdir = d.getVar('WORKDIR',True)
+ s = d.getVar('S',True)
+ if 'work-shared' in s or 'task-' in workdir or 'native' in workdir:
+ return True
+ else:
+ return False
def get_source_from_downloads(d,stage_name):
- '''copy tarball of $P to $WORKDIR when this tarball exists in $DL_DIR'''
- if stage_name in 'patched' 'configured':
- return
- pf = d.getVar('PF', True)
- dl_dir = d.getVar('DL_DIR',True)
- try:
- source = os.path.join(dl_dir,os.path.basename(d.getVar('SRC_URI', True).split()[0]))
- if os.path.exists(source) and not os.path.isdir(source):
- return source
- except (IndexError, OSError):
- pass
- return ''
+ '''copy tarball of $P to $WORKDIR when this tarball exists in $DL_DIR'''
+ if stage_name in 'patched' 'configured':
+ return
+ pf = d.getVar('PF', True)
+ dl_dir = d.getVar('DL_DIR',True)
+ try:
+ source = os.path.join(dl_dir,os.path.basename(d.getVar('SRC_URI', True).split()[0]))
+ if os.path.exists(source) and not os.path.isdir(source):
+ return source
+ except (IndexError, OSError):
+ pass
+ return ''
def do_tarball(workdir,srcdir,tarname):
- '''tar "srcdir" under "workdir" to "tarname"'''
- import tarfile
-
- sav_dir = os.getcwd()
- os.chdir(workdir)
- if (len(os.listdir(srcdir))) != 0:
- tar = tarfile.open(tarname, "w:gz")
- tar.add(srcdir)
- tar.close()
- else:
- tarname = ''
- os.chdir(sav_dir)
- return tarname
-
-def archive_sources_from_directory(d,stage_name):
- '''archive sources codes tree to tarball when tarball of $P doesn't exist in $DL_DIR'''
- import shutil
-
- s = d.getVar('S',True)
- work_dir=d.getVar('WORKDIR', True)
- PF = d.getVar('PF',True)
- tarname = PF + '-' + stage_name + ".tar.gz"
-
- if os.path.exists(s) and work_dir in s:
- try:
- source_dir = os.path.join(work_dir,[ i for i in s.replace(work_dir,'').split('/') if i][0])
- except IndexError:
- if not cmp(s,work_dir):
- return ''
- else:
- return ''
- source = os.path.basename(source_dir)
- return do_tarball(work_dir,source,tarname)
+ '''tar "srcdir" under "workdir" to "tarname"'''
+ import tarfile
+
+ sav_dir = os.getcwd()
+ os.chdir(workdir)
+ if (len(os.listdir(srcdir))) != 0:
+ tar = tarfile.open(tarname, "w:gz")
+ tar.add(srcdir)
+ tar.close()
+ else:
+ tarname = ''
+ os.chdir(sav_dir)
+ return tarname
+
+def archive_sources_from_directory(d,stage_name):
+ '''archive sources codes tree to tarball when tarball of $P doesn't exist in $DL_DIR'''
+ import shutil
+
+ s = d.getVar('S',True)
+ work_dir=d.getVar('WORKDIR', True)
+ PF = d.getVar('PF',True)
+ tarname = PF + '-' + stage_name + ".tar.gz"
+
+ if os.path.exists(s) and work_dir in s:
+ try:
+ source_dir = os.path.join(work_dir,[ i for i in s.replace(work_dir,'').split('/') if i][0])
+ except IndexError:
+ if not cmp(s,work_dir):
+ return ''
+ else:
+ return ''
+ source = os.path.basename(source_dir)
+ return do_tarball(work_dir,source,tarname)
def archive_sources(d,stage_name):
- '''copy tarball from $DL_DIR to $WORKDIR if have tarball, archive source codes tree in $WORKDIR if $P is directory instead of tarball'''
- import shutil
- work_dir = d.getVar('WORKDIR',True)
- file = get_source_from_downloads(d,stage_name)
- if file:
- shutil.copy(file,work_dir)
- file = os.path.basename(file)
- else:
- file = archive_sources_from_directory(d,stage_name)
- return file
-
+ '''copy tarball from $DL_DIR to $WORKDIR if have tarball, archive source codes tree in $WORKDIR if $P is directory instead of tarball'''
+ import shutil
+ work_dir = d.getVar('WORKDIR',True)
+ file = get_source_from_downloads(d,stage_name)
+ if file:
+ shutil.copy(file,work_dir)
+ file = os.path.basename(file)
+ else:
+ file = archive_sources_from_directory(d,stage_name)
+ return file
def archive_patches(d,patchdir,series):
- '''archive patches to tarball and also include series files if 'series' is True'''
- import shutil
-
- s = d.getVar('S',True)
- work_dir = d.getVar('WORKDIR', True)
- patch_dir = os.path.basename(patchdir)
- tarname = patch_dir + ".tar.gz"
- if series == 'all' and os.path.exists(os.path.join(s,'patches/series')):
- shutil.copy(os.path.join(s,'patches/series'),patchdir)
- tarname = do_tarball(work_dir,patch_dir,tarname)
- shutil.rmtree(patchdir, ignore_errors=True)
- return tarname
+ '''archive patches to tarball and also include series files if 'series' is True'''
+ import shutil
+
+ s = d.getVar('S',True)
+ work_dir = d.getVar('WORKDIR', True)
+ patch_dir = os.path.basename(patchdir)
+ tarname = patch_dir + ".tar.gz"
+ if series == 'all' and os.path.exists(os.path.join(s,'patches/series')):
+ shutil.copy(os.path.join(s,'patches/series'),patchdir)
+ tarname = do_tarball(work_dir,patch_dir,tarname)
+ shutil.rmtree(patchdir, ignore_errors=True)
+ return tarname
def select_archive_patches(d,option):
- '''select to archive all patches including non-applying and series or applying patches '''
- if option == "all":
- patchdir = get_series(d)
- elif option == "applying":
- patchdir = get_applying_patches(d)
- try:
- os.rmdir(patchdir)
- except OSError:
- tarpatch = archive_patches(d,patchdir,option)
- return tarpatch
- return
+ '''select to archive all patches including non-applying and series or applying patches '''
+ if option == "all":
+ patchdir = get_series(d)
+ elif option == "applying":
+ patchdir = get_applying_patches(d)
+ try:
+ os.rmdir(patchdir)
+ except OSError:
+ tarpatch = archive_patches(d,patchdir,option)
+ return tarpatch
+ return
def archive_logs(d,logdir,bbinc=False):
- '''archive logs in temp to tarball and .bb and .inc files if bbinc is True '''
- import shutil
-
- pf = d.getVar('PF',True)
- work_dir = d.getVar('WORKDIR',True)
- log_dir = os.path.basename(logdir)
- tarname = pf + '-' + log_dir + ".tar.gz"
- tarname = do_tarball(work_dir,log_dir,tarname)
- if bbinc:
- shutil.rmtree(logdir, ignore_errors=True)
- return tarname
+ '''archive logs in temp to tarball and .bb and .inc files if bbinc is True '''
+ import shutil
+
+ pf = d.getVar('PF',True)
+ work_dir = d.getVar('WORKDIR',True)
+ log_dir = os.path.basename(logdir)
+ tarname = pf + '-' + log_dir + ".tar.gz"
+ tarname = do_tarball(work_dir,log_dir,tarname)
+ if bbinc:
+ shutil.rmtree(logdir, ignore_errors=True)
+ return tarname
def get_licenses(d):
- '''get licenses for running .bb file'''
- import oe.license
-
- licenses_type = d.getVar('LICENSE', True) or ""
- lics = oe.license.is_included(licenses_type)[1:][0]
- lice = ''
- for lic in lics:
- licens = d.getVarFlag('SPDXLICENSEMAP', lic)
- if licens != None:
- lice += licens
- else:
- lice += lic
- return lice
-
+ '''get licenses for running .bb file'''
+ import oe.license
+
+ licenses_type = d.getVar('LICENSE', True) or ""
+ lics = oe.license.is_included(licenses_type)[1:][0]
+ lice = ''
+ for lic in lics:
+ licens = d.getVarFlag('SPDXLICENSEMAP', lic)
+ if licens != None:
+ lice += licens
+ else:
+ lice += lic
+ return lice
+
def move_tarball_deploy(d,tarball_list):
- '''move tarball in location to ${DEPLOY_DIR}/sources'''
- import shutil
-
- if tarball_list is []:
- return
- target_sys = d.getVar('TARGET_SYS', True)
- pf = d.getVar('PF', True)
- licenses = get_licenses(d)
- work_dir = d.getVar('WORKDIR',True)
- tar_sources = d.getVar('DEPLOY_DIR', True) + '/sources/' + target_sys + '/' + licenses + '/' + pf
- if not os.path.exists(tar_sources):
- bb.mkdirhier(tar_sources)
- for source in tarball_list:
- if source:
- if os.path.exists(os.path.join(tar_sources, source)):
- os.remove(os.path.join(tar_sources,source))
- shutil.move(os.path.join(work_dir,source),tar_sources)
+ '''move tarball in location to ${DEPLOY_DIR}/sources'''
+ import shutil
+
+ if tarball_list is []:
+ return
+ target_sys = d.getVar('TARGET_SYS', True)
+ pf = d.getVar('PF', True)
+ licenses = get_licenses(d)
+ work_dir = d.getVar('WORKDIR',True)
+ tar_sources = d.getVar('DEPLOY_DIR', True) + '/sources/' + target_sys + '/' + licenses + '/' + pf
+ if not os.path.exists(tar_sources):
+ bb.mkdirhier(tar_sources)
+ for source in tarball_list:
+ if source:
+ if os.path.exists(os.path.join(tar_sources, source)):
+ os.remove(os.path.join(tar_sources,source))
+ shutil.move(os.path.join(work_dir,source),tar_sources)
def check_archiving_type(d):
- '''check the type for archiving package('tar' or 'srpm')'''
- try:
- if d.getVar('SOURCE_ARCHIVE_PACKAGE_TYPE', True).upper() not in d.getVar('ARCHIVE_TYPE', True).split():
- raise AttributeError
- except AttributeError:
- bb.fatal("\"SOURCE_ARCHIVE_PACKAGE_TYPE\" is \'tar\' or \'srpm\', no other types")
+ '''check the type for archiving package('tar' or 'srpm')'''
+ try:
+ if d.getVar('SOURCE_ARCHIVE_PACKAGE_TYPE', True).upper() not in d.getVar('ARCHIVE_TYPE', True).split():
+ raise AttributeError
+ except AttributeError:
+ bb.fatal("\"SOURCE_ARCHIVE_PACKAGE_TYPE\" is \'tar\' or \'srpm\', no other types")
def store_package(d,package_name):
- '''store tarbablls name to file "tar-package"'''
- try:
- f = open(os.path.join(d.getVar('WORKDIR',True),'tar-package'),'a')
- f.write(package_name + ' ')
- f.close()
- except IOError:
- pass
+ '''store tarbablls name to file "tar-package"'''
+ try:
+ f = open(os.path.join(d.getVar('WORKDIR',True),'tar-package'),'a')
+ f.write(package_name + ' ')
+ f.close()
+ except IOError:
+ pass
def get_package(d):
- '''get tarballs name from "tar-package"'''
- work_dir = (d.getVar('WORKDIR', True))
- tarpackage = os.path.join(work_dir,'tar-package')
- try:
- f = open(tarpackage,'r')
- line = list(set(f.readline().replace('\n','').split()))
- except UnboundLocalError,IOError:
- pass
- f.close()
- return line
+ '''get tarballs name from "tar-package"'''
+ work_dir = (d.getVar('WORKDIR', True))
+ tarpackage = os.path.join(work_dir,'tar-package')
+ try:
+ f = open(tarpackage,'r')
+ line = list(set(f.readline().replace('\n','').split()))
+ except UnboundLocalError,IOError:
+ pass
+ f.close()
+ return line
def archive_sources_patches(d,stage_name):
- '''archive sources and patches to tarball. stage_name will append strings ${stage_name} to ${PR} as middle name. for example, zlib-1.4.6-prepatch(stage_name).tar.gz '''
- import shutil
-
- check_archiving_type(d)
- if not_tarball(d) or tar_filter(d):
- return
-
- source_tar_name = archive_sources(d,stage_name)
- if stage_name == "prepatch":
- if d.getVar('PATCHES_ARCHIVE_WITH_SERIES',True).upper() == 'TRUE':
- patch_tar_name = select_archive_patches(d,"all")
- elif d.getVar('PATCHES_ARCHIVE_WITH_SERIES',True).upper() == 'FALSE':
- patch_tar_name = select_archive_patches(d,"applying")
- else:
- bb.fatal("Please define 'PATCHES_ARCHIVE_WITH_SERIES' is strings 'True' or 'False' ")
- else:
- patch_tar_name = ''
-
- if d.getVar('SOURCE_ARCHIVE_PACKAGE_TYPE', True).upper() not in 'SRPM':
- move_tarball_deploy(d,[source_tar_name,patch_tar_name])
- else:
- tarpackage = os.path.join(d.getVar('WORKDIR', True),'tar-package')
- if os.path.exists(tarpackage):
- os.remove(tarpackage)
- for package in os.path.basename(source_tar_name), patch_tar_name:
- if package:
- store_package(d,str(package) + ' ')
+ '''archive sources and patches to tarball. stage_name will append strings ${stage_name} to ${PR} as middle name. for example, zlib-1.4.6-prepatch(stage_name).tar.gz '''
+ import shutil
+
+ check_archiving_type(d)
+ if not_tarball(d) or tar_filter(d):
+ return
+
+ source_tar_name = archive_sources(d,stage_name)
+ if stage_name == "prepatch":
+ if d.getVar('PATCHES_ARCHIVE_WITH_SERIES',True).upper() == 'TRUE':
+ patch_tar_name = select_archive_patches(d,"all")
+ elif d.getVar('PATCHES_ARCHIVE_WITH_SERIES',True).upper() == 'FALSE':
+ patch_tar_name = select_archive_patches(d,"applying")
+ else:
+ bb.fatal("Please define 'PATCHES_ARCHIVE_WITH_SERIES' is strings 'True' or 'False' ")
+ else:
+ patch_tar_name = ''
+
+ if d.getVar('SOURCE_ARCHIVE_PACKAGE_TYPE', True).upper() not in 'SRPM':
+ move_tarball_deploy(d,[source_tar_name,patch_tar_name])
+ else:
+ tarpackage = os.path.join(d.getVar('WORKDIR', True),'tar-package')
+ if os.path.exists(tarpackage):
+ os.remove(tarpackage)
+ for package in os.path.basename(source_tar_name), patch_tar_name:
+ if package:
+ store_package(d,str(package) + ' ')
def archive_scripts_logs(d):
- '''archive scripts and logs. scripts include .bb and .inc files and logs include stuff in "temp".'''
-
- if tar_filter(d):
- return
- work_dir = d.getVar('WORKDIR', True)
- temp_dir = os.path.join(work_dir,'temp')
- source_archive_log_with_scripts = d.getVar('SOURCE_ARCHIVE_LOG_WITH_SCRIPTS', True)
- if source_archive_log_with_scripts == 'logs_with_scripts':
- logdir = get_bb_inc(d)
- tarlog = archive_logs(d,logdir,True)
- elif source_archive_log_with_scripts == 'logs':
- if os.path.exists(temp_dir):
- tarlog = archive_logs(d,temp_dir,False)
- else:
- return
-
- if d.getVar('SOURCE_ARCHIVE_PACKAGE_TYPE', True).upper() not in 'SRPM':
- move_tarball_deploy(d,[tarlog])
-
- else:
- store_package(d,tarlog)
+ '''archive scripts and logs. scripts include .bb and .inc files and logs include stuff in "temp".'''
+
+ if tar_filter(d):
+ return
+ work_dir = d.getVar('WORKDIR', True)
+ temp_dir = os.path.join(work_dir,'temp')
+ source_archive_log_with_scripts = d.getVar('SOURCE_ARCHIVE_LOG_WITH_SCRIPTS', True)
+ if source_archive_log_with_scripts == 'logs_with_scripts':
+ logdir = get_bb_inc(d)
+ tarlog = archive_logs(d,logdir,True)
+ elif source_archive_log_with_scripts == 'logs':
+ if os.path.exists(temp_dir):
+ tarlog = archive_logs(d,temp_dir,False)
+ else:
+ return
+
+ if d.getVar('SOURCE_ARCHIVE_PACKAGE_TYPE', True).upper() not in 'SRPM':
+ move_tarball_deploy(d,[tarlog])
+
+ else:
+ store_package(d,tarlog)
def dumpdata(d):
- '''dump environment to "${P}-${PR}.showdata.dump" including all kinds of variables and functions when running a task'''
-
- if tar_filter(d):
- return
- workdir = bb.data.getVar('WORKDIR', d, 1)
- distro = bb.data.getVar('DISTRO', d, 1)
- s = d.getVar('S', True)
- pf = d.getVar('PF', True)
- target_sys = d.getVar('TARGET_SYS', True)
- licenses = get_licenses(d)
- dumpdir = d.getVar('DEPLOY_DIR', True) + '/sources/' + target_sys + '/' + licenses + '/' + pf
- if not os.path.exists(dumpdir):
- bb.mkdirhier(dumpdir)
-
- dumpfile = os.path.join(dumpdir, bb.data.expand("${P}-${PR}.showdata.dump",d))
-
- bb.note("Dumping metadata into '%s'" % dumpfile)
- f = open(dumpfile, "w")
- # emit variables and shell functions
- bb.data.emit_env(f, d, True)
- # emit the metadata which isnt valid shell
- for e in d.keys():
- if bb.data.getVarFlag(e, 'python', d):
- f.write("\npython %s () {\n%s}\n" % (e, bb.data.getVar(e, d, 1)))
- f.close()
+ '''dump environment to "${P}-${PR}.showdata.dump" including all kinds of variables and functions when running a task'''
+
+ if tar_filter(d):
+ return
+ workdir = bb.data.getVar('WORKDIR', d, 1)
+ distro = bb.data.getVar('DISTRO', d, 1)
+ s = d.getVar('S', True)
+ pf = d.getVar('PF', True)
+ target_sys = d.getVar('TARGET_SYS', True)
+ licenses = get_licenses(d)
+ dumpdir = d.getVar('DEPLOY_DIR', True) + '/sources/' + target_sys + '/' + licenses + '/' + pf
+ if not os.path.exists(dumpdir):
+ bb.mkdirhier(dumpdir)
+
+ dumpfile = os.path.join(dumpdir, bb.data.expand("${P}-${PR}.showdata.dump",d))
+
+ bb.note("Dumping metadata into '%s'" % dumpfile)
+ f = open(dumpfile, "w")
+ # emit variables and shell functions
+ bb.data.emit_env(f, d, True)
+ # emit the metadata which isnt valid shell
+ for e in d.keys():
+ if bb.data.getVarFlag(e, 'python', d):
+ f.write("\npython %s () {\n%s}\n" % (e, bb.data.getVar(e, d, 1)))
+ f.close()
def create_diff_gz(d):
- '''creating .diff.gz in ${DEPLOY_DIR_SRC}/${P}-${PR}.diff.g gz for mapping all content in 's' including patches to xxx.diff.gz'''
- import shutil
- import subprocess
-
- if tar_filter(d):
- return
- work_dir = d.getVar('WORKDIR', True)
- exclude_from = d.getVar('ARCHIVE_EXCLUDE_FROM', True).split()
- pf = d.getVar('PF', True)
- licenses = get_licenses(d)
- target_sys = d.getVar('TARGET_SYS', True)
- diff_dir = d.getVar('DEPLOY_DIR', True) + '/sources/' + target_sys + '/' + licenses + '/' + pf
- diff_file = os.path.join(diff_dir, bb.data.expand("${P}-${PR}.diff.gz",d))
-
- f = open(os.path.join(work_dir,'temp/exclude-from-file'), 'a')
- for i in exclude_from:
- f.write(i)
- f.write("\n")
- f.close()
-
- s=d.getVar('S', True)
- distro = d.getVar('DISTRO',True)
- dest = s + '/' + distro + '/files'
- if not os.path.exists(dest):
- bb.mkdirhier(dest)
- for i in os.listdir(os.getcwd()):
- if os.path.isfile(i):
- try:
- shutil.copy(i, dest)
- except IOError:
- subprocess.call('fakeroot cp -rf ' + i + " " + dest, shell=True)
-
- bb.note("Creating .diff.gz in ${DEPLOY_DIR_SRC}/${P}-${PR}.diff.gz")
- cmd = "LC_ALL=C TZ=UTC0 diff --exclude-from=" + work_dir + "/temp/exclude-from-file -Naur " + s + '.org' + ' ' + s + " | gzip -c > " + diff_file
- d.setVar('DIFF', cmd + "\n")
- d.setVarFlag('DIFF', 'func', '1')
- bb.build.exec_func('DIFF', d)
- shutil.rmtree(s + '.org', ignore_errors=True)
+ '''creating .diff.gz in ${DEPLOY_DIR_SRC}/${P}-${PR}.diff.g gz for mapping all content in 's' including patches to xxx.diff.gz'''
+ import shutil
+ import subprocess
+
+ if tar_filter(d):
+ return
+ work_dir = d.getVar('WORKDIR', True)
+ exclude_from = d.getVar('ARCHIVE_EXCLUDE_FROM', True).split()
+ pf = d.getVar('PF', True)
+ licenses = get_licenses(d)
+ target_sys = d.getVar('TARGET_SYS', True)
+ diff_dir = d.getVar('DEPLOY_DIR', True) + '/sources/' + target_sys + '/' + licenses + '/' + pf
+ diff_file = os.path.join(diff_dir, bb.data.expand("${P}-${PR}.diff.gz",d))
+
+ f = open(os.path.join(work_dir,'temp/exclude-from-file'), 'a')
+ for i in exclude_from:
+ f.write(i)
+ f.write("\n")
+ f.close()
+
+ s=d.getVar('S', True)
+ distro = d.getVar('DISTRO',True)
+ dest = s + '/' + distro + '/files'
+ if not os.path.exists(dest):
+ bb.mkdirhier(dest)
+ for i in os.listdir(os.getcwd()):
+ if os.path.isfile(i):
+ try:
+ shutil.copy(i, dest)
+ except IOError:
+ subprocess.call('fakeroot cp -rf ' + i + " " + dest, shell=True)
+
+ bb.note("Creating .diff.gz in ${DEPLOY_DIR_SRC}/${P}-${PR}.diff.gz")
+ cmd = "LC_ALL=C TZ=UTC0 diff --exclude-from=" + work_dir + "/temp/exclude-from-file -Naur " + s + '.org' + ' ' + s + " | gzip -c > " + diff_file
+ d.setVar('DIFF', cmd + "\n")
+ d.setVarFlag('DIFF', 'func', '1')
+ bb.build.exec_func('DIFF', d)
+ shutil.rmtree(s + '.org', ignore_errors=True)
# This function will run when user want to get tarball for sources and patches after do_unpack
python do_archive_original_sources_patches(){
- archive_sources_patches(d,'prepatch')
+ archive_sources_patches(d,'prepatch')
}
# This function will run when user want to get tarball for patched sources after do_patch
python do_archive_patched_sources(){
- archive_sources_patches(d,'patched')
+ archive_sources_patches(d,'patched')
}
# This function will run when user want to get tarball for configured sources after do_configure
python do_archive_configured_sources(){
- archive_sources_patches(d,'configured')
+ archive_sources_patches(d,'configured')
}
# This function will run when user want to get tarball for logs or both logs and scripts(.bb and .inc files)
python do_archive_scripts_logs(){
- archive_scripts_logs(d)
+ archive_scripts_logs(d)
}
-# This function will run when user want to know what variable and functions in a running task are and also can get a diff file including
+# This function will run when user want to know what variable and functions in a running task are and also can get a diff file including
# all content a package should include.
python do_dumpdata_create_diff_gz(){
- dumpdata(d)
- create_diff_gz(d)
+ dumpdata(d)
+ create_diff_gz(d)
}
# This functions prepare for archiving "linux-yocto" because this package create directory 's' before do_patch instead of after do_unpack.
# This is special control for archiving linux-yocto only.
python do_archive_linux_yocto(){
- s = d.getVar('S', True)
- if 'linux-yocto' in s:
- source_tar_name = archive_sources(d,'')
- if d.getVar('SOURCE_ARCHIVE_PACKAGE_TYPE', True).upper() not in 'SRPM':
- move_tarball_deploy(d,[source_tar_name,''])
+ s = d.getVar('S', True)
+ if 'linux-yocto' in s:
+ source_tar_name = archive_sources(d,'')
+ if d.getVar('SOURCE_ARCHIVE_PACKAGE_TYPE', True).upper() not in 'SRPM':
+ move_tarball_deploy(d,[source_tar_name,''])
}
do_kernel_checkout[postfuncs] += "do_archive_linux_yocto "
# remove tarball for sources, patches and logs after creating srpm.
python do_remove_tarball(){
- if d.getVar('SOURCE_ARCHIVE_PACKAGE_TYPE', True).upper() == 'SRPM':
- work_dir = d.getVar('WORKDIR', True)
- try:
- for file in os.listdir(os.getcwd()):
- if file in get_package(d):
- os.remove(file)
- os.remove(os.path.join(work_dir,'tar-package'))
- except (TypeError,OSError):
- pass
+ if d.getVar('SOURCE_ARCHIVE_PACKAGE_TYPE', True).upper() == 'SRPM':
+ work_dir = d.getVar('WORKDIR', True)
+ try:
+ for file in os.listdir(os.getcwd()):
+ if file in get_package(d):
+ os.remove(file)
+ os.remove(os.path.join(work_dir,'tar-package'))
+ except (TypeError,OSError):
+ pass
}
do_remove_taball[deptask] = "do_archive_scripts_logs"
do_package_write_rpm[postfuncs] += "do_remove_tarball "
diff --git a/meta/classes/package_rpm.bbclass b/meta/classes/package_rpm.bbclass
index 9abad5e..58a9aac 100644
--- a/meta/classes/package_rpm.bbclass
+++ b/meta/classes/package_rpm.bbclass
@@ -1152,7 +1152,6 @@ python do_package_rpm () {
d.setVarFlag('SBUILDSPEC', 'func', '1')
bb.build.exec_func('SBUILDSPEC', d)
-
# Build the rpm package!
d.setVar('BUILDSPEC', cmd + "\n")
d.setVarFlag('BUILDSPEC', 'func', '1')
--
1.7.11.2
^ permalink raw reply related [flat|nested] 8+ messages in thread
* [PATCH 2/6] archiver.bbclass: fix the coding style
2012-08-26 6:51 [PATCH 0/6] archiver.bbclass: fixes and clean up Robert Yang
2012-08-26 6:51 ` [PATCH 1/6] archiver.bbclass: indent fixes Robert Yang
@ 2012-08-26 6:51 ` Robert Yang
2012-08-26 6:51 ` [PATCH 3/6] archiver.bbclass: fix the fakeroot and other issues Robert Yang
` (4 subsequent siblings)
6 siblings, 0 replies; 8+ messages in thread
From: Robert Yang @ 2012-08-26 6:51 UTC (permalink / raw)
To: openembedded-core; +Cc: Zhenfeng.Zhao
* Make the comment line under 80 characters.
* Use the triple double quotes for the docstring.
* Add a whitespace behind the comma (,).
* Other minor fixes.
[YOCTO #2619]
Signed-off-by: Robert Yang <liezhi.yang@windriver.com>
---
meta/classes/archive-configured-source.bbclass | 9 +-
meta/classes/archive-original-source.bbclass | 9 +-
meta/classes/archive-patched-source.bbclass | 9 +-
meta/classes/archiver.bbclass | 288 +++++++++++++++----------
4 files changed, 190 insertions(+), 125 deletions(-)
diff --git a/meta/classes/archive-configured-source.bbclass b/meta/classes/archive-configured-source.bbclass
index 1a609b3..1eaaf4c 100644
--- a/meta/classes/archive-configured-source.bbclass
+++ b/meta/classes/archive-configured-source.bbclass
@@ -1,6 +1,9 @@
-# This file is for getting archiving packages with configured sources(archive 's' after configure stage),logs(archive 'temp' after package_write_rpm),dump data
-# and creating diff file(get all environment variables and functions in building and mapping all content in 's' including patches to xxx.diff.gz.
-# All archived packages will be deployed in ${DEPLOY_DIR}/sources
+# This file is for getting archiving packages with configured
+# sources(archive ${S} after configure stage), logs(archive 'temp' after
+# package_write_rpm), dump data and creating diff file(get all
+# environment variables and functions in building and mapping all
+# content in ${S} including patches to xxx.diff.gz. All archived
+# packages will be deployed in ${DEPLOY_DIR}/sources
inherit archiver
diff --git a/meta/classes/archive-original-source.bbclass b/meta/classes/archive-original-source.bbclass
index b085533..1b3f8d0 100644
--- a/meta/classes/archive-original-source.bbclass
+++ b/meta/classes/archive-original-source.bbclass
@@ -1,6 +1,9 @@
-# This file is for getting archiving packages with original sources(archive 's' after unpack stage),patches,logs(archive 'temp' after package_write_rpm),dump data and
-# creating diff file(get all environment variables and functions in building and mapping all content in 's' including patches to xxx.diff.gz.
-# All archived packages will be deployed in ${DEPLOY_DIR}/sources
+# This file is for getting archiving packages with original
+# sources(archive ${S} after unpack stage), patches, logs(archive 'temp'
+# after package_write_rpm), dump data and creating diff file(get all
+# environment variables and functions in building and mapping all
+# content in ${S} including patches to xxx.diff.gz. All archived packages
+# will be deployed in ${DEPLOY_DIR}/sources
inherit archiver
diff --git a/meta/classes/archive-patched-source.bbclass b/meta/classes/archive-patched-source.bbclass
index a6d368f..40b2dcb 100644
--- a/meta/classes/archive-patched-source.bbclass
+++ b/meta/classes/archive-patched-source.bbclass
@@ -1,6 +1,9 @@
-# This file is for getting archiving packages with patched sources(archive 's' before do_patch stage),logs(archive 'temp' after package_write_rpm),dump data and
-# creating diff file(get all environment variables and functions in building and mapping all content in 's' including patches to xxx.diff.gz.
-# All archived packages will be deployed in ${DEPLOY_DIR}/sources
+# This file is for getting archiving packages with patched
+# sources(archive ${S} before do_patch stage), logs(archive 'temp' after
+# package_write_rpm), dump data and creating diff file(get all
+# environment variables and functions in building and mapping all
+# content in ${S} including patches to xxx.diff.gz. All archived
+# packages will be deployed in ${DEPLOY_DIR}/sources
inherit archiver
diff --git a/meta/classes/archiver.bbclass b/meta/classes/archiver.bbclass
index 117ad02..b01b078 100644
--- a/meta/classes/archiver.bbclass
+++ b/meta/classes/archiver.bbclass
@@ -1,9 +1,9 @@
# ex:ts=4:sw=4:sts=4:et
# -*- tab-width: 4; c-basic-offset: 4; indent-tabs-mode: nil -*-
#
-# This file is used for archiving sources ,patches,and logs to tarball.
-# It also output building environment to xxx.dump.data and create xxx.diff.gz to record
-# all content in ${S} to a diff file.
+# This file is used for archiving sources, patches, and logs to a
+# tarball. It also output building environment to xxx.dump.data and
+# create xxx.diff.gz to record all content in ${S} to a diff file.
#
ARCHIVE_EXCLUDE_FROM ?= ".pc autom4te.cache"
@@ -11,11 +11,11 @@ ARCHIVE_TYPE ?= "TAR SRPM"
DISTRO ?= "poky"
PATCHES_ARCHIVE_WITH_SERIES = 'TRUE'
SOURCE_ARCHIVE_LOG_WITH_SCRIPTS ?= '${@d.getVarFlag('ARCHIVER_MODE', 'log_type') \
- if d.getVarFlag('ARCHIVER_MODE', 'log_type') != 'none' else 'logs_with_scripts'}'
-SOURCE_ARCHIVE_PACKAGE_TYPE ?= '${@d.getVarFlag('ARCHIVER_MODE','type') \
- if d.getVarFlag('ARCHIVER_MODE', 'log_type')!= 'none' else 'tar'}'
-FILTER ?= '${@d.getVarFlag('ARCHIVER_MODE','filter') \
- if d.getVarFlag('ARCHIVER_MODE', 'filter')!= 'none' else 'no'}'
+ if d.getVarFlag('ARCHIVER_MODE', 'log_type') != 'none' else 'logs_with_scripts'}'
+SOURCE_ARCHIVE_PACKAGE_TYPE ?= '${@d.getVarFlag('ARCHIVER_MODE', 'type') \
+ if d.getVarFlag('ARCHIVER_MODE', 'log_type') != 'none' else 'tar'}'
+FILTER ?= '${@d.getVarFlag('ARCHIVER_MODE', 'filter') \
+ if d.getVarFlag('ARCHIVER_MODE', 'filter')!= 'none' else 'no'}'
COPYLEFT_LICENSE_INCLUDE ?= 'GPL* LGPL*'
@@ -44,7 +44,9 @@ def copyleft_recipe_type(d):
return 'target'
def copyleft_should_include(d):
- """Determine if this recipe's sources should be deployed for compliance"""
+ """
+ Determine if this recipe's sources should be deployed for compliance
+ """
import ast
import oe.license
from fnmatch import fnmatchcase as fnmatch
@@ -67,7 +69,11 @@ def copyleft_should_include(d):
return False, 'recipe has excluded licenses: %s' % ', '.join(reason)
def tar_filter(d):
- """Only tarball the packages belonging to COPYLEFT_LICENSE_INCLUDE and miss packages in COPYLEFT_LICENSE_EXCLUDE. Don't tarball any packages when \"FILTER\" is \"no\""""
+ """
+ Only archive the package belongs to COPYLEFT_LICENSE_INCLUDE
+ and ignore the one in COPYLEFT_LICENSE_EXCLUDE. Don't exclude any
+ packages when \"FILTER\" is \"no\"
+ """
if d.getVar('FILTER', True).upper() == "YES":
included, reason = copyleft_should_include(d)
if not included:
@@ -78,7 +84,9 @@ def tar_filter(d):
return False
def get_bb_inc(d):
- '''create a directory "script-logs" including .bb and .inc file in ${WORKDIR}'''
+ """
+ create a directory "script-logs" including .bb and .inc file in ${WORKDIR}
+ """
import re
import shutil
@@ -87,26 +95,26 @@ def get_bb_inc(d):
work_dir = d.getVar('WORKDIR', True)
bbfile = d.getVar('FILE', True)
bbdir = os.path.dirname(bbfile)
- script_logs = os.path.join(work_dir,'script-logs')
- bb_inc = os.path.join(script_logs,'bb_inc')
+ script_logs = os.path.join(work_dir, 'script-logs')
+ bb_inc = os.path.join(script_logs, 'bb_inc')
bb.mkdirhier(script_logs)
bb.mkdirhier(bb_inc)
- def find_file(dir,file):
+ def find_file(dir, file):
for root, dirs, files in os.walk(dir):
if file in files:
- return os.path.join(root,file)
+ return os.path.join(root, file)
def get_inc (file):
- f = open(file,'r')
+ f = open(file, 'r')
for line in f.readlines():
if 'require' not in line:
bbinc.append(file)
else:
try:
incfile = pat.match(line).group(1)
- incfile = bb.data.expand(os.path.basename(incfile),d)
- abs_incfile = find_file(bbdir,incfile)
+ incfile = bb.data.expand(os.path.basename(incfile), d)
+ abs_incfile = find_file(bbdir, incfile)
if abs_incfile:
bbinc.append(abs_incfile)
get_inc(abs_incfile)
@@ -115,23 +123,26 @@ def get_bb_inc(d):
get_inc(bbfile)
bbinc = list(set(bbinc))
for bbincfile in bbinc:
- shutil.copy(bbincfile,bb_inc)
+ shutil.copy(bbincfile, bb_inc)
try:
- bb.mkdirhier(os.path.join(script_logs,'temp'))
- oe.path.copytree(os.path.join(work_dir,'temp'), os.path.join(script_logs,'temp'))
- except (IOError,AttributeError):
+ bb.mkdirhier(os.path.join(script_logs, 'temp'))
+ oe.path.copytree(os.path.join(work_dir, 'temp'), os.path.join(script_logs, 'temp'))
+ except (IOError, AttributeError):
pass
return script_logs
def get_series(d):
- '''copy patches and series file to a pointed directory which will be archived to tarball in ${WORKDIR}'''
+ """
+ copy patches and series file to a pointed directory which will be
+ archived to tarball in ${WORKDIR}
+ """
import shutil
src_patches=[]
pf = d.getVar('PF', True)
work_dir = d.getVar('WORKDIR', True)
- s = d.getVar('S',True)
+ s = d.getVar('S', True)
dest = os.path.join(work_dir, pf + '-series')
shutil.rmtree(dest, ignore_errors=True)
bb.mkdirhier(dest)
@@ -141,22 +152,25 @@ def get_series(d):
locals = (fetch.localpath(url) for url in fetch.urls)
for local in locals:
src_patches.append(local)
- if not cmp(work_dir,s):
+ if not cmp(work_dir, s):
tmp_list = src_patches
else:
tmp_list = src_patches[1:]
for patch in tmp_list:
try:
- shutil.copy(patch,dest)
+ shutil.copy(patch, dest)
except IOError:
if os.path.isdir(patch):
- bb.mkdirhier(os.path.join(dest,patch))
- oe.path.copytree(patch, os.path.join(dest,patch))
+ bb.mkdirhier(os.path.join(dest, patch))
+ oe.path.copytree(patch, os.path.join(dest, patch))
return dest
def get_applying_patches(d):
- """only copy applying patches to a pointed directory which will be archived to tarball"""
+ """
+ only copy applying patches to a pointed directory which will be
+ archived to tarball
+ """
import shutil
pf = d.getVar('PF', True)
@@ -169,35 +183,40 @@ def get_applying_patches(d):
for patch in patches:
_, _, local, _, _, parm = bb.decodeurl(patch)
if local:
- shutil.copy(local,dest)
+ shutil.copy(local, dest)
return dest
def not_tarball(d):
- '''packages including key words 'work-shared','native', 'task-' will be passed'''
-
- workdir = d.getVar('WORKDIR',True)
- s = d.getVar('S',True)
+ """
+ packages including key words 'work-shared', 'native', 'task-' will be passed
+ """
+ workdir = d.getVar('WORKDIR', True)
+ s = d.getVar('S', True)
if 'work-shared' in s or 'task-' in workdir or 'native' in workdir:
return True
else:
return False
-def get_source_from_downloads(d,stage_name):
- '''copy tarball of $P to $WORKDIR when this tarball exists in $DL_DIR'''
+def get_source_from_downloads(d, stage_name):
+ """
+ copy tarball of $P to $WORKDIR when this tarball exists in $DL_DIR
+ """
if stage_name in 'patched' 'configured':
return
pf = d.getVar('PF', True)
- dl_dir = d.getVar('DL_DIR',True)
+ dl_dir = d.getVar('DL_DIR', True)
try:
- source = os.path.join(dl_dir,os.path.basename(d.getVar('SRC_URI', True).split()[0]))
+ source = os.path.join(dl_dir, os.path.basename(d.getVar('SRC_URI', True).split()[0]))
if os.path.exists(source) and not os.path.isdir(source):
return source
except (IndexError, OSError):
pass
return ''
-def do_tarball(workdir,srcdir,tarname):
- '''tar "srcdir" under "workdir" to "tarname"'''
+def do_tarball(workdir, srcdir, tarname):
+ """
+ tar "srcdir" under "workdir" to "tarname"
+ """
import tarfile
sav_dir = os.getcwd()
@@ -211,54 +230,66 @@ def do_tarball(workdir,srcdir,tarname):
os.chdir(sav_dir)
return tarname
-def archive_sources_from_directory(d,stage_name):
- '''archive sources codes tree to tarball when tarball of $P doesn't exist in $DL_DIR'''
+def archive_sources_from_directory(d, stage_name):
+ """
+ archive sources codes tree to tarball when tarball of $P doesn't
+ exist in $DL_DIR
+ """
import shutil
- s = d.getVar('S',True)
+ s = d.getVar('S', True)
work_dir=d.getVar('WORKDIR', True)
- PF = d.getVar('PF',True)
+ PF = d.getVar('PF', True)
tarname = PF + '-' + stage_name + ".tar.gz"
if os.path.exists(s) and work_dir in s:
try:
- source_dir = os.path.join(work_dir,[ i for i in s.replace(work_dir,'').split('/') if i][0])
+ source_dir = os.path.join(work_dir, [ i for i in s.replace(work_dir, '').split('/') if i][0])
except IndexError:
- if not cmp(s,work_dir):
+ if not cmp(s, work_dir):
return ''
else:
return ''
source = os.path.basename(source_dir)
- return do_tarball(work_dir,source,tarname)
+ return do_tarball(work_dir, source, tarname)
-def archive_sources(d,stage_name):
- '''copy tarball from $DL_DIR to $WORKDIR if have tarball, archive source codes tree in $WORKDIR if $P is directory instead of tarball'''
+def archive_sources(d, stage_name):
+ """
+ copy tarball from $DL_DIR to $WORKDIR if have tarball, archive
+ source codes tree in $WORKDIR if $P is directory instead of tarball
+ """
import shutil
- work_dir = d.getVar('WORKDIR',True)
- file = get_source_from_downloads(d,stage_name)
+
+ work_dir = d.getVar('WORKDIR', True)
+ file = get_source_from_downloads(d, stage_name)
if file:
- shutil.copy(file,work_dir)
+ shutil.copy(file, work_dir)
file = os.path.basename(file)
else:
- file = archive_sources_from_directory(d,stage_name)
+ file = archive_sources_from_directory(d, stage_name)
return file
-def archive_patches(d,patchdir,series):
- '''archive patches to tarball and also include series files if 'series' is True'''
+def archive_patches(d, patchdir, series):
+ """
+ archive patches to tarball and also include series files if 'series' is True
+ """
import shutil
- s = d.getVar('S',True)
+ s = d.getVar('S', True)
work_dir = d.getVar('WORKDIR', True)
patch_dir = os.path.basename(patchdir)
tarname = patch_dir + ".tar.gz"
- if series == 'all' and os.path.exists(os.path.join(s,'patches/series')):
- shutil.copy(os.path.join(s,'patches/series'),patchdir)
- tarname = do_tarball(work_dir,patch_dir,tarname)
+ if series == 'all' and os.path.exists(os.path.join(s, 'patches/series')):
+ shutil.copy(os.path.join(s, 'patches/series'), patchdir)
+ tarname = do_tarball(work_dir, patch_dir, tarname)
shutil.rmtree(patchdir, ignore_errors=True)
return tarname
-def select_archive_patches(d,option):
- '''select to archive all patches including non-applying and series or applying patches '''
+def select_archive_patches(d, option):
+ """
+ select to archive all patches including non-applying and series or
+ applying patches
+ """
if option == "all":
patchdir = get_series(d)
elif option == "applying":
@@ -266,25 +297,27 @@ def select_archive_patches(d,option):
try:
os.rmdir(patchdir)
except OSError:
- tarpatch = archive_patches(d,patchdir,option)
+ tarpatch = archive_patches(d, patchdir, option)
return tarpatch
return
-def archive_logs(d,logdir,bbinc=False):
- '''archive logs in temp to tarball and .bb and .inc files if bbinc is True '''
+def archive_logs(d, logdir, bbinc=False):
+ """
+ archive logs in temp to tarball and .bb and .inc files if bbinc is True
+ """
import shutil
- pf = d.getVar('PF',True)
- work_dir = d.getVar('WORKDIR',True)
+ pf = d.getVar('PF', True)
+ work_dir = d.getVar('WORKDIR', True)
log_dir = os.path.basename(logdir)
tarname = pf + '-' + log_dir + ".tar.gz"
- tarname = do_tarball(work_dir,log_dir,tarname)
+ tarname = do_tarball(work_dir, log_dir, tarname)
if bbinc:
shutil.rmtree(logdir, ignore_errors=True)
return tarname
def get_licenses(d):
- '''get licenses for running .bb file'''
+ """get licenses for running .bb file"""
import oe.license
licenses_type = d.getVar('LICENSE', True) or ""
@@ -299,8 +332,8 @@ def get_licenses(d):
return lice
-def move_tarball_deploy(d,tarball_list):
- '''move tarball in location to ${DEPLOY_DIR}/sources'''
+def move_tarball_deploy(d, tarball_list):
+ """move tarball in location to ${DEPLOY_DIR}/sources"""
import shutil
if tarball_list is []:
@@ -308,100 +341,114 @@ def move_tarball_deploy(d,tarball_list):
target_sys = d.getVar('TARGET_SYS', True)
pf = d.getVar('PF', True)
licenses = get_licenses(d)
- work_dir = d.getVar('WORKDIR',True)
+ work_dir = d.getVar('WORKDIR', True)
tar_sources = d.getVar('DEPLOY_DIR', True) + '/sources/' + target_sys + '/' + licenses + '/' + pf
if not os.path.exists(tar_sources):
bb.mkdirhier(tar_sources)
for source in tarball_list:
if source:
if os.path.exists(os.path.join(tar_sources, source)):
- os.remove(os.path.join(tar_sources,source))
- shutil.move(os.path.join(work_dir,source),tar_sources)
+ os.remove(os.path.join(tar_sources, source))
+ shutil.move(os.path.join(work_dir, source), tar_sources)
def check_archiving_type(d):
- '''check the type for archiving package('tar' or 'srpm')'''
+ """check the type for archiving package('tar' or 'srpm')"""
try:
if d.getVar('SOURCE_ARCHIVE_PACKAGE_TYPE', True).upper() not in d.getVar('ARCHIVE_TYPE', True).split():
raise AttributeError
except AttributeError:
bb.fatal("\"SOURCE_ARCHIVE_PACKAGE_TYPE\" is \'tar\' or \'srpm\', no other types")
-def store_package(d,package_name):
- '''store tarbablls name to file "tar-package"'''
+def store_package(d, package_name):
+ """
+ store tarbablls name to file "tar-package"
+ """
try:
- f = open(os.path.join(d.getVar('WORKDIR',True),'tar-package'),'a')
+ f = open(os.path.join(d.getVar('WORKDIR', True), 'tar-package'), 'a')
f.write(package_name + ' ')
f.close()
except IOError:
pass
def get_package(d):
- '''get tarballs name from "tar-package"'''
+ """
+ get tarballs name from "tar-package"
+ """
work_dir = (d.getVar('WORKDIR', True))
- tarpackage = os.path.join(work_dir,'tar-package')
+ tarpackage = os.path.join(work_dir, 'tar-package')
try:
- f = open(tarpackage,'r')
- line = list(set(f.readline().replace('\n','').split()))
- except UnboundLocalError,IOError:
+ f = open(tarpackage, 'r')
+ line = list(set(f.readline().replace('\n', '').split()))
+ except UnboundLocalError, IOError:
pass
f.close()
return line
-def archive_sources_patches(d,stage_name):
- '''archive sources and patches to tarball. stage_name will append strings ${stage_name} to ${PR} as middle name. for example, zlib-1.4.6-prepatch(stage_name).tar.gz '''
+def archive_sources_patches(d, stage_name):
+ """
+ archive sources and patches to tarball. stage_name will append
+ strings ${stage_name} to ${PR} as middle name. for example,
+ zlib-1.4.6-prepatch(stage_name).tar.gz
+ """
import shutil
check_archiving_type(d)
if not_tarball(d) or tar_filter(d):
return
- source_tar_name = archive_sources(d,stage_name)
+ source_tar_name = archive_sources(d, stage_name)
if stage_name == "prepatch":
- if d.getVar('PATCHES_ARCHIVE_WITH_SERIES',True).upper() == 'TRUE':
- patch_tar_name = select_archive_patches(d,"all")
- elif d.getVar('PATCHES_ARCHIVE_WITH_SERIES',True).upper() == 'FALSE':
- patch_tar_name = select_archive_patches(d,"applying")
+ if d.getVar('PATCHES_ARCHIVE_WITH_SERIES', True).upper() == 'TRUE':
+ patch_tar_name = select_archive_patches(d, "all")
+ elif d.getVar('PATCHES_ARCHIVE_WITH_SERIES', True).upper() == 'FALSE':
+ patch_tar_name = select_archive_patches(d, "applying")
else:
bb.fatal("Please define 'PATCHES_ARCHIVE_WITH_SERIES' is strings 'True' or 'False' ")
else:
patch_tar_name = ''
if d.getVar('SOURCE_ARCHIVE_PACKAGE_TYPE', True).upper() not in 'SRPM':
- move_tarball_deploy(d,[source_tar_name,patch_tar_name])
+ move_tarball_deploy(d, [source_tar_name, patch_tar_name])
else:
- tarpackage = os.path.join(d.getVar('WORKDIR', True),'tar-package')
+ tarpackage = os.path.join(d.getVar('WORKDIR', True), 'tar-package')
if os.path.exists(tarpackage):
os.remove(tarpackage)
for package in os.path.basename(source_tar_name), patch_tar_name:
if package:
- store_package(d,str(package) + ' ')
+ store_package(d, str(package) + ' ')
def archive_scripts_logs(d):
- '''archive scripts and logs. scripts include .bb and .inc files and logs include stuff in "temp".'''
+ """
+ archive scripts and logs. scripts include .bb and .inc files and
+ logs include stuff in "temp".
+ """
if tar_filter(d):
return
work_dir = d.getVar('WORKDIR', True)
- temp_dir = os.path.join(work_dir,'temp')
+ temp_dir = os.path.join(work_dir, 'temp')
source_archive_log_with_scripts = d.getVar('SOURCE_ARCHIVE_LOG_WITH_SCRIPTS', True)
if source_archive_log_with_scripts == 'logs_with_scripts':
logdir = get_bb_inc(d)
- tarlog = archive_logs(d,logdir,True)
+ tarlog = archive_logs(d, logdir, True)
elif source_archive_log_with_scripts == 'logs':
if os.path.exists(temp_dir):
- tarlog = archive_logs(d,temp_dir,False)
+ tarlog = archive_logs(d, temp_dir, False)
else:
return
if d.getVar('SOURCE_ARCHIVE_PACKAGE_TYPE', True).upper() not in 'SRPM':
- move_tarball_deploy(d,[tarlog])
+ move_tarball_deploy(d, [tarlog])
else:
- store_package(d,tarlog)
+ store_package(d, tarlog)
def dumpdata(d):
- '''dump environment to "${P}-${PR}.showdata.dump" including all kinds of variables and functions when running a task'''
+ """
+ dump environment to "${P}-${PR}.showdata.dump" including all
+ kinds of variables and functions when running a task
+ """
if tar_filter(d):
return
@@ -415,20 +462,23 @@ def dumpdata(d):
if not os.path.exists(dumpdir):
bb.mkdirhier(dumpdir)
- dumpfile = os.path.join(dumpdir, bb.data.expand("${P}-${PR}.showdata.dump",d))
+ dumpfile = os.path.join(dumpdir, bb.data.expand("${P}-${PR}.showdata.dump", d))
bb.note("Dumping metadata into '%s'" % dumpfile)
f = open(dumpfile, "w")
# emit variables and shell functions
bb.data.emit_env(f, d, True)
- # emit the metadata which isnt valid shell
+ # emit the metadata which isn't valid shell
for e in d.keys():
if bb.data.getVarFlag(e, 'python', d):
f.write("\npython %s () {\n%s}\n" % (e, bb.data.getVar(e, d, 1)))
f.close()
def create_diff_gz(d):
- '''creating .diff.gz in ${DEPLOY_DIR_SRC}/${P}-${PR}.diff.g gz for mapping all content in 's' including patches to xxx.diff.gz'''
+ """
+ creating .diff.gz in ${DEPLOY_DIR_SRC}/${P}-${PR}.diff.g gz for
+ mapping all content in 's' including patches to xxx.diff.gz
+ """
import shutil
import subprocess
@@ -467,41 +517,47 @@ def create_diff_gz(d):
bb.build.exec_func('DIFF', d)
shutil.rmtree(s + '.org', ignore_errors=True)
-# This function will run when user want to get tarball for sources and patches after do_unpack
+# This function will run when user want to get tarball for sources and
+# patches after do_unpack
python do_archive_original_sources_patches(){
- archive_sources_patches(d,'prepatch')
+ archive_sources_patches(d, 'prepatch')
}
-# This function will run when user want to get tarball for patched sources after do_patch
+# This function will run when user want to get tarball for patched
+# sources after do_patch
python do_archive_patched_sources(){
- archive_sources_patches(d,'patched')
+ archive_sources_patches(d, 'patched')
}
-# This function will run when user want to get tarball for configured sources after do_configure
+# This function will run when user want to get tarball for configured
+# sources after do_configure
python do_archive_configured_sources(){
- archive_sources_patches(d,'configured')
+ archive_sources_patches(d, 'configured')
}
-# This function will run when user want to get tarball for logs or both logs and scripts(.bb and .inc files)
+# This function will run when user want to get tarball for logs or both
+# logs and scripts(.bb and .inc files)
python do_archive_scripts_logs(){
archive_scripts_logs(d)
}
-# This function will run when user want to know what variable and functions in a running task are and also can get a diff file including
+# This function will run when user want to know what variable and
+# functions in a running task are and also can get a diff file including
# all content a package should include.
python do_dumpdata_create_diff_gz(){
dumpdata(d)
create_diff_gz(d)
}
-# This functions prepare for archiving "linux-yocto" because this package create directory 's' before do_patch instead of after do_unpack.
-# This is special control for archiving linux-yocto only.
+# This functions prepare for archiving "linux-yocto" because this
+# package create directory 's' before do_patch instead of after
+# do_unpack. This is special control for archiving linux-yocto only.
python do_archive_linux_yocto(){
s = d.getVar('S', True)
if 'linux-yocto' in s:
- source_tar_name = archive_sources(d,'')
+ source_tar_name = archive_sources(d, '')
if d.getVar('SOURCE_ARCHIVE_PACKAGE_TYPE', True).upper() not in 'SRPM':
- move_tarball_deploy(d,[source_tar_name,''])
+ move_tarball_deploy(d, [source_tar_name, ''])
}
do_kernel_checkout[postfuncs] += "do_archive_linux_yocto "
@@ -513,8 +569,8 @@ python do_remove_tarball(){
for file in os.listdir(os.getcwd()):
if file in get_package(d):
os.remove(file)
- os.remove(os.path.join(work_dir,'tar-package'))
- except (TypeError,OSError):
+ os.remove(os.path.join(work_dir, 'tar-package'))
+ except (TypeError, OSError):
pass
}
do_remove_taball[deptask] = "do_archive_scripts_logs"
--
1.7.11.2
^ permalink raw reply related [flat|nested] 8+ messages in thread
* [PATCH 3/6] archiver.bbclass: fix the fakeroot and other issues
2012-08-26 6:51 [PATCH 0/6] archiver.bbclass: fixes and clean up Robert Yang
2012-08-26 6:51 ` [PATCH 1/6] archiver.bbclass: indent fixes Robert Yang
2012-08-26 6:51 ` [PATCH 2/6] archiver.bbclass: fix the coding style Robert Yang
@ 2012-08-26 6:51 ` Robert Yang
2012-08-26 6:51 ` [PATCH 4/6] archiver.bbclass: remove the "upper()" function Robert Yang
` (3 subsequent siblings)
6 siblings, 0 replies; 8+ messages in thread
From: Robert Yang @ 2012-08-26 6:51 UTC (permalink / raw)
To: openembedded-core; +Cc: Zhenfeng.Zhao
* Fix the fakeroot issue
The archiver.bbclass is used for archiving sources, patches, and logs,
it uses the "rpmbuild -bs" from the package_rpm.bbclass to generate the
.src.rpm, but it didn't work (it's not easy to explain it clearly):
Reason:
- It directly used the "fakeroot" command, we don't have such a
command in native tools, so it would use the fakeroot from the host,
and it would fail when there is no fakeroot on the host.
- The "rpmbuild -bs" doesn't need to work under root, but it is in the
function do_package_write_rpm which is running under fakeroot, and
"rpmbuild" needs to know the source file's user/group name, the source
file is the tarball which is created by the postfuncs of do_unpack
or do_patch which doesn't use the fakeroot, so the created file's
owner would be the real user, e.g.: robert, but there is no such a
user under our native tools' fakeroot(pseudo), then the rpmbuild would
fail. It worked when use the host's fakeroot in the past was because
that the host's fakeroot knows the users on the host.
Fix:
- Remove the incorrect "fakeroot".
- Change the source file's owner to root.root under fakeroot will fix the
problem.
* Other fixes:
- The typo: "do_remove_taball -> do_remove_tarball" which will cause the
tarball is not removed.
- Add the _sourcedir defination to the rpmbuild command since the the
SOURCES would be added to the specfile when archiver.bbclass is
inherited, otherwise there would be errors when "rpmbuild -bb", though
the build is OK. It only added the defination to "rpmbuild -bs",
didn't add to "rpmbuild -bb".
[YOCTO #2619]
Signed-off-by: Robert Yang <liezhi.yang@windriver.com>
---
meta/classes/archiver.bbclass | 2 +-
meta/classes/package_rpm.bbclass | 11 +++++++++--
2 files changed, 10 insertions(+), 3 deletions(-)
diff --git a/meta/classes/archiver.bbclass b/meta/classes/archiver.bbclass
index b01b078..7056714 100644
--- a/meta/classes/archiver.bbclass
+++ b/meta/classes/archiver.bbclass
@@ -573,7 +573,7 @@ python do_remove_tarball(){
except (TypeError, OSError):
pass
}
-do_remove_taball[deptask] = "do_archive_scripts_logs"
+do_remove_tarball[deptask] = "do_archive_scripts_logs"
do_package_write_rpm[postfuncs] += "do_remove_tarball "
export get_licenses
export get_package
diff --git a/meta/classes/package_rpm.bbclass b/meta/classes/package_rpm.bbclass
index 58a9aac..b999c28 100644
--- a/meta/classes/package_rpm.bbclass
+++ b/meta/classes/package_rpm.bbclass
@@ -585,11 +585,17 @@ python write_specfile () {
if d.getVar('SOURCE_ARCHIVE_PACKAGE_TYPE', True) and d.getVar('SOURCE_ARCHIVE_PACKAGE_TYPE', True).upper() == 'SRPM':
source_number = 0
patch_number = 0
+ workdir = d.getVar('WORKDIR', True)
for source in source_list:
+ # The rpmbuild doesn't need the root permission, but it needs
+ # to know the file's user and group name, the only user and
+ # group in fakeroot is "root" when working in fakeroot.
+ os.chown("%s/%s" % (workdir, source), 0, 0)
spec_preamble_top.append('Source' + str(source_number) + ': %s' % source)
source_number += 1
if patch_list:
for patch in patch_list:
+ os.chown("%s/%s" % (workdir, patch), 0, 0)
print_deps(patch, "Patch" + str(patch_number), spec_preamble_top, d)
patch_number += 1
# We need a simple way to remove the MLPREFIX from the package name,
@@ -1142,8 +1148,9 @@ python do_package_rpm () {
cmd = cmd + " --define '_rpmfc_magic_path " + magicfile + "'"
cmd = cmd + " --define '_tmppath " + workdir + "'"
if d.getVar('SOURCE_ARCHIVE_PACKAGE_TYPE', True) and d.getVar('SOURCE_ARCHIVE_PACKAGE_TYPE', True).upper() == 'SRPM':
- cmdsrpm = cmd + " --define '_sourcedir " + workdir + "' --define '_srcrpmdir " + creat_srpm_dir(d) + "'"
- cmdsrpm = 'fakeroot ' + cmdsrpm + " -bs " + outspecfile
+ cmd = cmd + " --define '_sourcedir " + workdir + "'"
+ cmdsrpm = cmd + " --define '_srcrpmdir " + creat_srpm_dir(d) + "'"
+ cmdsrpm = cmdsrpm + " -bs " + outspecfile
cmd = cmd + " -bb " + outspecfile
# Build the source rpm package !
--
1.7.11.2
^ permalink raw reply related [flat|nested] 8+ messages in thread
* [PATCH 4/6] archiver.bbclass: remove the "upper()" function
2012-08-26 6:51 [PATCH 0/6] archiver.bbclass: fixes and clean up Robert Yang
` (2 preceding siblings ...)
2012-08-26 6:51 ` [PATCH 3/6] archiver.bbclass: fix the fakeroot and other issues Robert Yang
@ 2012-08-26 6:51 ` Robert Yang
2012-08-26 6:52 ` [PATCH 5/6] copyleft_compliance.bbclass: remove the duplicated code Robert Yang
` (2 subsequent siblings)
6 siblings, 0 replies; 8+ messages in thread
From: Robert Yang @ 2012-08-26 6:51 UTC (permalink / raw)
To: openembedded-core; +Cc: Zhenfeng.Zhao
The configuration value from the conf file is lower case, e.g. srpm,
tar, so there is no reason to use the upper case which makes things
complicated.
[YOCTO #2619]
Signed-off-by: Robert Yang <liezhi.yang@windriver.com>
---
meta/classes/archiver.bbclass | 26 +++++++++++---------------
meta/classes/package_rpm.bbclass | 12 ++++++------
2 files changed, 17 insertions(+), 21 deletions(-)
diff --git a/meta/classes/archiver.bbclass b/meta/classes/archiver.bbclass
index 7056714..19c5567 100644
--- a/meta/classes/archiver.bbclass
+++ b/meta/classes/archiver.bbclass
@@ -7,9 +7,9 @@
#
ARCHIVE_EXCLUDE_FROM ?= ".pc autom4te.cache"
-ARCHIVE_TYPE ?= "TAR SRPM"
+ARCHIVE_TYPE ?= "tar srpm"
DISTRO ?= "poky"
-PATCHES_ARCHIVE_WITH_SERIES = 'TRUE'
+PATCHES_ARCHIVE_WITH_SERIES = 'yes'
SOURCE_ARCHIVE_LOG_WITH_SCRIPTS ?= '${@d.getVarFlag('ARCHIVER_MODE', 'log_type') \
if d.getVarFlag('ARCHIVER_MODE', 'log_type') != 'none' else 'logs_with_scripts'}'
SOURCE_ARCHIVE_PACKAGE_TYPE ?= '${@d.getVarFlag('ARCHIVER_MODE', 'type') \
@@ -74,7 +74,7 @@ def tar_filter(d):
and ignore the one in COPYLEFT_LICENSE_EXCLUDE. Don't exclude any
packages when \"FILTER\" is \"no\"
"""
- if d.getVar('FILTER', True).upper() == "YES":
+ if d.getVar('FILTER', True) == "yes":
included, reason = copyleft_should_include(d)
if not included:
return False
@@ -235,7 +235,6 @@ def archive_sources_from_directory(d, stage_name):
archive sources codes tree to tarball when tarball of $P doesn't
exist in $DL_DIR
"""
- import shutil
s = d.getVar('S', True)
work_dir=d.getVar('WORKDIR', True)
@@ -353,10 +352,7 @@ def move_tarball_deploy(d, tarball_list):
def check_archiving_type(d):
"""check the type for archiving package('tar' or 'srpm')"""
- try:
- if d.getVar('SOURCE_ARCHIVE_PACKAGE_TYPE', True).upper() not in d.getVar('ARCHIVE_TYPE', True).split():
- raise AttributeError
- except AttributeError:
+ if d.getVar('SOURCE_ARCHIVE_PACKAGE_TYPE', True) not in d.getVar('ARCHIVE_TYPE', True).split():
bb.fatal("\"SOURCE_ARCHIVE_PACKAGE_TYPE\" is \'tar\' or \'srpm\', no other types")
def store_package(d, package_name):
@@ -399,16 +395,16 @@ def archive_sources_patches(d, stage_name):
source_tar_name = archive_sources(d, stage_name)
if stage_name == "prepatch":
- if d.getVar('PATCHES_ARCHIVE_WITH_SERIES', True).upper() == 'TRUE':
+ if d.getVar('PATCHES_ARCHIVE_WITH_SERIES', True) == 'yes':
patch_tar_name = select_archive_patches(d, "all")
- elif d.getVar('PATCHES_ARCHIVE_WITH_SERIES', True).upper() == 'FALSE':
+ elif d.getVar('PATCHES_ARCHIVE_WITH_SERIES', True) == 'no':
patch_tar_name = select_archive_patches(d, "applying")
else:
- bb.fatal("Please define 'PATCHES_ARCHIVE_WITH_SERIES' is strings 'True' or 'False' ")
+ bb.fatal("Please define 'PATCHES_ARCHIVE_WITH_SERIES' to 'yes' or 'no' ")
else:
patch_tar_name = ''
- if d.getVar('SOURCE_ARCHIVE_PACKAGE_TYPE', True).upper() not in 'SRPM':
+ if d.getVar('SOURCE_ARCHIVE_PACKAGE_TYPE', True) != 'srpm':
move_tarball_deploy(d, [source_tar_name, patch_tar_name])
else:
tarpackage = os.path.join(d.getVar('WORKDIR', True), 'tar-package')
@@ -438,7 +434,7 @@ def archive_scripts_logs(d):
else:
return
- if d.getVar('SOURCE_ARCHIVE_PACKAGE_TYPE', True).upper() not in 'SRPM':
+ if d.getVar('SOURCE_ARCHIVE_PACKAGE_TYPE', True) != 'srpm':
move_tarball_deploy(d, [tarlog])
else:
@@ -556,14 +552,14 @@ python do_archive_linux_yocto(){
s = d.getVar('S', True)
if 'linux-yocto' in s:
source_tar_name = archive_sources(d, '')
- if d.getVar('SOURCE_ARCHIVE_PACKAGE_TYPE', True).upper() not in 'SRPM':
+ if d.getVar('SOURCE_ARCHIVE_PACKAGE_TYPE', True) != 'srpm':
move_tarball_deploy(d, [source_tar_name, ''])
}
do_kernel_checkout[postfuncs] += "do_archive_linux_yocto "
# remove tarball for sources, patches and logs after creating srpm.
python do_remove_tarball(){
- if d.getVar('SOURCE_ARCHIVE_PACKAGE_TYPE', True).upper() == 'SRPM':
+ if d.getVar('SOURCE_ARCHIVE_PACKAGE_TYPE', True) == 'srpm':
work_dir = d.getVar('WORKDIR', True)
try:
for file in os.listdir(os.getcwd()):
diff --git a/meta/classes/package_rpm.bbclass b/meta/classes/package_rpm.bbclass
index b999c28..d44ab4c 100644
--- a/meta/classes/package_rpm.bbclass
+++ b/meta/classes/package_rpm.bbclass
@@ -570,19 +570,19 @@ python write_specfile () {
# append information for logs and patches to %prep
def add_prep(d,spec_files_bottom):
- if d.getVar('SOURCE_ARCHIVE_PACKAGE_TYPE', True) and d.getVar('SOURCE_ARCHIVE_PACKAGE_TYPE', True).upper() == 'SRPM':
+ if d.getVar('SOURCE_ARCHIVE_PACKAGE_TYPE', True) == 'srpm':
spec_files_bottom.append('%%prep -n %s' % d.getVar('PN', True) )
spec_files_bottom.append('%s' % "echo \"include logs and patches, Please check them in SOURCES\"")
spec_files_bottom.append('')
# get the name of tarball for sources, patches and logs
def get_tarballs(d):
- if d.getVar('SOURCE_ARCHIVE_PACKAGE_TYPE', True) and d.getVar('SOURCE_ARCHIVE_PACKAGE_TYPE', True).upper() == 'SRPM':
+ if d.getVar('SOURCE_ARCHIVE_PACKAGE_TYPE', True) == 'srpm':
return get_package(d)
# append the name of tarball to key word 'SOURCE' in xxx.spec.
def tail_source(d,source_list=[],patch_list=None):
- if d.getVar('SOURCE_ARCHIVE_PACKAGE_TYPE', True) and d.getVar('SOURCE_ARCHIVE_PACKAGE_TYPE', True).upper() == 'SRPM':
+ if d.getVar('SOURCE_ARCHIVE_PACKAGE_TYPE', True) == 'srpm':
source_number = 0
patch_number = 0
workdir = d.getVar('WORKDIR', True)
@@ -1020,7 +1020,7 @@ python write_specfile () {
python do_package_rpm () {
def creat_srpm_dir(d):
- if d.getVar('SOURCE_ARCHIVE_PACKAGE_TYPE', True) and d.getVar('SOURCE_ARCHIVE_PACKAGE_TYPE', True).upper() == 'SRPM':
+ if d.getVar('SOURCE_ARCHIVE_PACKAGE_TYPE', True) == 'srpm':
clean_licenses = get_licenses(d)
pkgwritesrpmdir = bb.data.expand('${PKGWRITEDIRSRPM}/${PACKAGE_ARCH_EXTEND}', d)
pkgwritesrpmdir = pkgwritesrpmdir + '/' + clean_licenses
@@ -1147,14 +1147,14 @@ python do_package_rpm () {
cmd = cmd + " --define 'debug_package %{nil}'"
cmd = cmd + " --define '_rpmfc_magic_path " + magicfile + "'"
cmd = cmd + " --define '_tmppath " + workdir + "'"
- if d.getVar('SOURCE_ARCHIVE_PACKAGE_TYPE', True) and d.getVar('SOURCE_ARCHIVE_PACKAGE_TYPE', True).upper() == 'SRPM':
+ if d.getVar('SOURCE_ARCHIVE_PACKAGE_TYPE', True) == 'srpm':
cmd = cmd + " --define '_sourcedir " + workdir + "'"
cmdsrpm = cmd + " --define '_srcrpmdir " + creat_srpm_dir(d) + "'"
cmdsrpm = cmdsrpm + " -bs " + outspecfile
cmd = cmd + " -bb " + outspecfile
# Build the source rpm package !
- if d.getVar('SOURCE_ARCHIVE_PACKAGE_TYPE', True) and d.getVar('SOURCE_ARCHIVE_PACKAGE_TYPE', True).upper() == 'SRPM':
+ if d.getVar('SOURCE_ARCHIVE_PACKAGE_TYPE', True) == 'srpm':
d.setVar('SBUILDSPEC', cmdsrpm + "\n")
d.setVarFlag('SBUILDSPEC', 'func', '1')
bb.build.exec_func('SBUILDSPEC', d)
--
1.7.11.2
^ permalink raw reply related [flat|nested] 8+ messages in thread
* [PATCH 5/6] copyleft_compliance.bbclass: remove the duplicated code
2012-08-26 6:51 [PATCH 0/6] archiver.bbclass: fixes and clean up Robert Yang
` (3 preceding siblings ...)
2012-08-26 6:51 ` [PATCH 4/6] archiver.bbclass: remove the "upper()" function Robert Yang
@ 2012-08-26 6:52 ` Robert Yang
2012-08-26 6:52 ` [PATCH 6/6] archiver.bbclass: fix the remove error Robert Yang
2012-08-29 22:21 ` [PATCH 0/6] archiver.bbclass: fixes and clean up Saul Wold
6 siblings, 0 replies; 8+ messages in thread
From: Robert Yang @ 2012-08-26 6:52 UTC (permalink / raw)
To: openembedded-core; +Cc: Zhenfeng.Zhao
A part of the code in copyleft_compliance.bbclass is duplicated to
archiver.bbclass, remove the duplicated lines.
[YOCTO #2619]
Signed-off-by: Robert Yang <liezhi.yang@windriver.com>
---
meta/classes/copyleft_compliance.bbclass | 51 ++------------------------------
1 file changed, 3 insertions(+), 48 deletions(-)
diff --git a/meta/classes/copyleft_compliance.bbclass b/meta/classes/copyleft_compliance.bbclass
index c59cb7a..e68942d 100644
--- a/meta/classes/copyleft_compliance.bbclass
+++ b/meta/classes/copyleft_compliance.bbclass
@@ -6,55 +6,10 @@
#
# vi:sts=4:sw=4:et
-COPYLEFT_SOURCES_DIR ?= '${DEPLOY_DIR}/copyleft_sources'
-
-COPYLEFT_LICENSE_INCLUDE ?= 'GPL* LGPL*'
-COPYLEFT_LICENSE_INCLUDE[type] = 'list'
-COPYLEFT_LICENSE_INCLUDE[doc] = 'Space separated list of globs which include licenses'
-
-COPYLEFT_LICENSE_EXCLUDE ?= 'CLOSED Proprietary'
-COPYLEFT_LICENSE_EXCLUDE[type] = 'list'
-COPYLEFT_LICENSE_INCLUDE[doc] = 'Space separated list of globs which exclude licenses'
-
-COPYLEFT_RECIPE_TYPE ?= '${@copyleft_recipe_type(d)}'
-COPYLEFT_RECIPE_TYPE[doc] = 'The "type" of the current recipe (e.g. target, native, cross)'
-
-COPYLEFT_RECIPE_TYPES ?= 'target'
-COPYLEFT_RECIPE_TYPES[type] = 'list'
-COPYLEFT_RECIPE_TYPES[doc] = 'Space separated list of recipe types to include'
-
-COPYLEFT_AVAILABLE_RECIPE_TYPES = 'target native nativesdk cross crosssdk cross-canadian'
-COPYLEFT_AVAILABLE_RECIPE_TYPES[type] = 'list'
-COPYLEFT_AVAILABLE_RECIPE_TYPES[doc] = 'Space separated list of available recipe types'
-
-def copyleft_recipe_type(d):
- for recipe_type in oe.data.typed_value('COPYLEFT_AVAILABLE_RECIPE_TYPES', d):
- if oe.utils.inherits(d, recipe_type):
- return recipe_type
- return 'target'
+# Need the copyleft_should_include
+inherit archiver
-def copyleft_should_include(d):
- """Determine if this recipe's sources should be deployed for compliance"""
- import ast
- import oe.license
- from fnmatch import fnmatchcase as fnmatch
-
- recipe_type = d.getVar('COPYLEFT_RECIPE_TYPE', True)
- if recipe_type not in oe.data.typed_value('COPYLEFT_RECIPE_TYPES', d):
- return False, 'recipe type "%s" is excluded' % recipe_type
-
- include = oe.data.typed_value('COPYLEFT_LICENSE_INCLUDE', d)
- exclude = oe.data.typed_value('COPYLEFT_LICENSE_EXCLUDE', d)
-
- try:
- is_included, reason = oe.license.is_included(d.getVar('LICENSE', True), include, exclude)
- except oe.license.LicenseError as exc:
- bb.fatal('%s: %s' % (d.getVar('PF', True), exc))
- else:
- if is_included:
- return True, 'recipe has included licenses: %s' % ', '.join(reason)
- else:
- return False, 'recipe has excluded licenses: %s' % ', '.join(reason)
+COPYLEFT_SOURCES_DIR ?= '${DEPLOY_DIR}/copyleft_sources'
python do_prepare_copyleft_sources () {
"""Populate a tree of the recipe sources and emit patch series files"""
--
1.7.11.2
^ permalink raw reply related [flat|nested] 8+ messages in thread
* [PATCH 6/6] archiver.bbclass: fix the remove error
2012-08-26 6:51 [PATCH 0/6] archiver.bbclass: fixes and clean up Robert Yang
` (4 preceding siblings ...)
2012-08-26 6:52 ` [PATCH 5/6] copyleft_compliance.bbclass: remove the duplicated code Robert Yang
@ 2012-08-26 6:52 ` Robert Yang
2012-08-29 22:21 ` [PATCH 0/6] archiver.bbclass: fixes and clean up Saul Wold
6 siblings, 0 replies; 8+ messages in thread
From: Robert Yang @ 2012-08-26 6:52 UTC (permalink / raw)
To: openembedded-core; +Cc: Zhenfeng.Zhao
* The "tar-package" is used for saving the "Source" list for rpmbuild,
there is no such a file when "ARCHIVER_MODE[type] ?= srpm", and there
would be errors, it hadn't happen before was becuase that the remove
function didn't work. Let the "rpmbuild --rmsource" to remove the
Sources, and the remove function will just remove the tar-package file.
* Remove several unwanted "try ... exception" sentences, let the error
raise rather than ignore them when the error happens.
* Remove several un-needed code.
[YOCTO #2619]
Signed-off-by: Robert Yang <liezhi.yang@windriver.com>
---
meta/classes/archiver.bbclass | 51 ++++++++++++++++------------------------
meta/classes/package_rpm.bbclass | 25 ++++++--------------
2 files changed, 27 insertions(+), 49 deletions(-)
diff --git a/meta/classes/archiver.bbclass b/meta/classes/archiver.bbclass
index 19c5567..3146d02 100644
--- a/meta/classes/archiver.bbclass
+++ b/meta/classes/archiver.bbclass
@@ -359,26 +359,22 @@ def store_package(d, package_name):
"""
store tarbablls name to file "tar-package"
"""
- try:
- f = open(os.path.join(d.getVar('WORKDIR', True), 'tar-package'), 'a')
- f.write(package_name + ' ')
- f.close()
- except IOError:
- pass
+ f = open(os.path.join(d.getVar('WORKDIR', True), 'tar-package'), 'a')
+ f.write(package_name + ' ')
+ f.close()
def get_package(d):
"""
get tarballs name from "tar-package"
"""
work_dir = (d.getVar('WORKDIR', True))
- tarpackage = os.path.join(work_dir, 'tar-package')
- try:
- f = open(tarpackage, 'r')
- line = list(set(f.readline().replace('\n', '').split()))
- except UnboundLocalError, IOError:
- pass
- f.close()
- return line
+ tarlist = os.path.join(work_dir, 'tar-package')
+ if os.path.exists(tarlist):
+ f = open(tarlist, 'r')
+ line = f.readline().rstrip('\n').split()
+ f.close()
+ return line
+ return []
def archive_sources_patches(d, stage_name):
@@ -407,9 +403,9 @@ def archive_sources_patches(d, stage_name):
if d.getVar('SOURCE_ARCHIVE_PACKAGE_TYPE', True) != 'srpm':
move_tarball_deploy(d, [source_tar_name, patch_tar_name])
else:
- tarpackage = os.path.join(d.getVar('WORKDIR', True), 'tar-package')
- if os.path.exists(tarpackage):
- os.remove(tarpackage)
+ tarlist = os.path.join(d.getVar('WORKDIR', True), 'tar-package')
+ if os.path.exists(tarlist):
+ os.remove(tarlist)
for package in os.path.basename(source_tar_name), patch_tar_name:
if package:
store_package(d, str(package) + ' ')
@@ -558,18 +554,11 @@ python do_archive_linux_yocto(){
do_kernel_checkout[postfuncs] += "do_archive_linux_yocto "
# remove tarball for sources, patches and logs after creating srpm.
-python do_remove_tarball(){
- if d.getVar('SOURCE_ARCHIVE_PACKAGE_TYPE', True) == 'srpm':
- work_dir = d.getVar('WORKDIR', True)
- try:
- for file in os.listdir(os.getcwd()):
- if file in get_package(d):
- os.remove(file)
- os.remove(os.path.join(work_dir, 'tar-package'))
- except (TypeError, OSError):
- pass
+python do_remove_tarlist(){
+ work_dir = d.getVar('WORKDIR', True)
+ tarlist = os.path.join(work_dir, 'tar-package')
+ if os.path.exists(tarlist):
+ os.remove(tarlist)
}
-do_remove_tarball[deptask] = "do_archive_scripts_logs"
-do_package_write_rpm[postfuncs] += "do_remove_tarball "
-export get_licenses
-export get_package
+do_remove_tarlist[deptask] = "do_archive_scripts_logs"
+do_package_write_rpm[postfuncs] += "do_remove_tarlist "
diff --git a/meta/classes/package_rpm.bbclass b/meta/classes/package_rpm.bbclass
index d44ab4c..2c4c89a 100644
--- a/meta/classes/package_rpm.bbclass
+++ b/meta/classes/package_rpm.bbclass
@@ -575,16 +575,11 @@ python write_specfile () {
spec_files_bottom.append('%s' % "echo \"include logs and patches, Please check them in SOURCES\"")
spec_files_bottom.append('')
- # get the name of tarball for sources, patches and logs
- def get_tarballs(d):
- if d.getVar('SOURCE_ARCHIVE_PACKAGE_TYPE', True) == 'srpm':
- return get_package(d)
-
# append the name of tarball to key word 'SOURCE' in xxx.spec.
- def tail_source(d,source_list=[],patch_list=None):
+ def tail_source(d):
if d.getVar('SOURCE_ARCHIVE_PACKAGE_TYPE', True) == 'srpm':
+ source_list = get_package(d)
source_number = 0
- patch_number = 0
workdir = d.getVar('WORKDIR', True)
for source in source_list:
# The rpmbuild doesn't need the root permission, but it needs
@@ -593,11 +588,6 @@ python write_specfile () {
os.chown("%s/%s" % (workdir, source), 0, 0)
spec_preamble_top.append('Source' + str(source_number) + ': %s' % source)
source_number += 1
- if patch_list:
- for patch in patch_list:
- os.chown("%s/%s" % (workdir, patch), 0, 0)
- print_deps(patch, "Patch" + str(patch_number), spec_preamble_top, d)
- patch_number += 1
# We need a simple way to remove the MLPREFIX from the package name,
# and dependency information...
def strip_multilib(name, d):
@@ -915,8 +905,7 @@ python write_specfile () {
spec_preamble_top.append('Group: %s' % srcsection)
spec_preamble_top.append('Packager: %s' % srcmaintainer)
spec_preamble_top.append('URL: %s' % srchomepage)
- source_list = get_tarballs(d)
- tail_source(d,source_list,None)
+ tail_source(d)
# Replaces == Obsoletes && Provides
if srcrreplaces and srcrreplaces.strip() != "":
@@ -1151,13 +1140,13 @@ python do_package_rpm () {
cmd = cmd + " --define '_sourcedir " + workdir + "'"
cmdsrpm = cmd + " --define '_srcrpmdir " + creat_srpm_dir(d) + "'"
cmdsrpm = cmdsrpm + " -bs " + outspecfile
- cmd = cmd + " -bb " + outspecfile
-
- # Build the source rpm package !
- if d.getVar('SOURCE_ARCHIVE_PACKAGE_TYPE', True) == 'srpm':
+ # Build the .src.rpm
d.setVar('SBUILDSPEC', cmdsrpm + "\n")
d.setVarFlag('SBUILDSPEC', 'func', '1')
bb.build.exec_func('SBUILDSPEC', d)
+ # Remove the source (SOURCE0, SOURCE1 ...)
+ cmd = cmd + " --rmsource "
+ cmd = cmd + " -bb " + outspecfile
# Build the rpm package!
d.setVar('BUILDSPEC', cmd + "\n")
--
1.7.11.2
^ permalink raw reply related [flat|nested] 8+ messages in thread
* Re: [PATCH 0/6] archiver.bbclass: fixes and clean up
2012-08-26 6:51 [PATCH 0/6] archiver.bbclass: fixes and clean up Robert Yang
` (5 preceding siblings ...)
2012-08-26 6:52 ` [PATCH 6/6] archiver.bbclass: fix the remove error Robert Yang
@ 2012-08-29 22:21 ` Saul Wold
6 siblings, 0 replies; 8+ messages in thread
From: Saul Wold @ 2012-08-29 22:21 UTC (permalink / raw)
To: Robert Yang; +Cc: Zhenfeng.Zhao, openembedded-core
On 08/25/2012 11:51 PM, Robert Yang wrote:
>
> * Fix the indent and coding style
> * Fix the fakeroot error and other issues
> * remove the "upper()" function
> * copyleft_compliance.bbclass: remove the duplicated code
> * fix the remove error
>
> I have sent a patch to yocto@yoctoproject.org to update the
> local.conf.sample.extended
>
> // Robert
>
> The following changes since commit b4c5725af4cd85d5644f0373e2674e903c4eab2b:
>
> yocto-bsp: add missing xserver-xf86-config .bbappend for qemu (2012-08-25 14:47:07 +0100)
>
> are available in the git repository at:
>
> git://git.pokylinux.org/poky-contrib robert/archiver
> http://git.pokylinux.org/cgit.cgi/poky-contrib/log/?h=robert/archiver_sample
>
> Robert Yang (6):
> archiver.bbclass: indent fixes
> archiver.bbclass: fix the coding style
> archiver.bbclass: fix the fakeroot and other issues
> archiver.bbclass: remove the "upper()" function
> copyleft_compliance.bbclass: remove the duplicated code
> archiver.bbclass: fix the remove error
>
> meta/classes/archive-configured-source.bbclass | 9 +-
> meta/classes/archive-original-source.bbclass | 9 +-
> meta/classes/archive-patched-source.bbclass | 9 +-
> meta/classes/archiver.bbclass | 884 +++++++++++++------------
> meta/classes/copyleft_compliance.bbclass | 51 +-
> meta/classes/package_rpm.bbclass | 43 +-
> 6 files changed, 503 insertions(+), 502 deletions(-)
>
Merged into OE-Core
Thanks
Sau!
^ permalink raw reply [flat|nested] 8+ messages in thread
end of thread, other threads:[~2012-08-29 22:33 UTC | newest]
Thread overview: 8+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2012-08-26 6:51 [PATCH 0/6] archiver.bbclass: fixes and clean up Robert Yang
2012-08-26 6:51 ` [PATCH 1/6] archiver.bbclass: indent fixes Robert Yang
2012-08-26 6:51 ` [PATCH 2/6] archiver.bbclass: fix the coding style Robert Yang
2012-08-26 6:51 ` [PATCH 3/6] archiver.bbclass: fix the fakeroot and other issues Robert Yang
2012-08-26 6:51 ` [PATCH 4/6] archiver.bbclass: remove the "upper()" function Robert Yang
2012-08-26 6:52 ` [PATCH 5/6] copyleft_compliance.bbclass: remove the duplicated code Robert Yang
2012-08-26 6:52 ` [PATCH 6/6] archiver.bbclass: fix the remove error Robert Yang
2012-08-29 22:21 ` [PATCH 0/6] archiver.bbclass: fixes and clean up Saul Wold
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox