Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 6 additions & 2 deletions elbepack/aptpkgutils.py
Original file line number Diff line number Diff line change
Expand Up @@ -67,17 +67,21 @@ def getdeps(pkg):
yield d.name


def getalldeps(c, pkgname):
retval = []
def getalldeps(c, pkgname, blacklist=()):
retval = [pkgname]
togo = [pkgname]

while togo:
pp = togo.pop()
if pp in blacklist:
continue
pkg = c[pp]

for p in getdeps(pkg.candidate):
if p in retval:
continue
if p in blacklist:
continue
if p not in c:
continue
retval.append(p)
Expand Down
12 changes: 11 additions & 1 deletion elbepack/efilesystem.py
Original file line number Diff line number Diff line change
Expand Up @@ -112,13 +112,20 @@ def extract_target(src, xml, dst, cache):
arch = xml.text('project/buildimage/arch', key='arch')

if xml.tgt.has('diet'):
if xml.has('target/pkg-blacklist/'):
blacklist = [p.et.text for p in xml.node('target/pkg-blacklist/target')]
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Instead of silently ignoring the entry for non-diet builds, please throw an error instead.

withdeps = []
for p in pkglist:
deps = cache.get_dependencies(p)
if p in blacklist:
continue
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Instead of having multiple places checking the blacklist, IMO it would be cleaner to move all the blacklist checking into cache.get_dependencies() by also having it return the original package and drop the withdeps += [p] below.

deps = cache.get_dependencies(p, blacklist)
withdeps += [d.name for d in deps]
withdeps += [p]

pkglist = list(set(withdeps))
elif xml.has('target/pkg-blacklist/'):
logging.error(
'Impossible to blacklist packages outside of diet mode')

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

Expand Down
4 changes: 2 additions & 2 deletions elbepack/rpcaptcache.py
Original file line number Diff line number Diff line change
Expand Up @@ -224,8 +224,8 @@ def commit(self):
ElbeInstallProgress(fileno=sys.stdout.fileno()))
self.cache.open(progress=ElbeOpProgress())

def get_dependencies(self, pkgname):
deps = getalldeps(self.cache, pkgname)
def get_dependencies(self, pkgname, blacklist):
deps = getalldeps(self.cache, pkgname, blacklist)
return [APTPackage(self.cache[p]) for p in deps]

def get_installed_pkgs(self, section='all'):
Expand Down
9 changes: 8 additions & 1 deletion elbepack/schema/dbsfed.xsd
Original file line number Diff line number Diff line change
Expand Up @@ -1133,7 +1133,7 @@ SPDX-FileCopyrightText: Linutronix GmbH
<element name="pkg-blacklist" type="rfs:blacklist" minOccurs="0" maxOccurs="1">
<annotation>
<documentation>
avoid installation of packages into sysroot
avoid installation of packages into sysroot or target
</documentation>
</annotation>
</element>
Expand Down Expand Up @@ -3094,6 +3094,13 @@ SPDX-FileCopyrightText: Linutronix GmbH
</documentation>
</annotation>
<sequence>
<element name="target" type="rfs:pkg-list" minOccurs="0" maxOccurs="unbounded">
<annotation>
<documentation>
avoid installing the specified packages into the target (only works in diet mode)
</documentation>
</annotation>
</element>
<element name="sysroot" type="rfs:pkg-list" minOccurs="0" maxOccurs="unbounded">
<annotation>
<documentation>
Expand Down
Loading