Getting Previous Builds and Recreating Previous Build Workspaces

Introduction

Fuze provides command features for downloading previously built packages, importing dependencies from previously built packages so that you can work locally, as well as recreating a workspace locally that was used to create a build associated with a FuzeID.

Every FuzeID stores enough metadata to fully recreate that build, and download the packages that were created (if those packages were stored to FuzeDB). A recreated workspace results in the following on the local system:

  • Workspace with valid workspace.ini file

  • Workspace with the build map file that was used to create the FuzeID

  • Workspace with all source code repositories with the branches that were used to create the FuzeID

  • Local FuzeDB’s populated with the created packages that were generated with that FuzeID

In short, recreating a workspace creates a functionally correct copy of the workspace and Fuze attributes that were used to generate the referenced FuzeID. If the build rules of engagement have been followed, a bit-exact build can be generated from this workspace.

Note

Getting previous builds and recreating workspaces do NOT require Docker running in the local system

Downloading a Previously Built Package

Whenever a Fuze build uses the --update-packages or --add-packages commands, the created packages are stored in the FuzeDB system and are available to be downloaded by anyone.

Pre-Requisites

  • Valid workspace.ini file

  • Valid FuzeID of the build from which you wish to get the packages

--get-packages Command

The --get-packages command allows you to download all publicly available packages. You may use the --get-packages command two different ways.

  1. Directly specifying a FuzeID

  2. Telling Fuze to give you the latest from the package repo.

Directly Specify a FuzeID

To do so, specify the FuzeID and an optional destination (the destination can be outside of the workspace). If the optional [destination] argument is omitted, the default .fuze location will be used.

fuze --get-packages <FuzeID> [destination]

Example:

Assume the FuzeID 230117-441-6478 contains the following packages:

  • logs.zip (the logs package is always included)

  • internal-test-cs7-kepler-slc38-v7.11.230117-441-6478.zip

  • release-cs7-kepler-slc38-v7.11.230117-441-6478.zip

$ ls
workspace.ini

$ fuze --get-packages 230117-441-6478 pkgs
2023-02-03 09:06:55,655 [            fuze.__init__        :225  ]  INFO     Checking if there is internet connectivity...
...
2023-02-03 09:06:55,959 [            fuze.execute         :717  ]  INFO     Getting requested packages for [230117-441-6478] please be patient
2023-02-03 09:06:56,103 [     Environment.getPackages     :363  ]  INFO     Downloading packages to: pkgs/cs7
[ cs7 => internal-test-cs7-kepler-slc38-v7.11.230117-441-6478.zip ] | |                                #           | 262144 Elapsed Time: 0:00:03
[ cs7 => release-cs7-kepler-slc38-v7.11.230117-441-6478.zip ] | |                  #                               | 262144 Elapsed Time: 0:00:01
[ cs7 => logs.zip ] | |  #                                                                                          | 30820 Elapsed Time: 0:00:00
2023-02-03 09:07:01,788 [            fuze.execute         :727  ]  INFO     Local package now available: pkgs/cs7/test-cs7-kepler-slc38/internal-test-cs7-kepler-slc38-v7.11.230117-441-6478.zip
2023-02-03 09:07:01,788 [            fuze.execute         :727  ]  INFO     Local package now available: pkgs/cs7/cs7-kepler-slc38/release-cs7-kepler-slc38-v7.11.230117-441-6478.zip
2023-02-03 09:07:01,788 [            fuze.execute         :727  ]  INFO     Local package now available: pkgs/cs7/common/logs.zip

$ ls
fuze.out       pkgs/          workspace.ini

$ tree pkgs/cs7
pkgs/cs7
├── common
│   └── logs.zip
├── cs7-kepler-slc38
│   └── release-cs7-kepler-slc38-v7.11.230117-441-6478.zip
└── test-cs7-kepler-slc38
|   └── internal-test-cs7-kepler-slc38-v7.11.230117-441-6478.zip

Get the Latest

This method gets the packages from the HEAD of the package repo for that product. If the optional [destination] argument is omitted, the default .fuze location will be used.

