mirror of
https://github.com/clearlinux/autospec.git
synced 2026-11-25 23:23:59 +00:00
Enable auto exclude for library compat packages
When making a library compatibility package, the only files that are needed are the library binary and versioned symlinks to the library. All the other files are to be excluded as they might conflict with the files in the main package. To that end, add a setting in options.conf for a package to signify it is a compatibility library and do matching for files that meet the above requirements and exclude all others.
This commit is contained in:
committed by
Matthew Johnson
parent
2ad5514017
commit
1fd3342315
+3
-1
@@ -115,7 +115,9 @@ config_options = {
|
||||
"security_sensitive": "set flags for security-sensitive builds",
|
||||
"so_to_lib": "add .so files to the lib package instead of dev",
|
||||
"autoupdate": "this package is trusted enough to automatically update "
|
||||
"(used by other tools)"}
|
||||
"(used by other tools)",
|
||||
"compat": "this package is a library compatability package and only "
|
||||
"ships versioned library files"}
|
||||
|
||||
# simple_pattern_pkgconfig patterns
|
||||
# contains patterns for parsing build.log for missing dependencies
|
||||
|
||||
+24
-1
@@ -62,6 +62,29 @@ class FileManager(object):
|
||||
print(" New %files content found")
|
||||
self.newfiles_printed = True
|
||||
|
||||
def compat_exclude(self, filename):
|
||||
"""
|
||||
Exclude non-library files if the package is for compatability.
|
||||
"""
|
||||
if not config.config_opts.get("compat"):
|
||||
return False
|
||||
|
||||
patterns = [
|
||||
re.compile(r"^/usr/lib/[a-zA-Z0-9\.\_\-\+]*\.so\."),
|
||||
re.compile(r"^/usr/lib64/[a-zA-Z0-9\.\_\-\+]*\.so\."),
|
||||
re.compile(r"^/usr/lib32/[a-zA-Z0-9\.\_\-\+]*\.so\."),
|
||||
re.compile(r"^/usr/lib64/lib(asm|dw|elf)-[0-9.]+\.so"),
|
||||
re.compile(r"^/usr/lib32/lib(asm|dw|elf)-[0-9.]+\.so"),
|
||||
re.compile(r"^/usr/lib64/haswell/[a-zA-Z0-9\.\_\-\+]*\.so\.")]
|
||||
|
||||
exclude = True
|
||||
for pat in patterns:
|
||||
if pat.search(filename):
|
||||
exclude = False
|
||||
break
|
||||
|
||||
return exclude
|
||||
|
||||
def file_pat_match(self, filename, pattern, package, replacement="", prefix=""):
|
||||
"""
|
||||
Search for pattern in filename, if pattern matches push package file.
|
||||
@@ -75,7 +98,7 @@ class FileManager(object):
|
||||
pat = re.compile(pattern)
|
||||
match = pat.search(filename)
|
||||
if match:
|
||||
if filename in self.excludes:
|
||||
if filename in self.excludes or self.compat_exclude(filename):
|
||||
self.push_package_file("%exclude " + filename, package)
|
||||
return True
|
||||
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
import unittest
|
||||
import config
|
||||
import files
|
||||
import tempfile
|
||||
import os
|
||||
@@ -39,6 +40,28 @@ class TestFiles(unittest.TestCase):
|
||||
self.assertEqual(self.fm.packages['dev'], set(['test-fn']))
|
||||
self.assertTrue(self.fm.newfiles_printed)
|
||||
|
||||
def test_compat_exclude_keep_file(self):
|
||||
"""
|
||||
Test compat_exclude with a file that shouldn't be excluded.
|
||||
"""
|
||||
config.config_opts['compat'] = True
|
||||
self.assertFalse(self.fm.compat_exclude('/usr/lib64/libfoo.so.1'))
|
||||
|
||||
def test_compat_exclude_exclude_file(self):
|
||||
"""
|
||||
Test compat_exclude with a file that should be excluded.
|
||||
"""
|
||||
config.config_opts['compat'] = True
|
||||
self.assertTrue(self.fm.compat_exclude('/usr/lib64/libfoo.so'))
|
||||
|
||||
def test_compat_exclude_not_compat_mode(self):
|
||||
"""
|
||||
Test compat_exclude with a file that should be excluded but isn't
|
||||
because the package isn't being run in compat mode.
|
||||
"""
|
||||
config.config_opts['compat'] = False
|
||||
self.assertFalse(self.fm.compat_exclude('/usr/lib64/libfoo.so'))
|
||||
|
||||
def test_file_pat_match(self):
|
||||
"""
|
||||
Test file_pat_match with good match and no replacement or prefix
|
||||
|
||||
Reference in New Issue
Block a user