0

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
U880D
  • 8,601
  • 6
  • 24
  • 40
  • Please take note that your question is only about using system tools, administration and configuration and therefore suited better on other sites like serverfault.com, superuser.com, unix.stackexchange.com, etc. Here it seems to be off-topic. – U880D Jun 27 '23 at 18:14

1 Answers1

0

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

U880D
  • 8,601
  • 6
  • 24
  • 40