fuze --get-packages <product> [destination] --latest

Example: Getting the latest CS7 packages

$ ls
workspace.ini

$ fuze --get-packages cs7 pkgs --latest
2023-02-03 09:13:33,153 [            fuze.__init__        :225  ]  INFO     Checking if there is internet connectivity...
...
2023-02-03 09:13:33,586 [            fuze.execute         :713  ]  INFO     Getting 'latest' packages -- cs7:230203-315-7551 ... please be patient
2023-02-03 09:13:33,728 [     Environment.getPackages     :363  ]  INFO     Downloading packages to: pkgs/cs7
[ cs7 => internal-test-cs7-kepler-slc38-v7.255.230203-315-7551.zip ] | |                           #               | 262144 Elapsed Time: 0:00:02
[ cs7 => release-cs7-kepler-slc38-v7.255.230203-315-7551.zip ] | |               #                                 | 104855 Elapsed Time: 0:00:01
[ cs7 => logs.zip ] | |  #                                                                                          | 30806 Elapsed Time: 0:00:00
2023-02-03 09:13:38,625 [            fuze.execute         :727  ]  INFO     Local package now available: pkgs/cs7/test-cs7-kepler-slc38/internal-test-cs7-kepler-slc38-v7.255.230203-315-7551.zip
2023-02-03 09:13:38,625 [            fuze.execute         :727  ]  INFO     Local package now available: pkgs/cs7/cs7-kepler-slc38/release-cs7-kepler-slc38-v7.255.230203-315-7551.zip
2023-02-03 09:13:38,625 [            fuze.execute         :727  ]  INFO     Local package now available: pkgs/cs7/common/logs.zip

$ ls
fuze.out       pkgs/          workspace.ini

$ tree pkgs/cs7
pkgs/cs7/
├── common
│   └── logs.zip
├── cs7-kepler-slc38
│   └── release-cs7-kepler-slc38-v7.255.230203-315-7551.zip
└── test-cs7-kepler-slc38
|   └── internal-test-cs7-kepler-slc38-v7.255.230203-315-7551.zip

Importing Dependent Packages to Work Locally

The --import-dependencies command looks at the referred build map and imports the dependent packages into the user’s local Fuze environment. Specifically, they get placed either in the optional user-specified destination, or to the FTL location.

Once downloaded, Fuze then unpacks them so they are ready to use. The difference between --import-dependencies and --download-dependencies is this unpacking operation.

Pre-Requisites

  • Valid workspace.ini file

  • Valid target build map containing the dependency references

--import-dependencies Command

Issue the following command in the directory in which your workspace.ini file resides:

fuze --build-map <path_to_buildmap> --import-dependencies [--destination <dir>]

Once complete, you will have all of the unpacked packages in your specified destination. A copy of the dependent packages is also contained in the FTL for convenience or viewing.

Example:

Assume you are working (i.e., developing and building) in a repository called therepo. Your workspace might look like this, where the deps directory must contain the dependencies required to build:

$ ls
cs7.json       deps/    therepo/       workspace.ini

Note that cs7.json is the build map we are using. I’ve put it here for convenience of explanation and example. The build map can be called from anywhere in the workspace, notably within in therepo.

