sysmocom-archiver: cleanup whitespaces
This commit is contained in:
parent
12c250ece5
commit
cadbd162ed
|
@ -1,6 +1,6 @@
|
||||||
# This file is used for archiving sources ,patches,and logs to tarball.
|
# 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
|
# It also output building environment to xxx.dump.data and create xxx.diff.gz to record
|
||||||
# all content in ${S} to a diff file.
|
# all content in ${S} to a diff file.
|
||||||
|
|
||||||
ARCHIVE_EXCLUDE_FROM ?= ".pc autom4te.cache"
|
ARCHIVE_EXCLUDE_FROM ?= ".pc autom4te.cache"
|
||||||
ARCHIVE_TYPE ?= "TAR SRPM"
|
ARCHIVE_TYPE ?= "TAR SRPM"
|
||||||
|
@ -12,7 +12,7 @@ def get_bb_inc(d):
|
||||||
import re
|
import re
|
||||||
import os
|
import os
|
||||||
import shutil
|
import shutil
|
||||||
|
|
||||||
bbinc = []
|
bbinc = []
|
||||||
pat=re.compile('require\s*([^\s]*\.*)(.*)')
|
pat=re.compile('require\s*([^\s]*\.*)(.*)')
|
||||||
work_dir = d.getVar('WORKDIR', True)
|
work_dir = d.getVar('WORKDIR', True)
|
||||||
|
@ -22,12 +22,12 @@ def get_bb_inc(d):
|
||||||
bb_inc = os.path.join(script_logs,'bb_inc')
|
bb_inc = os.path.join(script_logs,'bb_inc')
|
||||||
bb.mkdirhier(script_logs)
|
bb.mkdirhier(script_logs)
|
||||||
bb.mkdirhier(bb_inc)
|
bb.mkdirhier(bb_inc)
|
||||||
|
|
||||||
def find_file(dir,file):
|
def find_file(dir,file):
|
||||||
for root, dirs, files in os.walk(dir):
|
for root, dirs, files in os.walk(dir):
|
||||||
if file in files:
|
if file in files:
|
||||||
return os.path.join(root,file)
|
return os.path.join(root,file)
|
||||||
|
|
||||||
def get_inc (file):
|
def get_inc (file):
|
||||||
f = open(file,'r')
|
f = open(file,'r')
|
||||||
for line in f.readlines():
|
for line in f.readlines():
|
||||||
|
@ -58,15 +58,15 @@ def get_bb_inc(d):
|
||||||
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=[]
|
||||||
pf = d.getVar('PF', True)
|
pf = d.getVar('PF', True)
|
||||||
work_dir = d.getVar('WORKDIR', 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')
|
dest = os.path.join(work_dir, pf + '-series')
|
||||||
shutil.rmtree(dest, ignore_errors=True)
|
shutil.rmtree(dest, ignore_errors=True)
|
||||||
bb.mkdirhier(dest)
|
bb.mkdirhier(dest)
|
||||||
|
|
||||||
src_uri = d.getVar('SRC_URI', True).split()
|
src_uri = d.getVar('SRC_URI', True).split()
|
||||||
fetch = bb.fetch2.Fetch(src_uri, d)
|
fetch = bb.fetch2.Fetch(src_uri, d)
|
||||||
locals = (fetch.localpath(url) for url in fetch.urls)
|
locals = (fetch.localpath(url) for url in fetch.urls)
|
||||||
|
@ -76,7 +76,7 @@ def get_series(d):
|
||||||
tmp_list = src_patches
|
tmp_list = src_patches
|
||||||
else:
|
else:
|
||||||
tmp_list = src_patches[1:]
|
tmp_list = src_patches[1:]
|
||||||
|
|
||||||
for patch in tmp_list:
|
for patch in tmp_list:
|
||||||
try:
|
try:
|
||||||
shutil.copy(patch,dest)
|
shutil.copy(patch,dest)
|
||||||
|
@ -94,7 +94,7 @@ def get_applying_patches(d):
|
||||||
|
|
||||||
pf = d.getVar('PF', True)
|
pf = d.getVar('PF', True)
|
||||||
work_dir = d.getVar('WORKDIR', True)
|
work_dir = d.getVar('WORKDIR', True)
|
||||||
dest = os.path.join(work_dir, pf + '-patches')
|
dest = os.path.join(work_dir, pf + '-patches')
|
||||||
shutil.rmtree(dest, ignore_errors=True)
|
shutil.rmtree(dest, ignore_errors=True)
|
||||||
bb.mkdirhier(dest)
|
bb.mkdirhier(dest)
|
||||||
|
|
||||||
|
@ -137,7 +137,7 @@ def get_source_from_downloads(d,stage_name):
|
||||||
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()
|
||||||
os.chdir(workdir)
|
os.chdir(workdir)
|
||||||
if (len(os.listdir(srcdir))) != 0:
|
if (len(os.listdir(srcdir))) != 0:
|
||||||
|
@ -149,10 +149,10 @@ def do_tarball(workdir,srcdir,tarname):
|
||||||
os.chdir(sav_dir)
|
os.chdir(sav_dir)
|
||||||
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)
|
||||||
work_dir=d.getVar('WORKDIR', True)
|
work_dir=d.getVar('WORKDIR', True)
|
||||||
PF = d.getVar('PF',True)
|
PF = d.getVar('PF',True)
|
||||||
|
@ -220,12 +220,12 @@ def archive_logs(d,logdir,bbinc=False):
|
||||||
tarname = do_tarball(work_dir,log_dir,tarname)
|
tarname = do_tarball(work_dir,log_dir,tarname)
|
||||||
if bbinc:
|
if bbinc:
|
||||||
shutil.rmtree(logdir, ignore_errors=True)
|
shutil.rmtree(logdir, ignore_errors=True)
|
||||||
return tarname
|
return tarname
|
||||||
|
|
||||||
def get_licenses(d):
|
def get_licenses(d):
|
||||||
'''get licenses for running .bb file'''
|
'''get licenses for running .bb file'''
|
||||||
licenses = d.getVar('LICENSE', 1).replace('&', '|')
|
licenses = d.getVar('LICENSE', 1).replace('&', '|')
|
||||||
licenses = licenses.replace('(', '').replace(')', '')
|
licenses = licenses.replace('(', '').replace(')', '')
|
||||||
clean_licenses = ""
|
clean_licenses = ""
|
||||||
for x in licenses.split():
|
for x in licenses.split():
|
||||||
if x.strip() == '' or x == 'CLOSED':
|
if x.strip() == '' or x == 'CLOSED':
|
||||||
|
@ -235,12 +235,11 @@ def get_licenses(d):
|
||||||
if '|' in clean_licenses:
|
if '|' in clean_licenses:
|
||||||
clean_licenses = clean_licenses.replace('|','')
|
clean_licenses = clean_licenses.replace('|','')
|
||||||
return clean_licenses
|
return clean_licenses
|
||||||
|
|
||||||
|
|
||||||
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 []:
|
||||||
return
|
return
|
||||||
target_sys = d.getVar('TARGET_SYS', True)
|
target_sys = d.getVar('TARGET_SYS', True)
|
||||||
|
@ -260,9 +259,9 @@ 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
|
||||||
except AttributeError:
|
except AttributeError:
|
||||||
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"'''
|
||||||
|
@ -290,10 +289,10 @@ 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)
|
||||||
if not_tarball(d):
|
if not_tarball(d):
|
||||||
return
|
return
|
||||||
|
|
||||||
source_tar_name = archive_sources(d,stage_name)
|
source_tar_name = archive_sources(d,stage_name)
|
||||||
if stage_name == "prepatch":
|
if stage_name == "prepatch":
|
||||||
if d.getVar('PATCHES_ARCHIVE_WITH_SERIES',True).upper() == 'TRUE':
|
if d.getVar('PATCHES_ARCHIVE_WITH_SERIES',True).upper() == 'TRUE':
|
||||||
|
@ -304,7 +303,7 @@ def archive_sources_patches(d,stage_name):
|
||||||
bb.fatal("Please define 'PATCHES_ARCHIVE_WITH_SERIES' is strings 'True' or 'False' ")
|
bb.fatal("Please define 'PATCHES_ARCHIVE_WITH_SERIES' is strings 'True' or 'False' ")
|
||||||
else:
|
else:
|
||||||
patch_tar_name = ''
|
patch_tar_name = ''
|
||||||
|
|
||||||
if d.getVar('SOURCE_ARCHIVE_PACKAGE_TYPE', True).upper() not in 'SRPM':
|
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:
|
else:
|
||||||
|
@ -329,7 +328,7 @@ def archive_scripts_logs(d):
|
||||||
tarlog = archive_logs(d,temp_dir,False)
|
tarlog = archive_logs(d,temp_dir,False)
|
||||||
else:
|
else:
|
||||||
return
|
return
|
||||||
|
|
||||||
if d.getVar('SOURCE_ARCHIVE_PACKAGE_TYPE', True).upper() not in 'SRPM':
|
if d.getVar('SOURCE_ARCHIVE_PACKAGE_TYPE', True).upper() not in 'SRPM':
|
||||||
move_tarball_deploy(d,[tarlog])
|
move_tarball_deploy(d,[tarlog])
|
||||||
|
|
||||||
|
@ -389,11 +388,11 @@ def create_diff_gz(d):
|
||||||
shutil.copy(i, dest)
|
shutil.copy(i, dest)
|
||||||
except IOError:
|
except IOError:
|
||||||
os.system('fakeroot cp -rf ' + i + " " + dest )
|
os.system('fakeroot cp -rf ' + i + " " + dest )
|
||||||
|
|
||||||
bb.note("Creating .diff.gz in ${DEPLOY_DIR_SRC}/${P}-${PR}.diff.gz")
|
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
|
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.setVar('DIFF', cmd + "\n")
|
||||||
d.setVarFlag('DIFF', 'func', '1')
|
d.setVarFlag('DIFF', 'func', '1')
|
||||||
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)
|
||||||
|
|
||||||
|
@ -417,7 +416,7 @@ 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)
|
||||||
|
|
Loading…
Reference in New Issue