Debian Codegraph @

tools/fix-spec

raw
1 #!/bin/sh
2 # patch given spec file to have the correct version and declare bundled NPM dependencies
3 # Usage: fix-spec <spec-file> [version]
4 set -eu
5
6 spec="$1"
7 version="${2:-}"
8
9 ROOT_DIR=$(realpath "$(dirname "$0")/..")
10
11 PROVIDES=$(awk '{print "Provides: bundled(npm(" $1 ")) = " $2}' "${ROOT_DIR}/runtime-npm-modules.txt")
12 awk -v p="$PROVIDES" 'gsub(/#NPM_PROVIDES/, p) 1' "$spec" > "$spec".new
13
14 if [ -n "$version" ]; then
15 sed -i '/Version/ s/\b0\b/'"$version"'/' "$spec".new
16 fi
17
18 mv -f "$spec".new "$spec"