$ fuze --build-map cs7.json --import-dependencies --destination deps
2023-02-03 09:46:53,842 [            fuze.__init__        :225  ]  INFO     Checking if there is internet connectivity
...
2023-02-03 09:46:54,218 [     BuildDocker.collectDependenc:652  ]  INFO     Searching for dependencies...
2023-02-03 09:46:54,405 [     BuildDocker.inspectPackages :626  ]  INFO     cs7-docs:230203-374-4088 comes from Fuze remote cache
2023-02-03 09:46:54,405 [     BuildDocker.inspectPackages :626  ]  INFO     se-sdk:230203-35a-2200 comes from Fuze remote cache
2023-02-03 09:46:54,405 [     BuildDocker.inspectPackages :626  ]  INFO     atf:230114-53-2444 comes from Fuze remote cache
2023-02-03 09:46:54,406 [     BuildDocker.inspectPackages :626  ]  INFO     cs7:220908-383-8235 comes from Fuze remote cache
2023-02-03 09:46:54,406 [     BuildDocker.inspectPackages :626  ]  INFO     demos-android:221012-36e-15756 comes from Fuze remote cache
2023-02-03 09:46:54,406 [     BuildDocker.inspectPackages :626  ]  INFO     fptools:230203-35a-6970 comes from Fuze remote cache
2023-02-03 09:46:54,406 [     BuildDocker.inspectPackages :626  ]  INFO     fptools:230203-35a-6970 comes from Fuze remote cache
2023-02-03 09:46:54,406 [     BuildDocker.inspectPackages :626  ]  INFO     gen-b:230203-35a-8377 comes from Fuze remote cache
2023-02-03 09:46:54,406 [     BuildDocker.inspectPackages :626  ]  INFO     fptools:230203-35a-6970 comes from Fuze remote cache
2023-02-03 09:46:54,406 [     BuildDocker.inspectPackages :626  ]  INFO     iaf:220223-357-1869 comes from Fuze remote cache
2023-02-03 09:46:54,407 [     BuildDocker.collectDependenc:660  ]  INFO     Collecting dependencies; please be patient...
...
2023-02-03 09:47:18,511 [     BuildDocker.build           :1198 ]  INFO     All dependencies have been imported; closing Fuze
2023-02-03 09:47:18,511 [     BuildDocker.build           :1199 ]  INFO     Browse imports at: /Users/johnmacdonald/tmp/ftl/230203-376-528

Fuze has found and retrieved all of the dependencies required to build with build map cs7.json. They have been stored to both the deps directory and to the FTL.

$ ls
cs7.json       deps/          fuze.out       therepo/       workspace.ini

$ tree -L 1 deps
deps
├── atf
├── demos-android
├── gen-b
├── iaf
├── jnet-jcos
└── se-sdk

Downloading Dependent Packages

The --download-dependencies is similar to --import-dependencies except it does not unpack the zip files.

Pre-Requisites

  • Valid workspace.ini file

  • Valid target build map containing the dependency references

--download-dependencies Command

Issue the following command in the directory in which your workspace.ini file resides:

fuze --build-map <path_to_buildmap> --download-dependencies [destination]

Once complete, you will have all of the unpacked packages in your specified destination, or the FTL if none specified.

Example: Assume the same workspace as in the previous section.

$ fuzeapp_macos --build-map cs7.json --download-dependencies deps
2023-02-03 10:16:20,205 [            fuze.__init__        :225  ]  INFO     Checking if there is internet connectivity...
...
2023-02-03 10:16:20,570 [     BuildDocker.collectDependenc:652  ]  INFO     Searching for dependencies...
2023-02-03 10:16:20,749 [     BuildDocker.inspectPackages :626  ]  INFO     atf:230114-53-2444 comes from Fuze remote cache
2023-02-03 10:16:20,749 [     BuildDocker.inspectPackages :626  ]  INFO     se-sdk:230203-35a-2200 comes from Fuze remote cache
2023-02-03 10:16:20,750 [     BuildDocker.inspectPackages :626  ]  INFO     cs7:220908-383-8235 comes from Fuze remote cache
2023-02-03 10:16:20,750 [     BuildDocker.inspectPackages :626  ]  INFO     demos-android:221012-36e-15756 comes from Fuze remote cache
2023-02-03 10:16:20,750 [     BuildDocker.inspectPackages :626  ]  INFO     cs7-docs:230203-374-4088 comes from Fuze local cache
2023-02-03 10:16:20,750 [     BuildDocker.inspectPackages :626  ]  INFO     fptools:230203-35a-6970 comes from Fuze remote cache
2023-02-03 10:16:20,750 [     BuildDocker.inspectPackages :626  ]  INFO     fptools:230203-35a-6970 comes from Fuze remote cache
2023-02-03 10:16:20,750 [     BuildDocker.inspectPackages :626  ]  INFO     gen-b:230203-35a-8377 comes from Fuze remote cache
2023-02-03 10:16:20,750 [     BuildDocker.inspectPackages :626  ]  INFO     iaf:220223-357-1869 comes from Fuze remote cache
2023-02-03 10:16:20,751 [     BuildDocker.inspectPackages :626  ]  INFO     fptools:230203-35a-6970 comes from Fuze remote cache
2023-02-03 10:16:20,751 [     BuildDocker.collectDependenc:660  ]  INFO     Collecting dependencies; please be patient...
...
2023-02-03 10:16:42,561 [            fuze.execute         :1027 ]  INFO     Dependencies downloaded to: /Users/johnmacdonald/tmp/demo/deps

