Skip to content

Instantly share code, notes, and snippets.

@GeoffWilliams
Created May 4, 2017 14:28
Show Gist options
  • Save GeoffWilliams/62f4758c46e4e3a3a8a6f81e4935576c to your computer and use it in GitHub Desktop.
Save GeoffWilliams/62f4758c46e4e3a3a8a6f81e4935576c to your computer and use it in GitHub Desktop.
Generate dummy/fake RPMs - great for acceptance testing systems
#!/bin/bash
#
# From: https://www.redhat.com/archives/rpm-list/2006-November/msg00062.html
#
# Generate dummy/fake RPMs - great for acceptance testing systems
#
NAME=$1
#
# GEnerate Provides:
PROVIDES="Provides: ${1}"
#
# Generate Spec file
SPECFILE=$(mktemp)
cat <<EOF > ${SPECFILE}
#----------- spec file starts ---------------
Name: ${NAME}
Version: 1.0.0
Release: 0
Vendor: dummy
Group: dummy
Summary: Provides %{name}
License: %{vendor}
# in Provides: you add whatever you want to fool the system
Buildroot: %{_tmppath}/%{name}-%{version}-root
${PROVIDES}
%description
%{summary}
%files
EOF
#
# Build it
BUILD_LOG=$(mktemp)
rpmbuild --define '_rpmdir /tmp' -bb "${SPECFILE}" > "${BUILD_LOG}"
if [ $? != 0 ]
then
echo "ERROR: Could nto build dummy rpm!"
fi
PKG=$(awk '/^Wrote:/ { print $2 }' < "${BUILD_LOG}" )
rm "${BUILD_LOG}"
#
# Install it:
#rpm -Uvh "${PKG}"
rm "${SPECFILE}"
echo "DONE! created ${PKG} and moved it here..."
mv $PKG .
@Skaldebane
Copy link

Hi there! I don't have rpmbuild installed, and searching in dnf shows mutliple options. Which one do you have installed?

@GeoffWilliams
Copy link
Author

GeoffWilliams commented Sep 13, 2021

This is for rpmbuild before dnf existed.

@Skaldebane
Copy link

Oh right... no worries anyway, I found it under the package copr-rpmbuild. I guess before dnf existed that would still be installed in the same way using yum.

And hey, thanks for the script! It worked like a charm for creating an android-tools dummy to keep using the ones bundled with Android Studio.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment