Skip to content

Commit 8b93378

Browse files
elbepack: fix create_pbuilder() with debootstrap_key_path set
The keyring argument that is forwarded to debootstrap by pbuilder needs to exist prior to calling pbuilder. Hence creating the file in a pbuilder hook is too late. Also debootstrap can only handle unarmored GPG keys, otherwise it fails with a confusing error message.
1 parent 2c8effa commit 8b93378

File tree

3 files changed

+16
-3
lines changed

3 files changed

+16
-3
lines changed

elbepack/elbeproject.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -873,6 +873,9 @@ def create_pbuilder(self, cross, noccache, ccachesize):
873873
'--aptconfdir', os.path.join(self.builddir, 'aptconfdir'),
874874
'--debootstrapopts', '--include=git,gnupg', *no_check_gpg, *keyring])
875875

876+
if debootstrap_key_path:
877+
os.remove(debootstrap_key_path)
878+
876879
def sync_xml_to_disk(self):
877880
try:
878881
sourcexmlpath = os.path.join(self.builddir, 'source.xml')

elbepack/pbuilder.py

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,10 @@
44

55
import os
66
import pathlib
7+
from tempfile import NamedTemporaryFile
78
from urllib.request import urlopen
89

10+
from elbepack.egpg import unarmor_openpgp_keyring
911
from elbepack.treeutils import strip_leading_whitespace_from_lines
1012

1113

@@ -177,8 +179,16 @@ def pbuilder_get_debootstrap_key_path(chrootpath, xml):
177179
# If we have a primary key for use with debootstrap, BuildEnv.debootstrap
178180
# will have added the key. We use the same key for the pbuilder
179181
# debootstrap options.
180-
if get_debootstrap_key(xml):
181-
return os.path.join(chrootpath, 'etc', 'apt', 'trusted.gpg.d', 'elbe-xml-primary-key.gpg')
182+
key = get_debootstrap_key(xml)
183+
if key is None:
184+
return None
185+
186+
tmp_file = NamedTemporaryFile(delete=False)
187+
188+
tmp_file.write(unarmor_openpgp_keyring(key))
189+
tmp_file.close()
190+
191+
return tmp_file.name
182192

183193

184194
def get_apt_keys(builddir, xml):

elbepack/rfs.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -155,7 +155,7 @@ def _cleanup_bootstrap(self):
155155
def import_debootstrap_key(self, key):
156156
if key:
157157
k = strip_leading_whitespace_from_lines(key)
158-
return self.add_key(unarmor_openpgp_keyring(k), 'elbe-xml-primary-key.gpg')
158+
return self.add_key(unarmor_openpgp_keyring(k), 'elbe-xml-primary-key')
159159

160160
def _strapcmd(self, arch, suite, cross, mmdebstrap):
161161
primary_mirror = self.xml.get_primary_mirror(

0 commit comments

Comments
 (0)