How to install a rpm package and its dependencies offline
In CentOS/RedHat you can use yumdownloader
for specific packages, this downloads all RPMs required, then, compress the directory, upload it to the server without Internet access and install RPMs.
Here you can find and example, installing Kubernetes without Internet access.
yumdownloader --assumeyes --destdir=/var/rpm_dir/docker-ce --resolve docker-ce
tar -czvf d4r-k8s.tar.gz /var/rpm_dir
# Upload files
scp d4r-k8s.tar.gz root@YOUR-IP:/root
# Connect to your server
ssh root@YOUR-IP
tar -xzvf /root/d4r-k8s.tar.gz -C /
# install Docker:
yum install -y --cacheonly --disablerepo=* /var/rpm_dir/docker-ce/*.rpm
Provide dependencies of RPM for offline install
You can't do what you're asking in %pre
and %post
, because (a) those are executed at install time which is well after dependency resolution and (b) you wouldn't be able to call rpm
to install things from your %pre
because the database is locked for the transaction you are part of.
When I've done something like this in the past, I have found the easiest thing to do is to put all the RPMs in a single directory on the media and instruct the deployment team to yum localinstall *rpm
from that directory. If some of the third-party RPMs are older than what is installed, it will just skip over them.
How to make rpm auto install dependencies
Create a (local) repository and use yum
to have it resolve the dependencies for you.
The CentOS wiki has a nice page providing a how-to on this. CentOS wiki HowTos/CreateLocalRepos.
Summarized and further minimized (not ideal, but quickest):
- Create a directory for you local repository, e.g.
/home/user/repo
. - Move the RPMs into that directory.
Fix some ownership and filesystem permissions:
# chown -R root.root /home/user/repo
Install the
createrepo
package if not installed yet, and run# createrepo /home/user/repo
# chmod -R o-w+r /home/user/repoCreate a repository configuration file, e.g.
/etc/yum.repos.d/myrepo.repo
containing[local]
name=My Awesome Repo
baseurl=file:///home/user/repo
enabled=1
gpgcheck=0Install your package using
# yum install packagename
How to install packages offline?
If the package is on PYPI, download it and its dependencies to some local directory.
E.g.
$ mkdir /pypi && cd /pypi
$ ls -la
-rw-r--r-- 1 pavel staff 237954 Apr 19 11:31 Flask-WTF-0.6.tar.gz
-rw-r--r-- 1 pavel staff 389741 Feb 22 17:10 Jinja2-2.6.tar.gz
-rw-r--r-- 1 pavel staff 70305 Apr 11 00:28 MySQL-python-1.2.3.tar.gz
-rw-r--r-- 1 pavel staff 2597214 Apr 10 18:26 SQLAlchemy-0.7.6.tar.gz
-rw-r--r-- 1 pavel staff 1108056 Feb 22 17:10 Werkzeug-0.8.2.tar.gz
-rw-r--r-- 1 pavel staff 488207 Apr 10 18:26 boto-2.3.0.tar.gz
-rw-r--r-- 1 pavel staff 490192 Apr 16 12:00 flask-0.9-dev-2a6c80a.tar.gz
Some packages may have to be archived into similar looking tarballs by hand. I do it a lot when I want a more recent (less stable) version of something. Some packages aren't on PYPI, so same applies to them.
Suppose you have a properly formed Python application in ~/src/myapp
. ~/src/myapp/setup.py
will have install_requires
list that mentions one or more things that you have in your /pypi
directory. Like so:
install_requires=[
'boto',
'Flask',
'Werkzeug',
# and so on
If you want to be able to run your app with all the necessary dependencies while still hacking on it, you'll do something like this:
$ cd ~/src/myapp
$ python setup.py develop --always-unzip --allow-hosts=None --find-links=/pypi
This way your app will be executed straight from your source directory. You can hack on things, and then rerun the app without rebuilding anything.
If you want to install your app and its dependencies into the current python environment, you'll do something like this:
$ cd ~/src/myapp
$ easy_install --always-unzip --allow-hosts=None --find-links=/pypi .
In both cases, the build will fail if one or more dependencies aren't present in /pypi
directory. It won't attempt to promiscuously install missing things from Internet.
I highly recommend to invoke setup.py develop ...
and easy_install ...
within an active virtual environment to avoid contaminating your global Python environment. It is (virtualenv that is) pretty much the way to go. Never install anything into global Python environment.
If the machine that you've built your app has same architecture as the machine on which you want to deploy it, you can simply tarball the entire virtual environment directory into which you easy_install
-ed everything. Just before tarballing though, you must make the virtual environment directory relocatable (see --relocatable option). NOTE: the destination machine needs to have the same version of Python installed, and also any C-based dependencies your app may have must be preinstalled there too (e.g. say if you depend on PIL, then libpng, libjpeg, etc must be preinstalled).
How can I install software or packages without Internet (offline)?
Check out Keryx; it's an offline repository manager.
How does it work? It lets you download updates and new programs (with dependencies) to your flash drive.
Its interface is similar to synaptic, but it works from a pendrive (it doesn't need installation). Unfortunately, the GUI needs wxwidgets, which don't come preinstalled on Ubuntu (they're cross-platform and installable from here and Ubuntu repository here). It can only install software in a Ubuntu system, but you can download the updates or new packages in any Linux, Windows or OS X.
Here you can find a tutorial.
Another detailed step-by-step tutorial is in this answer.
Launchpad also hosts downloadable files.
A screenshot:
Related Topics
Get Parent Directory of a File in Bash
Pytorch Says That Cuda Is Not Available
How Is Stack Size of Linux Process Related to Pthread, Fork and Exec
Binary Data Over Serial Terminal
How to Store the Output of a Git Command in a Variable
Linux Run Kernel Probe Systemtap Script Failed with Semantic Error: No Match"
How to Use the Linux Flock Command to Prevent Another Root Process from Deleting a File
Syntax With Pound and Percent Sign After Shell Parameter Name
Which Jdk's Distributions Can Run 'Javac -Source 1.6 -Target 1.5'
Linux Command to Delete All Files Except .Git Folder
Merging Through Fuzzy Matching of Variables in R
How to Start Redis-Server on a Different Port Than the Default Port 6379 in Ubuntu
Error: Clgetplatformids -1001 When Running Opencl Code (Linux)