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
920user=
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
2232path_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+
4574for 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
6092done
6193
0 commit comments