summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDaniel Widerin <daniel@widerin.net>2018-09-01 17:54:56 +0200
committerDaniel Widerin <daniel@widerin.net>2018-09-30 14:37:48 +0200
commit5fbcf066e63ac2d8df775054423b596549891e1c (patch)
treef00af23206c9ed0df7d81953c1e11c636dae7fe8
parent630a463f0f99c08d3395d9016185c23523ed1842 (diff)
use SETUP_CMD to skip auto-detection
-rw-r--r--CHANGELOG.md2
-rw-r--r--README.md11
-rwxr-xr-xrun.sh126
3 files changed, 79 insertions, 60 deletions
diff --git a/CHANGELOG.md b/CHANGELOG.md
index 1476299..26d814b 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -2,6 +2,8 @@
## 11-4-stable
+- Allow `SETUP_CMD` to skip auto-detection of build tool
+
## 11-3-stable
## 11-2-stable
diff --git a/README.md b/README.md
index d58ebf8..ea4ecbd 100644
--- a/README.md
+++ b/README.md
@@ -56,6 +56,17 @@ The following table shows which languages and package managers are supported.
| Python | [pip](https://pip.pypa.io/en/stable/) |
| Ruby | [gem](https://rubygems.org/) |
+Inject `SETUP_CMD` to the docker command to override the given package managers
+and run your custom command to setup your environment with a custom package manager.
+
+ ```sh
+ docker run \
+ --volume "$PWD":/code \
+ --env "SETUP_CMD=./my-custom-install-script.sh" \
+ --rm \
+ registry.gitlab.com/gitlab-org/security-products/license-management:latest analyze /code
+ ```
+
## Versioning and release process
diff --git a/run.sh b/run.sh
index 6326f07..d82d133 100755
--- a/run.sh
+++ b/run.sh
@@ -11,7 +11,9 @@ $(basename "$0") test
where:
-h show this help text
- PROJECT_PATH = the path of the project to be analyzed for licenses usage."
+ PROJECT_PATH = the path of the project to be analyzed for licenses usage.
+
+ Set SETUP_CMD to skip auto-detection and use the specified command to install project dependencies."
if [ $# -eq 0 ] ; then
echo "$usage"
@@ -81,65 +83,69 @@ case "$COMMAND" in
shift
pushd $APP_PATH
- # Before running license_finder, we need to install dependencies for the project.
- if test -f Gemfile ; then
- if test -n "$rvm_recommended_ruby" ; then
- # Install the Ruby version RVM found in the project files
- # This always end in the cryptic "bash: Searching: command not found" error but Ruby is installed
- # So we ignore the error.
- $($rvm_recommended_ruby) 2>/dev/null || true
- rvm use .
- gem install bundler
- # We need to install the license_finder gem into this Ruby version too.
- gem install license_finder
- fi
-
- # Ignore test and development dependencies.
- license_finder ignored_groups add development
- license_finder ignored_groups add test
- bundle install --without "development test"
- fi
-
- if test -f requirements.txt ; then
- # Install Python Pip packages.
- pip install -r requirements.txt
- fi
-
- if test -f package.json ; then
- # Install NPM packages.
- npm install --production
- # Try to install Peer packages too, npm install doesn't do it anymore.
- /node_modules/.bin/npm-install-peers
- fi
-
- if test -f bower.json ; then
- # Install Bower packages.
- bower install
- fi
-
- # Symlink the project into GOPATH to allow fetching dependencies.
- ln -sf `realpath $APP_PATH` /gopath/src/app
-
- if test -f Godeps/Godeps.json ; then
- # Install Go dependencies with Godeps.
- pushd /gopath/src/app
- godep restore
- popd
- elif find . -name "*.go" -printf "found" -quit |grep found >/dev/null ; then
- # Install Go dependencies with go get.
- pushd /gopath/src/app
- go get
- popd
- fi
-
- if test -f pom.xml ; then
- # Install Java Maven dependencies.
- mvn install
- fi
-
- if test -f build.gradle ; then
- # Install Java Gradle dependencies.
- gradle build
+ if [[ -z "${SETUP_CMD}" ]]; then
+ # Before running license_finder, we need to install dependencies for the project.
+ if test -f Gemfile ; then
+ if test -n "$rvm_recommended_ruby" ; then
+ # Install the Ruby version RVM found in the project files
+ # This always end in the cryptic "bash: Searching: command not found" error but Ruby is installed
+ # So we ignore the error.
+ $($rvm_recommended_ruby) 2>/dev/null || true
+ rvm use .
+ gem install bundler
+ # We need to install the license_finder gem into this Ruby version too.
+ gem install license_finder
+ fi
+
+ # Ignore test and development dependencies.
+ license_finder ignored_groups add development
+ license_finder ignored_groups add test
+ bundle install --without "development test"
+ fi
+
+ if test -f requirements.txt ; then
+ # Install Python Pip packages.
+ pip install -r requirements.txt
+ fi
+
+ if test -f package.json ; then
+ # Install NPM packages.
+ npm install --production
+ # Try to install Peer packages too, npm install doesn't do it anymore.
+ /node_modules/.bin/npm-install-peers
+ fi
+
+ if test -f bower.json ; then
+ # Install Bower packages.
+ bower install
+ fi
+
+ # Symlink the project into GOPATH to allow fetching dependencies.
+ ln -sf `realpath $APP_PATH` /gopath/src/app
+
+ if test -f Godeps/Godeps.json ; then
+ # Install Go dependencies with Godeps.
+ pushd /gopath/src/app
+ godep restore
+ popd
+ elif find . -name "*.go" -printf "found" -quit |grep found >/dev/null ; then
+ # Install Go dependencies with go get.
+ pushd /gopath/src/app
+ go get
+ popd
+ fi
+
+ if test -f pom.xml ; then
+ # Install Java Maven dependencies.
+ mvn install
+ fi
+
+ if test -f build.gradle ; then
+ gradle build
+ fi
+ else
+ echo "Running '${SETUP_CMD[@]}' to install project dependencies..."
+ ${SETUP_CMD[@]}
fi
# Run License Finder.