2024-11-15 01:58:24 +01:00
|
|
|
#!/bin/bash
|
|
|
|
|
|
|
|
if [[ -z $1 ]] ; then
|
|
|
|
echo "Must provide a package name"
|
2024-11-15 03:57:44 +01:00
|
|
|
echo "sign_build.sh <n-v-r | build_id | package name | rpm> [<arch=x86_64> | <nodebuginfo> | <latestfrom=*> | <gpg_key=kojiadmin@koozali.org> | <debug>]"
|
2024-11-15 01:58:24 +01:00
|
|
|
exit 1
|
|
|
|
else
|
|
|
|
PACKAGE=$1
|
|
|
|
echo "PACKAGE=$PACKAGE"
|
|
|
|
fi
|
|
|
|
|
|
|
|
GPG_KEY="kojiadmin@koozali.org"
|
|
|
|
DEBUGINFO="--debuginfo"
|
2024-11-15 03:57:44 +01:00
|
|
|
ARCHES=
|
|
|
|
DEBUG=
|
|
|
|
RPM=
|
2024-11-15 01:58:24 +01:00
|
|
|
for param in $2 $3 $4 $5 $6 $7; do
|
|
|
|
if [ $param ] ; then
|
|
|
|
case $param in
|
|
|
|
-h | --help )
|
2024-11-15 03:57:44 +01:00
|
|
|
echo "sign_build.sh <n-v-r | build_id | package name | rpm> [<arch=*> | <nodebuginfo> | <latestfrom=*> | <gpg_key=kojiadmin@koozali.org>]" ;;
|
2024-11-15 01:58:24 +01:00
|
|
|
debug )
|
|
|
|
DEBUG=true ;;
|
2024-11-15 03:57:44 +01:00
|
|
|
nodebuginfo )
|
|
|
|
DEBUGINFO= ;;
|
2024-11-15 01:58:24 +01:00
|
|
|
arch=* )
|
2024-11-15 03:57:44 +01:00
|
|
|
arches=${param#*=}
|
|
|
|
for arch in ${arches//,/ } ; do
|
|
|
|
ARCHES=ARCHES"--arch=$arch "
|
|
|
|
done
|
|
|
|
;;
|
2024-11-15 01:58:24 +01:00
|
|
|
latestfrom=* )
|
|
|
|
PACKAGE=$PACKAGE" --latestfrom="${param#*=} ;;
|
2024-11-15 03:57:44 +01:00
|
|
|
gpg_name=* )
|
|
|
|
GPG_NAME=${param#*=} ;;
|
2024-11-15 01:58:24 +01:00
|
|
|
* )
|
|
|
|
echo "Unkown parameter $param - aborting"
|
|
|
|
exit 1
|
|
|
|
;;
|
|
|
|
esac
|
|
|
|
else
|
|
|
|
break
|
|
|
|
fi
|
|
|
|
done
|
|
|
|
|
2024-11-15 03:57:44 +01:00
|
|
|
# If an rpm name passed assume signing of an individual rpm
|
|
|
|
if (${1##*.} == "rpm") ; then RPM="--rpm" ; fi
|
|
|
|
|
|
|
|
# sign the specified rpms (using either a git tag or the latestfrom)
|
2024-11-15 01:58:24 +01:00
|
|
|
tmpdir="$(mktemp -d /tmp/sign.XXXXXX)"
|
|
|
|
pushd $tmpdir > /dev/null
|
|
|
|
|
|
|
|
if [[ $DEBUG ]] ; then
|
|
|
|
echo "PACKAGE=$PACKAGE"
|
2024-11-15 03:57:44 +01:00
|
|
|
echo "ARCH=$ARCHES"
|
|
|
|
echo "DEBUGINFO=$DEBUGINFO"
|
|
|
|
echo "RPM=$RPM"
|
|
|
|
echo "GPG_NAME=$GPG_NAME"
|
2024-11-15 01:58:24 +01:00
|
|
|
fi
|
2024-11-15 03:57:44 +01:00
|
|
|
if [[ $DEBUG ]] ; then echo "koji download-build $DEBUGINFO $RPM $ARCHES $PACKAGE" ; fi
|
|
|
|
koji download-build $DEBUGINFO $RPM $ARCHES $PACKAGE
|
|
|
|
rpmsign --define "_gpg_name $GPG_NAME" --addsign *.rpm
|
2024-11-15 01:58:24 +01:00
|
|
|
koji import-sig *.rpm
|
|
|
|
popd > /dev/null
|
|
|
|
|
|
|
|
# if debug, leave the tmp directory in place
|
|
|
|
if [[ -z $DEBUG ]] ; then
|
|
|
|
rm -f $tmpdir/*
|
2024-11-15 03:57:44 +01:00
|
|
|
rmdir $tmpdir
|
2024-11-15 01:58:24 +01:00
|
|
|
fi
|
|
|
|
|
|
|
|
exit 0
|