#!/bin/bash
# generate_dummy_rpms.sh

# Install required tools if not present
# sudo dnf install -y rpm-build rpmdevtools

# Create necessary directories in current directory
mkdir -p SPECS BUILD BUILDROOT RPMS SRPMS

# Get absolute path of current directory
TOPDIR="$(pwd)"

for i in {1..150}; do
  NAME="dummy-package-$i"
  
  # Create spec file in local SPECS directory
  cat > SPECS/$NAME.spec <<EOF
Name:           $NAME
Version:        1.0.0
Release:        1%{?dist}
Summary:        Dummy test package $i
License:        MIT
BuildArch:      noarch

%description
This is a dummy test package for Katello testing.

%prep
# Nothing to prepare

%build
# Nothing to build

%install
mkdir -p %{buildroot}/usr/share/doc/$NAME
echo "This is dummy package $i" > %{buildroot}/usr/share/doc/$NAME/README

%files
/usr/share/doc/$NAME/README

%changelog
* $(date "+%a %b %d %Y") Test User <test@example.com> - 1.0.0-1
- Initial test package
EOF

  # Build the RPM using current directory as topdir
  rpmbuild -ba --define "_topdir $TOPDIR" SPECS/$NAME.spec
done

# Clean up build directories (optional - comment out if you want to keep them)
rm -rf BUILD BUILDROOT SRPMS SPECS

echo "RPMs created:"
ls -lh RPMS/noarch/dummy-package-*.rpm
