Commit c6bb16a9 authored by Natanael Copa's avatar Natanael Copa

abuild-keygen: use -a to add the needed config setting

So basicly, running 'abuild-keygen -a -i' will be all you need to do to
be able to use abuild-sign and install the signed packages.
parent 571e0567
......@@ -20,6 +20,7 @@ usage() {
echo "abuild-keygen $abuild_ver"
echo "usage: abuild-keygen [-ih]"
echo "options:"
echo " -a Set PACKAGER_PRIVKEY=<generated key> in $abuild_userconf"
echo " -i Install public key into /etc/apk/keys using sudo"
echo " -h Show this help"
echo ""
......@@ -46,8 +47,9 @@ else
default_name="$USER"
fi
while getopts "hi" opt; do
while getopts "ahi" opt; do
case $opt in
a) append_config=yes;;
h) usage;;
i) install_pubkey=yes;
esac
......@@ -69,7 +71,7 @@ pubkey="$privkey.pub"
# generate the private key in a subshell with stricter umask
(
umask 0077
umask 0007
openssl genrsa -out "$privkey" 2048
)
openssl rsa -in "$privkey" -pubout -out "$pubkey"
......@@ -87,7 +89,22 @@ else
echo "$privkey"
fi
if [ -n "$append_config" ]; then
if [ -f "$abuild_userconf" ]; then
# comment out the existing values
sed -i -e 's/^\(PACKAGER_PRIVKEY=.*\)/\#\1/' "$abuild_userconf"
fi
echo "PACKAGER_PRIVKEY=\"$privkey\"" >> "$abuild_userconf"
else
echo ""
echo "You might want add following line to $abuild_userconf:"
echo ""
echo "PACKAGER_PRIVKEY=\"$privkey\""
echo ""
fi
echo ""
echo "Please remember to make a safe backup of $privkey"
echo "Please remember to make a safe backup of your private key:"
echo "$privkey"
echo ""
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