1
0
Fork 0
mirror of https://cgit.krebsco.de/krops synced 2024-12-23 02:09:51 +01:00

populate: reference all packages using "pkgs"

This fixes pop.pass's dependency on the caller's PATH for finding
the pass executable, while at the same time keeping its argument
consistent with the naming in other pop.$x functions.
This commit is contained in:
Ingolf Wagner 2018-09-19 06:09:17 +02:00 committed by tv
parent 5ae2b7f369
commit b465376df8

View file

@ -1,7 +1,7 @@
with import ../../lib;
with shell;
{ coreutils, dash, findutils, git, jq, openssh, rsync, writeDash }:
{ coreutils, findutils, git, openssh, pass, rsync, writeDash }@pkgs:
let
check = { force, target }: let
@ -53,27 +53,27 @@ let
in /* sh */ ''
umask 0077
tmp_dir=$(${coreutils}/bin/mktemp -dt populate-pass.XXXXXXXX)
tmp_dir=$(${pkgs.coreutils}/bin/mktemp -dt populate-pass.XXXXXXXX)
trap cleanup EXIT
cleanup() {
rm -fR "$tmp_dir"
}
${findutils}/bin/find ${quote passPrefix} -type f |
${pkgs.findutils}/bin/find ${quote passPrefix} -type f |
while read -r gpg_path; do
rel_name=''${gpg_path#${quote passPrefix}}
rel_name=''${rel_name%.gpg}
pass_date=$(
${git}/bin/git -C ${quote pass.dir} log -1 --format=%aI "$gpg_path"
${pkgs.git}/bin/git -C ${quote pass.dir} log -1 --format=%aI "$gpg_path"
)
pass_name=${quote pass.name}/$rel_name
tmp_path=$tmp_dir/$rel_name
${coreutils}/bin/mkdir -p "$(${coreutils}/bin/dirname "$tmp_path")"
PASSWORD_STORE_DIR=${quote pass.dir} pass show "$pass_name" > "$tmp_path"
${coreutils}/bin/touch -d "$pass_date" "$tmp_path"
${pkgs.coreutils}/bin/mkdir -p "$(${pkgs.coreutils}/bin/dirname "$tmp_path")"
PASSWORD_STORE_DIR=${quote pass.dir} ${pkgs.pass}/bin/pass show "$pass_name" > "$tmp_path"
${pkgs.coreutils}/bin/touch -d "$pass_date" "$tmp_path"
done
${rsync' target /* sh */ "$tmp_dir"}
@ -93,7 +93,7 @@ let
populate = target: name: source: let
source' = source.${source.type};
target' = target // { path = "${target.path}/${name}"; };
in writeDash "populate.${target'.host}.${name}" ''
in pkgs.writeDash "populate.${target'.host}.${name}" ''
set -efu
${pop.${source.type} target' source'}
'';
@ -103,7 +103,7 @@ let
if test -d "$source_path"; then
source_path=$source_path/
fi
${rsync}/bin/rsync \
${pkgs.rsync}/bin/rsync \
-e ${quote (ssh' target)} \
-vFrlptD \
--delete-excluded \
@ -124,7 +124,7 @@ let
'';
ssh' = target: concatMapStringsSep " " quote [
"${openssh}/bin/ssh"
"${pkgs.openssh}/bin/ssh"
"-l" target.user
"-o" "ControlPersist=no"
"-p" target.port
@ -133,7 +133,7 @@ let
in
{ force ? false, source, target }: writeDash "populate.${target.host}" ''
{ force ? false, source, target }: pkgs.writeDash "populate.${target.host}" ''
set -efu
${check { inherit force target; }}
set -x