0

I have a directory full of rpms (And their dependencies). Currently I am executing yum localinstall ./packages_directory/*.rpm to install all packages in there. It automatically skips the ones already installed. However this is taking too long if all packages are already installed. I would like for it to go faster for installed packages. An alternative I thought is to check if each one of those packages are already installed (With some other command perhaps). If they are not installed then I run a localinstall on them. Can someone help me write the script for that? Or maybe a faster alternative.

  • 2
    run createrepo on the directory, then you can add a new repo to your yum.conf or whatever and do a yum install specifying just that repo. – meuh Jun 2 '16 at 20:29
  • 1
    Do not use Fedora 17. It is years EOL and unsupported. Update to current Fedora 23. – Jakuje Jun 2 '16 at 21:08
  • @Jakuje It is not an option – LinuxLearner Jun 3 '16 at 16:27
0

I came up with a script for it (Fedora 17). Assuming that the current directory where script is running is also the directory of where the rpms are located:

install_packages(){
    echo "Installing/Checking Fedora packages. Process may take a while..."
    for i in *
    do
        if test -f "$i" #Test if it is a file
        then
           i=$(basename $i) #Remove parent directory part of the string
           PACKAGE_NAME=${i::-4} #Remove .rpm from the end of file name
           if rpm -q $PACKAGE_NAME | grep "not installed" > /dev/null #If package not yet installed
           then
            echo "Installing $i ..."
                yum localinstall ./fc17/"$i" -y > /dev/null #Install this package 
           fi
        fi
    done    
    echo "Packages checked/installed"


}

For fedora 22 just replace yum localinstall with dnf install

  • 1
    You can make this go significantly faster by adding --nosignature --nodigest to your rpm -q call. – mattdm Jun 4 '16 at 17:29
  • 1
    Also, your filename munging to get package name will work with all official Fedora packages, but third-party vendor packages may make the filename differ from the package name. So you could replace that with rpm --nosignature --nodigest -qp --qf '%{name}-%{version}-%{release}.%{arch}\n' packagename.rpm – mattdm Jun 4 '16 at 17:31

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.