Consider that we develop a project and we have an huge repo of different RPMs. We want to release new versions and publish them into new repos, but we know that usually only several packages are upgraded. Nobody wants to copy all unchanged packages to a new repo. However, we could keep only changed packages in the new repo and refer to both repos in .repo file: yum will choose the latest packages.
[my-project-1.0] name=My Project 1.0 baseurl=http://myserver.org/repos/1.0 enabled=1 [my-project-1.1] name=My Project 1.1 baseurl=http://myserver.org/repos/1.1 enabled=1
Looks nice, but how many repositories can be supported by yum? Will it crash or work extremely slow if there are hundreds of repositories with different packages? Let us check it up.
We will create 200 repositories with different versions of packages many-repos-a, many-repos-b, and many-repos-c. Repo #(2 * i) will contain packages many-repos-a-#i and many-repos-a-#(2 * i) and repo #(2 * i + 1) is for many-repos-b-#i and many-repos-a-#(2 * i + 1), like this:
repo 0: a-0 c-0 repo 1: b-0 c-1 repo 2: a-1 c-2 repo 3: b-1 c-3
Let us start with a simple spec:
# cat many-repos.spec
Name: many-repos-a
Version: 1
Release: 0%{?dist}
Summary: Many repos
#Group: System Environment/Base
License: GNU GPL
BuildRoot: %{_tmppath}/%{name}-%{version}
BuildArch: noarch
%description
%prep
%build
%install
rm -rf %{buildroot}
mkdir -p %{buildroot}/opt/%{name}
%clean
rm -rf %{buildroot}
%files
%defattr(-,root,root,-)
/opt/*
%changelog
Build them now!
# time for ((i=0; i<100; ++i)); do sed -i "s/Version.*/Version: $i/" many-repos.spec ; rpmbuild -ba many-repos.spec ; done (a lot of lines...) real 0m6.266s user 0m2.635s sys 0m2.036s
It really fast, isn’t it?
Let us continue:
# sed -i 's/many-repos-a/many-repos-b/' many-repos.spec # for ((i=0; i<100; ++i)); do sed -i "s/Version.*/Version: $i/" many-repos.spec ; rpmbuild -ba many-repos.spec ; done # sed -i 's/many-repos-b/many-repos-c/' many-repos.spec # for ((i=0; i<200; ++i)); do sed -i "s/Version.*/Version: $i/" many-repos.spec ; rpmbuild -ba many-repos.spec ; done
The packages are ready. It’s time to create our repos:
# mkdir ~/many-repos; cd ~/many-repos # for ((i=0; i<100; ++i)); do ((j=i*2)); mkdir -p repo-$j; mv ~/rpmbuild/RPMS/noarch/many-repos-a-$i-* repo-$j; done # for ((i=0; i<100; ++i)); do ((j=i*2+1)); mkdir -p repo-$j; mv ~/rpmbuild/RPMS/noarch/many-repos-b-$i-* repo-$j; done # for ((i=0; i<200; ++i)); do mv ~/rpmbuild/RPMS/noarch/many-repos-c-$i-* repo-$i; done
…and make yum know them:
# cat many-repos.repo [many-repos-@VERSION@] name=Many repos - @VERSION@ baseurl=file:///root/many-repos/repo-@VERSION@ enabled=1 gpgcheck=0 # for ((i=0; i<200; ++i)); do cp many-repos.repo /etc/yum.repos.d/many-repos-$i.repo; sed -i "s/@VERSION@/$i/g" /etc/yum.repos.d/many-repos-$i.repo; done
All preparations are done; let’s run yum and look how much time it takes:
# yum clean all # time echo n | yum install many-repos-a (a lot of lines...) Total download size: 1.6 k Installed size: 0 Is this ok [y/N]: Exiting on user Command real 2m9.525s user 0m6.445s sys 0m1.268s
Two minutes! That’s too long, but let’s run yum once more – it will use its own cache:
# time echo n | yum install many-repos-a (some lines...) Total download size: 1.6 k Installed size: 0 Is this ok [y/N]: Exiting on user Command real 0m4.217s user 0m3.984s sys 0m0.118s
Four seconds for 200 repositories – that’s really nice!
So, yum has no problems with hundreds of repositories.
Reblogged this on Grid Dynamics OpenStack team blog.
Pingback: What’s New in Altai 1.0.2 from Maintainer’s Point of View | OpenStack Blog·