|
| 1 | +@echo off |
| 2 | +rem |
| 3 | +rem Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one |
| 4 | +rem or more contributor license agreements. Licensed under the Elastic License; |
| 5 | +rem you may not use this file except in compliance with the Elastic License. |
| 6 | +rem |
| 7 | + |
| 8 | +rem |
| 9 | +rem Create a CSV file listing the information about our 3rd party dependencies |
| 10 | +rem that is required for the stack-wide list. |
| 11 | +rem |
| 12 | +rem Usage: |
| 13 | +rem dependency_report.bat --csv <output_file> |
| 14 | +rem |
| 15 | +rem The format is that defined in https://github.com/elastic/release-manager/issues/207, |
| 16 | +rem i.e. a CSV file with the following fields: |
| 17 | +rem |
| 18 | +rem name,version,revision,url,license,copyright |
| 19 | +rem |
| 20 | +rem The way this script works, each component must have its own CSV file with |
| 21 | +rem those fields, and this script simply combines them into a single CSV file. |
| 22 | +rem Because of this, the field order is important - in each per-component CSV |
| 23 | +rem file the fields must be in the order shown above. |
| 24 | + |
| 25 | +setlocal EnableExtensions EnableDelayedExpansion |
| 26 | + |
| 27 | +if /i [%1] == [--csv] ( |
| 28 | + set OUTPUT_FILE=%2 |
| 29 | +) |
| 30 | + |
| 31 | +if [%OUTPUT_FILE%] == [] ( |
| 32 | + echo Usage: %~0 --csv ^<output_file^> |
| 33 | + exit /b 1 |
| 34 | +) |
| 35 | + |
| 36 | +cd %~dp0 |
| 37 | + |
| 38 | +rem IMPORTANT: this assumes all the *INFO.csv files have the following header: |
| 39 | +rem |
| 40 | +rem name,version,revision,url,license,copyright |
| 41 | + |
| 42 | +set FIRST=yes |
| 43 | +for %%i in (licenses\*INFO.csv) do ( |
| 44 | + if [!FIRST!] == [yes] ( |
| 45 | + set FIRST=no |
| 46 | + rem "|| rem": set errorlevel |
| 47 | + type %~dp0\%%i > %OUTPUT_FILE% || rem |
| 48 | + if ERRORLEVEL 1 ( |
| 49 | + exit /b 1 |
| 50 | + ) |
| 51 | + ) else ( |
| 52 | + findstr /v "^name," %~dp0\%%i >> %OUTPUT_FILE% |
| 53 | + ) |
| 54 | +) |
| 55 | + |
| 56 | +endlocal |
| 57 | + |
| 58 | + |
0 commit comments