Folder is emptied after installation of an RPM package

27 Views Asked by At

I am reading RPM packages from a CSV file and want to install them one after the other. If there is a "yes" or "ja" at the end of the line, the package is to be installed. Otherwise it should be skipped. The packages have already been downloaded and saved in the folder /var/tmp/updcache.

On RHEL 7, this works wonderfully. On RHEL 8, after installing the first package, the entire /var/tmp/updcache folder is emptied. So the installation attempt of the second package in the CSV file fails because it is no longer there. Likewise all other packages in the CSV.

What is the best way to prevent this? Is there an option for dnf that prevents the deletion?

Here is the script ...

while IFS= read -r line; do
    linecount=$(( $linecount+1 )) 
        if [[ "$line" == *yes ]] || [[ "$line" == *ja ]]; then
            package="$(echo "$line" | sed 's/[;].*$//')" 
            echo $package >> ./InstallationLog_$curdate.log
            dnf install -y -q /var/tmp/updcache/$package &>> ./InstallationLog_$curdate.log
            log="$(rpm -qa | grep -c $packageStat)"
        elif [[ "$line" == *no ]] || [[ "$line" == *nein ]]; then
            package="$(echo "$line" | sed 's/[;].*$//')"
            echo "Installation of $package was skipped!"
        fi
done <$install_list
1

There are 1 best solutions below

0
U880D On

What is the best way to prevent this? Is there an option for dnf that prevents the deletion?

In order to prevent dnf from auto cleaning the cache after or before package installation you may need to set according man dnf.conf in /etc/dnf/dnf.conf under section

[main]
...
keepcache=True
...

Keeps downloaded packages in the cache when set to True. Even if it is set to False and packages have not been installed they will still persist until next successful transaction. The default is False.

You may also have a look into dnf --help.

-C, --cacheonly run entirely from system cache, don't update cache

Similar Q&A