Skip to content

Commit 68efc27

Browse files
committed
Merge remote-tracking branch 'origin/master'
2 parents 5ecc5e7 + dba95fd commit 68efc27

File tree

1 file changed

+28
-4
lines changed
  • appimagebuilder/app_dir/deploy/pacman

1 file changed

+28
-4
lines changed

appimagebuilder/app_dir/deploy/pacman/venv.py

Lines changed: 28 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -9,17 +9,19 @@
99
#
1010
# The above copyright notice and this permission notice shall be included in
1111
# all copies or substantial portions of the Software.
12+
import glob
1213
import logging
1314
import os
1415
import re
1516
import shlex
1617
import subprocess
1718
import sys
1819
from pathlib import Path
20+
from tempfile import TemporaryDirectory
1921

2022
from appimagebuilder.common import shell
2123

22-
DEPENDS_ON = ["bsdtar", "pacman", "pacman-key", "fakeroot"]
24+
DEPENDS_ON = ["bsdtar", "pacman", "pacman-key", "fakeroot", "gpg-agent"]
2325

2426

2527
class PacmanVenvError(RuntimeError):
@@ -160,11 +162,33 @@ def _generate_config(self):
160162
f.write("Server = %s\n" % server)
161163

162164
def _configure_keyring(self):
163-
self._run_command("{fakeroot} {pacman-key} --config {config} --init")
164-
self._run_command(
165-
"{fakeroot} {pacman-key} --config {config} --populate archlinux"
165+
keyrings = list(
166+
map(
167+
lambda x: x.split('.gpg')[0],
168+
[os.path.basename(x) for x in glob.glob('/usr/share/pacman/keyrings/*.gpg')]
169+
)
166170
)
167171

172+
with TemporaryDirectory(prefix="appimage-builder.") as temp_dir:
173+
temp_gnupg_dir = str(Path(temp_dir) / 'gnupg')
174+
175+
os.symlink(self._gpg_dir.absolute(), temp_gnupg_dir, target_is_directory=True)
176+
177+
proc_gpgagent = self._run_command(
178+
"{fakeroot} {gpg-agent} --homedir"
179+
f" {temp_gnupg_dir}"
180+
" --daemon",
181+
assert_success=False,
182+
wait_for_completion=False
183+
)
184+
self._run_command("{fakeroot} {pacman-key} --config {config} --init")
185+
self._run_command(
186+
"{fakeroot} {pacman-key} --config {config} --populate "
187+
f"{' '.join(keyrings)}"
188+
)
189+
190+
proc_gpgagent.terminate()
191+
168192
def _run_command(
169193
self,
170194
command,

0 commit comments

Comments
 (0)