Created
July 2, 2018 15:41
-
-
Save adamgundry/0b99d80cfc8b74cbb249c97822bf247f to your computer and use it in GitHub Desktop.
Quick hack to collect licenses of dependencies using stack
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
# This is a quick hack using stack to list dependencies and then | |
# copying their licenses from the locations in which it stores them. | |
# It tries various possible filenames in the store first, then tries | |
# the global location for system packages. It will miss out licenses | |
# for parts of the local project, the "rts" package (but that's okay, | |
# because it is covered by the license for "base"), and will | |
# (silently) exclude licenses for underlying C libraries. | |
LOCAL_PATH=.stack-work/install/x86_64-linux/lts-9.0/8.0.2/doc/ | |
STORE_PATH=~/.stack/snapshots/x86_64-linux/lts-9.0/8.0.2/doc/ | |
GLOBAL_PATH=/opt/ghc/8.0.2/share/doc/ghc-8.0.2/html/libraries | |
DIR=licenses | |
LIST=stack-dependencies.txt | |
mkdir -p $DIR | |
stack list-dependencies --test | tr ' ' '-' > $LIST | |
for P in `cat $LIST` | |
do | |
cp $LOCAL_PATH/$P/LICENSE $DIR/$P.txt 2>/dev/null \ | |
|| cp `ls $STORE_PATH/$P/{LICENSE,LICENCE,LICENSE.txt,license.txt,licence.txt,BSD3,COPYING} 2>/dev/null | head -n 1` $DIR/$P.txt 2>/dev/null \ | |
|| cp $GLOBAL_PATH/$P/LICENSE $DIR/$P.txt 2>/dev/null \ | |
|| echo "Missing license for $P" | |
done |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment