Skip to content

Commit

Permalink
add support for DOWNLOAD_CLIDRIVER environment variable
Browse files Browse the repository at this point in the history
  • Loading branch information
bimalkjha committed May 21, 2023
1 parent ad58121 commit 68b4197
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 8 deletions.
10 changes: 9 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ ibm_db: 2.8.1

- For Node.js >= V15.x on RHEL and RHEL 8.x, GCC v8.2.1 is required.

- The latest node.js version using which `ibm_db` is tested: 20.0.0
- The latest node.js version using which `ibm_db` is tested: 20.2.0

## Install

Expand Down Expand Up @@ -128,6 +128,14 @@ To avoid this download, you can manually download clidriver from this location o
- TIP:
- If you don't have alternate hosting URL then, you can download the tar/zipped file of clidriver from the [IBM Hosted URL](#downloadCli) and can set the **IBM_DB_INSTALLER_URL** environment variable to the downloaded "tar/zipped clidriver's" parent directory path. No need to untar/unzip the clidriver and do not change the name of downloaded file.

`DOWNLOAD_CLIDRIVER :`

- USE:
- Set this environment variable to force downloading of odbc/clidriver. If clidriver is already present, existing clidriver will get deleted. If IBM_DB_HOME environment variable is set, still clidriver will get downloaded by ignoring value of IBM_DB_HOME.

- HOW:
- On distributed platforms, Set **DOWNLOAD_CLIDRIVER** environment variable to `true` to force downloading of clidriver from IBM hosted URL. Never set DOWNLOAD_CLIDRIVER on z/OS system.

### <a name="downloadCli"></a> Download clidriver ([based on your platform & architecture](#systemDetails)) from the below IBM Hosted URL:
> [DOWNLOAD CLI DRIVER](https://public.dhe.ibm.com/ibmdl/export/pub/software/data/db2/drivers/odbc_cli/)
Expand Down
Binary file modified build.zip
Binary file not shown.
22 changes: 15 additions & 7 deletions installer/driverInstall.js
Original file line number Diff line number Diff line change
Expand Up @@ -101,27 +101,36 @@ var install_node_ibm_db = function(file_url) {
*/

//If building for supporting VSCode Extn, then remove Clidriver folder and get it freshly
if(vscode_build && fs.existsSync(path.join(DOWNLOAD_DIR,'clidriver'))){
deleteFolderRecursive(path.join(DOWNLOAD_DIR,'clidriver'))
//If environment variable DOWNLOAD_CLIDRIVER is set to true, then remove Clidriver folder and get it freshly
if((vscode_build || process.env.DOWNLOAD_CLIDRIVER == "true") &&
fs.existsSync(path.join(DOWNLOAD_DIR,'clidriver'))){
deleteFolderRecursive(path.join(DOWNLOAD_DIR,'clidriver'));
}

//If environment variable DOWNLOAD_CLIDRIVER is set to true, then ignore setting of IBM_DB_HOME
if(process.env.DOWNLOAD_CLIDRIVER == "true"){
process.env.IBM_DB_HOME = '';
printMsg('DOWNLOAD_CLIDRIVER environment variable is set, ' +
'proceeding to download clidriver.\n');
}

// Check if env var IBM_DB_HOME is set
var IS_ENVIRONMENT_VAR;
var clidriverFound = true;
var clidriverFound = false;

if (process.env.IBM_DB_HOME) {
if (fs.existsSync(process.env.IBM_DB_HOME) || platform == "os390") {
IBM_DB_HOME = process.env.IBM_DB_HOME;
IS_ENVIRONMENT_VAR = true;
clidriverFound = true;
} else {
printMsg(process.env.IBM_DB_HOME + " directory does not exist. Please" +
" check if you have set the IBM_DB_HOME environment" +
" variable\'s value correctly.\n");
clidriverFound = false;
}
}

if (clidriverFound == false && fs.existsSync(DOWNLOAD_DIR + "/clidriver")){
if (clidriverFound == false && fs.existsSync(DOWNLOAD_DIR + "/clidriver/include/sqlcli.h")){
IBM_DB_HOME = path.resolve(DOWNLOAD_DIR, 'clidriver');
process.env.IBM_DB_HOME = IBM_DB_HOME.replace(/\s/g,'\\ ');
IS_ENVIRONMENT_VAR = false;
Expand All @@ -139,6 +148,7 @@ var install_node_ibm_db = function(file_url) {
} else {
IBM_DB_LIB = path.resolve(IBM_DB_HOME, 'lib');
}
clidriverFound = true;

if (!fs.existsSync(IBM_DB_LIB)) {
console.log(IBM_DB_LIB, " directory does not exist. Please ",
Expand All @@ -161,8 +171,6 @@ var install_node_ibm_db = function(file_url) {
process.env.IBM_DB_HOME = undefined;
}
}
} else {
clidriverFound = false;
}

/*
Expand Down

0 comments on commit 68b4197

Please sign in to comment.