$ tree deps
deps
├── atf
│   └── ATF-internal-v1.0.230114-53-2444.zip
├── demos-android
│   ├── pkg-IDEXDemo-v7.10.221012-36e-15756.zip
│   └── pkg-IDEXPay-v7.10.221012-36e-15756.zip
├── docs
│   └── pkg-cs7-docs-v7.255.230203-374-4088.zip
├── ffat
│   ├── RELEASE-Software-LPCT-lpct-v255.26.230203-35a-6970.zip
│   ├── RELEASE-Software-TOOLS-tools-v255.26.230203-35a-6970.zip
│   └── internal-test-ffat-v255.26.230203-35a-6970.zip
├── fptools
│   ├── RELEASE-Software-LPCT-lpct-v255.26.230203-35a-6970.zip
│   ├── RELEASE-Software-TOOLS-tools-v255.26.230203-35a-6970.zip
│   └── internal-test-ffat-v255.26.230203-35a-6970.zip
├── genb
│   ├── pkg-biometric-bridge-v255.255.230203-35a-8377.zip
│   ├── pkg-biometric-lib-module-v255.255.230203-35a-8377.zip
│   ├── pkg-biometric-slc38-powerlog-v255.255.230203-35a-8377.zip
│   ├── pkg-biometric-slc38-v255.255.230203-35a-8377.zip
│   ├── pkg-biometric-st31n-powerlog-v255.255.230203-35a-8377.zip
│   ├── pkg-biometric-st31n-v255.255.230203-35a-8377.zip
│   ├── pkg-biometric-thd89-powerlog-v255.255.230203-35a-8377.zip
│   ├── pkg-biometric-thd89-v255.255.230203-35a-8377.zip
│   ├── pkg-flash-programming-v255.255.230203-35a-8377.zip
│   ├── pkg-mfg-v255.255.230203-35a-8377.zip
│   ├── pkg-mock-se-v255.255.230203-35a-8377.zip
│   ├── pkg-scan-lib-module-v255.255.230203-35a-8377.zip
│   ├── pkg-scan-table-module-v255.255.230203-35a-8377.zip
│   ├── pkg-sensor-only-v255.255.230203-35a-8377.zip
│   └── pkg-utils-v255.255.230203-35a-8377.zip
├── iaf
│   └── IAF-internal-v0.0.220223-357-1869.zip
├── jnet-jcos
│   └── IDX-TrustedBio-M4-V2.3.0b-20220908-i-220908-383-8235.zip
├── lpct
│   ├── RELEASE-Software-LPCT-lpct-v255.26.230203-35a-6970.zip
│   ├── RELEASE-Software-TOOLS-tools-v255.26.230203-35a-6970.zip
│   └── internal-test-ffat-v255.26.230203-35a-6970.zip
└── se-sdk
|   ├── pkg-se-sdk-st31n-idm_kepler-v255.255.230203-35a-2200.zip
|   └── pkg-se-sdk_slc38bml800-v255.255.230203-35a-2200.zip

Recreating a Workspace (To Recreate a Previous Build)

Recreating a previous build, through recreating its workspace, is one of the most powerful features of Fuze. With it, you can be assured taking any previous Fuze build and making your local enviroment match the environment that was used to build that particular version.

You may recreate a workspace “on top of” an existing workspace, or in a wholly new location in your file system.

