Friday, June 3, 2016

How to Install packages from my hard drive.

Most if not all packages (files ending in *.rpm) are on the online repositories. In some cases you have the rpm from your pc or you have downloaded it from some site/server etc.  Question is how would one install it?

Simple answer is to use the rpm utility since openSUSE is one of the rpm-based distro like Rhel and Centos but we will not use that in our example since openSUSE has zypper.

To install the package name foo

      
    zypper in foo.rpm
  

or one can use the absolute path

      
    zypper in /path/to/foo.rpm
 

e.g.

      
    zypper in /var/run/media/jetchisel/foo.rpm 
 


Another question is: 


What if you have a bunch of packages (rpm's) that you want to install?  


One can work around it by using some shell tricks on the cli. One in particular is the use of glob and an array.

Save the rpm's in an array.

      
    packages=(*.rpm)
 

or use an absolute path.

      
    packages=(/path/to/myrpm/*.rpm)
 

e.g.

      
    packages=(/var/run/media/jetchisel/*.rpm)
 


Install the rpm's

      
    zypper in "${packages[@]}"
 

The last but not the least question.  


I have a bunch of rpm's which are the dependencies from the program/package that is located on the online repositories.


The alternative question is:    


how can I make a local directory (folder) to become a local repository?


First option is using zypper.


   zypper ar -t plaindir . local 


or one can use an absolute path for the directory.


   zypper ar -t plaindir  /path/to/rpm local 


let's take out that zypper code piece by piece.

 zypper ar  is add repository

  -t plaindir   means type is a plain directory (folder)

the    .    (dot)  means where you are located the value of the command    pwd  
 
  /path/to/rpm      is the absolute path.

   local   is the alias of the repository and it is arbitrary

Once the directory (folder) is added as a repo you can now refresh it.


   zypper ref local


Print the packages from the local repo.


   zypper --no-refresh se -t package -r local




Now install the package(s) and enjoy! :)


One can look for more option using the help option for zypper.


   zypper help ar 


The second option is using yast2 in the following order.

  1. yast2 
  2. Software Repositories
  3. Add
  4. Local Directory




No comments:

Post a Comment