Simple RPM repo in Gentoo

INTRO

So I’ve started creating a RPM repo so I can easily update my rabbitmq consumers. Here’s how I did it !

The code

echo '=app-arch/createrepo-0.10.4 ~amd64
=dev-python/pyliblzma-0.5.3-r1 ~amd64
=app-arch/deltarpm-3.6_pre20110223-r1 ~amd64
=sys-apps/yum-3.4.3_p20130218-r1 ~amd64
=dev-util/rpmdevtools-8.5 ~amd64
=dev-util/checkbashisms-2.15.10 ~amd64' >> /etc/portage/package.keywords
echo 'app-arch/deltarpm python
app-arch/rpm python' >> /etc/portage/package.use
emerge createrepo rpmdevtools

mkdir -p /usr/src/rpm
cd /usr/src/rpm
mkdir –p {BUILD,RPMS,SOURCES,SPECS,SRPMS,tmp}
cd /usr/src/rpm/SPECS
rpmdev-newspec serverstuff
echo '[serverstuff]
name=ServerStuff Repo
baseurl=https://serverstuff.info/repo/
enabled=1
gpgcheck=0' > /usr/src/rpm/SOURCES/serverstuff.repo

echo 'Name: serverstuff-repo
Version: 1
Release: 1%{?dist}
Summary: ServerStuff Repository
BuildArch: noarch

License: GPL
URL: https://serverstuff.info/
Source0: serverstuff.repo

%description
ServerStuff Repository

%install
rm -rf $RPM_BUILD_ROOT
mkdir -p $RPM_BUILD_ROOT/etc/yum.repos.d
cp %SOURCE0 $RPM_BUILD_ROOT/etc/yum.repos.d

%files
/etc/yum.repos.d

%changelog
* Sat Feb 6 2016 root
- Initial Creation' >/usr/src/rpm/SPECS/serverstuff-repo.spec

rpmbuild -bb serverstuff-repo.spec --define "_topdir /usr/src/rpm"
# I have my serverstuff.info apache serve from the htdocs dir
mkdir -p /var/www/serverstuff.info/htdocs/repo/
cp /usr/src/rpm/RPMS/noarch/serverstuff-repo-1-1.noarch.rpm /var/www/serverstuff.info/htdocs/repo/
createrepo /var/www/serverstuff.info/htdocs/repo/

Other issues

Now the same applies if you want to create another package. Just put it in the repo dir and run

createrepo --update /var/www/serverstuff.info/htdocs/repo/

If you’re doing this too fast, yum caches the repo and might have to do a clean metadata

yum --enablerepo=serverstuff clean metadata