-
Notifications
You must be signed in to change notification settings - Fork 25
Description
In trying to figure out how to use license-report for packaging, I've run into
the problem that typically, one wants to write the report to a different path
than where it will end up on the end-user's machine.
In particular, the links to the dependencies' licenses will break if the report
is moved out of licensedir.
Three solutions suggest themselves:
-
Add another path argument
prefixthat will be prepended tolicensedirwhen
it comes to writing the dependencies' licenses (i.e. the report will link to
the licenses as if they're saved underlicensedir, but they actually will be
saved toprefix/licensedir) -
Use relative paths in the report. To avoid desynchronization, perhaps have
licensedirimply writing the report tolicensedir/$target.mdor
licensedir/index.md? -
Do nothing, and have the end-user fudge the paths. One possible way to do this
(note thereadarray targetsline is due to
Add a cabal target command haskell/cabal#9744)licensedir="$prefix/usr/share/licenses/$pkgname/" install -Dm644 LICENSE* -t "$licensedir" mkdir "$licensedir/dependencies" readarray -t targets < <(jq -r '."install-plan"[] | {style, target: ( ."component-name" + if ."component-name" | contains(":")? | not then ":\(."pkg-name")" else "" end) } | select(.style == "local") | .target') for trg in "${targets[@]}"; do tmpprefix="$(mktemp -dp .)" pushd "$tmpprefix" cabal-plan license-report --licensedir . > "$trg.md" popd # alternatively, if absolute paths are desired cabal-plan license-report --licensedir "$tmpprefix" | \ sed "s#$tmpprefix#/usr/share/licenses/$pkgname/#" \ > "$tmpprefix/$trg.md" done cp -r "$tmpprefix"/* "$licensedir"