Offline Installation of NI Linux Device Drivers

Updated Apr 25, 2023

Environment

Driver

  • NI Linux Device Drivers

Operating System

  • Linux

My Linux system is not allowed to connect to the internet due to my company/client's privacy/security policy. Are there any methods to install Linux device drivers offline on my computer?  

NI provides two scripts to clone or create custom repositories for use on offline systems. The scripts target the RPM- and Debian-based Linux distributions that NI supports. This article instructs you on how to use the scripts to create offline repositories for installing software from the NI-Linux Device Drivers repository on ni.com to an offline machine. You can use these instructions with slight variations for use with any repository.

The offline installation media creation procedure requires a system running the same distribution as the target system with an internet connection to be able to access NI’s repositories. You must have root privileges on the system and must install a set of prerequisite software for the script to run properly.

Instructions and scripts are included separately and as a compressed .gz for downloading

 Host Online System

1. Setting up the Host System to Use the Script.

  1. This system should be running the same distribution as the target system and have an internet connection
  2. 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
  3. 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.
  4. Download the required script that matches the Linux distribution of your host and target system.
  5. 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.​​​​​
  1. 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.
  2. 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
  1. Determine the entry for the repository to clone.
    1. Check if the repository has a name:
      1. Navigate to the /etc/apt/sources.list.d/ directory.
      2. 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.
    2. If the repository does not have a name:
      1. The script expects an apt source entry, which has the form
        deb https://site.example.com/debian distribution component1 component2 component3
      1. Examples of this format can be found for the default Ubuntu repositories in the /etc/apt/sources.list file
      2. 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
  1. 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

  1. Determine the desired packages to include in the repository.
    1. The script requires the package name of each product that will be used to specify the repository.
    2. 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.
  2. 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
  1. Create a GPG key on the root keyring by running the following command
    sudo gpg --generate-key
    1. 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]
    2. This information can also be seen by running the following command
      sudo gpg --list-keys
    3. Take note of the long hexadecimal number on the second line. This is the key id that will be necessary when running the script.
  2. Determine which packages should be used to define the repository.
    1. The script requires the package name of each product that will be used to specify the repository.
    2. 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.
  3. 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

  1. Choose where the repository should be located on the target system.
    1. The created repository will be registered to the file path to where it is located.
    2. 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.
    3. For this example, we will be using the /srv/offline_repo directory.
  2. Copy the created repository to the selected location.
  3. Determine a name for the repository to use for registration.
    1. For this example, we’ll be using the name ni-offline-software-2022
  4. 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
      1. As root, create a file at this path: /etc/yum.repos.d/ni-offline-software-2022.repo
      2. 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
    1. Use the command: sudo zypper addrepo --no-gpgcheck --name ni-offline-software-2022 file:///srv/offline_repo
  • Ubuntu 20.04
    1. As root, create a file at this path:
      /etc/apt/sources.list.d/ni-offline-software-2022.list
    2. 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.