summaryrefslogtreecommitdiffstats
path: root/meta/lib/oe/package.py
diff options
context:
space:
mode:
Diffstat (limited to 'meta/lib/oe/package.py')
-rw-r--r--meta/lib/oe/package.py77
1 files changed, 77 insertions, 0 deletions
diff --git a/meta/lib/oe/package.py b/meta/lib/oe/package.py
index 05447f8808..b4c8ab7222 100644
--- a/meta/lib/oe/package.py
+++ b/meta/lib/oe/package.py
@@ -4,6 +4,8 @@
4# SPDX-License-Identifier: GPL-2.0-only 4# SPDX-License-Identifier: GPL-2.0-only
5# 5#
6 6
7import os
8import glob
7import stat 9import stat
8import mmap 10import mmap
9import subprocess 11import subprocess
@@ -532,5 +534,80 @@ def fixup_perms(d):
532 each_file = os.path.join(root, f) 534 each_file = os.path.join(root, f)
533 fix_perms(each_file, fs_perms_table[dir].fmode, fs_perms_table[dir].fuid, fs_perms_table[dir].fgid, dir) 535 fix_perms(each_file, fs_perms_table[dir].fmode, fs_perms_table[dir].fuid, fs_perms_table[dir].fgid, dir)
534 536
537# Get a list of files from file vars by searching files under current working directory
538# The list contains symlinks, directories and normal files.
539def files_from_filevars(filevars):
540 import oe.cachedpath
541
542 cpath = oe.cachedpath.CachedPath()
543 files = []
544 for f in filevars:
545 if os.path.isabs(f):
546 f = '.' + f
547 if not f.startswith("./"):
548 f = './' + f
549 globbed = glob.glob(f)
550 if globbed:
551 if [ f ] != globbed:
552 files += globbed
553 continue
554 files.append(f)
555
556 symlink_paths = []
557 for ind, f in enumerate(files):
558 # Handle directory symlinks. Truncate path to the lowest level symlink
559 parent = ''
560 for dirname in f.split('/')[:-1]:
561 parent = os.path.join(parent, dirname)
562 if dirname == '.':
563 continue
564 if cpath.islink(parent):
565 bb.warn("FILES contains file '%s' which resides under a "
566 "directory symlink. Please fix the recipe and use the "
567 "real path for the file." % f[1:])
568 symlink_paths.append(f)
569 files[ind] = parent
570 f = parent
571 break
572
573 if not cpath.islink(f):
574 if cpath.isdir(f):
575 newfiles = [ os.path.join(f,x) for x in os.listdir(f) ]
576 if newfiles:
577 files += newfiles
578
579 return files, symlink_paths
580
581# Called in package_<rpm,ipk,deb>.bbclass to get the correct list of configuration files
582def get_conffiles(pkg, d):
583 pkgdest = d.getVar('PKGDEST')
584 root = os.path.join(pkgdest, pkg)
585 cwd = os.getcwd()
586 os.chdir(root)
587
588 conffiles = d.getVar('CONFFILES:%s' % pkg);
589 if conffiles == None:
590 conffiles = d.getVar('CONFFILES')
591 if conffiles == None:
592 conffiles = ""
593 conffiles = conffiles.split()
594 conf_orig_list = files_from_filevars(conffiles)[0]
595
596 # Remove links and directories from conf_orig_list to get conf_list which only contains normal files
597 conf_list = []
598 for f in conf_orig_list:
599 if os.path.isdir(f):
600 continue
601 if os.path.islink(f):
602 continue
603 if not os.path.exists(f):
604 continue
605 conf_list.append(f)
606
607 # Remove the leading './'
608 for i in range(0, len(conf_list)):
609 conf_list[i] = conf_list[i][1:]
535 610
611 os.chdir(cwd)
612 return conf_list
536 613