Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support primary_key in mirror tag #367

Open
wants to merge 9 commits into
base: master
Choose a base branch
from
Prev Previous commit
Next Next commit
Make debootstrap use key for primary mirror if there is one
Signed-off-by: Stefan Kempf <stefan@kempfsn.de>
  • Loading branch information
Stefan Kempf committed Mar 18, 2023
commit d9c9feee695b56f9b4357441a92f3a1b99cd339f
22 changes: 20 additions & 2 deletions elbepack/rfs.py
Original file line number Diff line number Diff line change
@@ -144,6 +144,16 @@ def __exit__(self, typ, value, traceback):
do(f"rm {self.path}/etc/apt/sources.list.d/local.list")
do(f"rm {self.path}/etc/apt/trusted.gpg.d/elbe-localrepo.gpg")

def import_debootstrap_key(self, key):
path = ''

if key:
self.rfs.mkdir_p('etc/apt/trusted.gpg.d')
k = "\n".join(line.strip(" \t") for line in key.splitlines()[1:-1])
path = self.add_key(unarmor_openpgp_keyring(k), "elbe-xml-primary-key.gpg")

return path

def debootstrap(self, arch="default"):

# pylint: disable=too-many-statements
@@ -154,6 +164,10 @@ def debootstrap(self, arch="default"):

primary_mirror = self.xml.get_primary_mirror(
self.rfs.fname('/cdrom/targetrepo'), hostsysroot=self.hostsysroot)
primary_key = self.xml.get_primary_key(
self.rfs.fname('/cdrom/targetrepo'), hostsysroot=self.hostsysroot)

debootstrap_key_path = self.import_debootstrap_key(primary_key)

if self.xml.prj.has("mirror/primary_proxy"):
os.environ["no_proxy"] = "10.0.2.2,localhost,127.0.0.1"
@@ -202,13 +216,15 @@ def debootstrap(self, arch="default"):
else:
if self.xml.has("project/mirror/cdrom"):
keyring = f' --keyring="{self.rfs.fname("/elbe.keyring")}"'
elif debootstrap_key_path:
keyring = f' --keyring="{debootstrap_key_path}"'

cmd = (f'{strapcmd} --arch={arch} '
f'{keyring} "{suite}" "{self.rfs.path}" "{primary_mirror}"')

try:
self.cdrom_mount()
if keyring:
if keyring and self.xml.has("project/mirror/cdrom"):
self.convert_asc_to_gpg("/cdrom/targetrepo/repo.pub", "/elbe.keyring")
do(cmd)
except CommandError:
@@ -227,13 +243,15 @@ def debootstrap(self, arch="default"):
else:
if self.xml.has("project/mirror/cdrom"):
keyring = f' --keyring="{self.rfs.fname("/elbe.keyring")}"'
elif debootstrap_key_path:
keyring = f' --keyring="{debootstrap_key_path}"'

cmd = (f'{strapcmd} --foreign --arch={arch} '
f'{keyring} "{suite}" "{self.rfs.path}" "{primary_mirror}"')

try:
self.cdrom_mount()
if keyring:
if keyring and self.xml.has("project/mirror/cdrom"):
self.convert_asc_to_gpg("/cdrom/targetrepo/repo.pub", "/elbe.keyring")
do(cmd)