Host Online System
1. Setting up the Host System to Use the Script.
- This system should be running the same distribution as the target system and have an internet connection
- Install the prerequisite software by running the following commands for the chosen distribution
- RHEL / CentOS 8
sudo dnf install python36 createrepo - RHEL / CentOS 7
sudo yum install python36 createrepo yum-utils - openSUSE Leap 15.2
sudo zypper install python36 createrepo - Ubuntu 20.04
sudo apt-get install python36 apt-mirror dkpg-dev
- Register NI’s source repository with the system. Follow the steps to download and install the repository definition file for your system from Installing NI Driver Software on Linux Desktop. The steps to install the desired driver package are not required when performing offline installation.
- Download the required script that matches the Linux distribution of your host and target system.
- Determine what kind of offline media should be created such as DVD, USB, etc.
2. Using the Script to Clone an Entire Repository
You can use the attached script to clone an entire repository from its source and the resulting repository should be functionally identical to the origin. The following sections outline the RPM and Debian unique commands to perform to specify which repositories to clone.
2.1 On RPM-based Systems
Registered RPM repositories use a specific name on a system which must be passed to the script to clone the repository.
- Determine the name for the repository to clone. Run the following commands to list all known and enabled repositories on a system
- RHEL / CentOS 8
sudo dnf repolist - RHEL / CentOS 7
sudo yum repolist - openSUSE Leap 15.2
sudo zypper repos --show-enabled-only
Note that on openSUSE Leap 15.2, the script requires the alias of the repository and not the name.
In this example, we will be using the name ni-software-2022 for the NI-Linux Device Drivers 22Q1 repository.
- Run the following command from the directory where the script is located to clone the repository
./offline_rpm_repo.py repo --norepopath ni-software-2022
The new repository will by default be cloned to the offline_repo subdirectory of the directory where the script is run. Pass the --output to specify a different location.
2.2 On Debian-based Systems
Registered Debian repositories might use a specific name on the system that can be passed to the script to clone the repository. For a non-named repository, you must pass an apt source entry to the script to specify the repository. You can read more about the apt source entry format on the Debian wiki here: https://wiki.debian.org/SourcesList#sources.list_format
-
Determine the entry for the repository to clone.
-
Check if the repository has a name:
-
Navigate to the /etc/apt/sources.list.d/ directory.
-
Check the files in this directory for a file that matches the source repository to clone. In this example, there should be a file named ni-software-2022-focal.list. The filename without the extension ni-software-2022-focal is the name the script expects.
-
If the repository does not have a name:
-
The script expects an apt source entry, which has the form
deb https://site.example.com/debian distribution component1 component2 component3
-
-
-
Examples of this format can be found for the default Ubuntu repositories in the /etc/apt/sources.list file
-
When specifying the repository in this manner, it is important to enclose the apt source entry in quotes.
In this example, we use the name ni-software-2022-focal for the NI-Linux Device Drivers 22Q1 repository. The apt source entry equivalent is shown below and is the entry located inside the /etc/apt/sources.list.d/ni-software-2022-focal.list file:
deb https://download.ni.com/ni-linux-desktop/2022/Q1/deb/ni/focal focal ni
-
Run the following command from the directory where the script is located to clone the repository.
./offline_deb_repo.py repo --collapse ni-software-2022-focal
The new repository will by default be cloned to the offline_repo subdirectory of the directory where the script is run. Pass the --output to specify a different location.
3. Using the Script to Create a Repository for Specific Products
You can use the script to create a custom repository that provides all necessary packages for installing a particular package, including dependent packages from other registered repositories on the host system. The resulting repository is sufficient to install the software to a target system without needing to register any other repository.
3.1 On RPM-based Systems
-
Determine the desired packages to include in the repository.
-
The script requires the package name of each product that will be used to specify the repository.
-
In this example, we’ll be creating a repository that provides the NI-488.2 and NI-VISA products and their dependencies. The package names for these products are ni-488.2 and ni-visa, respectively.
-
Run the following command from the directory where the script is located to create the repository.
./offline_rpm_repo.py packages ni-488.2 ni-visa
The new repository will by default be cloned to the offline_repo subdirectory of the directory where the script is run. Pass the --output to specify a different location.
3.2 On Debian-based Systems
Unlike RPM-based repositories, Debian-based repositories require GPG signing by a key that must be registered with the target system. The script handles signing the appropriate files in the expected format but requires a GPG key to already exist which is suitable for signing.This example creates a sample key for signingthat the script will export alongside the created repository. More about GPG key signing and how it is used for repository signing can be found on the Debian wiki here: https://wiki.debian.org/Keysigning
- Create a GPG key on the root keyring by running the following command
sudo gpg --generate-key
- The GPG tool will prompt for various information necessary to create the key. Upon completion, the tool will print the generated key information to the terminal, looking something like this
pub rsa3072 2022-03-02 [SC] [expires: 2024-03-01]BB4931F582F3BF628815C834E5E662294857752D
uid First Last <email@example.com>
sub rsa3072 2022-03-08 [E] [expires: 2024-03-01] - This information can also be seen by running the following command
sudo gpg --list-keys - Take note of the long hexadecimal number on the second line. This is the key id that will be necessary when running the script.
- Determine which packages should be used to define the repository.
- The script requires the package name of each product that will be used to specify the repository.
- In this example, we’ll be creating a repository that provides the NI-488.2 and NI-VISA products and their dependencies. The package names for these products are ni-488.2 and ni-visa, respectively.
- Run the following command from the directory where the script is located to create the repository.
./offline_deb_repo.py packages --key-id BB4931F582F3BF628815C834E5E662294857752D ni-488.2 ni-visa
The new repository will by default be cloned to the offline_repo subdirectory of the directory where the script is run. Pass the --output to specify a different location.
Target Offline System
- Choose where the repository should be located on the target system.
- The created repository will be registered to the file path to where it is located.
- Placing the repository in an appropriate location can prevent issues with accidentally modifying or deleting the repository, which can cause issues even when installing software not sourced from the repository.
- For this example, we will be using the /srv/offline_repo directory.
- Copy the created repository to the selected location.
- Determine a name for the repository to use for registration.
- For this example, we’ll be using the name ni-offline-software-2022
- Register the repository on the system
NOTE: NI does not currently sign their packages. As such, GPG checking of repository packages must be disabled for NI software to properly install. The following instructions will add the repository and disable GPG checking.
- RHEL / CentOS 7/8
- As root, create a file at this path: /etc/yum.repos.d/ni-offline-software-2022.repo
- As root, edit the file to contain the following text:
[ni-offline-software-2022]
name=NI Offline Software 2022
enabled=1
gpgcheck=0
baseurl=file:///srv/offline_repo
- openSUSE Leap 15.2
- Use the command: sudo zypper addrepo --no-gpgcheck --name ni-offline-software-2022 file:///srv/offline_repo
- Ubuntu 20.04
- As root, create a file at this path:
/etc/apt/sources.list.d/ni-offline-software-2022.list - As root, edit the file to contain the following text:
deb [signed-by=/srv/offline_repo/dists/stable/key.asc] file:///srv/offline_repo
Installing from the New Repository
At this point, the target system is ready to be used to install the offline software. Packages can be installed as if the system was connected to the internet.
Script Help
The attached Python scripts are versatile and contain additional options to customize repository creation. Pass the --help flag to the scripts to obtain a detailed list of the various options and capabilities the scripts provide.