Skip to content

Commit 53c4e2c

Browse files
committed
elbepack: aptpkgutils: implement recursive package blacklisting in diet builds
Implements package blacklisting for diet builds, this allows the user to create a list of packages to exclude from the target. This will recursively avoid installing a package and all its dependencies on the target even if this package comes as a dependency of another package. This must be carefully used as it can create packages with lacking dependencies. Signed-off-by: Thomas Bonnefille <[email protected]>
1 parent d50f56f commit 53c4e2c

File tree

4 files changed

+26
-5
lines changed

4 files changed

+26
-5
lines changed

elbepack/aptpkgutils.py

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -67,17 +67,21 @@ def getdeps(pkg):
6767
yield d.name
6868

6969

70-
def getalldeps(c, pkgname):
71-
retval = []
70+
def getalldeps(c, pkgname, blacklist=()):
71+
retval = [pkgname]
7272
togo = [pkgname]
7373

7474
while togo:
7575
pp = togo.pop()
76+
if pp in blacklist:
77+
continue
7678
pkg = c[pp]
7779

7880
for p in getdeps(pkg.candidate):
7981
if p in retval:
8082
continue
83+
if p in blacklist:
84+
continue
8185
if p not in c:
8286
continue
8387
retval.append(p)

elbepack/efilesystem.py

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -112,13 +112,20 @@ def extract_target(src, xml, dst, cache):
112112
arch = xml.text('project/buildimage/arch', key='arch')
113113

114114
if xml.tgt.has('diet'):
115+
if xml.has('target/pkg-blacklist/'):
116+
blacklist = [p.et.text for p in xml.node('target/pkg-blacklist/target')]
115117
withdeps = []
116118
for p in pkglist:
117-
deps = cache.get_dependencies(p)
119+
if p in blacklist:
120+
continue
121+
deps = cache.get_dependencies(p, blacklist)
118122
withdeps += [d.name for d in deps]
119123
withdeps += [p]
120124

121125
pkglist = list(set(withdeps))
126+
elif xml.has('target/pkg-blacklist/'):
127+
logging.error(
128+
"Impossible to blacklist packages outside of diet mode")
122129

123130
file_list = []
124131
for line in pkglist:
@@ -133,6 +140,9 @@ def extract_target(src, xml, dst, cache):
133140
copy_filelist(src, file_list, dst)
134141
else:
135142
# first copy most diretories
143+
if xml.has('target/pkg-blacklist/'):
144+
logging.error(
145+
"Impossible to blacklist packages outside of diet mode")
136146
for f in src.listdir():
137147
subprocess.call(['cp', '-a', '--reflink=auto', f, dst.fname('')])
138148

elbepack/rpcaptcache.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -224,8 +224,8 @@ def commit(self):
224224
ElbeInstallProgress(fileno=sys.stdout.fileno()))
225225
self.cache.open(progress=ElbeOpProgress())
226226

227-
def get_dependencies(self, pkgname):
228-
deps = getalldeps(self.cache, pkgname)
227+
def get_dependencies(self, pkgname, blacklist):
228+
deps = getalldeps(self.cache, pkgname, blacklist)
229229
return [APTPackage(self.cache[p]) for p in deps]
230230

231231
def get_installed_pkgs(self, section='all'):

elbepack/schema/dbsfed.xsd

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3094,6 +3094,13 @@ SPDX-FileCopyrightText: Linutronix GmbH
30943094
</documentation>
30953095
</annotation>
30963096
<sequence>
3097+
<element name="target" type="rfs:pkg-list" minOccurs="0" maxOccurs="unbounded">
3098+
<annotation>
3099+
<documentation>
3100+
avoid installing the specified packages into the target (only works in diet mode)
3101+
</documentation>
3102+
</annotation>
3103+
</element>
30973104
<element name="sysroot" type="rfs:pkg-list" minOccurs="0" maxOccurs="unbounded">
30983105
<annotation>
30993106
<documentation>

0 commit comments

Comments
 (0)