Commit c9550f7c authored by BrLi's avatar BrLi

Merge branch 'master' of git://git.chakralinux.org/buildsystem

parents 5c1099c9 c3606b31
......@@ -33,6 +33,7 @@ export HISTFILESIZE=${HISTSIZE} # bash will remember N commands
export HISTCONTROL=ignoreboth # ingore duplicates and spaces (ignoreboth, ignoredups, ignorespace)
export EDITOR=vim
export VISUAL=vim
export GNUPGHOME=/chakra/.config/gnupg
# Aliases
function aliases() {
......
......@@ -69,28 +69,37 @@ actual_chroot() {
sleep 1
fi
local gnupg=${GNUPGHOME:-~/.gnupg}
local gnupg_chroot=chakra/.config/gnupg
if [[ -d $gnupg ]]; then
# starting from gpg 2.1.13 the agents are locaded under $XDG_RUNTIME_DIR/gnupg
# however, preventing from the case there isn't such environment variable, we use `id -u` instead
if [[ -S "$XDG_RUNTIME_DIR" ]]; then
local socket_dir=$XDG_RUNTIME_DIR/gnupg
else
local socket_dir=/run/user/$(id -u)/gnupg
if [[ ! -d "$gnupg_chroot" ]]; then
warning "/chakra/.gnupg does not exist"
msg "To be able to sign packages you will need to import your public key!"
msg "$ gpg --import /usr/share/chakra/signatures/<user>.asc"
mkdir -pm700 $gnupg_chroot
sleep 1
fi
local extra_gpg_agent=$socket_dir/S.gpg-agent.extra
if [[ -e $extra_gpg_agent && -e $gnupg/S.gpg-agent ]]; then # the expected layout on build server
msg "found $extra_gpg_agent, will bind it to container!"
binds+=(--bind-ro="$extra_gpg_agent":/chakra/.gnupg/S.gpg-agent.extra)
elif [[ -e $socket_dir/S.gpg-agent ]]; then # the typical layout of a local system
msg "found main socket on local system"
binds+=(--bind="$socket_dir/S.gpg-agent":/chakra/.gnupg/S.gpg-agent)
binds+=(--bind-ro="$(gpgconf --list-dirs dirmngr-socket)":/chakra/.gnupg/S.dirmngr)
local socket="$(gpgconf --list-dirs agent-socket)"
local extra_socket="$(gpgconf --list-dirs agent-extra-socket)"
if [[ -S $socket && -S $extra_socket ]]; then
msg "Found $extra_socket"
local -n socket_to_bind=extra_socket
elif [[ -S $socket ]]; then
msg "Could not find $extra_socket, using $socket"
local -n socket_to_bind=socket
else
msg "can't find any main socket"
fi
msg "found $gnupg, will bind it to container!"
binds+=(--bind="$gnupg":/chakra/.gnupg)
if [[ -R socket_to_bind ]]; then
msg "bindind $socket_to_bind to container"
# Ideally we'd get that value from the chroots gpgconf but I don't
# want to actually run systemd-nspawn right here
local chroot_socket="/$gnupg_chroot/S.gpg-agent"
binds+=(--bind-ro="$socket_to_bind":"$chroot_socket")
fi
else
msg "I can't find anything about $gnupg, exiting automatic bind process..."
sleep 1
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment