2024-11-15 01:58:24 +01:00
|
|
|
#!/bin/bash
|
|
|
|
# sign all rpms in the specified pkg list
|
|
|
|
if [[ -z $1 ]] ; then
|
|
|
|
echo "Must provide a pkg list"
|
2024-11-15 03:57:44 +01:00
|
|
|
echo "sign_build_list.sh <pkg list> [<arch=*> | <gpg_name=kojiadmin@koozali.org> | <gpg_key=44922a28> | <nodebuginfo> | <debug> | <dryrun> ]"
|
2024-11-15 01:58:24 +01:00
|
|
|
exit 1
|
|
|
|
else
|
|
|
|
PKGLIST=$1
|
|
|
|
fi
|
|
|
|
|
2024-11-15 03:57:44 +01:00
|
|
|
ARCHES=
|
|
|
|
GPG_NAME="kojiadmin@koozali.org"
|
|
|
|
GPG_KEY=
|
|
|
|
DEBUG=
|
|
|
|
DRY_RUN=
|
|
|
|
ARCHES=
|
|
|
|
DEBUGINFO="--debuginfo"
|
2024-11-15 01:58:24 +01:00
|
|
|
|
|
|
|
for param in $2 $3 $4 $5 $6 $7 ; do
|
|
|
|
if [ $param ] ; then
|
2024-11-15 03:57:44 +01:00
|
|
|
case $param in
|
2024-11-15 01:58:24 +01:00
|
|
|
-h | --help )
|
2024-11-15 03:57:44 +01:00
|
|
|
echo "sign_build_list.sh <pkg list> [<arch=x86_64> | <gpg_name=kojiadmin@koozali.org> | <gpg_key=44922a28> | <nodebuginfo> | <debug> | <dryrun> ]"
|
|
|
|
exit
|
2024-11-15 01:58:24 +01:00
|
|
|
;;
|
|
|
|
debug )
|
2024-11-15 03:57:44 +01:00
|
|
|
DEBUG=true ;;
|
|
|
|
dryrun )
|
|
|
|
DRY_RUN=true ;;
|
|
|
|
nodebuginfo )
|
|
|
|
DEBUGINFO= ;;
|
|
|
|
arch=* )
|
|
|
|
arches=${param#*=}
|
|
|
|
for arch in ${arches//,/ } ; do
|
|
|
|
ARCHES=ARCHES"--arch=$arch "
|
|
|
|
done
|
|
|
|
;;
|
|
|
|
gpg_name=* )
|
|
|
|
GPG_NAME=${param#*=} ;;
|
2024-11-15 01:58:24 +01:00
|
|
|
gpg_key=* )
|
2024-11-15 03:57:44 +01:00
|
|
|
GPG_KEY=${param#*=} ;;
|
2024-11-15 01:58:24 +01:00
|
|
|
* )
|
2024-11-15 03:57:44 +01:00
|
|
|
echo "Unkown parameter $param - aborting"
|
|
|
|
exit 1
|
|
|
|
;;
|
|
|
|
esac
|
2024-11-15 01:58:24 +01:00
|
|
|
else
|
2024-11-15 03:57:44 +01:00
|
|
|
break
|
2024-11-15 01:58:24 +01:00
|
|
|
fi
|
|
|
|
done
|
|
|
|
if [[ $DEBUG ]] ; then
|
|
|
|
echo "PKGLIST=$PKGLIST"
|
2024-11-15 03:57:44 +01:00
|
|
|
echo "ARCHES=$ARCHES"
|
|
|
|
echo "DEBUGINFO=$DEBUGINFO"
|
|
|
|
echo "GPG_NAME=$GPG_NAME"
|
2024-11-15 01:58:24 +01:00
|
|
|
echo "GPG_KEY=$GPG_KEY"
|
2024-11-15 03:57:44 +01:00
|
|
|
echo "DRY_RUN=$DRY_RUN"
|
2024-11-15 01:58:24 +01:00
|
|
|
fi
|
|
|
|
|
|
|
|
# use a temporary directory to export the rpms for signing
|
2024-11-15 03:57:44 +01:00
|
|
|
if [[ $DRY_RUN ]] ; then
|
|
|
|
echo "mktemp -d /tmp/sign.XXXXXX"
|
|
|
|
else
|
2024-11-15 01:58:24 +01:00
|
|
|
tmpdir="$(mktemp -d /tmp/sign.XXXXXX)"
|
|
|
|
pushd $tmpdir > /dev/null
|
2024-11-15 03:57:44 +01:00
|
|
|
fi
|
2024-11-15 01:58:24 +01:00
|
|
|
|
|
|
|
if [[ -e "$PKGLIST" ]] ; then
|
|
|
|
# extract list of rpms to download
|
|
|
|
while read -r pkgline; do
|
2024-11-15 03:57:44 +01:00
|
|
|
BUILD=${pkgline##*/}
|
2024-11-15 01:58:24 +01:00
|
|
|
if [[ $DEBUG ]] ; then
|
|
|
|
echo "$pkgline"
|
2024-11-15 03:57:44 +01:00
|
|
|
echo "koji download-build $BUILD"
|
2024-11-15 01:58:24 +01:00
|
|
|
fi
|
2024-11-15 03:57:44 +01:00
|
|
|
# If an rpm name passed assume signing of an individual rpm, else signing all
|
|
|
|
RPM=
|
|
|
|
if (${BUILD##*.} == "rpm") ; then
|
|
|
|
RPM="--rpm"
|
|
|
|
fi
|
|
|
|
if [[ $GPG_KEY ]] ; then # check if already signed with this key
|
|
|
|
DIR=/mnt/koji/packages/${BUILD%-*-*}/$(echo $BUILD | awk -F '-' '{print $(NF-1)}')/$(echo ${BUILD##*-})/data/signed/$GPG_KEY
|
|
|
|
if [[ $DEBUG ]] ; then echo "DIR=$DIR" ; fi
|
|
|
|
EXISTS=
|
|
|
|
if ($RPM == "--rpm") ; then
|
|
|
|
if [[ $DEBUG ]] ; then echo "Check for existing $DIR/$BUILD"
|
|
|
|
if [[ -f $DIR/$BUILD ]] ; then EXISTS=True ; fi
|
|
|
|
else
|
|
|
|
if [[ $DEBUG ]] ; then echo "Check for existing $DIR"
|
|
|
|
if [[ -d $DIR ]] ; then EXISTS=True ; fi
|
|
|
|
fi
|
|
|
|
if [[ $EXISTS ]] ; then
|
|
|
|
echo "$BUILD already signed with this key - ignoring"
|
|
|
|
continue
|
|
|
|
fi
|
|
|
|
fi
|
|
|
|
if [[ $DRY_RUN ]] ; then
|
|
|
|
echo "koji download-build $DEBUGINFO $ARCHES $RPM $BUILD"
|
|
|
|
else
|
|
|
|
koji download-build $DEBUGINFO $ARCHES $RPM $BUILD
|
|
|
|
fi
|
2024-11-15 01:58:24 +01:00
|
|
|
fi
|
|
|
|
done <$PKGLIST
|
|
|
|
else
|
|
|
|
echo "Cannot find pkglist $PKGLIST - aborting"
|
|
|
|
exit 1
|
|
|
|
fi
|
2024-11-15 03:57:44 +01:00
|
|
|
if [[ $DRY_RUN ]] ; then
|
|
|
|
echo "rpmsign --define \"_gpg_name $GPG_NAME\" --addsign *.rpm"
|
|
|
|
echo "koji import-sig *.rpm"
|
|
|
|
else
|
|
|
|
rpmsign --define "_gpg_name $GPG_NAME" --addsign *.rpm
|
2024-11-15 01:58:24 +01:00
|
|
|
koji import-sig *.rpm
|
|
|
|
popd > /dev/null
|
2024-11-15 03:57:44 +01:00
|
|
|
fi
|
2024-11-15 01:58:24 +01:00
|
|
|
|
|
|
|
exit 0
|