#!/bin/bash # # Copyright (C) 2015 by Michael Olbrich # # See CREDITS for details about who has contributed to this project. # # For further information about the PTXdist project and license conditions # see the README file. # license_file="${1}" exception_file="${2}" output="$(dirname "$0")/lib/ptxd_make_spdx.sh" delim='|' if [ "${#}" -ne 2 ]; then echo "usage: $0 " exit 1 fi if [ ! -f "${license_file}" ]; then echo "license file missing!" exit 1 fi if [ ! -f "${exception_file}" ]; then echo "exception file missing!" exit 1 fi export IFS="${delim}" ( sed '/^$/q' "$0" cat <&2 cat "${license_file}" | while read line; do line="${last} ${line}" last= count="$(echo "${line}" | sed "s/[^${delim}]//g" | wc -c)" if [ "${cols}" -eq 0 ]; then cols="${count}" fi if [ "${count}" -lt "${cols}" ]; then last="${line}" continue fi if [ "${count}" -gt "${cols}" ]; then echo "Too many columns: ${count}!" >&2 exit 1 fi set -- ${line} if [ "${2}" = "License Identifier" -o -z "${2}" ]; then continue fi echo -n " ${2}) " if [ "${5}" = "YES" ]; then echo -n 'osi="true" ' fi echo ";;" done last= cols=0 echo "parsing exception file ..." >&2 cat "${exception_file}" | while read line; do line="${last} ${line}" last= count="$(echo "${line}" | sed "s/[^${delim}]//g" | wc -c)" if [ "${cols}" -eq 0 ]; then cols="${count}" fi if [ "${count}" -lt "${cols}" ]; then last="${line}" continue fi if [ "${count}" -gt "${cols}" ]; then echo "Too many columns: ${count}!" >&2 exit 1 fi set -- ${line} if [ "${2}" = "Exception Identifier" -o -z "${2}" ]; then continue fi echo -n " ${2}) exception=\"true\" " echo ";;" done cat < "${output}"