File rpmkey-openSUSE-Build-Service.spec of Package rpmkey-openSUSE-Build_Service
%define pubkeyname openSUSE-Build-Service
%define version 1.0
%define release 1
Summary: The %{pubkeyname} rpm public key
Name: rpmkey-%{pubkeyname}
Version: %{version}
Release: %{release}
License: GPL
Group: System/Packages
Source: %{pubkeyname}.asc
BuildArch: noarch
BuildRoot: %{_tmppath}/buildroot-%{name}
Distribution: SuSE
%description
The %{pubkeyname} rpm public key. If you trust the %{pubkeyname} component
and you want to automatically import this key to the RPM database,
then install this RPM.
Please note that this key does only guarantee that the package got build within
the Build Service at opensuse.org. It does NOT guarantee any trust about the
content of the packages, since everybody can build packages at that place.
All what is guaranteed is that the source from the src.rpm does match to the
binary rpm and that all source versions are hosted at opensuse.org.
%prep
%setup -q -c -T a1
%build
%install
mkdir -p %{buildroot}%{_prefix}/lib/rpm/gnupg
cp -a %{SOURCE0} %{buildroot}%{_prefix}/lib/rpm/gnupg
%pre
old_key=`cat %{_prefix}/lib/rpm/gnupg/%{pubkeyname}.asc | grep RPMDB_NAME | cut -d'=' -f2 | cut -d'\ ' -f2`
if [ -f %{_prefix}/lib/rpm/gnupg/%{pubkeyname}.asc ]; then
echo "removing old-key for %pubkeyname (%old_key) from database"
# make backup if necessary
if [ -e /root/.rpmmacros ]; then
tmp=$(mktemp -d)
cp /root/.rpmmacros $tmp/rpmmacros.bak
fi
# avoid rpm error: "waiting for exclusive lock on /var/lib/rpm/Packages"
echo "%%_dbi_config_Packages %%{nil}" >> /root/.rpmmacros
rpm -e --allmatches %{old_key} 2> /dev/null
# cleanup
if [ -e $tmp/rpmmacros.bak ]; then
# restore backup
mv $tmp/rpmmacros.bak /root/.rpmmacros
rm -rf $tmp
else
rm -f /root/.rpmmacros
fi
fi
%files
%defattr(-, root, root)
%{_prefix}/lib/rpm/gnupg/%{pubkeyname}.asc