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.
This commit is contained in:
Natanael Copa 2009-07-23 06:38:52 +00:00
parent 571e056711
commit c6bb16a9f9
1 changed files with 20 additions and 3 deletions

View File

@ -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 ""