Skip to content

Commit 4549523

Browse files
author
Chris Kleeschulte
committed
Added more sophisticated move and build scriot.
1 parent 0e6819b commit 4549523

File tree

1 file changed

+40
-8
lines changed

1 file changed

+40
-8
lines changed

move_and_sign_manifest.sh

100644100755
Lines changed: 40 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,22 +1,32 @@
11
#!/bin/bash
22

3+
easysigning=false
4+
process_args () {
5+
if [[ -n "${1}" ]] && [[ "${1}" == "--easysigning" ]]; then
6+
easysigning=true
7+
elif [[ -n "${1}" ]] && [[ "${1}" == "-h" || "${1}" == "--help" ]]; then
8+
echo "usage: move_and_signing_manifest.sh [--easysigning]"
9+
echo ""
10+
echo "--easysigning allows you to type your gpg private key passphrase once to sign multiple manifest files."
11+
exit 0
12+
fi
13+
}
314

4-
function get_input_from_user () {
15+
get_input_from_user () {
516
get_user_name
617
get_path_to_gitian_sigs
718
}
819

920
user=
10-
function get_user_name () {
21+
get_user_name () {
1122
default=$(whoami)
12-
while [ 1 ]; do
23+
if [ -z "${user}" ]; then
1324
echo -n "Enter desired signing name (default: $default):"
1425
read user
1526
if [ -z "${user}" ]; then
1627
user=$default
1728
fi
18-
break
19-
done
29+
fi
2030
}
2131

2232
path_to_gitian_sigs=
@@ -42,8 +52,30 @@ get_build_name () {
4252
echo ${1/-res.yml/}
4353
}
4454

55+
check_for_gpg () {
56+
hash gpg 2>/dev/null || { echo >&2 "This script requires the 'gpg' program, it may not be installed or not on your path."; exit 1; }
57+
}
58+
59+
passphrase=
60+
sign_manifest () {
61+
if [[ "${easysigning}" = true ]] && [[ -z "${passphrase}" ]]; then
62+
echo -n "Please enter your passphrase for default gpg public key (never use this on a multi-user system): "
63+
read -s passphrase
64+
echo ""
65+
fi
66+
echo "Attempting to sign manifest: ${1}"
67+
if [ -n "${passphrase}" ]; then
68+
gpg --batch --yes -b --passphrase "${passphrase}" "${1}"
69+
else
70+
gpg -b "${1}"
71+
fi
72+
}
73+
4574
for manifest in result/*.yml; do
46-
echo $manifest
75+
76+
process_args $1
77+
78+
check_for_gpg
4779

4880
get_input_from_user
4981

@@ -54,8 +86,8 @@ for manifest in result/*.yml; do
5486
mkdir -p "${manifest_dir}"
5587
cp "${manifest}" "${manifest_dir}"
5688
manifest_file="${manifest_dir}/${basename}"
57-
echo "Attempting to sign manifest: ${manifest_file}"
58-
gpg -b "${manifest_file}"
89+
90+
sign_manifest "${manifest_file}"
5991

6092
done
6193

0 commit comments

Comments
 (0)