How to Add a Single Debian Package and a Single File to the Linux Filesystem

This example will go over the steps to add a file, a debian package, and build the LINUX filesystem using the filesystem tools Build-FS and CopyTarget. At the completion of this example, you will have customized your LINUX filesystem, have flashed your customized LINUX filesystem image onto the DRIVE platform, have booted up the target platform with your customized LINUX filesystem, and have verified the added package and the added file on the target.
  1. In this example, we have chosen to use the file ${NV_WORKSPACE}/drive-linux/filesystem/content/samples/hello_world.txt that is part of the DRIVE OS samples to add to the LINUX filesystem.

  2. You are, otherwise, welcome to use any other file you desire, but the rest of this example will refer to hello_world.txt.

  3. Create a the CopyTarget Manifest ${NV_WORKSPACE}/drive-linux/filesystem/copytarget/manifest/copytarget-hello.yaml and add entry to ${NV_WORKSPACE}/drive-linux/filesystem/content/samples/hello_world.txt as shown below. A list of file metadata (perm, owner, group) must be specified to provide detail to describe the file.

  4. In this example, we customize the standard LINUX filesystem; thus, we need to specify the filesystem variant that the file hello_world.txt is part of. Importantly, we need to provide the source location (pdk_sdk_installed_path) and the destination that the file hello_world.txt should reside in the customized LINUX filesystem.

  5. As per steps 2 and 3, an example that describes hello_world.txt is provided in the code block below. Copy this excerpt into ${NV_WORKSPACE}/drive-linux/filesystem/copytarget/manifest/copytarget-hello.yaml.
    fileList:
        - destination: /hello_world.txt
          source:
              pdk_sdk_installed_path: ${NV_WORKSPACE}/drive-linux/filesystem/content/samples/hello_world.txt
          perm: 644
          owner: root
          group: root
  6. Further, in this example, we demonstrate adding a LINUX debian package to the filesystem using the Build-FS config. To add a package, an entry must be added to the "DebianPackages" block of the config file.
  7. Update the /opt/nvidia/driveos/common/filesystems/build-fs/17/configs/driveos-example-hello_world-rfs.CONFIG.json Build-FS config to add the CopyTarget YAML created above in the "CopyTargets" block and the parted debian package in the "DebianPackages" block of the config file.
    {
        "OS": "linux",
        "Output": "driveos-example-hello_world-rfs",
        "Base": "${BASE_DIR}/targetfs.img",
        "Mirrors": [
            {
                "Type": "local_debian_folder",
                "Path": "${MIRROR_DIR}"
            }
        ],
        "CopyTargets": [
            "${COPYTARGETYAML_DIR}/copytarget-hello.yaml"
        ],
        "DebianPackages": [
            "bsdmainutils"
        ]
    }
  8. Run the build-fs tool using the command-line below to create a filesystem with above customizations. The created filesystem shall be at path ${NV_WORKSPACE}/drive-linux/filesystem/targetfs-images/driveos-example-hello_world-rfs.img because of the output name specified in /opt/nvidia/driveos/common/filesystems/build-fs/17/configs/driveos-example-hello_world-rfs.CONFIG.json. (FIX config) Copy the rebuilt filesystem to replace the starting filesystem at ${NV_WORKSPACE}/drive-linux/filesystem/targetfs-images/targetfs.img.
    $ sudo -E /usr/bin/python3 -B /opt/nvidia/driveos/common/filesystems/build-fs/17/bin/build_fs.py -w ${NV_WORKSPACE}/ -i /opt/nvidia/driveos/common/filesystems/build-fs/17/configs/driveos-linux-example-hello_world-rfs.CONFIG.json -o ${NV_WORKSPACE}/drive-linux/filesystem/targetfs-images/
    $ sudo ln -sf ${NV_WORKSPACE}/drive-linux/filesystem/targetfs-images/driveos-example-hello_world-rfs.img ${NV_WORKSPACE}/drive-linux/filesystem/targetfs-images/targetfs.img
    
  9. The DRIVE OS flashing tool bootburn.py PCT picks up filesystem by default at path ${NV_WORKSPACE}/drive-linux/filesystem/targetfs-images/targetfs.img.
  10. Use bootburn.py to flash the filesystem.
  11. Reboot the target.
  12. The target should have rebooted with your customized LINUX filesystem.
  13. Verify that intended customizations are present:
    1. Check ls at / path to verify /hello-world.txt exists:
      1. $ ls /hello-world.txt
    2. Use the hexdump command below to confirm the bsdmainutils package is installed:
      1. $ hexdump -C /hello-world.txt