Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions MANIFEST.in
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
graft src
graft etc
graft thirdparty
graft samples

recursive-exclude thirdparty/dev *
prune tests
Expand All @@ -18,6 +19,8 @@ include setup.cfg
include .gitignore
include configure
include configure.bat
include deltacode
include deltacode.bat
include .travis.yml

global-exclude *.py[co] __pycache__ *.*~
114 changes: 114 additions & 0 deletions deltacode
Original file line number Diff line number Diff line change
@@ -0,0 +1,114 @@
#!/bin/bash
#
# Copyright (c) 2018 nexB Inc. http://www.nexb.com/ - All rights reserved.
#

# A minimal shell wrapper to the CLI entry point fo DeltaCode


###################################################################################
# from https://raw.githubusercontent.com/mkropat/sh-realpath/58c03982cfd8accbcf0c4426a4adf0f120a8b2bb/realpath.sh
# realpath emulation for portability on *nix
# this allow running scancode from aribtrary locations and from symlinks
#
# Copyright (c) 2014 Michael Kropat
#
# Permission is hereby granted, free of charge, to any person obtaining a copy
# of this software and associated documentation files (the "Software"), to deal
# in the Software without restriction, including without limitation the rights
# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
# copies of the Software, and to permit persons to whom the Software is
# furnished to do so, subject to the following conditions:
#
# The above copyright notice and this permission notice shall be included in
# all copies or substantial portions of the Software.
#
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
# THE SOFTWARE.

realpath() {
canonicalize_path "$(resolve_symlinks "$1")"
}

resolve_symlinks() {
_resolve_symlinks "$1"
}

_resolve_symlinks() {
_assert_no_path_cycles "$@" || return

local dir_context path
path=$(readlink -- "$1")
if [ $? -eq 0 ]; then
dir_context=$(dirname -- "$1")
_resolve_symlinks "$(_prepend_dir_context_if_necessary "$dir_context" "$path")" "$@"
else
printf '%s\n' "$1"
fi
}

_prepend_dir_context_if_necessary() {
if [ "$1" = . ]; then
printf '%s\n' "$2"
else
_prepend_path_if_relative "$1" "$2"
fi
}

_prepend_path_if_relative() {
case "$2" in
/* ) printf '%s\n' "$2" ;;
* ) printf '%s\n' "$1/$2" ;;
esac
}

_assert_no_path_cycles() {
local target path

target=$1
shift

for path in "$@"; do
if [ "$path" = "$target" ]; then
return 1
fi
done
}

canonicalize_path() {
if [ -d "$1" ]; then
_canonicalize_dir_path "$1"
else
_canonicalize_file_path "$1"
fi
}

_canonicalize_dir_path() {
(cd "$1" 2>/dev/null && pwd -P)
}

_canonicalize_file_path() {
local dir file
dir=$(dirname -- "$1")
file=$(basename -- "$1")
(cd "$dir" 2>/dev/null && printf '%s/%s\n' "$(pwd -P)" "$file")
}

###################################################################################
# Now run scancode proper

DELTACODE_BIN="$( realpath "${BASH_SOURCE[0]}" )"
DELTACODE_ROOT_DIR="$( cd "$( dirname "${DELTACODE_BIN}" )" && pwd )"

DELTACODE_CONFIGURED_PYTHON="$DELTACODE_ROOT_DIR/bin/python"
if [ ! -f "$DELTACODE_CONFIGURED_PYTHON" ]; then
echo "* Configuring DeltaCode for first use..."
CONFIGURE_QUIET=1 "$DELTACODE_ROOT_DIR/configure" etc/conf
fi

"$DELTACODE_ROOT_DIR/bin/deltacode" "$@"
34 changes: 34 additions & 0 deletions deltacode.bat
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
@echo OFF
@rem Copyright (c) 2018 nexB Inc. http://www.nexb.com/ - All rights reserved.

@rem A minimal shell wrapper to the CLI entry point

set DELTACODE_ROOT_DIR=%~dp0
@rem Use a trailing space in the next line to set the variable to an empty string
set DELTACODE_CMD_LINE_ARGS=
set DELTACODE_CONFIGURED_PYTHON=%DELTACODE_ROOT_DIR%\bin\python.exe

@rem Collect all command line arguments in a variable
:collectarg
if ""%1""=="""" goto continue
call set DELTACODE_CMD_LINE_ARGS=%DELTACODE_CMD_LINE_ARGS% %1
shift
goto collectarg

:continue

if not exist "%DELTACODE_CONFIGURED_PYTHON%" goto configure
goto deltacode

:configure
echo * Configuring DeltaCode for first use...
set CONFIGURE_QUIET=1
call "%DELTACODE_ROOT_DIR%\configure" etc/conf
if %errorlevel% neq 0 (
exit /b %errorlevel%
)

:deltacode
"%DELTACODE_ROOT_DIR%\bin\deltacode" %DELTACODE_CMD_LINE_ARGS%

:EOS
3 changes: 3 additions & 0 deletions etc/release/MANIFEST.in.release
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
graft src
graft etc
graft thirdparty
graft samples

recursive-exclude thirdparty/dev *
prune tests
Expand All @@ -18,6 +19,8 @@ include setup.cfg
include .gitignore
include configure
include configure.bat
include deltacode
include deltacode.bat
include .travis.yml

global-exclude *.py[co] __pycache__ *.*~
7 changes: 4 additions & 3 deletions etc/release/release.sh
Original file line number Diff line number Diff line change
Expand Up @@ -50,11 +50,12 @@ function test_scan {
extract_dir=$(ls -d */)
cd $extract_dir

./configure etc/conf

./bin/deltacode --help
./deltacode --help
echo "TEST help passed: ./deltacode --help"

./deltacode -n samples/samples.json -o samples/samples.json
echo "TEST sample delta passed: ./deltacode -n samples/samples.json -o samples/samples.json"

# cleanup
cd ..
rm -rf $extract_dir
Expand Down
Loading