Pre-Requisites

  • Valid workspace.ini file (note that the [repos] section will be ignored by the --get-workspace operation

  • Valid FuzeID of the build you wish to recreate

--get-workspace Command

Issue the following command in the directory in which your workspace.ini file resides:

fuze --get-workspace <FuzeID> [--create-branch <branch_name>]

A valid FuzeID is required.

If you specify the --create-branch option (and supply a branch name), the repos that are cloned into the workspace will have the specified branch created and it will be checked out.

What Gets Copied to Your Local Environment?

The following will be copied from the FuzeDB into the recreated workspace:

  • All source repos

  • The build map file

  • All packages that were created with the original build will be in the package cache (i.e., the .fuze directory)

Example:

$ ls
workspace.ini

$ fuze --get-workspace 230203-26b-3397
2023-02-03 10:33:19,893 [            fuze.__init__        :225  ]  INFO     Checking if there is internet connectivity...
...
2023-02-03 10:33:20,351 [     Environment.__parseSources  :159  ]  WARNING  Unable to find therepo in your current workspace; cloning it from remote; please be patient...
2023-02-03 10:35:35,232 [     Environment.__parseSources  :165  ]  INFO     Pulling latest changes from remote...
...
2023-02-03 10:35:38,299 [     Environment.getPackages     :363  ]  INFO     Downloading packages to: /Users/johnmacdonald/.fuze/cs7
...
2023-02-03 10:35:51,480 [     Environment.getWorkspace    :508  ]  INFO     Local package now available: /Users/johnmacdonald/.fuze/CS7_Packages
2023-02-03 10:35:51,480 [     Environment.getWorkspace    :508  ]  INFO     Local package now available: /Users/johnmacdonald/.fuze/CS7_Packages
2023-02-03 10:35:51,480 [     Environment.getWorkspace    :508  ]  INFO     Local package now available: /Users/johnmacdonald/.fuze/CS7_Packages
2023-02-03 10:35:51,481 [     Environment.getWorkspace    :508  ]  INFO     Local package now available: /Users/johnmacdonald/.fuze/CS7_Packages
2023-02-03 10:35:51,483 [     Environment.getWorkspace    :508  ]  INFO     Local package now available: /Users/johnmacdonald/.fuze/CS7_Packages
2023-02-03 10:35:51,484 [     Environment.getWorkspace    :510  ]  INFO     Command line to re-create same Fuze execution as 230203-26b-3397 is below:
2023-02-03 10:35:51,484 [     Environment.getWorkspace    :523  ]  INFO     fuze --build-map /Users/johnmacdonald/tmp/demo/230203-26b-3397.json --target all --add_packages

$ ls
230203-26b-3397.json  fuze.out              therepo/              workspace.ini

To rebuild this, I can use the downloaded build map and the variation on the build command that results in the targets and packages I desire.

Without specifying a new branch with --create-branch, the repository is sitting at the commitID associated with the build, in an unattached HEAD state:

$ cd therepo
$ git status
HEAD detached at 4b07fc6a4f

If I use the --create-branch option, my repository is now on that newly created branch:

$ fuze --get-workspace 230203-26b-3397 --create-branch JIRA-123-hot-fix
2023-02-03 10:46:28,855 [            fuze.__init__        :225  ]  INFO     Checking if there is internet connectivity...
...
2023-02-03 10:46:29,644 [     Environment.__parseSources  :165  ]  INFO     Pulling latest changes from remote...
2023-02-03 10:46:32,918 [     Environment.__parseSources  :179  ]  INFO     Checking out 4b07fc6a4f517d8e9aa91eb306b1463846dea502 from therepo...
...
2023-02-03 10:46:33,652 [     Environment.__parseSources  :193  ]  INFO     Creating branch or checking out remote branch (if it exists) -- repo: [therepo] branch: [JIRA-123-hot-fix]
...

$ ls
230203-26b-3397.json  fuze.out              therepo/              workspace.ini
$ cd therepo
$ git status
On branch JIRA-123-hot-fix