mirror of
https://git.yoctoproject.org/poky
synced 2026-06-01 13:09:50 +00:00
archiver.bbclass: fix the coding style
* 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] (From OE-Core rev: 885a95992abe11ebef7a8e4363e6002ee80403bf) Signed-off-by: Robert Yang <liezhi.yang@windriver.com> Signed-off-by: Saul Wold <sgw@linux.intel.com> Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
This commit is contained in:
committed by
Richard Purdie
parent
c96f6ee659
commit
2ba95cc79e
@@ -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
|
# This file is for getting archiving packages with configured
|
||||||
# and creating diff file(get all environment variables and functions in building and mapping all content in 's' including patches to xxx.diff.gz.
|
# sources(archive ${S} after configure stage), logs(archive 'temp' after
|
||||||
# All archived packages will be deployed in ${DEPLOY_DIR}/sources
|
# 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
|
inherit archiver
|
||||||
|
|
||||||
|
|||||||
@@ -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
|
# This file is for getting archiving packages with original
|
||||||
# creating diff file(get all environment variables and functions in building and mapping all content in 's' including patches to xxx.diff.gz.
|
# sources(archive ${S} after unpack stage), patches, logs(archive 'temp'
|
||||||
# All archived packages will be deployed in ${DEPLOY_DIR}/sources
|
# 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
|
inherit archiver
|
||||||
|
|
||||||
|
|||||||
@@ -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
|
# This file is for getting archiving packages with patched
|
||||||
# creating diff file(get all environment variables and functions in building and mapping all content in 's' including patches to xxx.diff.gz.
|
# sources(archive ${S} before do_patch stage), logs(archive 'temp' after
|
||||||
# All archived packages will be deployed in ${DEPLOY_DIR}/sources
|
# 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
|
inherit archiver
|
||||||
|
|
||||||
|
|||||||
@@ -1,9 +1,9 @@
|
|||||||
# ex:ts=4:sw=4:sts=4:et
|
# ex:ts=4:sw=4:sts=4:et
|
||||||
# -*- tab-width: 4; c-basic-offset: 4; indent-tabs-mode: nil -*-
|
# -*- tab-width: 4; c-basic-offset: 4; indent-tabs-mode: nil -*-
|
||||||
#
|
#
|
||||||
# This file is used for archiving sources ,patches,and logs to tarball.
|
# This file is used for archiving sources, patches, and logs to a
|
||||||
# It also output building environment to xxx.dump.data and create xxx.diff.gz to record
|
# tarball. It also output building environment to xxx.dump.data and
|
||||||
# all content in ${S} to a diff file.
|
# create xxx.diff.gz to record all content in ${S} to a diff file.
|
||||||
#
|
#
|
||||||
|
|
||||||
ARCHIVE_EXCLUDE_FROM ?= ".pc autom4te.cache"
|
ARCHIVE_EXCLUDE_FROM ?= ".pc autom4te.cache"
|
||||||
@@ -44,7 +44,9 @@ def copyleft_recipe_type(d):
|
|||||||
return 'target'
|
return 'target'
|
||||||
|
|
||||||
def copyleft_should_include(d):
|
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 ast
|
||||||
import oe.license
|
import oe.license
|
||||||
from fnmatch import fnmatchcase as fnmatch
|
from fnmatch import fnmatchcase as fnmatch
|
||||||
@@ -67,7 +69,11 @@ def copyleft_should_include(d):
|
|||||||
return False, 'recipe has excluded licenses: %s' % ', '.join(reason)
|
return False, 'recipe has excluded licenses: %s' % ', '.join(reason)
|
||||||
|
|
||||||
def tar_filter(d):
|
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":
|
if d.getVar('FILTER', True).upper() == "YES":
|
||||||
included, reason = copyleft_should_include(d)
|
included, reason = copyleft_should_include(d)
|
||||||
if not included:
|
if not included:
|
||||||
@@ -78,7 +84,9 @@ def tar_filter(d):
|
|||||||
return False
|
return False
|
||||||
|
|
||||||
def get_bb_inc(d):
|
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 re
|
||||||
import shutil
|
import shutil
|
||||||
|
|
||||||
@@ -125,7 +133,10 @@ def get_bb_inc(d):
|
|||||||
return script_logs
|
return script_logs
|
||||||
|
|
||||||
def get_series(d):
|
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
|
import shutil
|
||||||
|
|
||||||
src_patches=[]
|
src_patches=[]
|
||||||
@@ -156,7 +167,10 @@ def get_series(d):
|
|||||||
return dest
|
return dest
|
||||||
|
|
||||||
def get_applying_patches(d):
|
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
|
import shutil
|
||||||
|
|
||||||
pf = d.getVar('PF', True)
|
pf = d.getVar('PF', True)
|
||||||
@@ -173,8 +187,9 @@ def get_applying_patches(d):
|
|||||||
return dest
|
return dest
|
||||||
|
|
||||||
def not_tarball(d):
|
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)
|
workdir = d.getVar('WORKDIR', True)
|
||||||
s = d.getVar('S', True)
|
s = d.getVar('S', True)
|
||||||
if 'work-shared' in s or 'task-' in workdir or 'native' in workdir:
|
if 'work-shared' in s or 'task-' in workdir or 'native' in workdir:
|
||||||
@@ -183,7 +198,9 @@ def not_tarball(d):
|
|||||||
return False
|
return False
|
||||||
|
|
||||||
def get_source_from_downloads(d, stage_name):
|
def get_source_from_downloads(d, stage_name):
|
||||||
'''copy tarball of $P to $WORKDIR when this tarball exists in $DL_DIR'''
|
"""
|
||||||
|
copy tarball of $P to $WORKDIR when this tarball exists in $DL_DIR
|
||||||
|
"""
|
||||||
if stage_name in 'patched' 'configured':
|
if stage_name in 'patched' 'configured':
|
||||||
return
|
return
|
||||||
pf = d.getVar('PF', True)
|
pf = d.getVar('PF', True)
|
||||||
@@ -197,7 +214,9 @@ def get_source_from_downloads(d,stage_name):
|
|||||||
return ''
|
return ''
|
||||||
|
|
||||||
def do_tarball(workdir, srcdir, tarname):
|
def do_tarball(workdir, srcdir, tarname):
|
||||||
'''tar "srcdir" under "workdir" to "tarname"'''
|
"""
|
||||||
|
tar "srcdir" under "workdir" to "tarname"
|
||||||
|
"""
|
||||||
import tarfile
|
import tarfile
|
||||||
|
|
||||||
sav_dir = os.getcwd()
|
sav_dir = os.getcwd()
|
||||||
@@ -212,7 +231,10 @@ def do_tarball(workdir,srcdir,tarname):
|
|||||||
return tarname
|
return tarname
|
||||||
|
|
||||||
def archive_sources_from_directory(d, stage_name):
|
def archive_sources_from_directory(d, stage_name):
|
||||||
'''archive sources codes tree to tarball when tarball of $P doesn't exist in $DL_DIR'''
|
"""
|
||||||
|
archive sources codes tree to tarball when tarball of $P doesn't
|
||||||
|
exist in $DL_DIR
|
||||||
|
"""
|
||||||
import shutil
|
import shutil
|
||||||
|
|
||||||
s = d.getVar('S', True)
|
s = d.getVar('S', True)
|
||||||
@@ -232,8 +254,12 @@ def archive_sources_from_directory(d,stage_name):
|
|||||||
return do_tarball(work_dir, source, tarname)
|
return do_tarball(work_dir, source, tarname)
|
||||||
|
|
||||||
def archive_sources(d, stage_name):
|
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'''
|
"""
|
||||||
|
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
|
import shutil
|
||||||
|
|
||||||
work_dir = d.getVar('WORKDIR', True)
|
work_dir = d.getVar('WORKDIR', True)
|
||||||
file = get_source_from_downloads(d, stage_name)
|
file = get_source_from_downloads(d, stage_name)
|
||||||
if file:
|
if file:
|
||||||
@@ -244,7 +270,9 @@ def archive_sources(d,stage_name):
|
|||||||
return file
|
return file
|
||||||
|
|
||||||
def archive_patches(d, patchdir, series):
|
def archive_patches(d, patchdir, series):
|
||||||
'''archive patches to tarball and also include series files if 'series' is True'''
|
"""
|
||||||
|
archive patches to tarball and also include series files if 'series' is True
|
||||||
|
"""
|
||||||
import shutil
|
import shutil
|
||||||
|
|
||||||
s = d.getVar('S', True)
|
s = d.getVar('S', True)
|
||||||
@@ -258,7 +286,10 @@ def archive_patches(d,patchdir,series):
|
|||||||
return tarname
|
return tarname
|
||||||
|
|
||||||
def select_archive_patches(d, option):
|
def select_archive_patches(d, option):
|
||||||
'''select to archive all patches including non-applying and series or applying patches '''
|
"""
|
||||||
|
select to archive all patches including non-applying and series or
|
||||||
|
applying patches
|
||||||
|
"""
|
||||||
if option == "all":
|
if option == "all":
|
||||||
patchdir = get_series(d)
|
patchdir = get_series(d)
|
||||||
elif option == "applying":
|
elif option == "applying":
|
||||||
@@ -271,7 +302,9 @@ def select_archive_patches(d,option):
|
|||||||
return
|
return
|
||||||
|
|
||||||
def archive_logs(d, logdir, bbinc=False):
|
def archive_logs(d, logdir, bbinc=False):
|
||||||
'''archive logs in temp to tarball and .bb and .inc files if bbinc is True '''
|
"""
|
||||||
|
archive logs in temp to tarball and .bb and .inc files if bbinc is True
|
||||||
|
"""
|
||||||
import shutil
|
import shutil
|
||||||
|
|
||||||
pf = d.getVar('PF', True)
|
pf = d.getVar('PF', True)
|
||||||
@@ -284,7 +317,7 @@ def archive_logs(d,logdir,bbinc=False):
|
|||||||
return tarname
|
return tarname
|
||||||
|
|
||||||
def get_licenses(d):
|
def get_licenses(d):
|
||||||
'''get licenses for running .bb file'''
|
"""get licenses for running .bb file"""
|
||||||
import oe.license
|
import oe.license
|
||||||
|
|
||||||
licenses_type = d.getVar('LICENSE', True) or ""
|
licenses_type = d.getVar('LICENSE', True) or ""
|
||||||
@@ -300,7 +333,7 @@ def get_licenses(d):
|
|||||||
|
|
||||||
|
|
||||||
def move_tarball_deploy(d, tarball_list):
|
def move_tarball_deploy(d, tarball_list):
|
||||||
'''move tarball in location to ${DEPLOY_DIR}/sources'''
|
"""move tarball in location to ${DEPLOY_DIR}/sources"""
|
||||||
import shutil
|
import shutil
|
||||||
|
|
||||||
if tarball_list is []:
|
if tarball_list is []:
|
||||||
@@ -319,7 +352,7 @@ def move_tarball_deploy(d,tarball_list):
|
|||||||
shutil.move(os.path.join(work_dir, source), tar_sources)
|
shutil.move(os.path.join(work_dir, source), tar_sources)
|
||||||
|
|
||||||
def check_archiving_type(d):
|
def check_archiving_type(d):
|
||||||
'''check the type for archiving package('tar' or 'srpm')'''
|
"""check the type for archiving package('tar' or 'srpm')"""
|
||||||
try:
|
try:
|
||||||
if d.getVar('SOURCE_ARCHIVE_PACKAGE_TYPE', True).upper() not in d.getVar('ARCHIVE_TYPE', True).split():
|
if d.getVar('SOURCE_ARCHIVE_PACKAGE_TYPE', True).upper() not in d.getVar('ARCHIVE_TYPE', True).split():
|
||||||
raise AttributeError
|
raise AttributeError
|
||||||
@@ -327,7 +360,9 @@ def check_archiving_type(d):
|
|||||||
bb.fatal("\"SOURCE_ARCHIVE_PACKAGE_TYPE\" is \'tar\' or \'srpm\', no other types")
|
bb.fatal("\"SOURCE_ARCHIVE_PACKAGE_TYPE\" is \'tar\' or \'srpm\', no other types")
|
||||||
|
|
||||||
def store_package(d, package_name):
|
def store_package(d, package_name):
|
||||||
'''store tarbablls name to file "tar-package"'''
|
"""
|
||||||
|
store tarbablls name to file "tar-package"
|
||||||
|
"""
|
||||||
try:
|
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.write(package_name + ' ')
|
||||||
@@ -336,7 +371,9 @@ def store_package(d,package_name):
|
|||||||
pass
|
pass
|
||||||
|
|
||||||
def get_package(d):
|
def get_package(d):
|
||||||
'''get tarballs name from "tar-package"'''
|
"""
|
||||||
|
get tarballs name from "tar-package"
|
||||||
|
"""
|
||||||
work_dir = (d.getVar('WORKDIR', True))
|
work_dir = (d.getVar('WORKDIR', True))
|
||||||
tarpackage = os.path.join(work_dir, 'tar-package')
|
tarpackage = os.path.join(work_dir, 'tar-package')
|
||||||
try:
|
try:
|
||||||
@@ -349,7 +386,11 @@ def get_package(d):
|
|||||||
|
|
||||||
|
|
||||||
def archive_sources_patches(d, stage_name):
|
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 '''
|
"""
|
||||||
|
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
|
import shutil
|
||||||
|
|
||||||
check_archiving_type(d)
|
check_archiving_type(d)
|
||||||
@@ -378,7 +419,10 @@ def archive_sources_patches(d,stage_name):
|
|||||||
store_package(d, str(package) + ' ')
|
store_package(d, str(package) + ' ')
|
||||||
|
|
||||||
def archive_scripts_logs(d):
|
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):
|
if tar_filter(d):
|
||||||
return
|
return
|
||||||
@@ -401,7 +445,10 @@ def archive_scripts_logs(d):
|
|||||||
store_package(d, tarlog)
|
store_package(d, tarlog)
|
||||||
|
|
||||||
def dumpdata(d):
|
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):
|
if tar_filter(d):
|
||||||
return
|
return
|
||||||
@@ -421,14 +468,17 @@ def dumpdata(d):
|
|||||||
f = open(dumpfile, "w")
|
f = open(dumpfile, "w")
|
||||||
# emit variables and shell functions
|
# emit variables and shell functions
|
||||||
bb.data.emit_env(f, d, True)
|
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():
|
for e in d.keys():
|
||||||
if bb.data.getVarFlag(e, 'python', d):
|
if bb.data.getVarFlag(e, 'python', d):
|
||||||
f.write("\npython %s () {\n%s}\n" % (e, bb.data.getVar(e, d, 1)))
|
f.write("\npython %s () {\n%s}\n" % (e, bb.data.getVar(e, d, 1)))
|
||||||
f.close()
|
f.close()
|
||||||
|
|
||||||
def create_diff_gz(d):
|
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 shutil
|
||||||
import subprocess
|
import subprocess
|
||||||
|
|
||||||
@@ -467,35 +517,41 @@ def create_diff_gz(d):
|
|||||||
bb.build.exec_func('DIFF', d)
|
bb.build.exec_func('DIFF', d)
|
||||||
shutil.rmtree(s + '.org', ignore_errors=True)
|
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(){
|
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(){
|
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(){
|
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(){
|
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.
|
# all content a package should include.
|
||||||
python do_dumpdata_create_diff_gz(){
|
python do_dumpdata_create_diff_gz(){
|
||||||
dumpdata(d)
|
dumpdata(d)
|
||||||
create_diff_gz(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 functions prepare for archiving "linux-yocto" because this
|
||||||
# This is special control for archiving linux-yocto only.
|
# 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(){
|
python do_archive_linux_yocto(){
|
||||||
s = d.getVar('S', True)
|
s = d.getVar('S', True)
|
||||||
if 'linux-yocto' in s:
|
if 'linux-yocto' in s:
|
||||||
|
|||||||
Reference in New Issue
Block a user