Under Construction

Creating a Local Repository

The following three steps are required to create a local YUM repository in the local file system:

Step 1: Create a directory for the repository:

aixnim # mkdir /var/myrepo
aixnim #

Step 2: All RPM packages that are to be offered via this repository must be copied into the directory:

aixnim # cp /tmp/zchunk-*.rpm /var/myrepo
aixnim # chmod a+r /var/myrepo/*.rpm
aixnim #

Note: This step can also be omitted; an empty repository is then created.

Step 3: Create the repository with the createrepo command. This creates the necessary metadata in the repodata directory of the repository:

aixnim # createrepo /var/myrepo
Spawning worker 0 with 1 pkgs
Spawning worker 1 with 1 pkgs
Spawning worker 2 with 1 pkgs
Workers Finished
Saving Primary metadata
Saving file lists metadata
Saving other metadata
Generating sqlite DBs
Sqlite DBs complete
aixnim #

The command creates a series of metadata in the repodata subdirectory:

aixnim # ls -lR /var/myrepo/repodata
total 64
-rw-r--r--    1 root     system         1397 Dec  3 12:09 0850138fcd1761a71c3973363a0c0db099438d4fcb98f89e7b8207ed68b5b159-primary.xml.gz
-rw-r--r--    1 root     system          578 Dec  3 12:09 10673361cca921a85928e56c5f08f97457c1eb0db2b32dbf867c6263409fb4eb-filelists.xml.gz
-rw-r--r--    1 root     system         6324 Dec  3 12:09 64c51b0c798e179f7e9d69955f709498a0d4d5c4efbc0ca473e6dcc7120fa56f-other.sqlite.bz2
-rw-r--r--    1 root     system         1477 Dec  3 12:09 75cd39b107183913ac32f498bb8d2cafd41eedf3c20ef0ebcf9370ee43f3a3ba-filelists.sqlite.bz2
-rw-r--r--    1 root     system         3121 Dec  3 12:09 7fff9af4d2ddc2b143d8df076d4902711b5bce1b418ef7484b952d6dac13c499-other.xml.gz
-rw-r--r--    1 root     system         3174 Dec  3 12:09 8df291fcfa845eae9627ecd5c13505b1d9111bab0163de7e1a2ad8cc4ca8ccaf-primary.sqlite.bz2
-rw-r--r--    1 root     system         2972 Dec  3 12:09 repomd.xml
aixnim #

The most important of these files is the repomd.xml file.

To use the new repository, it must be added to the existing YUM configuration first. We create the following minimal repo file under /tmp:

aixnim # cat /tmp/myrepo.repo
[myrepo]
name=my private repository
baseurl=file:///var/myrepo
aixnim #

The repo file can then be added to the existing configuration with the yum-config-manager command and the “—add-repo” option:

aixnim # yum-config-manager --add-repo=/tmp/myrepo.repo  
adding repo from: /tmp/myrepo.repo
grabbing file /tmp/myrepo.repo to /opt/freeware/etc/yum/repos.d/myrepo.repo
myrepo.repo                                                                      |   62 B  00:00:00    
repo saved to /opt/freeware/etc/yum/repos.d/myrepo.repo
aixnim #

The new repository can then be used immediately:

aixnim # yum repolist
myrepo                                                                           | 2.9 kB  00:00:00    
myrepo/primary_db                                                                | 3.1 kB  00:00:00    
repo id                                     repo name                                             status
AIX_Toolbox                                 AIX generic repository                                2740
AIX_Toolbox_71                              AIX 7.1 specific repository                            295
AIX_Toolbox_noarch                          AIX noarch repository                                  301
myrepo                                      my private repository                                    3
repolist: 3339
aixnim #

The output of “yum repolist” shows that 3 RPM packages are available in the new repository myrepo (my private repository).

We temporarily deactivate the AIX toolbox repositories so that only the new repository is active:

aixnim # yum-config-manager --disable AIX*

aixnim #

We now add another RPM package to the new myrepo repository:

aixnim # cp libzstd-1.4.4-32_1.aix7.1.ppc.rpm /var/myrepo
aixnim # chmod a+r /var/myrepo/libzstd-1.4.4-32_1.aix7.1.ppc.rpm
aixnim #

However, the new RPM package is not visible to YUM:

aixnim # yum list available
Available Packages
zchunk.ppc                                          1.1.4-32_1                                    myrepo
zchunk-devel.ppc                                    1.1.4-32_1                                    myrepo
zchunk-libs.ppc                                     1.1.4-32_1                                    myrepo
aixnim #

In order for the new RPM package to be visible to YUM, the metadata (repomd.xml) must be updated. This can be done by running createrepo again:

aixnim # createrepo /var/myrepo
Spawning worker 0 with 1 pkgs
Spawning worker 1 with 1 pkgs
Spawning worker 2 with 1 pkgs
Spawning worker 3 with 1 pkgs
Workers Finished
Saving Primary metadata
Saving file lists metadata
Saving other metadata
Generating sqlite DBs
Sqlite DBs complete
aixnim #

By default, YUM uses buffered information, so the cache should either be completely emptied or at least the metadata removed from the cache:

aixnim # yum clean all
Cleaning repos: myrepo
Cleaning up Everything
aixnim #

The newly added RPM package is now listed as an available RPM package:

aixnim # yum list available
myrepo                                                                           | 2.9 kB  00:00:00    
myrepo/primary_db                                                                | 3.4 kB  00:00:00    
Available Packages
libzstd.ppc                                         1.4.4-32_1                                    myrepo
zchunk.ppc                                          1.1.4-32_1                                    myrepo
zchunk-devel.ppc                                    1.1.4-32_1                                    myrepo
zchunk-libs.ppc                                     1.1.4-32_1                                    myrepo
aixnim #

This means that every time RPM packages are added to a repository, the metadata of the repository must be updated using createrepo. On systems that use the repository, the cache may have to be cleared so that YUM can access the new metadata. By default, the buffered data is no longer used after 21600 seconds (6 hours) (metadata_expire = 21600).